/* Ash.AI. Tokens from reference/ash-ai-test-copy.html. Layout from PHASE-1-PROMPT.md "The app":
   body 17px+, taps 48px+, everything tapped sits in the bottom half, iPhone safe areas. */
:root {
  --bg: #FBFAF5; --surface: #ffffff; --sunk: #F1EEE6; --line: #E2DDD2;
  --ink: #1A1A1A; --ink-2: #4F4C47; --ink-3: #86817A;
  --brass: #D13405; --brass-ink: #ffffff; --brass-soft: #FCE6DD; --gold: #7E6741;
  --head: var(--surface); --head-ink: var(--ink); --head-2: var(--ink-3);
  --ok: #2f7a4f; --ok-soft: #e1f0e6; --warn: #B12C04; --warn-soft: #FCE6DD; --bad: #b0392e; --bad-soft: #f7e0dd;
  --ask: #1C2A36; --ask-soft: #E3E8EE; --res: #6E5A37; --res-soft: #F1ECE1;
  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --body: "Source Sans 3", "Segoe UI", Roboto, Arial, sans-serif;
  --r: 12px;
  --dock-h: 0px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #1A1A1A; --surface: #2C2C2C; --sunk: #232323; --line: #3B3B3B;
  --ink: #FBFAF5; --ink-2: #C9C4B8; --ink-3: #8F8A80;
  --brass: #E83A05; --brass-ink: #ffffff; --brass-soft: #3D2117; --gold: #C2AA7C;
  --head: #121212; --head-ink: #FBFAF5; --head-2: #B9A57E;
  --ok: #6cc08f; --ok-soft: #1f3328; --warn: #F2875F; --warn-soft: #3D2117; --bad: #ec8277; --bad-soft: #3d2421;
  --ask: #A9C2D8; --ask-soft: #1C2A36; --res: #D2BC8F; --res-soft: #352D20; color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #1A1A1A; --surface: #2C2C2C; --sunk: #232323; --line: #3B3B3B;
  --ink: #FBFAF5; --ink-2: #C9C4B8; --ink-3: #8F8A80;
  --brass: #E83A05; --brass-ink: #ffffff; --brass-soft: #3D2117; --gold: #C2AA7C;
  --head: #121212; --head-ink: #FBFAF5; --head-2: #B9A57E;
  --ok: #6cc08f; --ok-soft: #1f3328; --warn: #F2875F; --warn-soft: #3D2117; --bad: #ec8277; --bad-soft: #3d2421;
  --ask: #A9C2D8; --ask-soft: #1C2A36; --res: #D2BC8F; --res-soft: #352D20; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh; background: var(--bg); color: var(--ink);
  font: 17px/1.45 var(--body); -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--head); }
button, input, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); margin: 0; text-wrap: balance; }
h1 { font-size: 26px; font-weight: 800; line-height: 1.15; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); }
p { margin: 0; }
[hidden] { display: none !important; }
.muted { color: var(--ink-2); }
.small { font-size: 15px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Logos: light version by default, darkmode version when the phone is dark. */
.logo-dark { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-light { display: none; } :root:not([data-theme="light"]) .logo-dark { display: block; } }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }

/* Buttons */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r);
  min-height: 48px; padding: 10px 16px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center; text-decoration: none; color: var(--ink);
}
.btn.primary { background: var(--brass); border-color: var(--brass); color: var(--brass-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.block { width: 100%; }
.btn.big { min-height: 56px; font: 700 18px/1 var(--display); }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, .chip:focus-visible, textarea:focus-visible, input:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }

/* Sign-in */
.signin { min-height: 100dvh; display: flex; flex-direction: column; max-width: 520px; margin: 0 auto;
  padding: env(safe-area-inset-top) 16px max(24px, env(safe-area-inset-bottom)); }
.signin .top { flex: 1; display: grid; place-items: center; padding: 24px 0; }
.signin .top img { width: min(240px, 60vw); height: auto; }
.signin .bottom { display: grid; gap: 12px; padding-bottom: 8px; }
.msg { min-height: 1.4em; text-align: center; }
.msg.bad { color: var(--bad); }
.msg.ok { color: var(--ok); }

/* App header */
header.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--head); color: var(--head-ink); border-bottom: 3px solid var(--brass); }
header.top .in { max-width: 640px; margin: 0 auto; padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  display: flex; align-items: center; gap: 10px; min-height: 56px; }
header.top .logo { height: 26px; width: auto; flex: none; }
header.top .title { font: 700 18px/1.2 var(--display); flex: 1; min-width: 0; }
header.top .btn.ghost { color: var(--head-ink); min-width: 48px; padding-inline: 10px; }
.notice { max-width: 640px; margin: 0 auto; padding: 8px 16px; font-size: 15px; background: var(--warn-soft); color: var(--warn); }

