:root {
    --paper: #f4f5f0;
    --surface: #ffffff;
    --ink: #1b1d1d;
    --muted: #6d726f;
    --line: #daddd7;
    --accent: #f45b4f;
    --accent-dark: #c93d35;
    --teal: #146c64;
    --yellow: #edc84b;
    --shadow: 0 18px 50px rgba(24, 29, 27, 0.12);
    font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    color: var(--ink);
    background: var(--paper);
    font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body { min-width: 320px; background: var(--paper); }

button, input, textarea { font: inherit; letter-spacing: 0; }

button { color: inherit; }

button, a, input, textarea { -webkit-tap-highlight-color: transparent; }

button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
    outline: 3px solid rgba(20, 108, 100, 0.28);
    outline-offset: 2px;
}

.hidden { display: none !important; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.welcome-view {
    min-height: 100dvh;
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(390px, 0.72fr);
}

.welcome-visual {
    min-height: 100dvh;
    position: relative;
    overflow: hidden;
    color: #fff;
    background: #181b1b url('/assets/covers/cover-stage.jpg') center/cover no-repeat;
    padding: clamp(28px, 5vw, 68px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.welcome-shade {
    position: absolute;
    inset: 0;
    background: rgba(10, 15, 14, 0.48);
}

.brand-lockup, .welcome-title, .cover-strip { position: relative; z-index: 1; }

.brand-lockup { display: flex; align-items: center; gap: 12px; font-size: 18px; font-weight: 700; }

.brand-mark {
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    background: var(--yellow);
    color: #181a19;
    border-radius: 50%;
}

.brand-mark svg { width: 23px; height: 23px; }

.brand-mark.compact { width: 36px; height: 36px; }

.brand-mark.compact svg { width: 19px; }

.eyebrow { margin: 0 0 14px; color: var(--yellow); font-size: 12px; font-weight: 800; letter-spacing: 0.18em; }

.welcome-title h1 { margin: 0; font-size: clamp(72px, 10vw, 156px); line-height: 0.88; letter-spacing: 0; }

.welcome-title > p:last-child { margin: 25px 0 0; font-size: clamp(20px, 2.2vw, 32px); }

.cover-strip { display: flex; align-items: flex-end; }

.cover-strip img {
    width: clamp(68px, 7vw, 104px);
    aspect-ratio: 1;
    object-fit: cover;
    border: 4px solid rgba(255, 255, 255, 0.86);
    border-radius: 3px;
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.26);
}

.cover-strip img + img { margin-left: -13px; }

.cover-strip img:nth-child(2) { transform: rotate(5deg) translateY(-3px); }

.cover-strip img:nth-child(3) { transform: rotate(-4deg); }

.entry-panel { min-height: 100dvh; display: grid; align-items: center; padding: clamp(30px, 5vw, 78px); }

.entry-inner { width: min(100%, 420px); margin: auto; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); margin-bottom: 54px; }

.segment { border: 0; background: transparent; padding: 14px 6px; color: var(--muted); cursor: pointer; position: relative; }

.segment.active { color: var(--ink); font-weight: 750; }

.segment.active::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--accent); }

.entry-form { display: grid; gap: 22px; }

.form-heading { display: flex; align-items: baseline; gap: 13px; margin-bottom: 11px; }

.form-heading h2 { margin: 0; font-size: clamp(27px, 3vw, 36px); line-height: 1.2; }

.step-number { color: var(--accent); font: 700 12px/1 monospace; }

.field { display: grid; gap: 9px; }

