/* Replies — a pocket reply desk. Cool Laguna Madre palette; the draft is set as a letter (New York serif on iOS). */
:root {
  --bg: #e8f0ef;          /* surf */
  --sheet: #ffffff;       /* paper */
  --ink: #12343b;         /* laguna ink */
  --muted: #5d7579;
  --line: #cfdedd;
  --primary: #0e5e6f;     /* laguna */
  --primary-ink: #ffffff;
  --check: #b7791f;       /* channel-marker amber */
  --check-bg: #fdf3dc;
  --urgent: #c2413a;
  --ok: #2f7d5f;          /* seagrass */
  --chip: #dbe8e6;
  --letter: #fffdf8;
  --shadow: 0 1px 2px rgba(18, 52, 59, .06), 0 8px 24px rgba(18, 52, 59, .08);
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  --rounded: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1d21; --sheet: #12292e; --ink: #e3eeec; --muted: #93abae; --line: #23413f; --primary: #3fa3b5;
    --primary-ink: #04161a; --check: #f0b54a; --check-bg: #33290f; --urgent: #ef6b62; --ok: #5cc08f; --chip: #1c3a3f;
    --letter: #172f34; --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 var(--sans); -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; padding: env(safe-area-inset-top) 0 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- list ---------- */
.top { display: flex; align-items: baseline; justify-content: space-between; padding: 18px 20px 6px; }
.top h1 { font: 700 34px/1.1 var(--rounded); margin: 0; letter-spacing: -.5px; }
.top .count { color: var(--muted); font-size: 15px; }
.status { padding: 0 20px 10px; color: var(--muted); font-size: 13px; min-height: 18px; }
.status .off { color: var(--urgent); }
.banner { margin: 6px 16px 12px; padding: 12px 14px; border-radius: 14px; background: var(--sheet); box-shadow: var(--shadow); display: flex; gap: 12px; align-items: center; }
.banner p { margin: 0; flex: 1; font-size: 14px; }
.banner button { border: 0; background: var(--primary); color: var(--primary-ink); padding: 8px 12px; border-radius: 10px; font-weight: 600; }
.list { margin: 0 12px 120px; padding: 0; list-style: none; background: var(--sheet); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.row { position: relative; display: block; width: 100%; text-align: left; border: 0; background: none; padding: 14px 16px 14px 20px; border-top: 1px solid var(--line); cursor: pointer; }
.row:first-child { border-top: 0; }
.row.urgent::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 4px; border-radius: 0 3px 3px 0; background: var(--urgent); }
.row .l1 { display: flex; gap: 8px; align-items: baseline; }
.row .who { font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .when { color: var(--muted); font-size: 13px; flex: none; }
.row .subj { margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .why { color: var(--muted); font-size: 14px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.chip { font-size: 12.5px; padding: 3px 8px; border-radius: 999px; background: var(--chip); color: var(--ink); }
.chip.check { background: var(--check-bg); color: var(--check); font-weight: 600; }
.chip.warn { background: color-mix(in srgb, var(--urgent) 14%, transparent); color: var(--urgent); font-weight: 600; }
.chip.alias { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.empty { margin: 60px 32px; text-align: center; color: var(--muted); }
.empty h2 { font: 650 22px var(--rounded); color: var(--ink); margin: 0 0 6px; }

/* ---------- detail sheet ---------- */
.sheet { position: fixed; inset: 0; background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch; padding: env(safe-area-inset-top) 0 calc(150px + env(safe-area-inset-bottom)); transform: translateY(0); transition: transform .22s ease-out; z-index: 5; }
.sheet[hidden] { display: block; transform: translateY(100%); pointer-events: none; visibility: hidden; }
.sheet .bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; }
.sheet .back { border: 0; background: none; color: var(--primary); font-size: 17px; padding: 8px; }
.sheet .from-alias { color: var(--muted); font-size: 13px; text-align: right; padding-right: 8px; }
.head { padding: 0 20px 10px; }
.head .who { font: 650 22px/1.2 var(--rounded); }
.head .addr { color: var(--muted); font-size: 14px; word-break: break-all; }
.head .subj { margin-top: 8px; font-weight: 600; }
.head .when { color: var(--muted); font-size: 14px; }
.theirs { margin: 6px 16px 14px; background: var(--sheet); border-radius: 14px; padding: 12px 14px; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); }
.theirs.clamped { max-height: 8.6em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }
.more { border: 0; background: none; color: var(--primary); padding: 0 20px 6px; font-size: 15px; }
.atts { padding: 0 20px 8px; color: var(--muted); font-size: 14px; }
.notes { margin: 0 16px 10px; display: grid; gap: 8px; }
.note { padding: 10px 12px; border-radius: 12px; font-size: 14.5px; background: var(--chip); }
.note.check { background: var(--check-bg); color: var(--check); }
.note.warn { background: color-mix(in srgb, var(--urgent) 12%, transparent); color: var(--urgent); }
.note button { margin-top: 8px; border: 0; background: var(--primary); color: var(--primary-ink); border-radius: 9px; padding: 7px 12px; font-weight: 600; display: block; }
.recips { padding: 4px 20px 8px; font-size: 14px; color: var(--muted); display: flex; gap: 10px; align-items: center; }
.recips .to { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toggle { border: 1px solid var(--line); background: var(--sheet); border-radius: 999px; padding: 5px 11px; font-size: 13px; white-space: nowrap; }
.toggle[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }

/* the letter: the one expressive surface */
.letter { margin: 2px 12px 8px; background: var(--letter); border-radius: 4px 18px 18px 18px; box-shadow: var(--shadow); padding: 18px 18px 14px; border: 1px solid var(--line); }
.letter textarea { width: 100%; border: 0; background: transparent; resize: none; font: 19px/1.5 var(--serif); color: var(--ink); min-height: 220px; padding: 0; outline: none; overflow: hidden; }
.letter .sig { margin-top: 10px; color: var(--muted); font-size: 13px; font-family: var(--sans); }
.letter.busy { opacity: .45; }
.drafting { padding: 26px 20px; color: var(--muted); font-family: var(--serif); font-size: 18px; }

/* thumb-zone action bar */
.actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr 1fr 1.6fr; gap: 8px; }
.actions[hidden] { display: none; }
.actions button { border: 0; border-radius: 14px; padding: 14px 6px; font-weight: 600; font-size: 16px; background: var(--sheet); color: var(--ink); box-shadow: var(--shadow); }
.actions .send { background: var(--primary); color: var(--primary-ink); font-size: 17px; }
.actions button:disabled { opacity: .45; }

/* revise / later sheets */
.pop { position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; background: var(--sheet); border-radius: 20px 20px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(0, 0, 0, .18); }
.pop[hidden] { display: none; }
.pop h3 { margin: 0 0 10px; font: 650 18px var(--rounded); }
.pop textarea { width: 100%; min-height: 96px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font: 17px/1.4 var(--sans); background: var(--bg); color: var(--ink); }
.pop .row2 { display: flex; gap: 8px; margin-top: 10px; }
.pop .row2 button { flex: 1; border: 0; border-radius: 12px; padding: 13px; font-weight: 600; background: var(--chip); }
.pop .row2 .go { background: var(--primary); color: var(--primary-ink); flex: 1.4; }
.pop .mic[aria-pressed="true"] { background: var(--urgent); color: #fff; }
.choices { display: grid; gap: 8px; }
.choices button { border: 0; border-radius: 12px; padding: 14px; text-align: left; background: var(--chip); font-size: 16px; }
.choices button span { float: right; color: var(--muted); }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .28); z-index: 7; }
.scrim[hidden] { display: none; }

/* toast with undo */
.toast { position: fixed; left: 12px; right: 12px; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 9; background: var(--ink); color: var(--bg); border-radius: 14px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; font-size: 15px; }
.toast[hidden] { display: none; }
.toast p { margin: 0; flex: 1; }
.toast button { border: 0; background: var(--bg); color: var(--ink); border-radius: 10px; padding: 8px 14px; font-weight: 700; }
.toast .bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--primary); border-radius: 0 0 14px 14px; }

