:root {
  --bg: var(--apple-background); --surface: var(--apple-surface); --surface-raised: var(--apple-surface); --surface-soft: var(--apple-background);
  --border: var(--apple-divider); --border-strong: #86868b; --text: var(--apple-text); --muted: var(--apple-muted);
  --muted-strong: var(--apple-secondary); --blue: var(--apple-link); --blue-strong: #0058b0; --green: #087b56;
  --green-dark: #056443; --red: #b42336; --red-dark: #981b2c; --amber: #9b6500; --radius: var(--apple-card-radius);
  --blue-soft: #edf5ff; --green-soft: #eef8f3; --red-soft: #fff1f2; --amber-soft: #fff8e8;
  font-family: var(--apple-font-body);
  color: var(--text); background: var(--bg); color-scheme: light;
}
* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); font-size: var(--apple-body-size); line-height: 1.47059; letter-spacing: var(--apple-body-tracking); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button, select { cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
[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; }
.skip-link { position: fixed; z-index: 1000; left: 1rem; top: -5rem; padding: .7rem 1rem; border-radius: 8px; background: var(--blue-strong); color: white; }
.skip-link:focus { top: 1rem; }
.mono { font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace; font-variant-numeric: tabular-nums; letter-spacing: normal; }
.muted { margin: .3rem 0 0; color: var(--muted); }
.eyebrow { margin: 0 0 8px; color: var(--muted); font-size: 12px; font-weight: 600; line-height: 1.33333; letter-spacing: -.01em; }
.app { min-height: 100vh; }
.toast { position: fixed; z-index: 900; right: 1rem; top: 5rem; max-width: min(420px, calc(100vw - 2rem)); padding: 1rem 1.2rem; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: 0 8px 32px #1d1d1f1f; overflow-wrap: anywhere; }
.toast.error { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-card { width: min(480px, 100%); display: grid; gap: var(--apple-card-gap); padding: var(--apple-space-large); border: 0; border-radius: var(--radius); background: var(--surface); box-shadow: var(--apple-card-shadow); }
.login-brand, .brand { display: flex; align-items: center; gap: .75rem; }
.login-brand strong, .login-brand span, .brand strong, .brand span { display: block; }
.login-brand strong, .brand strong { font-size: 1.1rem; font-weight: 650; letter-spacing: -.025em; }
.login-brand span, .brand span { color: var(--muted); font-size: .6875rem; font-weight: 600; line-height: 1.3; letter-spacing: .1em; }
.brand-mark { width: 40px; height: 40px; display: grid; flex: 0 0 auto; place-items: center; border: 1px solid var(--text); border-radius: 12px; background: var(--text); color: white; font-size: .8125rem; font-weight: 750; letter-spacing: -.03em; }
.login-copy { margin: .45rem 0; }
.login-copy h1 { margin: 0; font-family: var(--apple-font-display); font-size: 28px; font-weight: 600; line-height: 1.14286; letter-spacing: .007em; }
.login-note { margin: 0; color: var(--muted); text-align: center; font-size: .8rem; }
.login-note a, .footer a { color: inherit; text-underline-offset: 3px; }
.login-note a:hover, .footer a:hover { color: var(--text); }
.topbar { min-height: 76px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--apple-card-gap); padding: 10px 28px; border-bottom: 1px solid var(--border); background: var(--bg); }
.header-status, .topbar-meta { display: flex; align-items: center; gap: .75rem; min-width: 0; flex-wrap: wrap; }
.topbar-meta { justify-content: flex-end; }
.topbar-meta > a.button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.header-live { display: inline-flex; align-items: center; gap: .45rem; min-height: 36px; padding: .35rem .7rem; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-soft); color: var(--muted); font: 600 .75rem/1.3 "Cascadia Mono", Consolas, monospace; overflow-wrap: anywhere; }
.header-live strong { color: var(--muted-strong); font-weight: 600; }
.clock { color: var(--muted); font-size: .78rem; }
.workspace { width: min(1720px, 100%); margin: auto; display: grid; gap: var(--apple-card-gap); padding: 28px 40px 40px; }
.workspace-intro { display: flex; align-items: center; justify-content: space-between; gap: 28px; padding: 28px 0 40px; }
.workspace-intro h1 { margin: 0; font-family: var(--apple-font-display); font-size: 80px; font-weight: 600; line-height: 1.05; letter-spacing: -.015em; }
.workspace-intro > p { max-width: 440px; margin: 0; font-family: var(--apple-font-display); font-size: 28px; font-weight: 600; line-height: 1.14286; letter-spacing: .007em; }
.workspace-intro > p span { color: var(--muted); }
.viewer-mode .admin-only { display: none !important; }
.viewer-mode .monitor-grid { grid-template-columns: minmax(0, 1fr); }
.viewer-mode .global-list-container { height: calc(100vh - 240px); min-height: 480px; }
.panel { min-width: 0; border: 0; border-radius: var(--radius); background: var(--surface); box-shadow: var(--apple-card-shadow); }
.connection-panel, .sessions-panel { padding: var(--apple-card-padding); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.section-heading h1, .section-heading h2, .monitor-heading h2, .session-summary h2 { margin: 0; font-family: var(--apple-font-display); font-size: var(--apple-section-size); font-weight: 600; line-height: var(--apple-section-line); letter-spacing: var(--apple-section-tracking); }
.connection-heading { align-items: end; }
.connection-picker { width: min(330px, 100%); }
label { display: block; margin-bottom: 8px; color: var(--muted-strong); font-size: 14px; font-weight: 600; line-height: 1.42857; }
input, select { width: 100%; min-width: 0; min-height: 44px; padding: .65rem .8rem; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text); }
input::placeholder { color: var(--muted); opacity: 1; }
input:hover, select:hover { border-color: var(--border-strong); }
select:disabled { cursor: not-allowed; opacity: .72; color: var(--muted-strong); }
.connection-form { display: grid; grid-template-columns: repeat(3, minmax(150px, .8fr)) minmax(220px, 1.35fr) auto; align-items: end; gap: 16px; margin-top: 24px; }
.connection-status { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem 1.5rem; margin-top: 1rem; padding: .9rem 1rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-soft); }
.connection-status > div { min-width: 0; display: grid; gap: .2rem; }
.connection-status > div:first-child { flex: 1 1 320px; }
.connection-status strong { font-size: .82rem; overflow-wrap: anywhere; }
.connection-status .status-grow { flex: 1 1 180px; }
.status-label { color: var(--muted); font-size: 12px; font-weight: 600; line-height: 1.33333; letter-spacing: -.01em; text-transform: uppercase; }
.button { min-height: 44px; border: 1px solid var(--text); border-radius: var(--apple-pill-radius); padding: 8px 15px; background: transparent; color: var(--text); font-size: 14px; font-weight: 400; line-height: 20px; letter-spacing: -.016em; white-space: nowrap; transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease; }
.button:hover:not(:disabled) { background: #e9e9ee; border-color: #96969f; }
.button:active:not(:disabled) { background: #dcdce3; }
.button:disabled { cursor: not-allowed; opacity: .45; }
.button.primary, .button.success { border-color: var(--blue); background: var(--blue); color: white; }
.button.primary:hover:not(:disabled), .button.success:hover:not(:disabled) { border-color: var(--blue-strong); background: var(--blue-strong); }
.button.danger { border-color: var(--red); background: var(--red); color: white; }
.button.danger:hover:not(:disabled) { border-color: var(--red-dark); background: var(--red-dark); }
.button.danger.subtle { border-color: #e4b3ba; background: var(--red-soft); color: var(--red); }
.button.danger.subtle:hover:not(:disabled) { border-color: var(--red); background: #ffe2e6; color: var(--red-dark); }
.button.warning { border-color: var(--amber); background: var(--amber-soft); color: #805400; }
.button.warning:hover:not(:disabled) { border-color: var(--amber); background: #fff0c9; }
.button.ghost { background: var(--surface); }
.button.small { min-height: 44px; padding: 8px 15px; font-size: 14px; }
.button.full { width: 100%; }
.form-error { min-height: 1.25em; margin: 0; color: var(--red); }
.session-heading { align-items: end; }
.session-form { display: grid; grid-template-columns: minmax(220px, 1fr) auto; align-items: end; gap: .65rem; }
.session-history { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: .8rem; margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--border); }
.history-label { color: var(--muted); font-size: .75rem; font-weight: 600; line-height: 1.3; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.session-tabs { display: flex; gap: .55rem; min-width: 0; overflow-x: auto; padding: .2rem 2px .35rem; scrollbar-color: var(--border-strong) transparent; }
.session-tab-item { display: inline-flex; flex: 0 0 auto; align-items: stretch; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); }
.session-tab { min-height: 44px; border: 0; padding: .5rem .75rem; background: transparent; color: var(--muted-strong); white-space: nowrap; }
.session-tab-item.selected { border-color: var(--blue); background: var(--blue-soft); box-shadow: inset 0 -2px var(--blue); }
.session-tab-item.selected .session-tab { color: var(--blue-strong); font-weight: 600; }
.session-tab-delete { width: 44px; min-height: 44px; border: 0; border-left: 1px solid var(--border); background: transparent; color: var(--muted); font-size: 1rem; }
.session-tab-delete:hover { background: var(--red-dark); color: white; }
.monitor-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(390px, 1fr); gap: var(--apple-card-gap); align-items: stretch; }
.monitor-panel { min-width: 0; overflow: hidden; }
.monitor-heading { min-height: 82px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; padding: 28px; border-bottom: 1px solid var(--border); }
.monitor-title { display: flex; align-items: center; gap: .7rem; }
.live-dot { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.count-label { color: var(--muted-strong); font: 600 .75rem/1.4 "Cascadia Mono", Consolas, monospace; white-space: nowrap; }
.comment-load-status { display: grid; gap: .1rem; min-width: 0; }
.comment-load-status .count-label { display: block; min-height: 1.4em; }
.comment-load-progress { display: block; min-height: 1.4em; overflow: hidden; color: var(--muted); font: 500 .75rem/1.4 "Cascadia Mono", Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; }
.monitor-toolbar { display: grid; grid-template-columns: minmax(160px, 1fr) 160px; gap: 16px; padding: 20px 28px; }
.search-field { margin: 0; }
.feed-meta { min-height: 40px; display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .55rem 1.25rem; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface-soft); color: var(--muted); font-size: .75rem; }
.list-container { height: clamp(420px, 55vh, 720px); overflow: auto; background: var(--surface-soft); scrollbar-color: var(--border-strong) transparent; }
.comment-list { list-style: none; margin: 0; padding: 16px; }
.comment-item { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 16px; margin-bottom: 10px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.comment-item:last-child { margin-bottom: 0; }
.comment-item.first-match { border-color: var(--amber); background: var(--amber-soft); box-shadow: inset 4px 0 var(--amber); }
.comment-item.first-match .avatar { background: #f4e5bf; color: #6c4700; }
.first-match-badge { padding: .25rem .45rem; border: 1px solid var(--amber); border-radius: 6px; background: #fff0c9; color: #805400; font-size: .75rem; font-weight: 700; line-height: 1.2; letter-spacing: .04em; }
.deleted-badge { padding: .25rem .45rem; border: 1px solid var(--red); border-radius: 6px; background: var(--red-soft); color: var(--red); font-size: .75rem; font-weight: 600; line-height: 1.2; }
.reply-badge { padding: .25rem .45rem; border: 1px solid var(--blue); border-radius: 6px; background: var(--blue-soft); color: var(--blue-strong); font-size: .75rem; font-weight: 600; line-height: 1.2; }
.comment-item.deleted { background: var(--surface-soft); border-style: dashed; }
.comment-item.deleted .comment-message { text-decoration: line-through; }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-soft); color: var(--muted-strong); font-size: .75rem; font-weight: 650; line-height: 1; }
.comment-main { min-width: 0; }
.comment-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: .35rem .55rem; }
.comment-name { color: var(--text); font-size: 17px; font-weight: 600; }
.comment-id, .comment-time { color: var(--muted); font: .75rem/1.4 "Cascadia Mono", Consolas, monospace; overflow-wrap: anywhere; }
.comment-time { margin-left: auto; white-space: nowrap; }
.comment-message { margin: 8px 0 0; color: var(--text); font-size: var(--apple-body-size); line-height: 1.47059; overflow-wrap: anywhere; }
.no-winner { padding: 2rem 1rem; color: var(--muted); text-align: center; }
.session-stack { min-width: 0; display: grid; gap: 1.25rem; align-content: start; }
.session-summary { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 16px; padding: 28px; border-bottom: 1px solid var(--border); }
.title-row, .action-row { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; }
.session-summary h2 { margin-top: .55rem; }
.timer { color: var(--amber); font-size: .9rem; font-weight: 700; }
.badge { display: inline-flex; align-items: center; gap: .4rem; min-height: 30px; padding: .3rem .65rem; border: 1px solid var(--border); border-radius: 999px; font-size: .75rem; font-weight: 600; line-height: 1.3; }
.badge i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.neutral { background: var(--surface-soft); color: var(--muted-strong); }
.badge.active, .badge.ok { border-color: #a4d6bf; background: var(--green-soft); color: var(--green-dark); }
.badge.finalizing, .badge.warning { border-color: #d9bb77; background: var(--amber-soft); color: #805400; }
.badge.error, .badge.interrupted { border-color: #e4b3ba; background: var(--red-soft); color: var(--red); }
.badge.ended { background: var(--surface-soft); color: var(--muted-strong); }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 20px 28px 4px; }
.stats-grid > div { padding: .8rem .85rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-soft); }
.stats-grid span, .stats-grid strong { display: block; }
.stats-grid span { color: var(--muted); font-size: .75rem; }
.stats-grid strong { margin-top: 8px; font-family: var(--apple-font-display); font-size: 28px; font-weight: 600; line-height: 32px; font-variant-numeric: tabular-nums; }
.session-list-container { height: clamp(340px, 43vh, 600px); }
.empty-state { min-height: 470px; display: grid; place-content: center; justify-items: center; padding: 2rem; text-align: center; }
.empty-state p { max-width: 430px; color: var(--muted); }
.empty-symbol { width: 52px; height: 52px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-soft); color: var(--muted-strong); font-size: .875rem; font-weight: 700; }
.footer { display: flex; justify-content: space-between; gap: 16px; margin: 0 40px; padding: 20px 0 28px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; line-height: 16px; }
@media (max-width: 1180px) {
  .connection-form { grid-template-columns: 1fr 1fr; }
  .connection-form .button { grid-column: 1 / -1; }
  .monitor-grid { grid-template-columns: 1fr; }
  .global-list-container, .session-list-container { height: min(520px, 55vh); }
  .session-heading { align-items: flex-start; flex-direction: column; }
  .session-form { width: 100%; }
}
@media (max-width: 820px) {
  .workspace { padding-inline: 22px; }
  .workspace-intro { align-items: flex-start; flex-direction: column; gap: 16px; padding: 20px 0 28px; }
  .workspace-intro h1 { font-size: 48px; line-height: 1.083493; letter-spacing: -.003em; }
  .workspace-intro > p { font-size: 21px; line-height: 25px; letter-spacing: .011em; }
  .topbar { grid-template-columns: minmax(0, 1fr) auto; }
  .header-status { grid-column: 1 / -1; grid-row: 2; }
  .clock { display: none; }
  .connection-heading { align-items: flex-start; flex-direction: column; }
  .connection-picker { width: 100%; }
  .connection-form, .session-form { grid-template-columns: 1fr; }
  .connection-form .button { grid-column: auto; }
  .connection-status { align-items: flex-start; }
  .connection-status > div { flex: 1 1 100%; }
  .connection-status .status-grow { flex-basis: 100%; }
  .session-history { grid-template-columns: 1fr; }
  .session-summary { flex-direction: column; }
  .action-row { width: 100%; flex-wrap: wrap; }
  .action-row .button { flex: 1; }
  .footer { flex-direction: column; margin-inline: 22px; }
}
@media (max-width: 520px) {
  .topbar { grid-template-columns: minmax(0, 1fr); padding: 16px 22px; gap: 16px; }
  .topbar-meta { justify-content: space-between; }
  .login-view { padding: 1rem; }
  .login-card { padding: 28px; }
  .login-copy h1 { font-size: 24px; line-height: 28px; }
  .brand span, .header-live span { display: none; }
  .header-status { align-items: stretch; flex-direction: column; }
  .header-live { justify-content: center; }
  .workspace { padding: 20px 22px 28px; }
  .connection-panel, .sessions-panel { padding: 20px; }
  .monitor-heading, .monitor-toolbar, .session-summary { padding: 20px; }
  .stats-grid { padding-inline: 20px; }
  .monitor-heading, .feed-meta { align-items: flex-start; flex-direction: column; }
  .monitor-toolbar { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .comment-item { grid-template-columns: 36px minmax(0, 1fr); }
  .comment-time { width: 100%; margin-left: 0; }
  .list-container { height: auto; max-height: 70vh; min-height: 360px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
