:root {
  color-scheme: light dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --canvas: #fafafa;
  --paper: #ffffff;
  --rail: #f3f3f3;
  --soft: #ebebeb;
  --hover: #f2f2f2;
  --ink: #212121;
  --quiet: #5e5e5e;
  --line: #dbdbdb;
  --control: #878787;
  --accent: #292929;
  --focus: #292929;
  --primary: #242424;
  --on-primary: #ffffff;
  --mark: #242424;
  --on-mark: #ffffff;
  --success: #262626;
  --success-bg: #ededed;
  --attention: #646464;
  --danger: #252525;
  --danger-bg: #eaeaea;
  --veil: #15151570;
  --section-gap: 32px;
  --curve: cubic-bezier(.2, .65, .25, 1);
  color: var(--ink);
  background: var(--canvas);
}
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #191919;
    --paper: #222222;
    --rail: #1e1e1e;
    --soft: #2e2e2e;
    --hover: #282828;
    --ink: #eeeeee;
    --quiet: #b9b9b9;
    --line: #3b3b3b;
    --control: #7b7b7b;
    --accent: #eeeeee;
    --focus: #eeeeee;
    --primary: #ededed;
    --on-primary: #1e1e1e;
    --mark: #e8e8e8;
    --on-mark: #141414;
    --success: #e0e0e0;
    --success-bg: #333333;
    --attention: #c2c2c2;
    --danger: #eeeeee;
    --danger-bg: #343434;
    --veil: #0c0c0caa;
  }
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; line-height: 1.5; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1 { font-size: clamp(1.65rem, 3vw, 2.2rem); line-height: 1.22; font-weight: 720; }
h2 { font-size: 1rem; font-weight: 710; }
h3 { font-size: 1rem; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .58; }
.muted { color: var(--quiet); font-size: .875rem; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
main:focus { outline-offset: -4px; }
.skip-link { position: fixed; left: 1rem; top: .75rem; z-index: 6; transform: translateY(-200%); padding: 10px 16px; border-radius: 4px; background: var(--paper); color: var(--accent); }
.skip-link:focus { transform: none; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 36px; padding: 6px 11px; border: 1px solid var(--control); border-radius: 4px; background: transparent; color: var(--ink); font-size: .875rem; font-weight: 630; }
.button:not(:disabled):hover, .text-button:hover { background: var(--soft); }
.button-primary, .button-primary:not(:disabled):hover { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.button-primary:not(:disabled):hover { filter: brightness(.89); }
.button-danger { color: var(--danger); border-color: var(--danger); }
.button-danger:not(:disabled):hover { background: var(--danger-bg); }
.text-button { min-height: 36px; padding: 4px 8px; border: 0; border-radius: 4px; background: transparent; color: var(--quiet); font-size: .875rem; font-weight: 610; }
.text-button:hover { color: var(--ink); }
input, select { min-width: 0; min-height: 42px; padding: 8px 11px; border: 1px solid var(--control); border-radius: 4px; color: var(--ink); background: var(--paper); font-size: .9375rem; }
input::placeholder { color: var(--quiet); opacity: 1; }
input:hover, select:hover { border-color: var(--ink); }
.form-message { color: var(--danger); background: var(--danger-bg); border-radius: 4px; padding: 10px 12px; font-size: .875rem; }
.form-message.success { color: var(--success); background: var(--success-bg); }

.brand { display: inline-flex; align-items: center; gap: .65rem; font-weight: 740; font-size: .975rem; min-width: 0; }
.brand-mark, .now-art { display: grid; grid-auto-flow: column; place-content: center; align-items: center; gap: 3px; width: 34px; height: 34px; flex: 0 0 34px; border-radius: 4px; background: var(--mark); color: var(--on-mark); }
.brand-mark i, .now-art i { width: 2px; height: 8px; border-radius: 1px; background: currentColor; }
.brand-mark i:nth-child(2), .now-art i:nth-child(2) { height: 15px; }
.brand-mark i:nth-child(3), .now-art i:nth-child(3) { height: 10px; }
.brand small { display: block; margin-top: 1px; color: var(--quiet); font-size: .75rem; font-weight: 500; }

.auth { display: grid; align-items: start; justify-items: center; min-height: 100vh; min-height: 100dvh; padding: clamp(44px, 17vh, 160px) 22px 44px; }
.auth-content { width: min(100%, 360px); }
.auth-content > .brand { padding-bottom: 23px; width: 100%; border-bottom: 1px solid var(--line); }
.auth-form { margin-top: 29px; }
.auth-form h1 { font-size: clamp(1.7rem, 4vw, 2rem); }
.auth-form .form { margin-top: 22px; }
.form { display: grid; gap: .5rem; }
.form label { font-size: .875rem; font-weight: 650; }
.form label:not(:first-child) { margin-top: .55rem; }
.form > .button { min-height: 44px; margin-top: .7rem; }
.secret-field { position: relative; display: grid; }
.secret-field input { width: 100%; padding-right: 65px; }
.secret-field button { position: absolute; inset-block: 1px; right: 3px; }

.workspace { display: grid; grid-template-columns: minmax(174px, 207px) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100dvh; padding: 24px 16px 14px; border-right: 1px solid var(--line); background: var(--rail); }
.sidebar > .brand { padding-inline: 9px; }
.sidebar nav { display: grid; gap: 4px; margin-top: 34px; }
.nav-button { position: relative; min-height: 43px; padding: 7px 11px; border: 0; border-radius: 4px; text-align: left; color: var(--quiet); background: transparent; font-size: .9rem; }
.nav-button:hover { background: var(--soft); color: var(--ink); }
.nav-button[aria-current="page"] { background: var(--soft); color: var(--ink); font-weight: 700; }
.nav-button[aria-current="page"]::before { position: absolute; inset: 10px auto 10px 0; width: 2px; background: var(--accent); content: ""; }
.sidebar-footer { display: flex; align-items: center; gap: .55rem; padding-top: 12px; margin-top: auto; border-top: 1px solid var(--line); }
.sidebar-footer div { display: grid; flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: .8125rem; }
.sidebar-footer small { color: var(--quiet); }
.workspace-main { min-width: 0; }
main { max-width: 1450px; margin: 0 auto; padding: clamp(25px, 4.2vw, 63px) clamp(21px, 4.2vw, 60px); }
.page-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 18px; margin-bottom: var(--section-gap); }
.page-actions, .connection { display: flex; align-items: center; gap: .65rem; }
.connection { gap: .4rem; color: var(--quiet); font-size: .8125rem; }
.connection i { width: 6px; height: 6px; flex: 0 0 6px; border-radius: 3px; background: var(--quiet); }
.connection[data-state="online"] i { background: var(--success); }
.connection[data-state="offline"] i { background: transparent; border: 1px solid currentColor; }
.connection time { font-variant-numeric: tabular-nums; }
#notice:not([hidden]) { margin-bottom: 15px; }

.metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin-bottom: var(--section-gap); border-block: 1px solid var(--line); }
.metrics div { min-width: 0; padding: 11px clamp(10px, 1.7vw, 22px) 12px; }
.metrics div:first-child { padding-left: 0; }
.metrics div + div { border-left: 1px solid var(--line); }
.metrics dt { color: var(--quiet); font-size: .8125rem; }
.metrics dd { margin-top: 3px; font-size: 1.65rem; line-height: 1.15; font-weight: 670; font-variant-numeric: tabular-nums; }

