:root {
  color-scheme: dark;
  --bg-primary: #0d0e14;
  --bg-elevated: #161821;
  --bg-input: #242735;
  --bg-hover: #2d3044;
  --border-subtle: #282b3a;
  --border-emphasis: #3a3e52;
  --text-primary: #d4d7e8;
  --text-secondary: #8b8fa6;
  --accent-blue: #7ba2f7;
  --accent-blue-hover: #8fb5ff;
  --accent-green: #8fd694;
  --accent-red: #f07a8d;
  --font-ui: ui-sans-serif, -apple-system, system-ui, "Segoe UI", Helvetica, "Apple Color Emoji", Arial, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
  --muted: var(--text-secondary);
  --line: var(--border-subtle);
  --accent: var(--accent-blue);
  font: 13px/1.5 var(--font-ui);
  color: var(--text-primary);
  background: var(--bg-primary);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, summary { touch-action: manipulation; }
button { min-height: 32px; padding: 5px 12px; border: 1px solid transparent; border-radius: 4px; background: var(--accent-blue); color: var(--bg-primary); font-size: 13px; font-weight: 500; cursor: pointer; }
button:hover { background: var(--accent-blue-hover); }
button.secondary { border-color: var(--border-emphasis); background: transparent; color: var(--text-primary); }
button.secondary:hover { background: var(--border-emphasis); }
button.quiet { padding: 5px 8px; background: transparent; color: var(--text-secondary); font-weight: 400; }
button.quiet:hover { background: var(--bg-hover); color: var(--text-primary); }
button.forget:hover { color: var(--accent-red); }
button:disabled { cursor: default; opacity: .5; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 3px; }
a { color: var(--accent-blue); }
#portal { max-width: 808px; margin: 0 auto; padding: 0 24px; }
header { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--border-subtle); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text-primary); text-decoration: none; white-space: nowrap; }
.brand-icon { width: 24px; height: 24px; }
.brand-text { display: inline-flex; align-items: baseline; font-size: 16px; font-weight: 600; }
.tlbx-wordmark { letter-spacing: .09em; }
.product-label { color: var(--text-secondary); font-size: 14px; font-weight: 400; }
.account { display: flex; align-items: center; gap: 6px; min-width: 0; }
#account-label { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
main { padding: 24px 0; }
h1 { margin: 0 0 8px; font-size: 24px; line-height: 1.25; font-weight: 600; }
h2 { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.muted { margin: 0 0 16px; color: var(--text-secondary); }
.auth { max-width: 560px; margin: 0 auto; }
#import-back { margin: -4px 0 12px -8px; }
form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-size: 13px; }
.optional { color: var(--text-secondary); font-weight: 400; }
input, textarea, select { width: 100%; min-width: 0; min-height: 36px; padding: 7px 10px; border: 1px solid var(--border-emphasis); border-radius: 4px; background: var(--bg-input); color: var(--text-primary); }
input:hover, textarea:hover, select:hover { border-color: var(--accent-blue); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent-blue); box-shadow: 0 0 0 3px rgb(123 162 247 / 15%); }
textarea { min-height: 96px; max-width: 100%; resize: vertical; font: 12px/1.5 "Cascadia Code", "JetBrains Mono", Consolas, monospace; }
summary { width: fit-content; color: var(--text-secondary); cursor: pointer; }
details label { margin-top: 10px; }
details textarea { margin-top: 8px; }
#import-options > summary { color: var(--text-primary); font-weight: 500; }
#import-options form { margin-top: 12px; }
.auth form > button { justify-self: start; }
.key-note { margin: 0; color: var(--text-secondary); font-size: 12px; }
.registration { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border-subtle); }
.registration > summary { color: var(--text-primary); font-weight: 500; }
.registration > .muted { margin: 12px 0; font-size: 12px; }
input[type=file] { padding: 5px 8px; font-size: 12px; }
input::file-selector-button { margin-right: 10px; padding: 4px 8px; border: 1px solid var(--border-emphasis); border-radius: 3px; background: var(--bg-elevated); color: var(--text-primary); font: inherit; cursor: pointer; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.section-heading h1 { margin: 0; }
.section-heading-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.device-list { overflow: hidden; border: 1px solid var(--border-subtle); border-radius: 6px; background: var(--bg-elevated); }
.device-list:empty { display: none; }
.device { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border-subtle); }
.device:last-child { border-bottom: 0; }
.device-icon { flex: none; width: 28px; height: 24px; fill: none; stroke: var(--text-secondary); stroke-width: 1.5; }
.device-content { flex: 1; min-width: 0; }
.device-name { margin: 0 0 2px; font-size: 14px; line-height: 1.4; font-weight: 600; overflow-wrap: anywhere; }
.device-state { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: 12px; }
.dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--text-secondary); }
.online .dot { background: var(--accent-green); }
.device.switching .device-status { color: var(--accent-blue); }
.device-actions { display: flex; align-items: center; gap: 8px; }
.device-actions button { white-space: nowrap; }
.empty { max-width: 560px; margin: 16px 0; color: var(--text-secondary); }
.notice { margin: 16px 0; padding: 10px 12px; border-left: 2px solid var(--accent-blue); background: var(--bg-elevated); overflow-wrap: anywhere; }
.notice.error { border-color: var(--accent-red); color: var(--accent-red); }
.key-privacy { color: var(--text-secondary); font-size: 12px; }
.key-privacy strong { color: var(--text-primary); font-weight: 500; }
#devices > .muted { margin: 12px 0 0; font-size: 12px; }
footer { display: flex; align-items: center; gap: 8px 20px; padding: 12px 0; border-top: 1px solid var(--border-subtle); color: var(--text-secondary); font-size: 12px; }
footer #install { margin-left: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
#workspace { display: flex; flex-direction: column; height: 100dvh; }
#workspace-container { flex: 1; min-height: 0; }
#workspace-container > iframe { display: block; width: 100%; height: 100%; border: 0; }
.connection-error { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; background: rgb(13 14 20 / 94%); text-align: center; }
.connection-error p { max-width: 500px; margin: 0; color: var(--text-secondary); overflow-wrap: anywhere; }
.connection-error button { min-width: 180px; }
#install-help { max-width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; padding: 20px; border: 1px solid var(--border-subtle); border-radius: 8px; background: var(--bg-elevated); color: var(--text-primary); }
#install-help::backdrop { background: rgb(0 0 0 / 60%); }
#install-help h2 { font-size: 18px; }
#install-help p { color: var(--text-secondary); }
#install-help button { margin-top: 4px; }
@media (max-width: 640px) {
  #portal { padding: 0 16px; }
  header { min-height: 56px; }
  .account .quiet { padding-right: 0; font-size: 12px; }
  main { padding: 20px 0; }
  .section-heading { flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
  .section-heading-actions { width: 100%; }
  .section-heading-actions > button:first-child { flex: 1; }
  button, input, select, input::file-selector-button { min-height: 44px; }
  summary { display: flex; align-items: center; min-height: 44px; list-style: none; }
  summary::before { content: "▸"; margin-right: 7px; font-size: 11px; }
  details[open] > summary::before { content: "▾"; }
  summary::-webkit-details-marker { display: none; }
  #import-options form { margin-top: 6px; }
  .device { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 4px 10px; padding: 8px 12px; }
  .device-name { margin-bottom: 1px; line-height: 1.25; }
  .device-actions { grid-column: 2; justify-content: space-between; gap: 4px; }
  .device-actions > button:first-child { flex: 1; }
  .device-actions .quiet { padding: 5px 8px; font-size: 12px; }
  .device-state { font-size: 11px; line-height: 1.4; }
  footer { flex-wrap: wrap; gap: 4px 12px; padding: 8px 0; }
  footer > span:nth-child(2) { display: none; }
  .notice { margin: 12px 0; }
}
@media (pointer: coarse) and (min-width: 641px) {
  button, input, select, input::file-selector-button, summary { min-height: 44px; }
}
@media (prefers-reduced-motion: no-preference) {
  button, input, textarea, select { transition: background-color .15s, border-color .15s, color .15s, opacity .15s; }
}

.domain-migration h2 { margin: 0 0 6px; font-size: 14px; }
.domain-migration p { margin: 0 0 8px; color: var(--text-secondary); font-size: 12px; }
.domain-migration #migration-message:empty { display: none; }
.domain-migration #migration-message { margin: 8px 0 0; }
