:root {
  color-scheme: dark;
  --bg: #101311; --surface: #171c18; --raised: #1e2520; --line: #303a31;
  --ink: #f0f5ed; --muted: #a6b4a7; --accent: #d7f88b; --accent-ink: #192113;
  --warn: #ffd19e; --space: clamp(16px, 4vw, 36px);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--bg); }
html.chat-open, html.chat-open body { overflow: hidden; overscroll-behavior: none; }
button, input, textarea { font: inherit; }
button { cursor: pointer; color: inherit; }
button:disabled { opacity: .48; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button, input { min-height: 44px; }
h1, h2, p { margin: 0; }
.primary { border: 0; background: var(--accent); color: var(--accent-ink); border-radius: 13px; font-weight: 700; }
.primary:hover:not(:disabled) { background: #e4ffa9; }
.eyebrow, .nav-label { font-size: .69rem; font-weight: 750; letter-spacing: .16em; color: var(--muted); }
.gate { min-height: 100svh; display: grid; place-items: center; padding: 24px; background: radial-gradient(ellipse at 50% 0%, #253328 0%, var(--bg) 60%); }
.pair-card { width: min(100%, 410px); padding: clamp(24px, 6vw, 40px); border: 1px solid var(--line); border-radius: 28px; background: var(--surface); }
.mark { margin-bottom: 24px; }
.pair-card h1 { margin: 8px 0 12px; font-size: clamp(2rem, 6vw, 2.6rem); letter-spacing: -.055em; line-height: 1.05; }
.pair-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.5; }
#pair-form { display: grid; gap: 10px; margin-top: 25px; }
#pair-form label { font-size: .85rem; }
#pair-token { min-width: 0; width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg); color: var(--ink); font-size: 16px; }
#pair-button { margin-top: 4px; }
.gate-status { margin-top: 15px; font-size: .83rem; min-height: 2.4em; }
.portal {
  position: fixed;
  inset: 0 0 auto;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  grid-template-columns: 254px minmax(0, 1fr);
  overflow: hidden;
}
.sidebar { display: flex; min-height: 0; flex-direction: column; padding: 20px 14px 12px; border-right: 1px solid var(--line); background: var(--surface); }
.identity { display: flex; gap: 11px; align-items: center; padding: 2px 7px 19px; }
.identity strong, .identity span { display: block; }
.identity strong { line-height: 1.05; font-size: 1.1rem; }
.identity span, .sidebar-footer span { color: var(--muted); font-size: .77rem; }
.identity span { margin-top: 5px; }
.new-chat { text-align: left; padding: 0 14px; }
.new-chat span { margin-right: 4px; font-size: 1.15em; }
.schedule-nav { margin-top: 8px; border: 1px solid var(--line); border-radius: 11px; background: var(--raised); text-align: left; padding: 0 14px; }
.nav-label { margin: 25px 10px 10px; }
#chat-list { min-height: 0; overflow-y: auto; flex: 1; }
.chat-link { width: 100%; display: block; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; border: 0; border-radius: 10px; background: transparent; text-align: left; padding: 8px 10px; font-size: .88rem; color: var(--muted); }
.chat-link:hover, .chat-link[aria-current="true"] { background: var(--raised); color: var(--ink); }
.chat-link[aria-current="true"] { box-shadow: inset 2px 0 var(--accent); }
.no-chats { font-size: .83rem; color: var(--muted); padding: 6px 10px; }
.sidebar-footer { border-top: 1px solid var(--line); padding: 14px 8px 0; margin-top: 10px; display: flex; flex-direction: column; }
.sidebar-footer strong { font-size: .85rem; margin-top: 4px; }
.text-button { align-self: flex-start; background: none; color: var(--muted); border: 0; padding: 0; font-size: .8rem; }
.text-button:hover { color: var(--ink); }
.conversation {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.topbar { display: flex; align-items: center; gap: 9px; min-height: 62px; padding: 8px var(--space); padding-top: max(8px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); }
.chat-heading { min-width: 0; flex: 1; }
.chat-heading h1 { font-size: .96rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.connection { color: var(--muted); font-size: .71rem; display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.connection i { width: 6px; height: 6px; border-radius: 50%; background: #9bd784; }
.connection.offline i { background: #f8ad72; }
.icon-button { display: grid; place-items: center; min-width: 44px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; font-size: 1.3rem; }
.mobile-only, .close-drawer, .scrim { display: none; }
.thread { overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding: 0 var(--space); min-height: 0; scrollbar-gutter: stable; }
.empty { display: grid; justify-items: start; align-content: center; width: min(100%, 700px); min-height: 100%; margin: 0 auto; padding: 34px 0; }
.empty-badge { margin-bottom: 18px; }
.empty h2 { margin: 8px 0 12px; font-size: clamp(1.85rem, 6vw, 3.4rem); letter-spacing: -.06em; line-height: 1.05; }
.empty p:not(.eyebrow) { color: var(--muted); line-height: 1.55; max-width: 360px; }
.example { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-top: 20px; font-size: .86rem; }
.example span { padding-left: 7px; color: var(--accent); }
.messages { max-width: 700px; margin: 0 auto; padding: 0 0 20px; }
.messages:empty { padding: 0; }
.exchange { padding-top: 22px; }
.user-message { margin-left: auto; width: fit-content; max-width: min(91%, 565px); padding: 12px 15px; border-radius: 16px 16px 3px 16px; background: var(--raised); }
.answer { margin-top: 17px; padding-bottom: 10px; }
.answer-header { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .76rem; font-weight: 700; margin-bottom: 6px; }
.answer-header img { width: 18px; height: 18px; }
.message-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.58; font-size: .96rem; }
.message-text pre { white-space: pre-wrap; padding: 12px; margin: 10px 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.turn-note { color: var(--muted); font-size: .84rem; line-height: 1.45; margin: 7px 0 4px; }
.turn-note.problem, .notice { color: var(--warn); }
.receipts { border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; margin-top: 12px; background: var(--surface); }
.receipts strong { color: var(--accent); font-size: .81rem; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 145px), 1fr)); gap: 10px; margin-top: 9px; }
.photo-card { min-width: 0; margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); }
.photo-preview {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  max-height: 300px;
  background: var(--raised);
}
.photo-preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.photo-card figcaption { padding: 8px 10px; display: grid; gap: 4px; }
.photo-name { font-size: .82rem; overflow-wrap: anywhere; }
.photo-status { color: var(--muted); font-size: .75rem; }
.photo-download { color: var(--accent); font-size: .8rem; width: fit-content; min-height: 36px; display: grid; align-items: center; }
.composer-wrap { padding: 10px var(--space) max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg); }
.composer { max-width: 700px; margin: 0 auto; display: flex; align-items: flex-end; padding: 8px; gap: 8px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); }
.composer:focus-within { border-color: #7b9969; }
.composer textarea { flex: 1; min-width: 0; display: block; resize: vertical; max-height: 28dvh; min-height: 44px; border: 0; outline: none; background: none; color: var(--ink); padding: 8px; font-size: 16px; line-height: 1.35; }
.composer textarea::placeholder { color: var(--muted); }
.send { display: grid; place-items: center; flex: none; width: 44px; height: 44px; touch-action: manipulation; }
.composer-note, .notice { max-width: 700px; margin: 7px auto 0; font-size: .74rem; color: var(--muted); }
.notice { margin: 0 auto 8px; color: var(--warn); }
.schedules-panel { grid-row: 2 / 4; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px var(--space) 30px; }
.schedule-content { max-width: 700px; margin: 0 auto; }
.schedule-content h2 { font-size: 1.5rem; margin: 0 0 8px; }
.schedule-intro, .schedule-summary { color: var(--muted); font-size: .88rem; line-height: 1.5; }
.schedule-form, .schedule-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.schedule-form { display: grid; gap: 8px; margin: 16px 0 8px; }
.schedule-form label { font-size: .86rem; }
.schedule-form label span { color: var(--muted); }
.schedule-form input:not([type="checkbox"]), .schedule-form textarea {
  width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg); color: var(--ink); font-size: 16px; padding: 9px 10px;
}
.schedule-form textarea { resize: vertical; }
.schedule-form #schedule-hours { max-width: 160px; }
.schedule-check { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.schedule-check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
.schedule-actions { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.schedule-actions .primary { padding: 0 12px; }
.schedule-status { min-height: 1.3em; color: var(--muted); font-size: .83rem; }
.schedule-status.problem { color: var(--warn); }
.schedule-list { display: grid; gap: 10px; margin-top: 8px; }
.schedule-card h3 { margin: 0 0 6px; font-size: .98rem; overflow-wrap: anywhere; }
.schedule-card .schedule-actions { margin-top: 4px; }
.schedule-card .text-button { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
@media (max-width: 700px) {
  .portal { grid-template-columns: minmax(0, 1fr); }
  .topbar { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .mobile-only, .close-drawer { display: grid; }
  .close-drawer { margin-left: auto; }
  .sidebar { position: absolute; z-index: 3; inset: 0 auto 0 0; width: min(86vw, 320px); padding-top: max(18px, env(safe-area-inset-top)); padding-bottom: max(12px, env(safe-area-inset-bottom)); visibility: hidden; transform: translateX(-100%); }
  .sidebar.open { visibility: visible; transform: translateX(0); }
  .scrim { display: block; z-index: 2; position: absolute; inset: 0; border: 0; background: #000a; }
  .thread { scrollbar-gutter: auto; }
  .composer-wrap { padding-inline: max(var(--space), env(safe-area-inset-left)) max(var(--space), env(safe-area-inset-right)); }
  .schedules-panel { padding-inline: max(var(--space), env(safe-area-inset-left)) max(var(--space), env(safe-area-inset-right)); }
  .composer textarea { resize: none; }
}
