/* Base tokens, page shell, login, setup and session list. */
:root {
  color-scheme: dark;
  --ink: #e7eaf0;
  --muted: #87909d;
  --paper: #101318;
  --card: #191d24;
  --line: #303640;
  --coral: #ff596b;
  --coral-dark: #db4055;
  --teal: #55d6b2;
  --teal-soft: #1c3834;
  --yellow: #edc76a;
  --shadow: 0 18px 48px rgb(0 0 0 / 24%);
  --font-ui: "Avenir Next", Avenir, "Yu Gothic", sans-serif;
}

* { box-sizing: border-box; }
html { overflow-y: scroll; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; transform: none !important; }
.shell { width: min(1120px, calc(100% - 48px)); margin: 0 auto; padding: 28px 0 42px; }
.topbar { display: flex; min-height: 38px; align-items: center; justify-content: space-between; margin-bottom: 27px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-size: 15px; font-weight: 850; letter-spacing: -.055em; text-decoration: none; }
.brand-mark { display: block; flex: 0 0 auto; }
.brand-wordmark { display: block; flex: 0 0 auto; width: 90px; height: auto; }

.view { animation: rise .35s ease both; }
[hidden] { display: none !important; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.login-panel { width: min(100%, 560px); margin: 0 auto; padding: clamp(24px, 5vw, 44px); overflow: hidden; }
.login-action h1 { margin: 0 0 10px; font-size: 16px; }
.login-action > p { color: var(--muted); font-size: 12px; line-height: 1.7; }
.login-panel .login-guest-note { margin: 20px 0 0; color: var(--muted); font-size: 11px; line-height: 1.8; }
.login-status { color: var(--muted); font-size: 12px; line-height: 1.6; }
.login-status[data-kind="error"] { color: var(--coral); }
.login-status:empty { display: none; }
.topbar .button { margin: 0; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: inherit; font-size: clamp(42px, 7vw, 74px); font-weight: 500; letter-spacing: -.075em; line-height: .98; }
.setup-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(260px, .8fr); gap: 20px; align-items: stretch; }
.setup-grid.guest-mode { grid-template-columns: 1fr; }
.panel { border: 1px solid var(--line); border-radius: 6px; background: var(--card); box-shadow: var(--shadow); }
.setup-panel, .recent-panel { padding: 26px; }
.panel-heading { display: flex; align-items: center; gap: 13px; margin-bottom: 25px; }
.panel-heading.compact { margin-bottom: 20px; }
.panel-heading h2 { margin: 0; font-size: 17px; letter-spacing: -.035em; }
.storage-icon { display: grid; width: 37px; height: 37px; flex: 0 0 37px; place-items: center; border-radius: 5px; background: var(--teal-soft); color: var(--teal); font-size: 15px; }
.field { display: grid; gap: 8px; margin-bottom: 17px; color: #b3bbc5; font-size: 11px; font-weight: 800; }
.field input, .field select, .field textarea { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 4px; outline: 0; background: #11151a; color: var(--ink); padding: 12px 13px; font-size: 13px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgb(85 214 178 / 14%); }
.turn-permit-field > p { margin: 0 0 14px; color: #b3bbc5; font-size: 12px; line-height: 1.6; }
.transfer-progress { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; }
.transfer-progress h3, .transfer-progress p { margin: 0; }
.transfer-progress h3 { font-size: 12px; }
.transfer-progress p { color: #b3bbc5; font-size: 12px; line-height: 1.6; }
.transfer-diagnostics { display: grid; gap: 8px; color: #b3bbc5; font-size: 11px; }
.network-metrics { width: 100%; border-collapse: collapse; color: #b3bbc5; font-size: 11px; line-height: 1.45; table-layout: fixed; }
.network-metrics th, .network-metrics td { border-bottom: 1px solid var(--line); padding: 3px 5px; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.network-metrics th { width: 35%; color: var(--muted); font-weight: 700; }
.network-metrics tr:last-child th, .network-metrics tr:last-child td { border-bottom: 0; }
#transferUploadSummary { color: #59d6b2; }
.network-event-panel { margin-top: 18px; padding: 18px; }
.network-event-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.terminal-ui .network-event-heading .terminal-section-code { margin: 0; }
summary.network-event-heading { cursor: pointer; list-style: none; }
summary.network-event-heading::-webkit-details-marker { display: none; }
summary.network-event-heading::before { content: ''; flex: 0 0 auto; width: 0; height: 0; border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-left: 7px solid var(--muted); }
.network-event-panel[open] > summary::before { border-top: 7px solid var(--muted); border-right: 5px solid transparent; border-bottom: 0; border-left: 5px solid transparent; }
summary.network-event-heading > div { flex: 1; }
.network-event-panel:not([open]) > summary.network-event-heading { margin-bottom: 0; padding-bottom: 0; }
summary.network-event-heading:focus-visible { outline: 2px solid var(--teal); outline-offset: 4px; }
.network-event-count { color: var(--muted); font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }
.network-event-log { display: block; width: 100%; height: 280px; resize: vertical; overflow: auto; border: 1px solid var(--line); border-radius: 3px; outline: 0; background: #080e0b; color: #a5bca9; padding: 10px; font: 11px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; tab-size: 2; }
.network-event-log:focus { border-color: var(--teal); box-shadow: 0 0 0 2px rgb(85 214 178 / 14%); }
.network-event-log { white-space: pre; user-select: text; }
.network-event-warning { color: #ffd166; }
.network-event-error { color: #ff8f9a; }
.device-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; align-items: end; }
.button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: 9px; border: 0; border-radius: 4px; padding: 12px 16px; font-size: 12px; font-weight: 850; text-decoration: none; transition: transform .15s, background .15s, border-color .15s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button-primary { width: 100%; margin-top: 3px; background: var(--coral); color: white; }
.button-primary:hover:not(:disabled), .button-record:hover:not(:disabled) { background: var(--coral-dark); }
.button-quiet { min-height: 42px; margin-bottom: 17px; border: 1px solid var(--line); background: transparent; color: var(--ink); padding: 10px 12px; white-space: nowrap; }
.button-quiet:hover:not(:disabled) { border-color: var(--teal); }
.inline-message { min-height: 16px; margin: -5px 0 11px; color: var(--coral-dark); font-size: 11px; line-height: 1.5; }
.recent-panel { min-height: 265px; }
.session-list, .take-list { display: grid; }
.session-list { gap: 9px; }
.session-entry { display: flex; align-items: center; justify-content: flex-start; gap: 10px; border-top: 1px solid var(--line); padding: 12px 0 3px; }
.session-entry-info { min-width: 0; flex: 1 1 auto; }
.session-entry-name { overflow: hidden; margin: 0 0 4px; font-size: 12px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.session-entry-meta { margin: 0; color: var(--muted); font-size: 10px; }
.session-open { flex: 0 0 auto; margin-left: auto; border: 0; background: transparent; color: var(--teal); padding: 7px 0 7px 8px; font-size: 10px; font-weight: 850; }
.session-open:hover { color: var(--coral-dark); }
.session-delete { flex: 0 0 auto; border: 0; background: transparent; color: #ff8792; padding: 7px 0 7px 8px; font-size: 10px; font-weight: 850; }
.session-delete:hover:not(:disabled) { color: var(--coral); }
.session-delete:disabled { opacity: .5; }
.session-bulk-delete { flex: 0 0 auto; margin: 0; padding: 8px 10px; white-space: nowrap; }
.session-selection { display: flex; flex: 0 0 16px; align-items: center; }
.session-selection input { width: 16px; height: 16px; accent-color: var(--teal); }
.empty-state { margin: 0; color: #899398; font-size: 12px; line-height: 1.7; }
.page-footer { margin-top: 25px; color: #778184; font-size: 9px; font-weight: 750; letter-spacing: .08em; text-align: center; text-transform: uppercase; }
.page-footer span { padding: 0 7px; color: var(--coral); }
.studio-head { margin-bottom: 22px; }
.text-button { border: 0; background: transparent; color: var(--muted); padding: 0; font-size: 11px; font-weight: 800; text-decoration: none; }
.text-button:hover { color: var(--teal); }
.text-button span { margin-right: 4px; font-size: 15px; }
.settings-title { margin: 0 0 14px; font-size: 16px; letter-spacing: -.025em; }
.settings-panel > p { color: var(--muted); font-size: 13px; line-height: 1.8; overflow-wrap: anywhere; }
.settings-panel > p:last-child { margin-bottom: 0; }
.settings-warning { color: var(--coral); }
.settings-form { display: grid; gap: 12px; }
.settings-form .field { margin: 0; }
.settings-form .button { width: 100%; }
.settings-panel .settings-status { margin-top: 16px; color: var(--ink); }
.settings-status:empty { display: none; }
.studio-title-row { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-top: 19px; }
.studio-title-row h1 { font-size: clamp(34px, 5vw, 54px); overflow-wrap: anywhere; }
.participant-chip { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 4px; background: #14181e; padding: 6px 11px 6px 6px; color: #c5cbd3; font-size: 10px; font-weight: 800; }
.role-badge { border-radius: 3px; background: #3b3320; padding: 5px 7px; color: var(--yellow); font-size: 9px; font-weight: 850; }
.role-badge.guest { background: var(--teal-soft); color: var(--teal); }
.participant-controls { display: flex; flex: 0 0 auto; align-items: center; gap: 10px; }
.session-delete { min-height: 36px; margin: 0; padding: 7px 10px; font-size: 9px; }
.studio-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: stretch; }
.studio-grid > .room-panel { margin-top: 0; }