/* Screens scroll above the dock (composer + tab bar). */
main.wrap { max-width: 640px; margin: 0 auto; padding: 12px max(16px, env(safe-area-inset-right)) calc(var(--dock-h) + 16px) max(16px, env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: 14px; }
.section { display: flex; flex-direction: column; gap: 10px; }
.empty { border: 1.5px dashed var(--line); border-radius: var(--r); padding: 18px; color: var(--ink-2); text-align: center; display: grid; gap: 6px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }

/* Ask cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card .head { display: flex; gap: 10px; justify-content: space-between; align-items: flex-start; }
.card .q { font-weight: 700; font-size: 17px; overflow-wrap: anywhere; min-width: 0; }
.card .when { font-size: 14px; color: var(--ink-3); }
.card .answer { font-size: 20px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.card .from { font-size: 14px; color: var(--ink-3); }
.chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 10px; font-size: 14px; font-weight: 600;
  background: var(--sunk); color: var(--ink-2); border: 1px solid transparent; white-space: nowrap; }
.chip.new { background: var(--brass-soft); color: var(--brass); }
.chip.exist { background: var(--ask-soft); color: var(--ask); }
.chip.done { background: var(--ok-soft); color: var(--ok); }
.chip.gate { background: var(--res-soft); color: var(--res); white-space: normal; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opts .btn { min-height: 48px; }
.other { display: flex; gap: 8px; }
.other input { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 12px; min-height: 48px; }

/* Dock: composer above the tab bar, fixed to the bottom. */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px); }
.dock .in { max-width: 640px; margin: 0 auto; padding: 8px max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
#composer-area { display: grid; gap: 8px; min-width: 0; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chips button { appearance: none; border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 8px 14px; min-height: 44px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.composer { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; min-width: 0; resize: none; border: 1px solid var(--line); background: var(--bg); border-radius: 22px;
  padding: 12px 16px; min-height: 48px; max-height: 140px; line-height: 1.35; font-size: 17px; }
.composer .btn { min-width: 48px; border-radius: 24px; }
.attached { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--ink-2); }
.attached img { width: 56px; height: 42px; object-fit: cover; border-radius: 8px; }
.compose-msg { font-size: 15px; color: var(--bad); }

nav.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 6px 0 4px; }
nav.tabs button { appearance: none; border: 0; background: transparent; border-radius: 10px; min-height: 48px; font: 700 15px/1 var(--display); color: var(--ink-3); cursor: pointer; }
nav.tabs button[aria-selected="true"] { color: var(--brass); background: var(--sunk); }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--brass); color: var(--brass-ink); font-size: 12px; line-height: 20px; margin-left: 4px; }

/* Settings */
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.setting:first-of-type { border-top: 0; }

/* Setup */
.setup { max-width: 520px; margin: 0 auto; padding: env(safe-area-inset-top) 16px max(24px, env(safe-area-inset-bottom)); display: grid; gap: 16px; }
.setup .top { text-align: center; padding-top: 24px; display: grid; gap: 6px; justify-items: center; }
.setup .top img { width: 120px; height: auto; }
ol.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.step header { display: flex; gap: 12px; align-items: center; }
.tick { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--line); font: 700 16px/1 var(--display); color: var(--ink-3); }
.step.done .tick { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.done .tick::before { content: '✓'; }
.step:not(.done) .tick::before { content: attr(data-n); }
.step .body { margin: 12px 0 0 44px; display: grid; gap: 8px; }
.share { display: inline-block; vertical-align: -6px; width: 26px; height: 26px; }

@media (prefers-reduced-motion: no-preference) { .card { animation: in .18s ease-out; } @keyframes in { from { transform: translateY(4px); opacity: .6; } to { transform: none; opacity: 1; } } }
