:root {
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  color: oklch(0.235 0.032 244);
  background: oklch(0.972 0.006 238);
  font-synthesis: none;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  --page: oklch(0.972 0.006 238);
  --surface: oklch(1 0 0);
  --surface-subtle: oklch(0.958 0.008 238);
  --surface-pressed: oklch(0.925 0.012 238);
  --ink: oklch(0.235 0.032 244);
  --ink-muted: oklch(0.465 0.028 240);
  --border: oklch(0.875 0.014 235);
  --primary: oklch(0.45 0.105 235);
  --primary-hover: oklch(0.39 0.105 235);
  --primary-soft: oklch(0.93 0.035 235);
  --teal: oklch(0.49 0.105 174);
  --teal-soft: oklch(0.94 0.04 174);
  --amber: oklch(0.53 0.135 69);
  --amber-soft: oklch(0.95 0.055 78);
  --rose: oklch(0.52 0.175 20);
  --rose-soft: oklch(0.95 0.04 18);
  --shadow-control: 0 1px 2px oklch(0.2 0.03 240 / .09);
  --radius-sm: 7px;
  --radius-md: 10px;
  --radius-lg: 14px;
}
* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--page); font-size: 14px; line-height: 20px; overflow-x: hidden; }
button, input, textarea { font: inherit; }
button { color: inherit; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button, input, textarea { border-radius: var(--radius-md); }
h1, h2, p { margin: 0; }
h1, h2 { text-wrap: balance; letter-spacing: -.018em; }
p { text-wrap: pretty; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.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: 20; top: 8px; left: -999px; padding: 8px 12px; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); }
.skip-link:focus { left: 12px; }
.connect-shell { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.connect-card { display: grid; width: min(100%, 440px); gap: 22px; padding: 34px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: 0 8px 12px oklch(.2 .03 240 / .12); }
.connect-card h1 { font-size: 24px; line-height: 30px; }
.connect-card p { margin-top: 6px; color: var(--ink-muted); }
.connect-card label, .new-recipient label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 650; }
.signal-mark { display: flex; width: 48px; height: 48px; align-items: end; justify-content: center; gap: 3px; padding: 12px; color: var(--primary); background: var(--primary-soft); border-radius: 13px; }
.signal-mark i { display: block; width: 4px; background: currentColor; border-radius: 4px; }
.signal-mark i:nth-child(1) { height: 6px; } .signal-mark i:nth-child(2) { height: 10px; } .signal-mark i:nth-child(3) { height: 15px; } .signal-mark i:nth-child(4) { height: 20px; }
.secret-row, .recipient-row { display: flex; gap: 8px; }
input, textarea { width: 100%; color: var(--ink); background: var(--surface); border: 1px solid var(--border); }
input { min-height: 44px; padding: 9px 12px; }
input::placeholder, textarea::placeholder { color: var(--ink-muted); opacity: 1; }
input:hover, textarea:hover { border-color: oklch(0.73 0.024 235); }
input:focus, textarea:focus { border-color: var(--primary); outline: 2px solid var(--primary-soft); }
.button, .icon-button, .send-button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; border: 0; cursor: pointer; transition: background-color 160ms ease, color 160ms ease, transform 100ms ease-out; }
.button { gap: 7px; padding: 8px 13px; font-weight: 650; }
.button.primary { color: white; background: var(--primary); box-shadow: var(--shadow-control); }
.button.primary:hover { background: var(--primary-hover); }
.button.quiet { color: var(--ink-muted); background: transparent; }
.button.quiet:hover, .icon-button:hover { color: var(--ink); background: var(--surface-subtle); }
.button:active, .icon-button:active, .send-button:active { transform: scale(.97); }
.form-error { min-height: 20px; color: var(--rose) !important; font-size: 13px; }
.app { min-height: 100vh; }
.app-header { display: flex; height: 60px; align-items: center; gap: 18px; padding: 0 max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left)); background: oklch(1 0 0 / .94); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 700; letter-spacing: -.018em; }
.brand-dot { width: 12px; height: 12px; background: var(--primary); border: 3px solid var(--primary-soft); border-radius: 50%; box-sizing: content-box; }
.line-status { display: flex; min-width: 0; align-items: center; gap: 7px; margin-left: auto; color: var(--ink-muted); font-size: 13px; }
.status-light { width: 8px; height: 8px; flex: 0 0 auto; background: var(--amber); border-radius: 50%; box-shadow: 0 0 0 3px var(--amber-soft); }
.line-status.ready .status-light { background: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.line-status.error .status-light { background: var(--rose); box-shadow: 0 0 0 3px var(--rose-soft); }
.messaging-shell { display: flex; width: min(100%, 1440px); height: calc(100vh - 60px); margin: 0 auto; background: var(--surface); }
.conversation-pane { display: flex; width: 340px; flex: 0 0 340px; flex-direction: column; background: var(--surface-subtle); border-right: 1px solid var(--border); overflow: hidden; }
.pane-header { display: flex; min-height: 82px; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 16px 14px 20px; }
.pane-header h1 { font-size: 22px; line-height: 28px; }
.pane-header p { color: var(--ink-muted); font-size: 12px; }
.pane-actions { display: flex; gap: 6px; }
.icon-button, .send-button { width: 42px; height: 42px; flex: 0 0 42px; padding: 0; color: var(--primary); background: var(--surface); border-radius: 50%; box-shadow: var(--shadow-control); }
.icon-button svg, .send-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.new-recipient { padding: 0 16px 14px; border-bottom: 1px solid var(--border); }
.new-recipient p { margin-top: 6px; color: var(--ink-muted); font-size: 12px; }
.sync-notice { padding: 9px 12px; margin: 0 12px 8px; color: var(--amber); background: var(--amber-soft); border-radius: var(--radius-sm); font-size: 12px; }
.conversation-list { min-height: 0; overflow: auto; overscroll-behavior: contain; }
.conversation-item { display: flex; width: calc(100% - 16px); min-height: 76px; align-items: center; gap: 12px; padding: 11px 12px; margin: 2px 8px; text-align: left; background: transparent; border: 0; border-radius: var(--radius-md); cursor: pointer; content-visibility: auto; contain-intrinsic-size: auto 76px; }
.conversation-item:hover { background: oklch(1 0 0 / .68); }
.conversation-item.selected { background: var(--surface); box-shadow: var(--shadow-control); }
.avatar, .contact-mark { display: grid; width: 42px; height: 42px; flex: 0 0 42px; place-items: center; color: var(--primary); background: var(--primary-soft); border-radius: 50%; font-weight: 700; }
.conversation-copy { min-width: 0; flex: 1; }
.conversation-top { display: flex; align-items: baseline; gap: 8px; }
.conversation-number { min-width: 0; flex: 1; overflow: hidden; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.conversation-time { color: var(--ink-muted); font-size: 11px; white-space: nowrap; }
.conversation-preview { margin-top: 3px; overflow: hidden; color: var(--ink-muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.pane-state { display: grid; gap: 12px; padding: 22px 20px; color: var(--ink-muted); text-align: center; }
.skeleton-line { width: 68%; height: 11px; background: var(--border); border-radius: 6px; animation: breathe 1.4s ease-in-out infinite alternate; }
.skeleton-line.wide { width: 90%; }
.thread-pane { min-width: 0; flex: 1; background: var(--surface); }
.thread-empty { display: grid; height: 100%; place-content: center; justify-items: center; padding: 28px; text-align: center; }
.empty-glyph { display: flex; width: 58px; height: 48px; align-items: center; justify-content: center; gap: 4px; margin-bottom: 18px; background: var(--primary-soft); border-radius: 14px; }
.empty-glyph span { width: 5px; height: 5px; background: var(--primary); border-radius: 50%; }
.thread-empty h2 { font-size: 18px; }
.thread-empty p { max-width: 44ch; margin: 7px 0 18px; color: var(--ink-muted); }
.thread { display: grid; height: 100%; grid-template-rows: auto 1fr auto; }
.thread-header { display: flex; min-height: 72px; align-items: center; gap: 11px; padding: 12px 20px; background: oklch(1 0 0 / .91); border-bottom: 1px solid var(--border); backdrop-filter: blur(18px) saturate(140%); }
.thread-person { min-width: 0; }
.thread-person h2 { overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.thread-person p { color: var(--ink-muted); font-size: 12px; }
.back-button { display: none; color: var(--ink); background: transparent; box-shadow: none; }
.message-history { display: flex; min-height: 0; flex-direction: column; gap: 5px; padding: 22px max(20px, 6vw); overflow: auto; overscroll-behavior: contain; }
.message-row { display: flex; flex-direction: column; align-items: flex-start; }
.message-row.outgoing { align-items: flex-end; }
.message-row.status-report { align-items: center; }
.message-row.status-report .message-bubble { color: var(--ink-muted); background: transparent; font-size: 12px; }
.message-bubble { width: fit-content; max-width: min(68%, 620px); padding: 9px 12px; color: var(--ink); background: var(--surface-subtle); border-radius: 14px 14px 14px 4px; overflow-wrap: anywhere; white-space: pre-wrap; }
.message-row.outgoing .message-bubble { color: white; background: var(--primary); border-radius: 14px 14px 4px 14px; }
.message-meta { margin: 3px 5px 7px; color: var(--ink-muted); font-size: 11px; }
.composer { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 12px max(16px, 5vw) 16px; background: oklch(1 0 0 / .92); border-top: 1px solid var(--border); backdrop-filter: blur(18px) saturate(140%); }
.composer textarea { min-height: 44px; max-height: 150px; padding: 11px 13px; resize: none; }
.send-button { color: white; background: var(--primary); }
.send-button:hover { background: var(--primary-hover); }
.send-button:disabled { color: var(--ink-muted); background: var(--surface-pressed); cursor: wait; }
.composer-note { min-height: 18px; grid-column: 1 / -1; color: var(--ink-muted); font-size: 12px; }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 10; max-width: min(380px, calc(100vw - 36px)); padding: 10px 13px; color: white; background: var(--ink); border-radius: var(--radius-md); box-shadow: 0 8px 12px oklch(.2 .03 240 / .16); }
@keyframes breathe { from { opacity: .42; } to { opacity: .86; } }
@media (max-width: 720px) {
  .app-header { height: 56px; padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); }
  .line-status { max-width: 44vw; }
  .line-status span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .app-header .button { min-width: 44px; padding: 7px; font-size: 0; }
  .app-header .button { min-height: 44px; }
  .app-header .button::after { content: "Exit"; font-size: 13px; }
  .messaging-shell { height: calc(100dvh - 56px); }
  .conversation-pane { width: 100%; flex-basis: 100%; border-right: 0; }
  .thread-pane { display: none; width: 100%; }
  .messaging-shell.thread-open .conversation-pane { display: none; }
  .messaging-shell.thread-open .thread-pane { display: block; }
  .back-button { display: inline-flex; }
  .icon-button, .send-button { width: 44px; height: 44px; flex-basis: 44px; }
  .thread-header { min-height: 64px; padding: 8px 10px; }
  .message-history { padding: 18px 12px; }
  .message-bubble { max-width: 84%; }
  .composer { padding: 10px 10px max(10px, env(safe-area-inset-bottom)); }
  .conversation-item { min-height: 80px; }
}
@media (max-width: 340px) { .line-status span:last-child { display: none; } }
@media (prefers-color-scheme: dark) {
  :root { --page: oklch(.18 .018 244); --surface: oklch(.225 .02 244); --surface-subtle: oklch(.26 .02 244); --surface-pressed: oklch(.31 .022 244); --ink: oklch(.94 .008 235); --ink-muted: oklch(.72 .018 235); --border: oklch(.35 .022 240); --primary: oklch(.66 .11 230); --primary-hover: oklch(.72 .11 230); --primary-soft: oklch(.31 .05 235); }
  .app-header, .thread-header, .composer { background: oklch(.225 .02 244 / .92); }
  .conversation-item:hover { background: oklch(.31 .02 244 / .72); }
  .button.primary, .send-button, .message-row.outgoing .message-bubble { color: oklch(.16 .025 244); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition-duration: .01ms !important; } }
@media (prefers-reduced-transparency: reduce) { .thread-header, .composer { background: var(--surface); backdrop-filter: none; } }
@media (prefers-contrast: more) { :root { --border: currentColor; } .message-bubble, input, textarea { border: 1px solid currentColor; } }
