:root { font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: #202329; background: #f5f6f8; color-scheme: light; --muted: #626973; --line: #e1e4e9; --accent: #b54336; }
* { box-sizing: border-box; letter-spacing: 0; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; }
#workspace { display: flex; flex-direction: column; height: 100dvh; }
#workspace > .topbar, #workspace > .tabs, #error-banner { flex-shrink: 0; }
#workspace > main { flex: 1; min-height: 0; overflow: auto; }
#sessions-view { height: 100%; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; border: 1px solid var(--line); background: white; color: inherit; border-radius: 6px; min-height: 42px; }
button:hover { background: #eff1f4; }
button:disabled { cursor: not-allowed; opacity: .45; }
a { color: var(--accent); text-decoration: none; }
button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid #b54336; outline-offset: 2px; }
input, textarea { border: 1px solid #bfc5ce; border-radius: 6px; padding: 10px 12px; background: white; min-width: 0; color: inherit; }
textarea { resize: vertical; }
h1, h2, p { margin: 0; }
h1 { font-size: 20px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 650; }
.secondary { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.topbar { height: 68px; display: flex; align-items: center; gap: 12px; padding: 0 24px; background: white; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand strong { font-size: 20px; }
.brand img { border-radius: 7px; }
.connection { font-size: 14px; color: var(--muted); white-space: nowrap; }
.connection.online { color: #167451; }
.icon-button { width: 42px; height: 42px; flex: 0 0 42px; display: inline-grid; place-items: center; border-color: transparent; }
button img, .tabs img { width: 18px; height: 18px; }
.tabs { display: flex; align-items: stretch; gap: 16px; padding: 0 24px; height: 54px; background: white; border-bottom: 1px solid var(--line); }
.tabs button { display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 0 4px; font-size: 14px; }
.tabs button.selected { border-bottom-color: var(--accent); color: var(--accent); }
.tabs a { margin-left: auto; align-self: center; font-size: 14px; white-space: nowrap; }
.tabs span { font-size: 12px; color: var(--muted); }
#error-banner { padding: 10px 24px; background: #fff0ec; color: #983b2c; font-size: 14px; overflow-wrap: anywhere; }
.session-layout { display: grid; grid-template-columns: 330px minmax(0, 1fr); height: 100%; }
.session-sidebar { min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #fcfcfd; }
.list-heading { display: flex; justify-content: space-between; align-items: center; padding: 22px 20px 14px; }
.list-heading span { font-size: 14px; color: #167451; }
#search { margin: 0 16px 14px; font-size: 16px; }
.session-scope { margin: 0 16px 12px; flex-shrink: 0; }
.session-scope label { flex: 1; text-align: center; }
#session-connect-bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
#session-connect-bar .secondary { min-width: 0; }
#connect-session { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; flex-shrink: 0; font-size: 14px; }
#session-list { overflow: auto; min-height: 0; }
.session-row { display: block; width: 100%; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 15px 20px; text-align: left; background: transparent; }
.session-row.selected { background: #f5e9e6; box-shadow: inset 3px 0 var(--accent); }
.session-row strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 15px; line-height: 1.5; font-weight: 600; overflow-wrap: anywhere; }
.session-row footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 9px; font-size: 12px; color: var(--muted); }
.session-row footer span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 190px; }
.badge { font-size: 12px; padding: 3px 7px; background: #e9ecf0; border-radius: 4px; color: #515965; white-space: nowrap; }
.badge.active, .badge.accepted, .badge.sent { color: #126247; background: #def2e9; }
.badge.armed, .badge.sending { color: #885210; background: #fff0d5; }
.badge.error, .badge.unconfirmed, .badge.interrupted { color: #9a352c; background: #ffe6e1; }
.detail { min-width: 0; min-height: 0; background: white; }
#selected-session { height: 100%; display: flex; flex-direction: column; }
.detail-heading { display: flex; flex-shrink: 0; align-items: flex-start; gap: 14px; padding: 20px 28px; border-bottom: 1px solid var(--line); }
.detail-heading > div { flex: 1; min-width: 0; }
.detail-heading h2 { overflow-wrap: anywhere; max-height: 76px; overflow: auto; }
.detail-heading .secondary { margin-top: 6px; font-size: 12px; }
.events { flex: 1; min-height: 0; overflow: auto; padding: 12px 28px 28px; }
.event { padding: 16px 0; border-bottom: 1px solid #eef0f3; }
.event header { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: 12px; color: var(--muted); }
.event header strong { font-size: 14px; color: #3c424a; }
.event.user header strong { color: var(--accent); }
.event pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; font: inherit; font-size: 16px; line-height: 1.7; }
.event.tool pre { font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; color: #59616c; max-height: 160px; overflow: auto; }
.composer { flex-shrink: 0; padding: 14px 28px max(18px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #fafbfc; }
.composer-options { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 8px; }
.segments { display: flex; gap: 2px; padding: 3px; background: #e8ebef; border-radius: 6px; min-width: 0; }
.segments label { cursor: pointer; position: relative; min-width: 0; }
.segments input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segments span { display: block; padding: 6px 12px; font-size: 14px; white-space: nowrap; border-radius: 4px; }
.segments input:checked + span { background: white; color: var(--accent); box-shadow: 0 1px 3px #20232915; }
.segments input:focus-visible + span { outline: 2px solid var(--accent); }
.composer textarea { display: block; width: 100%; max-height: 240px; min-height: 84px; }
.composer footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 10px; }
#command-state { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.primary { display: inline-flex; justify-content: center; align-items: center; gap: 9px; background: #a83e33; border-color: #a83e33; color: white; padding: 8px 18px; flex-shrink: 0; }
.primary:hover { background: #8e3027; }
.primary img { filter: invert(1); }
.danger { color: #a8342d; border-color: #edc8c4; }
.flat-view { max-width: 1200px; margin: 0 auto; padding: 28px 24px; }
.section-heading { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; margin-bottom: 20px; }
.process-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px 100px 100px; align-items: center; gap: 14px; padding: 14px 4px; border-bottom: 1px solid var(--line); font-size: 14px; }
.process-name { display: flex; align-items: center; gap: 12px; min-width: 0; }
.process-name img { width: 30px; height: 30px; object-fit: contain; }
.process-name strong { display: block; overflow-wrap: anywhere; font-weight: 600; }
.process-name small { color: var(--muted); font-size: 12px; }
.process-value { font-variant-numeric: tabular-nums; }
.record { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.record strong { font-size: 15px; overflow-wrap: anywhere; display: block; }
.record p { font-size: 14px; margin: 6px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.record aside { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.record button { padding: 6px 12px; font-size: 14px; }
.empty { padding: 60px 24px; color: var(--muted); text-align: center; font-size: 15px; }
.login-form { display: grid; gap: 16px; width: min(360px, calc(100% - 40px)); margin: 15dvh auto 0; }
.login-form h1 { font-size: 28px; margin-bottom: 16px; }
.login-form label { font-size: 14px; }
#login-error { font-size: 14px; color: #9a352c; }
.sr-only { position: absolute; width: 1px; height: 1px; clip: rect(0,0,0,0); overflow: hidden; }
.mobile-only { display: none; }
dialog { border: 1px solid var(--line); border-radius: 8px; padding: 20px; width: min(380px, calc(100% - 32px)); color: inherit; }
dialog::backdrop { background: #20232960; }
dialog header { display: flex; align-items: center; justify-content: space-between; }
dialog dl { margin-bottom: 0; }
dialog dt { margin-top: 12px; font-size: 12px; color: var(--muted); }
dialog dd { margin: 4px 0 0; font-size: 14px; overflow-wrap: anywhere; }
#pair-qr { margin: 16px auto; width: min(260px, 100%); }
#pair-qr svg { display: block; width: 100%; height: auto; }
.pair-settings { display: grid; gap: 8px; margin-top: 12px; font-size: 14px; }
.pair-settings select { font: inherit; color: inherit; background: white; border: 1px solid var(--line); border-radius: 6px; padding: 10px; width: 100%; }
#public-setting { display: flex; gap: 8px; align-items: center; min-height: 36px; }
.pair-status-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; color: var(--muted); }
#pair-status { overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .topbar { height: calc(62px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 14px 0; gap: 6px; }
  .brand { gap: 8px; }
  .brand strong { font-size: 16px; }
  .brand img { width: 28px; height: 28px; }
  .connection { font-size: 12px; max-width: 76px; }
  .tabs { padding: 0 12px; gap: 14px; height: 52px; }
  .tabs button { gap: 5px; font-size: 14px; }
  .tabs button img { display: none; }
  .tabs a { font-size: 12px; }
  .tabs span { display: none; }
  .session-layout { display: block; }
  .session-sidebar { height: 100%; border-right: 0; }
  .detail { display: none; height: 100%; }
  .session-layout.detail-open .session-sidebar { display: none; }
  .session-layout.detail-open .detail { display: block; }
  .mobile-only { display: inline-grid; }
  .detail-heading { padding: 12px 14px 12px 5px; gap: 6px; }
  .detail-heading h2 { font-size: 15px; max-height: 45px; }
  .detail-heading .secondary { max-height: 36px; overflow: hidden; }
  .events { padding: 8px 16px 20px; }
  .composer { padding: 10px 14px max(12px, env(safe-area-inset-bottom)); }
  .segments span { padding: 6px 9px; font-size: 13px; }
  .composer textarea { min-height: 78px; }
  .flat-view { padding: 20px 16px; }
  .section-heading { align-items: flex-start; }
  .section-heading .secondary { font-size: 12px; }
  .process-row { grid-template-columns: minmax(0, 1fr) 62px 76px; gap: 8px; }
  .process-row > :last-child { display: none; }
  #error-banner { padding: 8px 14px; font-size: 13px; }
  .topbar .icon-button { width: 34px; flex-basis: 34px; }
  .topbar .brand { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
