:root{
    --bg: #0e1621;
    --bg-secondary: #17212b;
    --fg: #e4e6eb;
    --muted: #708499;
    --border: rgba(255,255,255,0.1);
    --bubble-left: #18222d;
    --bubble-right: #3390ec;
    --bubble-right-hover: #2b7fd9;
    --accent: #3390ec;
    --input-bg: #17212b;
    --input-border: rgba(255,255,255,0.1);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --shadow: 0 2px 4px rgba(0,0,0,0.2);
}

*,::before,::after{box-sizing:border-box;}
html,body{height:100%;margin:0;padding:0;}

body{
    max-width:1080px;
    margin:0 auto;
    color:var(--fg);
    background-color:var(--bg);
    background-image:none;
    font-family:var(--font);
    -webkit-font-smoothing:antialiased;
    padding:0;
    display:flex;
    flex-direction:column;
    height:100vh;
    overflow:hidden;
}
body:not(.landing){
    box-shadow:0 0 0 1px var(--border);
}

.landing{
    display:flex;
    min-height:100vh;
    flex-direction:column;
    justify-content:center;
    gap:12px;
    padding:24px 10px;
}
.landing .landing-card{
    max-width:680px;
    margin:0 auto;
    padding:18px 18px 16px;
    background:rgba(0,0,0,0.28);
    border:1px solid var(--border);
    border-radius:16px;
    box-shadow:0 18px 45px rgba(0,0,0,0.35);
    backdrop-filter: blur(12px);
}
.landing .landing-title{
    text-align:center;
    color:var(--fg);
    font-weight:600;
    letter-spacing:0.2px;
    margin-bottom:10px;
}
.landing .top{display:none;}
.landing .room-bar{
    max-width:100%;
    margin:0;
    border-radius:12px;
    padding:12px 12px 10px;
}
.room-input.name-input{margin-top:10px;}
.room-input.name-input input{max-width:360px;}
.room-bar.inline{
    margin:0;
    padding:12px 16px;
    border-bottom:1px solid var(--border);
    background:var(--bg-secondary);
    display:flex;
    flex-direction:column;
    gap:10px;
    flex-shrink:0;
}
.room-bar.inline .room-title{
    color:var(--muted);
    font-size:14px;
}
.room-bar.inline .room-input.name-inline{
    display:flex;
    gap:8px;
    align-items:center;
}
.room-bar.inline input{
    flex:1;
}
.landing .room-input{justify-content:center;}
.landing .room-input input{max-width:360px;}
.landing .room-list{
    justify-content:flex-start;
    flex-direction:column;
}
.landing .mk-chat-box,
.landing .write{display:none !important;}
body.landing{height:auto;min-height:100vh;overflow:auto;}

/* Mobile layout tweaks */
@media (max-width: 768px){
    body{
        height:100vh;
        overflow-y:auto;
    }
    .talk.write{
        position:sticky;
        bottom:0;
        left:0;
        right:0;
        z-index:20;
    }
}

.top{
    padding:0 16px;
    background:var(--bg-secondary);
    height:54px;
    line-height:54px;
    text-align:center;
    color:var(--fg);
    border-bottom:1px solid var(--border);
    letter-spacing:0.3px;
    font-weight:500;
    font-size:16px;
    flex-shrink:0;
}

.room-bar{
    padding:12px 14px 6px 14px;
    background:rgba(255,255,255,0.03);
    border:1px solid var(--border);
    border-top:0;
    border-bottom:0;
}
.room-input{
    display:flex;
    gap:10px;
    align-items:center;
    margin-bottom:8px;
}
.room-input input{
    flex:1;
    height:38px;
    padding:0 12px;
    border-radius:10px;
    border:1px solid rgba(255,255,255,0.12);
    background:var(--input-bg);
    color:var(--fg);
    outline:none;
    font-family:var(--font);
}
.room-list{
    display:flex;
    flex-wrap:wrap;
    gap:8px;
    margin-top:6px;
}
.room-list-label{
    color:var(--muted);
    font-weight:600;
    letter-spacing:0.2px;
    margin:6px 2px 4px;
    display:flex;
    align-items:center;
    gap:8px;
}
.room-list-label:before{
    content:"⏺";
    font-size:12px;
    color:var(--muted);
}
.room-tag{
    padding:6px 10px;
    border-radius:10px;
    background:rgba(255,255,255,0.05);
    color:#e5d9ff;
    border:1px solid rgba(255,255,255,0.08);
    cursor:pointer;
    transition:transform .08s ease,filter .12s ease;
    font-size:13px;
}
.room-tag:hover{
    filter:brightness(1.05);
    transform:translateY(-1px);
}
.landing .room-tag{
    width:100%;
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:10px 12px;
    font-size:15px;
}
.landing .room-tag:after{
    content:"\2192";
    font-weight:700;
    color:#cbd5e1;
    font-size:16px;
}

