/*
 * Apeksha. Style: editorial greeting (taste skill, seed 1561472651), light.
 * White ground, tonal panels one step off it, ink text, one deep teal accent
 * kept to the live state and the progress mark. Near-black primary.
 *
 * Type: Host Grotesk for Latin; Malayalam falls through to Anek Malayalam
 * (Host Grotesk has no Malayalam glyphs, so the browser picks per character).
 *
 * Grid: one column up to 900px. From 900px, a centred 1100px column of
 * 12 x 77px + 11 x 16px gutters = 1100: the work takes 7 columns
 * (7 x 77 + 6 x 16 = 635) and the application panel 5 (5 x 77 + 4 x 16 = 449),
 * with one 16px gutter between: 635 + 16 + 449 = 1100.
 */

:root {
  --ground: #ffffff;
  --surface: #f5f5f2; /* one step toward stone: the office counter, not a template grey */
  --raised: #ffffff;
  --border: #e6e6e1;
  --rule: #eeeeea;
  --control: #d9d9d6;
  --text: #1f201d;
  --muted: #5e5e5b;
  --accent: #1b6e66;
  --accent-tint: #e6f0ee;
  --primary: #1f201d;
  --negative: #b42318;
  --pill-warning-bg: #fffbeb;
  --pill-warning-ink: #92400e;

  --radius-card: 22px;
  --radius-inner: 14px;
  --radius-control: 999px;
  --gap: 16px;
  --pad: 20px;
  --control-height: 44px;

  --font: 'Host Grotesk', 'Anek Malayalam', system-ui, sans-serif;
  --fs-title: 26px;
  --fs-lead: 18px;
  --fs-body: 16px;
  --fs-small: 13px;

  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font: 400 var(--fs-body) / 1.5 var(--font);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

button, input, a { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
svg { display: block; }

/* English beside Malayalam: same face, a quieter second line or suffix. */
h1 span, .panel-title span, .button span, .prompt-en, .status span {
  font-weight: 400;
  color: var(--muted);
}

/* ------------------------------------------------------------ bar */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 56px;
  padding: 0 16px;
  max-width: 1132px;
  width: 100%;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.brand-mark { width: 22px; height: 22px; fill: var(--text); }
.brand-ml { font-weight: 700; font-size: 19px; }
.brand-en { font-size: var(--fs-small); color: var(--muted); }

.settings { display: flex; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px 0 10px;
  border-radius: var(--radius-control);
  border: 0;
  background: var(--surface);
  font-size: 14px;
  transition: background-color .15s ease;
}
.chip:hover { background: var(--rule); }
.chip svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.chip.icon { width: 36px; padding: 0; justify-content: center; }
.chip[aria-pressed='true'] .off, .chip[aria-pressed='false'] .on { display: none; }
.chip[aria-pressed='false'] { color: var(--muted); }

/* ------------------------------------------------------------ layout */

.layout {
  flex: 1;
  width: 100%;
  max-width: 1132px;
  margin: 0 auto;
  padding: 0 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}
.work { display: flex; flex-direction: column; min-height: calc(100dvh - 56px); }
.screen { padding-top: 16px; }
.sheet { display: none; }

h1 {
  font-size: var(--fs-title);
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 8px 0 10px;
  text-wrap: balance;
}
h1 span { display: block; font-size: var(--fs-body); letter-spacing: 0; margin-top: 4px; }
.lede { font-size: var(--fs-body); margin: 0 0 24px; max-width: 34em; }

/* ------------------------------------------------------------ panels */

.panel, .sheet {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: var(--pad);
}
.panel-title { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
.panel-title span { margin-left: 6px; }

.examples { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.examples button {
  width: 100%;
  min-height: 48px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-inner);
  background: var(--raised);
  text-align: left;
  font-size: var(--fs-body);
  line-height: 1.35;
  transition: border-color .15s ease, transform .1s ease;
}
.examples button:hover { border-color: var(--control); }
.examples button:active { transform: scale(.99); }

/* ------------------------------------------------------------ conversation */

.progress { margin: 0 0 12px; font-size: var(--fs-small); color: var(--muted); display: flex; align-items: center; gap: 10px; }
.progress .track { flex: 1; height: 4px; border-radius: 2px; background: var(--rule); overflow: hidden; }
.progress .fill { display: block; height: 100%; background: var(--accent); transition: width .3s ease; }

.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.log li { max-width: 88%; padding: 10px 14px; border-radius: 18px; line-height: 1.45; }
.log p { margin: 0; }
.log .en { font-size: var(--fs-small); color: var(--muted); margin-top: 2px; }
.log .from-app { background: var(--surface); border-bottom-left-radius: 6px; align-self: flex-start; }
.log .from-user { background: var(--accent-tint); border-bottom-right-radius: 6px; align-self: flex-end; }
/* The question being asked shows in the dock; don't repeat it above. */
[data-stage='ask'] .log .from-app:last-child { display: none; }

/* ------------------------------------------------------------ call first */

.help h2 { font-size: var(--fs-title); line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; margin: 8px 0 4px; text-wrap: balance; }
.help-en { color: var(--muted); margin: 0 0 20px; }
.help-more { margin: 0 0 16px; }
.contacts { display: grid; gap: 8px; margin-bottom: 20px; }
.contact {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 16px;
  padding: 16px var(--pad);
  border-radius: var(--radius-card);
  background: var(--surface);
  text-decoration: none;
  transition: background-color .15s ease, transform .1s ease;
}
.contact:hover { background: var(--rule); }
.contact:active { transform: scale(.99); }
.contact-number { font-size: 32px; line-height: 1.1; font-weight: 400; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.contact:not(.call) .contact-number { font-size: var(--fs-lead); }
.contact-label { grid-column: 1; font-weight: 600; font-size: 15px; }
.contact-en { grid-column: 1; font-size: var(--fs-small); color: var(--muted); }
.contact-go {
  grid-column: 2;
  grid-row: 1 / span 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--control-height);
  padding: 0 18px;
  border-radius: var(--radius-control);
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
}
.contact:not(.call) .contact-go { background: var(--raised); color: var(--text); border: 1px solid var(--control); }
.contact-go svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.steps { margin: 0 0 24px; padding-left: 20px; }
.steps li { margin-bottom: 10px; }
.steps span { display: block; font-size: var(--fs-small); color: var(--muted); }

/* ------------------------------------------------------------ rows: review and panel */

.rows { margin: 0 0 16px; padding: 4px var(--pad); }
.row, .sheet-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.row:first-child, .sheet-row:first-child { border-top: 0; }
.row dt, .sheet-row dt { font-size: var(--fs-small); color: var(--muted); grid-column: 1; }
.row dd, .sheet-row dd { margin: 0; grid-column: 1; overflow-wrap: anywhere; font-weight: 500; }
.sheet-row dd.empty { color: var(--muted); font-weight: 400; }
.sheet-row[aria-current='step'] dt { color: var(--accent); font-weight: 600; }
.change {
  grid-column: 2;
  grid-row: 1 / span 2;
  height: 32px;
  padding: 0 14px;
  border-radius: var(--radius-control);
  border: 1px solid var(--control);
  background: var(--raised);
  font-size: 14px;
  transition: background-color .15s ease;
}
.change:hover { background: var(--surface); }

.sheet-count { margin: -6px 0 8px; font-size: var(--fs-small); color: var(--muted); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ buttons */

.actions { display: grid; gap: 8px; }
.actions.row { grid-template-columns: 1fr 1fr; margin-top: 16px; }
.actions.quiet { margin-top: 4px; }
.button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2px 8px;
  min-height: 52px;
  padding: 8px 20px;
  border-radius: var(--radius-control);
  border: 0;
  font-weight: 600;
  font-size: var(--fs-body);
  text-decoration: none;
  text-align: center;
  line-height: 1.3;
  transition: background-color .15s ease, transform .1s ease;
}
.button:active { transform: scale(.98); }
.button span { font-size: 14px; }
.button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.primary { background: var(--primary); color: #fff; }
.primary span { color: #d4d4d0; }
.primary:hover { background: #33342f; }
.secondary { background: var(--raised); color: var(--text); border: 1px solid var(--control); }
.secondary:hover { background: var(--surface); }
.text { background: none; min-height: 44px; color: var(--text); text-decoration: underline; text-decoration-color: var(--control); text-underline-offset: 4px; font-weight: 500; }
.text:hover { text-decoration-color: currentColor; }

/* ------------------------------------------------------------ letter */

.letter-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.letter-head h1 { margin: 8px 0 0; }
.toggle { display: inline-flex; background: var(--surface); border-radius: var(--radius-control); padding: 3px; }
.toggle button { border: 1px solid transparent; background: none; border-radius: var(--radius-control); height: 34px; padding: 0 16px; font-size: 14px; }
.toggle button[aria-pressed='true'] { background: var(--raised); border-color: var(--border); font-weight: 600; }

/* The letter is the one white card, on a tonal desk. */
.desk { background: var(--surface); border-radius: var(--radius-card); padding: 12px; }
.paper {
  background: var(--raised);
  border-radius: var(--radius-inner);
  padding: 28px 22px 32px;
  font-size: 15px;
  line-height: 1.75;
}
.paper p { margin: 0; }
.paper .block { margin-bottom: 16px; }
.paper .block-title { font-weight: 600; }
.paper .line { padding-left: 1.2em; }
.paper .subject { margin: 18px 0 14px; }
.paper .salutation { margin-bottom: 10px; }
.paper .body { text-indent: 2em; margin-bottom: 12px; }
.paper .foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; margin-top: 24px; }
.paper .meta { white-space: nowrap; }
.paper .sign { margin-left: auto; }
.paper .sign { text-align: right; }
.paper .sign-space { height: 2.4em; }
.paper .sign-name { font-weight: 600; }
.paper .copy { margin: 24px 0 0; font-size: .92em; }

.help.note { margin-top: 16px; padding: var(--pad); background: var(--surface); border-radius: var(--radius-card); }
.help.note h2 { font-size: var(--fs-lead); margin-top: 0; }
.help.note .help-en { margin-bottom: 14px; }
.help.note .contact { background: var(--raised); }
.help.note .steps { margin-bottom: 0; }

/* ------------------------------------------------------------ dock */

.dock {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  background: var(--ground);
  border-top: 1px solid var(--border);
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
}
[data-stage='start'] .dock { border-top: 0; }
[data-stage='quick'] .dock, [data-stage='review'] .dock { position: static; margin-top: 24px; }
[data-stage='letter'] .dock { display: none; }

.prompt { margin-bottom: 12px; }
.prompt p { margin: 0; }
.prompt-ml { font-size: var(--fs-lead); font-weight: 600; line-height: 1.4; }
.prompt-en { font-size: 14px; }
[data-stage='start'] .prompt, [data-stage='quick'] .prompt, [data-stage='review'] .prompt { display: none; }

.choices { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.choices button {
  border: 1px solid var(--border);
  background: var(--raised);
  border-radius: var(--radius-inner);
  padding: 7px 12px;
  font-size: 15px;
  line-height: 1.3;
  text-align: left;
  transition: border-color .15s ease;
}
.choices button span { display: block; font-size: 12px; color: var(--muted); }
.choices button:hover { border-color: var(--control); }

.controls { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.mic {
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 0;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  position: relative;
  transition: background-color .2s ease, transform .1s ease;
}
.mic svg { width: 30px; height: 30px; fill: currentColor; }
.mic:active { transform: scale(.95); }
.mic.listening { background: var(--accent); }
.mic.listening::after, .mic.speaking::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: ring 1.4s ease-out infinite;
}
.mic.speaking::after { border-color: var(--control); animation-duration: 2s; }
@keyframes ring { from { transform: scale(1); opacity: 1; } to { transform: scale(1.3); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .mic::after { animation: none !important; }
  * { transition: none !important; }
}

.status-wrap { min-width: 0; }
.status { margin: 0; font-weight: 600; font-size: 15px; line-height: 1.35; }
.status span { display: block; font-size: var(--fs-small); }
.live { margin: 2px 0 0; color: var(--accent); font-size: 15px; line-height: 1.35; overflow-wrap: anywhere; }
.live:empty { display: none; }

.typed { display: flex; gap: 8px; }
.typed input {
  flex: 1;
  min-width: 0;
  height: 48px;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--raised);
  padding: 0 18px;
  font-size: var(--fs-body);
}
.typed input::placeholder { color: #6b6b68; }
.typed input:focus { border-color: var(--accent); outline: none; }
.typed button {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  background: var(--surface);
  display: grid;
  place-items: center;
  transition: background-color .15s ease;
}
.typed button:hover { background: var(--rule); }
.typed svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.notice {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-radius: var(--radius-inner);
  background: var(--pill-warning-bg);
  color: var(--pill-warning-ink);
  font-size: var(--fs-small);
  line-height: 1.45;
}
.notice { display: flex; align-items: flex-start; gap: 12px; }
.notice button { flex: none; border: 0; background: none; padding: 0; font-size: var(--fs-small); font-weight: 600; color: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* ------------------------------------------------------------ the phone: the panel at the moments it matters */

@media (max-width: 899px) {
  /* On the letter screen the panel carries only the call-first note. */
  [data-stage='letter'] .sheet { display: block; background: none; padding: 0 0 24px; }
  [data-stage='letter'] .sheet > .panel-title,
  [data-stage='letter'] .sheet-count,
  [data-stage='letter'] .sheet-rows { display: none; }
}

/* ------------------------------------------------------------ wide: work beside the application */

@media (min-width: 900px) {
  :root { --fs-title: 32px; }
  .bar { padding: 0 16px; height: 72px; }
  .layout { grid-template-columns: 7fr 5fr; column-gap: 16px; align-items: start; }
  .screen { padding-top: 24px; }
  .sheet {
    display: block;
    position: sticky;
    top: 24px;
    margin-top: 24px;
  }
  .work { min-height: calc(100dvh - 72px); }
  /* The review rows live in the panel on wide screens. */
  #review .rows { display: none; }
  /* The letter is wider; the panel holds what to do with it. */
  [data-stage='letter'] .layout { grid-template-columns: 8fr 4fr; }
  [data-stage='letter'] .sheet { background: none; padding: 0; position: static; margin-top: 86px; }
  [data-stage='letter'] .sheet > .panel-title,
  [data-stage='letter'] .sheet-count,
  [data-stage='letter'] .sheet-rows { display: none; }
  [data-stage='letter'] .help.note { margin-top: 0; }
  .paper { padding: 48px 56px 56px; font-size: 16px; }
}

/* ------------------------------------------------------------ print: the letter only */

@media print {
  @page { size: A4; margin: 20mm 18mm; }
  body { display: block; }
  .bar, .notice, .dock, .letter-head, .actions, .sheet, #start, #quick, #chat, #review { display: none !important; }
  .layout { display: block; max-width: none; padding: 0; }
  .work { min-height: 0; }
  .desk { background: none; padding: 0; }
  .paper { padding: 0; font-size: 12.5pt; }
}