.now-playing { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; margin-bottom: var(--section-gap); padding: 10px 0 11px; border-bottom: 1px solid var(--line); }
.now-art { width: 38px; height: 38px; align-self: center; }
.now-copy h2 { margin-bottom: 3px; color: var(--accent); font-size: .75rem; font-weight: 720; }
#now-track { display: block; font-size: 1.15rem; font-weight: 710; line-height: 1.3; overflow-wrap: anywhere; }
#now-meta { margin: 3px 0 0; color: var(--quiet); font-size: .8125rem; overflow-wrap: anywhere; }
.now-controls { display: grid; grid-template-columns: minmax(72px, 148px) auto; gap: 3px 15px; align-items: center; }
.now-controls progress { grid-column: 1; margin: 0; height: 4px; }
.now-controls .muted { grid-column: 1; grid-row: 2; font-size: .75rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.now-controls .button { grid-column: 2; grid-row: 1 / 3; }

.room-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(177px, 207px); align-items: start; gap: clamp(20px, 2.4vw, 37px); }
.room-layout:has(.recent[hidden]) { grid-template-columns: minmax(0, 1fr); }
.listing, .panel { min-width: 0; }
.panel { border: 1px solid var(--line); border-radius: 4px; background: var(--paper); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding-bottom: 10px; }
.panel .panel-head { padding: 14px 17px 10px; }
.table-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.table-toolbar input { flex: 1 1 164px; max-width: 345px; }
.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .875rem; }
th, td { padding: 10px 9px; }
th { border-block: 1px solid var(--line); color: var(--quiet); background: var(--rail); font-size: .8125rem; font-weight: 650; white-space: nowrap; }
td { border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
th:first-child, td:first-child { padding-left: 11px; }
th:last-child, td:last-child { padding-right: 11px; }
tbody tr:hover, tbody tr:focus-within { background: var(--hover); }
td .button { min-height: 32px; padding: 4px 5px; border-color: transparent; }
.room-table td:last-child .button::after { content: ""; width: 5px; height: 5px; border: solid currentColor; border-width: 1px 1px 0 0; transform: rotate(45deg); }
.room-code { font: 650 .83rem ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--quiet); white-space: nowrap; }
.track-name { display: block; font-weight: 670; }
.track-artist { display: block; color: var(--quiet); font-size: .8125rem; }
.badge { display: inline-flex; align-items: center; gap: 5px; color: var(--quiet); font-size: .8125rem; white-space: nowrap; }
.badge::before { flex: 0 0 5px; width: 5px; height: 5px; border-radius: 3px; background: currentColor; content: ""; }
.badge.playing { color: var(--success); font-weight: 660; }
.badge.reconnecting { color: var(--attention); }
.badge.reconnecting::before { background: transparent; border: 1px solid currentColor; }
.empty-state { display: grid; gap: .25rem; padding: 21px 11px 24px; border-bottom: 1px solid var(--line); }
.empty-state strong { font-size: .9375rem; }
.empty-state p:empty { display: none; }
.pagination { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 9px; padding: 12px 0; }
.pagination > div { display: flex; gap: 6px; }
.recent { padding-left: 16px; border-left: 1px solid var(--line); }
.recent .panel-head { align-items: baseline; padding-bottom: 4px; }
.recent .panel-head button { min-height: 27px; padding: 0 2px; font-size: .8125rem; white-space: nowrap; }
.recent-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 2px 4px; padding: 9px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.recent-item:last-child { border-bottom: 0; }
.recent-item strong { grid-area: 1 / 1; font-size: .8125rem; }
.recent-item time { grid-area: 1 / 2; white-space: nowrap; font-size: .6875rem; font-variant-numeric: tabular-nums; }
.recent-item p { grid-column: 1 / -1; font-size: .75rem; }
.recent-item time, .recent-item p, .recent .quiet-empty { color: var(--quiet); }
.recent .quiet-empty { padding: 4px 0 12px; font-size: .875rem; }
.event-time { white-space: nowrap; }
.mobile-label { display: none; }