.field > span { font-size: 13px; font-weight: 700; color: #535856; }

.field input {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 4px;
    padding: 15px 16px;
    font-size: 16px;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field input:focus { outline: 0; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(20, 108, 100, 0.11); }

.room-code-input { text-transform: uppercase; font-family: ui-monospace, Consolas, monospace !important; font-weight: 800; }

.primary-button {
    border: 0;
    min-height: 54px;
    background: var(--ink);
    color: #fff;
    border-radius: 4px;
    padding: 0 17px 0 21px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 750;
    cursor: pointer;
    margin-top: 10px;
}

.primary-button:hover { background: var(--teal); }

.primary-button:disabled { opacity: 0.55; cursor: wait; }

.primary-button svg { width: 20px; }

.room-view { height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; }

.room-header {
    min-height: 72px;
    padding: 12px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 1px solid var(--line);
    background: rgba(244, 245, 240, 0.97);
    z-index: 10;
}

.room-identity { display: flex; align-items: center; gap: 11px; min-width: 0; }

.room-identity h1 { margin: 0 0 3px; font-size: 17px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 38vw; }

.code-button { border: 0; padding: 0; background: transparent; color: var(--muted); font: 700 12px/1 ui-monospace, Consolas, monospace; display: flex; gap: 5px; align-items: center; cursor: pointer; }

.code-button svg { width: 13px; height: 13px; }

.header-actions { display: flex; gap: 8px; align-items: center; }

.connection-state { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); margin-right: 7px; }

.connection-state > span { width: 7px; height: 7px; border-radius: 50%; background: #a9aeaa; }

.connection-state.online > span { background: #2ea66f; box-shadow: 0 0 0 4px rgba(46, 166, 111, 0.12); }

.icon-button, .icon-text-button {
    border: 1px solid var(--line);
    background: var(--surface);
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 4px;
}

.icon-button { width: 40px; padding: 0; flex: 0 0 40px; }

.icon-text-button { gap: 7px; padding: 0 13px; font-weight: 700; font-size: 13px; }

.icon-button:hover, .icon-text-button:hover { border-color: #aeb4af; background: #fafbf8; }

.icon-button svg, .icon-text-button svg { width: 18px; height: 18px; }

.invite-button { background: var(--accent); border-color: var(--accent); color: #fff; }

.invite-button:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.voice-button.active { background: #e7f4ef; border-color: #8bc7b3; color: #12624f; }

.voice-button.speaking { box-shadow: 0 0 0 3px rgba(46, 166, 111, 0.16); }

.room-workspace { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 420px; }

.chat-pane { min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; background: var(--surface); }

.message-list { min-height: 0; overflow-y: auto; padding: 30px clamp(18px, 4vw, 64px) 22px; scroll-behavior: smooth; }

.message-row { display: flex; gap: 10px; align-items: flex-end; margin: 14px 0; }

.message-row.mine { flex-direction: row-reverse; }

.avatar {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--avatar, var(--teal));
    color: #fff;
    font-size: 12px;
    font-weight: 800;
}

.message-stack { max-width: min(68%, 620px); }

.message-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; margin: 0 0 5px 2px; }

.message-row.mine .message-meta { justify-content: flex-end; }

.bubble { border-radius: 6px 6px 6px 1px; background: var(--paper); padding: 10px 13px; line-height: 1.55; overflow-wrap: anywhere; }

.mine .bubble { color: #fff; background: var(--teal); border-radius: 6px 6px 1px 6px; }

.bubble.image-bubble { padding: 4px; background: #e8ebe6; cursor: zoom-in; }

.mine .bubble.image-bubble { background: var(--teal); }

.image-bubble img { display: block; width: min(320px, 55vw); max-height: 360px; object-fit: cover; border-radius: 3px; }

.image-caption { padding: 7px 8px 5px; font-size: 13px; }

.system-message { margin: 18px auto; width: fit-content; max-width: 90%; color: var(--muted); font-size: 12px; text-align: center; }

.system-message span { background: var(--paper); padding: 6px 10px; border-radius: 3px; }

.empty-chat { min-height: 100%; display: grid; place-content: center; text-align: center; color: var(--muted); }

.empty-chat svg { width: 42px; height: 42px; margin: 0 auto 12px; color: var(--teal); }

.empty-chat p { margin: 0; }

.composer {
    margin: 0 clamp(14px, 3vw, 42px) 20px;
    padding: 7px;
    min-height: 58px;
    display: flex;
    align-items: flex-end;
    gap: 7px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.composer-button { border: 0; background: transparent; }

.message-input-wrap { flex: 1; min-width: 0; display: flex; }

.message-input-wrap textarea { width: 100%; min-height: 40px; max-height: 120px; resize: none; border: 0; outline: 0; background: transparent; padding: 9px 5px; line-height: 1.4; }

.send-button {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: grid;
    place-items: center;
    flex: 0 0 40px;
    cursor: pointer;
}

.send-button:hover { background: var(--accent-dark); }

.send-button svg { width: 18px; }

.music-pane { min-height: 0; overflow-y: auto; background: var(--paper); border-left: 1px solid var(--line); }

.now-playing-section, .queue-section, .catalog-section { padding: 22px; border-bottom: 1px solid var(--line); }

.section-label { display: flex; justify-content: space-between; align-items: center; font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; margin-bottom: 14px; }

.sync-badge { background: #e4e7e2; color: #676c69; padding: 4px 7px; border-radius: 3px; }

.sync-badge.live { background: #d9eee4; color: #1f704c; }

.album-frame { width: 100%; aspect-ratio: 16 / 10; position: relative; overflow: hidden; border-radius: 5px; background: #202322; }

.album-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }

.empty-record { display: none; position: absolute; inset: 0; place-items: center; color: rgba(255,255,255,.88); background: rgba(20,24,23,.35); }

.empty-record svg { width: 70px; height: 70px; }

.now-playing.empty .empty-record { display: grid; }

.track-heading { min-height: 70px; margin-top: 14px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

.track-heading h2 { margin: 0 0 4px; font-size: 20px; line-height: 1.25; }

.track-heading p { margin: 0; color: var(--muted); font-size: 13px; }

.listen-button { border: 0; background: var(--yellow); border-radius: 4px; padding: 9px 10px; display: flex; align-items: center; gap: 6px; white-space: nowrap; cursor: pointer; font-size: 12px; font-weight: 800; }

.listen-button svg { width: 15px; height: 15px; }

.progress-wrap { margin-top: 5px; }

input[type="range"] { width: 100%; accent-color: var(--accent); cursor: pointer; }

.time-row { display: flex; justify-content: space-between; color: var(--muted); font: 600 10px/1 ui-monospace, Consolas, monospace; margin-top: 3px; }

.player-controls { margin-top: 13px; display: flex; align-items: center; justify-content: center; gap: 10px; }

/* Lyrics section */
.lyrics-section { padding: 18px 22px; border-bottom: 1px solid var(--line); }

.lyrics-container {
    max-height: 260px;
    overflow-y: auto;
    scroll-behavior: smooth;
    padding: 8px 0;
    text-align: center;
}

.lyric-line {
    padding: 6px 4px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.6;
    transition: color 200ms ease, font-size 200ms ease;
}

.lyric-line.current {
    color: var(--ink);
    font-size: 16px;
    font-weight: 700;
}

/* Search bar */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.search-input-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 4px;
    padding: 0 10px;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.search-input-wrap:focus-within {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(20, 108, 100, 0.11);
}

.search-icon {
    width: 18px;
    height: 18px;
    color: var(--muted);
    flex: 0 0 18px;
}

.search-input-wrap input[type="search"] {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    padding: 10px 4px;
    font-size: 14px;
}

.search-input-wrap input[type="search"]::-webkit-search-cancel-button { appearance: none; }

.source-select {
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 4px;
    padding: 8px 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    min-width: 60px;
}

.source-select:focus-visible {
    outline: 3px solid rgba(20, 108, 100, 0.28);
    outline-offset: 2px;
}

/* Track thumbnail placeholder */
.track-thumb-placeholder {
    width: 44px;
    height: 44px;
    border-radius: 3px;
    background: var(--paper);
    display: grid;
    place-items: center;
    color: var(--muted);
}

.track-thumb-placeholder svg { width: 20px; height: 20px; }

.play-button { width: 48px; height: 48px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--ink); color: #fff; cursor: pointer; }

.play-button:disabled, .icon-button:disabled { opacity: .35; cursor: not-allowed; }

.play-button svg { width: 20px; height: 20px; }

.section-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }

.section-title-row h2 { margin: 0; font-size: 15px; }

.section-title-row span, .section-title-row a { font-size: 11px; color: var(--muted); }

.section-title-row a { text-decoration: underline; text-underline-offset: 3px; }

.queue-list, .catalog-list { display: grid; gap: 7px; }

.queue-item, .catalog-item { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 52px; }

.track-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 3px; }

.track-info { min-width: 0; }

.track-info strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.track-info span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.request-button { width: 34px; height: 34px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; border-radius: 50%; cursor: pointer; }

.request-button:hover { background: var(--yellow); border-color: var(--yellow); }

.request-button svg { width: 16px; height: 16px; }

.queue-index { font: 800 12px/1 ui-monospace, Consolas, monospace; color: var(--accent); width: 34px; text-align: center; }

.empty-copy { color: var(--muted); font-size: 12px; text-align: center; padding: 8px 0; }

.mobile-nav { display: none; }

.members-dialog, .voice-dialog, .image-dialog { border: 0; padding: 0; border-radius: 7px; box-shadow: var(--shadow); }

.members-dialog, .voice-dialog { width: min(420px, calc(100vw - 32px)); background: var(--surface); }

dialog::backdrop { background: rgba(20, 24, 23, 0.58); backdrop-filter: blur(2px); }

.dialog-header { padding: 17px 18px 12px 22px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }

.dialog-header h2 { margin: 0; font-size: 18px; }

.dialog-header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.members-list { padding: 12px 22px 22px; max-height: 60vh; overflow: auto; }

.member-row { min-height: 54px; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid #eceeea; }

.member-row:last-child { border-bottom: 0; }

.member-row strong { font-size: 14px; }

.member-row span:last-child { margin-left: auto; font-size: 11px; color: var(--teal); }

.voice-participant-list { min-height: 94px; max-height: 48vh; overflow-y: auto; padding: 10px 22px; }

.voice-participant {
    min-height: 54px;
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 24px;
    align-items: center;
    gap: 11px;
    border-bottom: 1px solid #eceeea;
}

.voice-participant:last-child { border-bottom: 0; }

.voice-participant .avatar { transition: box-shadow 150ms ease; }

.voice-participant.speaking .avatar { box-shadow: 0 0 0 3px rgba(46, 166, 111, 0.25); }

.voice-participant-info { min-width: 0; }

.voice-participant-info strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }

.voice-participant-info span { color: var(--muted); font-size: 11px; }

.voice-participant > svg { width: 17px; color: var(--muted); }

.voice-participant.speaking > svg { color: #23875f; }

.voice-actions { min-height: 70px; padding: 12px 22px 18px; display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); }

.voice-join-button { width: 100%; min-height: 44px; margin: 0; }

.voice-actions .icon-text-button { flex: 1; height: 44px; }

.voice-leave-button { color: var(--accent-dark); }

.image-dialog { background: transparent; max-width: min(92vw, 1100px); max-height: 90vh; overflow: visible; }

.image-dialog img { display: block; max-width: 92vw; max-height: 88vh; object-fit: contain; border-radius: 4px; }

.image-close { position: absolute; right: 0; top: -45px; width: 38px; height: 38px; border: 0; border-radius: 50%; background: #fff; display: grid; place-items: center; cursor: pointer; }

.toast-region { position: fixed; z-index: 100; right: 18px; top: 86px; display: grid; gap: 8px; pointer-events: none; }

.toast { width: min(340px, calc(100vw - 36px)); padding: 11px 14px; color: #fff; background: #252827; border-left: 4px solid var(--yellow); border-radius: 4px; box-shadow: var(--shadow); font-size: 13px; animation: toast-in 180ms ease both; }

.toast.error { border-left-color: var(--accent); }

@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

@media (max-width: 900px) {
    .welcome-view { grid-template-columns: 1fr; }
    .welcome-visual { min-height: 42dvh; padding: 24px; }
    .welcome-title { margin-top: 34px; }
    .welcome-title h1 { font-size: clamp(64px, 21vw, 112px); }
    .welcome-title > p:last-child { margin-top: 14px; font-size: 19px; }
    .cover-strip { display: none; }
    .entry-panel { min-height: 58dvh; align-items: start; padding: 24px 22px 38px; }
    .entry-inner { width: min(100%, 500px); }
    .segmented { margin-bottom: 30px; }
    .room-view { grid-template-rows: auto minmax(0, 1fr) auto; }
    .room-header { min-height: 66px; padding: 10px 13px; }
    .connection-state, .invite-button span { display: none; }
    .invite-button { width: 40px; padding: 0; }
    .room-identity h1 { max-width: 34vw; }
    .room-workspace { display: block; min-height: 0; position: relative; }
    .chat-pane, .music-pane { display: none; position: absolute; inset: 0; }
    .chat-pane.active-pane { display: grid; }
    .music-pane.active-pane { display: block; border-left: 0; }
    .mobile-nav { display: grid; grid-template-columns: 1fr 1fr; min-height: 62px; padding: 5px max(12px, env(safe-area-inset-right)) calc(5px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); border-top: 1px solid var(--line); background: var(--surface); }
    .mobile-nav-button { border: 0; background: transparent; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 3px; color: var(--muted); font-size: 10px; cursor: pointer; }
    .mobile-nav-button.active { color: var(--accent); font-weight: 700; }
    .mobile-nav-button svg { width: 20px; height: 20px; }
    .message-list { padding: 18px 13px 16px; }
    .message-stack { max-width: 78%; }
    .composer { margin: 0 10px 10px; }
    .now-playing-section, .queue-section, .catalog-section, .lyrics-section { padding: 18px; }
    .album-frame { aspect-ratio: 16 / 9; }
    .lyrics-container { max-height: 200px; }
    .search-bar { gap: 6px; }
}

@media (max-width: 500px) {
    .welcome-visual { min-height: 37dvh; }
    .entry-panel { min-height: 63dvh; }
    .brand-lockup { font-size: 16px; }
    .brand-mark { width: 36px; height: 36px; }
    .welcome-title h1 { font-size: 64px; }
    .form-heading h2 { font-size: 27px; }
    .header-actions { gap: 5px; }
    .header-actions .icon-button, .header-actions .icon-text-button { height: 37px; min-width: 37px; }
    .header-actions .icon-button { width: 37px; flex-basis: 37px; }
    .members-dialog .icon-button, .voice-dialog .icon-button { width: 38px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; }
}