.mk-chat-box{
    font-family:var(--font);
    font-size:15px;
    width:100%;
    padding:12px 16px;
    position:relative;
    overflow-y:auto;
    overflow-x:hidden;
    flex:1;
    background:var(--bg);
    background-image:url(https://org.stfptn.com/starfall.webp);
    background-repeat:repeat;
    background-size:cover;
    background-attachment:fixed;
}

.foot{line-height:50px;text-align:center;font-size:12px;color:var(--muted);}
.foot a{color:#cfd4ff;text-decoration:none;}

.write{
    min-height:60px;
    width:100%;
    display:flex;
    align-items:center;
    gap:10px;
    flex-wrap:wrap;
    background:var(--bg-secondary);
    border-top:1px solid var(--border);
    padding:8px 16px;
    flex-shrink:0;
}

@media (max-width: 768px){
    .write{
        flex-wrap:nowrap;
    }
    .write input{
        min-width:0;
    }
}
.write .actions{
    display:flex;
    gap:8px;
}
.write .actions .secondary{
    background: transparent;
    border:1px solid var(--input-border);
    color:var(--muted);
    padding:8px 12px;
    border-radius:16px;
    text-decoration:none;
    font-size:13px;
    transition:all 0.2s;
}
.write .actions .secondary:hover{
    background:var(--input-bg);
    border-color:var(--accent);
    color:var(--fg);
}
.write input{
    font-size:15px;
    flex:1;
    height:42px;
    padding:0 16px;
    border-radius:21px;
    border:1px solid var(--input-border);
    outline:none;
    background:var(--input-bg);
    color:var(--fg);
    font-family:var(--font);
    font-weight:400;
    transition:border-color 0.2s;
}
.write input:focus{
    border-color:var(--accent);
}
#fresh{color:var(--fg);}
.send{
    color:#fff;
    text-decoration:none;
    min-width:42px;
    width:42px;
    padding:0;
    background:var(--bubble-right);
    display:inline-flex;
    align-items:center;
    justify-content:center;
    height:42px;
    line-height:42px;
    text-align:center;
    border-radius:50%;
    font-weight:500;
    font-size:18px;
    transition:background-color 0.2s,transform 0.1s;
    border:none;
    cursor:pointer;
}
.send:hover{background:var(--bubble-right-hover);}
.send:active{transform:scale(0.95);}
.send.disabled{background:#4b5563;color:#9ca3af;cursor:not-allowed;}
.send.disabled:hover{background:#4b5563;}

.mk-chat-box .msg{
    margin:1px 0;
    position:relative;
    min-height:40px;
    display:flex;
    align-items:flex-end;
    gap:8px;
    padding:2px 0;
}
.mk-chat-box .msg + .msg{
    margin-top:4px;
}
.mk-chat-box .right{
    flex-direction:row-reverse;
    justify-content:flex-start;
}
.mk-chat-box .left{
    flex-direction:row;
    justify-content:flex-start;
}

.mk-chat-box img.head{
    width:36px;
    height:36px;
    position:relative;
    border-radius:50%;
    border:none;
    user-select:none;
    flex-shrink:0;
    object-fit:cover;
}

.mk-chat-box .name{
    color:var(--muted);
    font-size:13px;
    display:block;
    line-height:1.2;
    margin-bottom:2px;
    font-weight:500;
}
.mk-chat-box .right .name{display:none;}
.mk-chat-box .left .name{display:block;}

.mk-chat-box .msg-wrapper{
    display:flex;
    flex-direction:column;
    max-width:70%;
    min-width:120px;
}
.mk-chat-box .right .msg-wrapper{
    align-items:flex-end;
}
.mk-chat-box .left .msg-wrapper{
    align-items:flex-start;
}

.mk-chat-box .content{
    word-break:break-word;
    text-align:left;
    position:relative;
    display:inline-block;
    font-size:15px;
    padding:8px 12px;
    line-height:1.4;
    border-radius:12px;
    min-width:60px;
    color:#fff;
    box-shadow:0 1px 2px rgba(0,0,0,0.1);
    position:relative;
}
.mk-chat-box .msg .content .msg-img{
    display:block;
    max-width:300px;
    width:100%;
    border-radius:8px;
    margin:0;
    cursor:pointer;
}
.mk-chat-box .msg .content .msg-video{
    display:block;
    max-width:300px;
    width:100%;
    border-radius:8px;
    margin:0;
    background:#000;
}
.mk-chat-box .msg .content:has(.msg-img),
.mk-chat-box .msg .content:has(.msg-video){
    padding:0;
    background:transparent;
    box-shadow:none;
    border-radius:8px;
}
.mk-chat-box .msg .content:has(.msg-img):after,
.mk-chat-box .msg .content:has(.msg-video):after{
    display:none;
}
.mk-chat-box .content img:not(.head){width:100%;height:auto;display:block;}
.mk-chat-box .content a{color:#6ab7ff;text-decoration:none;border-bottom:1px solid rgba(106,183,255,0.3);}
.mk-chat-box .content a:hover{border-bottom-color:#6ab7ff;}
.mk-chat-box .right .content{
    background:var(--bubble-right);
    color:#fff;
    border-bottom-right-radius:4px;
}
.mk-chat-box .left .content{
    background:var(--bubble-left);
    color:var(--fg);
    border-bottom-left-radius:4px;
}

.mk-chat-box .content:after{
    content:"";
    position:absolute;
    width:0;
    height:0;
    bottom:0;
    z-index:1;
}
.mk-chat-box .right .content:after{
    right:-7px;
    border-left:7px solid var(--bubble-right);
    border-bottom:7px solid transparent;
}
.mk-chat-box .left .content:after{
    left:-7px;
    border-right:7px solid var(--bubble-left);
    border-bottom:7px solid transparent;
}

.mk-chat-box .tips{
    margin:12px;
    text-align:center;
    font-size:12px;
}
.mk-chat-box .tips span{
    display:inline-block;
    padding:4px 8px;
    background-color:#cccccc;
    color:#ffffff;
    border-radius:6px;
}
.mk-chat-box .tips .tips-primary{background-color:#428bca;}
.mk-chat-box .tips .tips-success{background-color:#5cb85c;}
.mk-chat-box .tips .tips-info{background-color:#5bc0de;}
.mk-chat-box .tips .tips-warning{background-color:#f0ad4e;}
.mk-chat-box .tips .tips-danger{background-color:#d9534f;}

.mk-chat-box::-webkit-scrollbar{width:6px;height:6px}
.mk-chat-box::-webkit-scrollbar-button:vertical{display:none}
.mk-chat-box::-webkit-scrollbar-track:vertical{background-color:transparent;}
.mk-chat-box::-webkit-scrollbar-track-piece{background-color:transparent;}
.mk-chat-box::-webkit-scrollbar-thumb:vertical{background-color:rgba(255,255,255,0.2);border-radius:3px}
.mk-chat-box::-webkit-scrollbar-thumb:vertical:hover,
.mk-chat-box::-webkit-scrollbar-thumb:vertical:active {background-color: rgba(255,255,255,0.3)}

.login{
    margin:80px auto 40px;
    display:flex;
    justify-content:center;
    align-items:center;
    gap:12px;
    background: rgba(255,255,255,0.05);
    padding:24px 20px;
    border:1px solid var(--border);
    border-radius:12px;
    max-width:520px;
    min-height:120px;
    backdrop-filter: blur(10px);
}
.login input{max-width:320px;text-align:center;}