.security-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.security-data div { display: flex; justify-content: space-between; gap: .65rem; padding: 11px 17px; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.security-data dt { color: var(--quiet); font-size: .9rem; }
.security-data dd { font-size: .9rem; text-align: right; font-weight: 650; }
.security-form { max-width: 490px; padding: 5px 17px 17px; }
.security-form > .button { justify-self: start; }

dialog { color: var(--ink); border: 1px solid var(--line); background: var(--paper); opacity: 0; transition: opacity 145ms var(--curve), display 145ms allow-discrete, overlay 145ms allow-discrete; }
dialog[open] { opacity: 1; }
dialog::backdrop { background: transparent; transition: background-color 145ms var(--curve), overlay 145ms allow-discrete, display 145ms allow-discrete; }
dialog[open]::backdrop { background: var(--veil); }
.drawer { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(100%, 508px); height: 100%; max-height: none; max-width: none; padding: 0; transform: translateX(17px); transition: transform 165ms var(--curve), opacity 165ms var(--curve), display 165ms allow-discrete, overlay 165ms allow-discrete; }
.drawer[open] { transform: none; }
@starting-style {
  dialog[open] { opacity: 0; }
  .drawer[open] { transform: translateX(17px); }
  dialog[open]::backdrop { background: transparent; }
}
.drawer-header { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.drawer-header .room-code { margin-bottom: 3px; }
.drawer-body { padding: 18px 20px max(24px, env(safe-area-inset-bottom)); }
.playback-detail { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px .7rem; align-items: start; }
.playback-detail .track-name { font-size: 1.2rem; overflow-wrap: anywhere; }
.playback-detail .badge { grid-area: 1 / 2 / 3 / 3; }
.playback-detail .muted { grid-column: 1; }
progress { appearance: none; display: block; width: 100%; height: 5px; margin: 14px 0 4px; border: 0; border-radius: 2px; background: var(--line); color: var(--accent); }
progress::-webkit-progress-bar { border-radius: 2px; background: var(--line); }
progress::-webkit-progress-value { border-radius: 2px; background: var(--accent); }
progress::-moz-progress-bar { border-radius: 2px; background: var(--accent); }
#detail-time { margin-bottom: 13px; font-variant-numeric: tabular-nums; }
#detail-info div { padding-inline: 0; }
.drawer-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: 10px 0 20px; }
.member { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.member-identity { min-width: 0; overflow-wrap: anywhere; }
.member-identity strong { display: block; font-size: .9375rem; }
.member-identity span { color: var(--quiet); font-size: .875rem; }
.member-actions { display: flex; gap: 5px; }
#detail-message { margin-top: 10px; }
.confirm { width: min(calc(100% - 28px), 420px); padding: 21px; border-radius: 4px; }
.confirm p { margin: .45rem 0 1rem; }
.confirm form { display: flex; justify-content: flex-end; gap: .5rem; }

@media (max-width: 1110px) {
  .room-layout { grid-template-columns: minmax(0, 1fr); }
  .recent { max-width: 540px; padding-left: 0; border-left: 0; }
}
@media (max-width: 760px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 11px 5px; padding: 11px 15px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar > .brand { padding: 0; }
  .sidebar nav { grid-row: 2; grid-column: 1 / -1; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin: 0; }
  .nav-button { min-height: 44px; border-radius: 0; text-align: center; padding-inline: 2px; font-size: .8125rem; }
  .nav-button[aria-current="page"] { background: transparent; }
  .nav-button[aria-current="page"]::before { inset: auto 10px 0; width: auto; height: 2px; }
  .sidebar-footer { margin: 0; padding: 0; border: 0; }
  .sidebar-footer div, .connection time { display: none; }
  .button, .text-button, td .button, input, select { min-height: 44px; }
  main { --section-gap: 16px; padding: 24px 16px 32px; }
  .page-heading { margin-bottom: var(--section-gap); }
  .page-actions { gap: .45rem; }
  .security-layout { grid-template-columns: minmax(0, 1fr); }
  .room-table, .room-table tbody, .room-table tr { display: block; }
  .room-table thead { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .room-table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .85fr) auto; grid-template-areas: "track track state" "code host actions" "count count actions"; gap: 2px .55rem; align-items: center; padding: 10px 2px; border-top: 1px solid var(--line); }
  .room-table tbody tr:last-child { border-bottom: 1px solid var(--line); }
  .room-table td { padding: 0; border: 0; }
  .room-table td:nth-child(1) { grid-area: track; }
  .room-table td:nth-child(2) { grid-area: code; }
  .room-table td:nth-child(3) { grid-area: host; color: var(--quiet); }
  .room-table td:nth-child(4) { grid-area: count; color: var(--quiet); font-variant-numeric: tabular-nums; }
  .room-table td:nth-child(5) { grid-area: state; }
  .room-table td:nth-child(6) { grid-area: actions; }
  .room-table td:nth-child(5), .room-table td:nth-child(6) { justify-self: end; }
  .room-table .mobile-label { display: inline; font-size: .8125rem; }
  .recent .panel-head button { min-height: 44px; }
}
@media (max-width: 520px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: var(--section-gap); }
  .metrics div { padding: 9px 12px; }
  .metrics div:nth-child(odd) { padding-left: 0; border-left: 0; }
  .metrics div:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .metrics dd { font-size: 1.35rem; }
  .now-playing { grid-template-columns: auto minmax(0, 1fr); gap: 7px 9px; margin-bottom: var(--section-gap); }
  .now-controls { grid-column: 2; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; }
  .table-toolbar input { flex-basis: 140px; }
  .page-actions #refresh { padding-inline: 8px; }
}
@media (prefers-contrast: more) {
  :root { --line: var(--control); --quiet: var(--ink); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
