:root {
  color-scheme: light;
  --page: #f2f0eb;
  --surface: #fbfaf7;
  --surface-strong: #fff;
  --ink: #191a18;
  --muted: #777873;
  --line: #dcdad3;
  --line-dark: #bcbab2;
  --accent: #dc4a39;
  --accent-soft: #f1ded9;
  --player: #111210;
  --player-muted: #c3c4bf;
  --shadow: 0 12px 36px rgba(27, 27, 24, .06);
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #171816;
  --surface: #1e201d;
  --surface-strong: #252723;
  --ink: #efeee9;
  --muted: #a1a39c;
  --line: #343631;
  --line-dark: #4a4c46;
  --accent: #ee6654;
  --accent-soft: #392c29;
  --player: #080908;
  --player-muted: #bfc0bb;
  --shadow: 0 12px 36px rgba(0, 0, 0, .18);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--page); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--page); }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }

.topbar {
  height: 68px; padding: 0 clamp(18px, 4vw, 56px); display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand-symbol { width: 34px; height: 34px; display: grid; place-items: center; position: relative; border: 1px solid var(--ink); font: 500 12px "DM Mono", monospace; letter-spacing: -.12em; }
.brand-symbol span { color: var(--accent); }
.brand-copy { display: flex; flex-direction: column; gap: 2px; line-height: 1; }
.brand-copy strong { font-size: 12px; letter-spacing: .15em; }
.brand-copy small, .section-kicker, .player-label, .panel-heading > span { font: 10px ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .12em; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 14px; }
.status-badge { display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; color: var(--accent); background: var(--accent-soft); font-size: 11px; font-weight: 600; }
.status-badge .dot, .video-live-tag i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-badge.is-offline { color: var(--muted); background: transparent; border: 1px solid var(--line); }
.user-badge { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; padding-left: 4px; }
.user-badge #userRoleIcon { color: var(--accent); font-size: 13px; }
.icon-button, .logout-button { border: 0; background: transparent; cursor: pointer; }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; }
.icon-button svg, .video-control svg, .music-cover svg, .music-toggle svg, .unlock-row button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.logout-button { height: 34px; padding: 0 12px; border-left: 1px solid var(--line); font-size: 12px; }