/* pairing */
.pair { max-width: 460px; margin: 0 auto; padding: 48px 24px; }
.pair h1 { font: 700 40px/1.05 var(--rounded); margin: 0 0 8px; }
.pair-lede { color: var(--muted); margin: 0 0 22px; font-size: 17px; }
.pair-steps { padding-left: 20px; margin: 0 0 26px; line-height: 1.6; }
.pair-form { display: grid; gap: 8px; }
.pair-form label { font-size: 14px; color: var(--muted); }
.pair-form input { font: 600 24px/1 ui-monospace, Menlo, monospace; letter-spacing: 2px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--sheet); color: var(--ink); text-transform: uppercase; }
.pair-form button { margin-top: 6px; border: 0; background: var(--primary); color: var(--primary-ink); border-radius: 12px; padding: 14px; font-weight: 650; font-size: 17px; }
.pair-err { background: color-mix(in srgb, var(--urgent) 12%, transparent); color: var(--urgent); padding: 10px 12px; border-radius: 10px; }

/* sections, files, requests */
.section { font: 650 15px var(--rounded); color: var(--muted); margin: 14px 24px 8px; }
.list.compact { margin-bottom: 8px; }
.files { margin: 0 12px 10px; padding: 10px 12px; background: var(--sheet); border-radius: 14px; }
.files-head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 14px; }
.linkbtn { border: 0; background: none; color: var(--primary); font-weight: 600; padding: 4px 0; }
.file { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.file:first-of-type { border-top: 0; }
.fname { grid-column: 1; border: 0; background: none; text-align: left; padding: 0; color: var(--primary); font-weight: 600; overflow-wrap: anywhere; }
.fmeta { grid-column: 1; color: var(--muted); font-size: 13px; }
.fx { grid-column: 2; grid-row: 1 / span 2; border: 0; background: var(--chip); border-radius: 999px; width: 30px; height: 30px; font-size: 18px; line-height: 1; }
.preview { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
.pv-bar { display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.pv-bar span { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-bar a, .pv-bar button { color: var(--primary); border: 0; background: none; font-weight: 600; font-size: 16px; }
.pv-frame { flex: 1; border: 0; width: 100%; background: #fff; }
.pv-img { max-width: 100%; max-height: 100%; object-fit: contain; margin: auto; }
.search { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; font: 17px var(--sans); background: var(--bg); color: var(--ink); margin-bottom: 10px; }
.rq { margin: 6px 12px 12px; padding: 14px; background: var(--sheet); border-radius: 16px; display: grid; gap: 10px; }
.rq p { margin: 0; }
.rq-field { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.rq-input { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: 16px var(--sans); background: var(--bg); color: var(--ink); }
.rq-text { width: 100%; min-height: 150px; border: 1px solid var(--line); border-radius: 12px; padding: 12px; font: 17px/1.45 var(--serif); background: var(--letter); color: var(--ink); }
.rq-text.short { min-height: 80px; font-family: var(--sans); font-size: 16px; }
.rq-check { display: flex; gap: 8px; align-items: center; font-weight: 600; margin-bottom: 6px; }
.rq-go { border: 0; border-radius: 14px; padding: 14px; background: var(--primary); color: var(--primary-ink); font-weight: 650; font-size: 17px; }
.rq-go:disabled { opacity: .5; }
.rq-msg { border-left: 3px solid var(--line); padding: 4px 10px; font-size: 15px; white-space: pre-wrap; }
.rq-msg.in { border-color: var(--ok); }