.page-shell { width: min(1440px, 100%); padding: clamp(24px, 4vw, 58px); margin: 0 auto; }
.view-section { display: none; }
.view-section.active { display: block; animation: appear .22s ease-out both; }
@keyframes appear { from { opacity: .5; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.lock-view { min-height: min(660px, calc(100vh - 150px)); display: none; align-items: center; justify-content: center; }
.lock-view.active { display: flex; }
.lock-card { width: min(420px, 100%); padding: 46px 42px 40px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.section-kicker { display: flex; align-items: center; gap: 9px; color: var(--accent); }
.kicker-line { width: 22px; height: 1px; background: currentColor; }
.lock-card h1 { margin: 27px 0 38px; font-size: clamp(30px, 5vw, 40px); font-weight: 500; letter-spacing: -.06em; }
.unlock-form label { display: block; margin-bottom: 9px; color: var(--muted); font-size: 12px; }
.unlock-form label:not(:first-child) { margin-top: 18px; }
.unlock-row { display: flex; border-bottom: 1px solid var(--line-dark); }
.unlock-row input { flex: 1; min-width: 0; height: 48px; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 15px; }
.unlock-row input::placeholder { color: #a5a59e; }
.unlock-row button { display: flex; align-items: center; gap: 8px; padding: 0 0 0 14px; border: 0; color: var(--accent); background: transparent; cursor: pointer; font-size: 13px; font-weight: 700; }
.unlock-row button svg { width: 17px; }
.unlock-error { min-height: 18px; margin: 11px 0 0; color: var(--accent); font-size: 12px; }

.live-view { padding-top: 2px; }
.stream-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; align-items: start; gap: 26px; }
.main-column { min-width: 0; }
.player-label { display: flex; justify-content: space-between; margin-bottom: 10px; }
.player-label span:first-child { color: var(--accent); }
.video-frame { position: relative; overflow: hidden; width: 100%; aspect-ratio: 16 / 9; min-height: 220px; background: var(--player); isolation: isolate; }
#streamVideo { display: block; width: 100%; height: 100%; object-fit: contain; background: var(--player); }
#drawingCanvas, #emojiOverlay, #danmakuOverlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#drawingCanvas { z-index: 4; }
.video-frame.drawing-mode-active #drawingCanvas { pointer-events: auto; cursor: crosshair; }
#emojiOverlay, #danmakuOverlay { z-index: 3; overflow: hidden; }
.placeholder-overlay { position: absolute; z-index: 2; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 22px; color: #e8e8e2; text-align: center; background: #151613; transition: opacity .25s ease; }
.placeholder-mark { height: 30px; display: flex; align-items: center; gap: 4px; margin-bottom: 16px; }
.placeholder-mark span { width: 2px; height: 10px; background: var(--accent); opacity: .75; }
.placeholder-mark span:nth-child(2) { height: 24px; }
.placeholder-mark span:nth-child(3) { height: 15px; }
.placeholder-overlay h2 { margin: 0; font-size: 16px; font-weight: 500; }
.placeholder-overlay p { margin: 6px 0 0; color: #989a93; font-size: 12px; }
.placeholder-overlay p:empty { display: none; }
.connect-button { margin-top: 18px; min-height: 34px; padding: 0 16px; border: 1px solid #4a4c45; color: #e6e6e1; background: transparent; cursor: pointer; font-size: 11px; }
.connect-button:disabled { color: #858780; cursor: default; }
.video-hud { position: absolute; z-index: 5; left: 15px; right: 15px; display: flex; align-items: center; justify-content: space-between; pointer-events: none; opacity: .95; }
.video-hud.top { top: 14px; }
.video-hud.bottom { bottom: 14px; }
.video-live-tag { display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px; color: #fff; background: var(--accent); font: 10px ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .08em; }
.quality-badge, .video-clock { padding: 5px 7px; color: var(--player-muted); background: rgba(0, 0, 0, .54); font: 10px ui-monospace, SFMono-Regular, Consolas, monospace; }
.video-controls { display: flex; gap: 5px; pointer-events: auto; }
.video-control { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.18); color: white; background: rgba(10,10,9,.62); cursor: pointer; }
.video-control.active { color: #fff; border-color: var(--accent); background: var(--accent); }
.video-control svg { width: 17px; height: 17px; }
.unmute-prompt { position: absolute; z-index: 6; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 10px 14px; border: 1px solid rgba(255,255,255,.25); color: #fff; background: rgba(0,0,0,.7); cursor: pointer; font-size: 12px; }
.exit-fullscreen-floating-btn { position: absolute; z-index: 8; right: 16px; top: 16px; padding: 8px 11px; border: 0; color: #fff; background: rgba(0,0,0,.75); cursor: pointer; }
.video-frame.is-page-fullscreen { position: fixed; z-index: 9998; inset: 0; width: 100vw; height: 100vh; aspect-ratio: auto; }
body.fullscreen-locked { overflow: hidden; }
.stream-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 19px 0 16px; border-bottom: 1px solid var(--line); }
.stream-heading h1 { margin: 0; font-size: 21px; font-weight: 600; letter-spacing: -.04em; }
.stream-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.heading-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.meta-square { width: 7px; height: 7px; background: var(--line-dark); }
.reaction-row { display: flex; align-items: center; gap: 8px; padding-top: 13px; }
.reaction-row button { width: 33px; height: 30px; border: 1px solid var(--line); color: var(--muted); background: var(--surface); cursor: pointer; font-size: 15px; line-height: 1; }
.reaction-row button:hover { color: var(--accent); border-color: var(--accent); }

.sidebar { min-width: 0; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.music-panel { display: flex; align-items: center; gap: 11px; min-height: 68px; padding: 12px 15px; border-bottom: 1px solid var(--line); }
.music-cover { width: 36px; height: 36px; flex: 0 0 auto; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); }
.music-cover svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.music-cover.playing svg { animation: rotate 5s linear infinite; }
@keyframes rotate { to { transform: rotate(360deg); } }
.music-copy { min-width: 0; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.music-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; }
.music-copy span { color: var(--muted); font-size: 10px; }
.music-toggle { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--line); background: transparent; cursor: pointer; }
.music-toggle svg { width: 13px; height: 13px; fill: currentColor; stroke: none; }
.room-info { padding: 15px; border-bottom: 1px solid var(--line); }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.panel-heading h2 { margin: 0; font-size: 13px; font-weight: 600; }
.panel-heading > span { font-size: 9px; }
.status-list { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 10px; margin: 17px 0 0; }
.status-list div { min-width: 0; }
.status-list dt { margin-bottom: 5px; color: var(--muted); font-size: 10px; }
.status-list dd { overflow: hidden; margin: 0; text-overflow: ellipsis; white-space: nowrap; font: 11px ui-monospace, SFMono-Regular, Consolas, monospace; }
.chat-panel { display: flex; min-height: 400px; flex: 1; flex-direction: column; }
.chat-heading { min-height: 50px; padding: 0 15px; border-bottom: 1px solid var(--line); }
.presence-status { color: var(--muted); font-size: 10px; }
.presence-status.connected { color: #5d8e68; }
.message-list { display: flex; flex: 1; flex-direction: column; gap: 13px; min-height: 280px; max-height: min(44vh, 500px); overflow-y: auto; padding: 15px; scrollbar-color: var(--line-dark) transparent; scrollbar-width: thin; }
.msg-item { max-width: 92%; }
.msg-item.self { align-self: flex-end; }
.msg-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.msg-author { font-size: 10px; font-weight: 600; }
.msg-time { color: var(--muted); font: 9px ui-monospace, SFMono-Regular, Consolas, monospace; }
.msg-bubble { width: fit-content; max-width: 100%; padding: 8px 10px; color: var(--ink); background: var(--page); font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; }
.msg-item.self .msg-bubble { color: #fff; background: #343631; }
:root[data-theme="dark"] .msg-item.self .msg-bubble { color: #151613; background: #d8d7d1; }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-form input { min-width: 0; height: 38px; flex: 1; padding: 0 10px; border: 1px solid var(--line); color: var(--ink); background: var(--surface-strong); font-size: 12px; }
.chat-form input::placeholder { color: #999a94; }
.chat-form button { padding: 0 12px; border: 0; color: #fff; background: var(--ink); cursor: pointer; font-size: 11px; }
:root[data-theme="dark"] .chat-form button { color: #161714; background: #efeee9; }
.floating-emoji { position: absolute; z-index: 5; animation: emoji-up 2.8s ease-out forwards; font-size: 24px; }
@keyframes emoji-up { from { opacity: 0; transform: translateY(0) scale(.75); } 15% { opacity: 1; } to { opacity: 0; transform: translateY(-260px) scale(1.2); } }
.floating-danmaku { position: absolute; top: var(--danmaku-top); left: 100%; display: flex; gap: 7px; max-width: 80%; overflow: hidden; white-space: nowrap; color: #fff; text-shadow: 0 1px 3px #000; animation: danmaku var(--danmaku-duration) linear forwards; font-size: 13px; }
.danmaku-author { font-weight: 700; }
@keyframes danmaku { to { left: -85%; } }
.toast { position: fixed; z-index: 10000; left: 50%; bottom: 28px; max-width: calc(100vw - 32px); padding: 10px 14px; transform: translate(-50%, 12px); opacity: 0; color: #fff; background: #242520; pointer-events: none; transition: opacity .2s, transform .2s; font-size: 12px; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.mobile-tabs-header { display: none; }

@media (min-width: 1200px) {
  .stream-layout { grid-template-columns: minmax(0, 1fr) 350px; gap: 32px; }
}
@media (max-width: 900px) {
  .page-shell { padding: 26px 22px; }
  .stream-layout { grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; }
}
@media (max-width: 700px) {
  .topbar { height: 58px; padding: 0 16px; }
  .brand-symbol { width: 30px; height: 30px; }
  .top-actions { gap: 8px; }
  .user-badge { display: none; }
  .page-shell { padding: 14px 0 28px; }
  .lock-card { width: calc(100% - 32px); padding: 34px 25px 29px; }
  .lock-view { min-height: calc(100vh - 100px); }
  .live-view { padding-top: 0; }
  .mobile-tabs-header { display: flex; gap: 0; padding: 0 16px 12px; }
  .mobile-tab-pill { flex: 1; height: 38px; border: 1px solid var(--line); color: var(--muted); background: var(--surface); cursor: pointer; font-size: 12px; }
  .mobile-tab-pill + .mobile-tab-pill { border-left: 0; }
  .mobile-tab-pill.active { color: var(--ink); border-bottom-color: var(--accent); }
  .stream-layout { display: flex; flex-direction: column; gap: 16px; }
  .main-column, .sidebar { width: 100%; }
  .main-column { padding: 0 12px; }
  .player-label { margin-bottom: 7px; padding: 0 3px; font-size: 9px; }
  .video-frame { min-height: 200px; }
  .video-hud { left: 9px; right: 9px; }
  .video-hud.top { top: 8px; }
  .video-hud.bottom { bottom: 8px; }
  .video-control { width: 31px; height: 31px; }
  .stream-heading { padding: 14px 2px 12px; }
  .stream-heading h1 { font-size: 18px; }
  .stream-heading p { font-size: 11px; }
  .heading-meta { font-size: 10px; }
  .reaction-row { padding-top: 10px; }
  .sidebar { display: contents; border: 0; box-shadow: none; }
  .music-panel, .room-info, .chat-panel { width: calc(100% - 24px); margin: 0 12px; background: var(--surface); border: 1px solid var(--line); }
  .music-panel { order: 1; }
  .room-info { order: 2; }
  .chat-panel { order: 3; min-height: 380px; }
  .stream-layout[data-mobile-tab="chat"] .room-info, .stream-layout[data-mobile-tab="chat"] .music-panel { display: none; }
  .stream-layout[data-mobile-tab="info"] .chat-panel { display: none; }
  .message-list { max-height: 42vh; min-height: 250px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
