/* Owner app for the AI phone secretary.
   One bold element: each message is shown as a "while you were out" phone slip.
   Everything else stays quiet: lichen-grey paper, spruce actions, system type. */

:root {
  --bg: #eef1ec;
  --surface: #ffffff;
  --ink: #1e3a34;
  --muted: #5d716b;
  --line: #d6ddd7;
  --spruce: #1f5a4c;
  --on-spruce: #ffffff;
  --slip: #f9dbe0;
  --slip-rule: #ecb6c0;
  --slip-ink: #4a1f2a;
  --urgent: #b42318;
  --warn-bg: #fff4e0;
  --warn-ink: #7a4a00;
  --focus: #2b6fd6;
  --radius-s: 8px;
  --radius-m: 14px;
  --display: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --text: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12201c;
    --surface: #1a2b26;
    --ink: #e4ece8;
    --muted: #9fb2ab;
    --line: #2c3f39;
    --spruce: #66b8a2;
    --on-spruce: #0c1a16;
    --slip: #3a2228;
    --slip-rule: #5f3540;
    --slip-ink: #f7dce2;
    --urgent: #ff8a7f;
    --warn-bg: #3a2c12;
    --warn-ink: #f3cf8c;
    --focus: #8ab4ff;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 var(--text);
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: var(--spruce); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

/* top bar */
.top {
  position: sticky; top: 0; z-index: 5;
  padding: calc(10px + env(safe-area-inset-top)) 20px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand {
  font: 600 18px/1.2 var(--display);
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}

main { max-width: 560px; margin: 0 auto; padding: 20px 16px 24px; outline: none; }
main:focus, main:focus-visible { outline: none; }
h1 { font: 650 26px/1.2 var(--display); margin: 4px 0 6px; letter-spacing: -0.02em; }
h2 { font: 620 19px/1.3 var(--display); margin: 28px 0 8px; }
p { margin: 0 0 12px; }
.lead { color: var(--muted); margin-bottom: 20px; max-width: 62ch; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* bottom tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 4px 8px;
  color: var(--muted); text-decoration: none; font-size: 12.5px;
}
.tabs a[aria-current="page"] { color: var(--spruce); font-weight: 600; }
.tabs svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.badge {
  position: absolute; top: 4px; left: calc(50% + 6px);
  min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px;
  background: var(--urgent); color: #fff; font: 700 12px/19px var(--text); text-align: center;
}

/* message list: plain rows, not cards */
.list { list-style: none; margin: 0 -16px; padding: 0; border-top: 1px solid var(--line); }
.list li { border-bottom: 1px solid var(--line); }
.list a {
  display: grid; grid-template-columns: 14px 1fr auto; column-gap: 8px; row-gap: 2px;
  padding: 14px 16px; color: var(--ink); text-decoration: none; background: var(--surface);
}
.list a:active { background: var(--bg); }
.dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 8px; background: transparent; }
.unread .dot { background: var(--spruce); }
.who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread .who { font-weight: 750; }
.when { color: var(--muted); font-size: 14px; white-space: nowrap; padding-top: 2px; }
.snippet {
  grid-column: 2 / 4; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.missed .snippet { font-style: italic; }
.tag {
  display: inline-block; font-size: 12.5px; font-weight: 650; padding: 1px 8px; border-radius: 6px;
  color: var(--urgent); border: 1.5px solid currentColor; margin-right: 6px; vertical-align: 1px;
}
.empty { text-align: center; padding: 48px 12px; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font: 620 19px/1.3 var(--display); margin-bottom: 6px; }

/* the phone message slip */
.slip {
  position: relative;
  margin: 8px 2px 22px;
  padding: 18px 18px 20px;
  color: var(--slip-ink);
  background-color: var(--slip);
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, var(--slip-rule) 31px 32px);
  background-position: 0 58px;
  border-radius: 4px 4px 10px 10px;
  box-shadow: 0 1px 0 var(--slip-rule), 0 14px 26px -18px rgba(74, 31, 42, 0.55);
  transform: rotate(-0.7deg);
}
.slip::before { /* torn perforation at the top */
  content: ""; position: absolute; left: 0; right: 0; top: -5px; height: 6px;
  background: radial-gradient(circle at 5px 6px, var(--bg) 3px, transparent 3.5px) 0 0 / 10px 6px repeat-x;
}
.slip h1 { font-size: 21px; margin: 0 0 12px; color: var(--slip-ink); }
.slip dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0 0 14px; font-size: 15.5px; }
.slip dt { opacity: 0.75; }
.slip dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.slip dd a { color: inherit; }
.ticks { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 14px; padding: 0; font-size: 15px; }
.ticks li { display: flex; align-items: center; gap: 7px; opacity: 0.55; }
.ticks li.on { opacity: 1; font-weight: 650; }
.ticks li::before {
  content: ""; width: 15px; height: 15px; border: 1.8px solid currentColor; border-radius: 3px;
  display: grid; place-items: center; font: 800 13px/1 var(--text);
}
.ticks li.on::before { content: "✓"; }
.ticks li.urgent.on { color: var(--urgent); }
.slip .text { font-size: 20px; line-height: 32px; margin: 0; white-space: pre-wrap; }
.slip .missed-text { font-size: 18px; line-height: 32px; margin: 0; font-style: italic; }
.warn {
  background: var(--warn-bg); color: var(--warn-ink);
  border-radius: var(--radius-s); padding: 10px 12px; margin: 0 0 16px; font-size: 15px;
}

/* buttons and actions */
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 20px; }
.btn {
  appearance: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 12px;
  font: 650 16px/1 var(--text); text-decoration: none;
  background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line);
}
.btn.primary { background: var(--spruce); color: var(--on-spruce); box-shadow: none; }
.btn.wide { width: 100%; }
.btn.danger { color: var(--urgent); }
.btn:disabled { opacity: 0.45; cursor: default; }
.linkbtn { appearance: none; border: 0; background: none; color: var(--spruce); font: inherit; padding: 8px 0; cursor: pointer; text-decoration: underline; }

details.talk { margin: 4px 0 24px; }
details.talk summary { cursor: pointer; color: var(--spruce); font-weight: 600; padding: 8px 0; }
.talk ol { list-style: none; margin: 8px 0 0; padding: 0; font-size: 15px; }
.talk li { display: grid; grid-template-columns: 48px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.talk .t { color: var(--muted); font-variant-numeric: tabular-nums; }
.talk .me { color: var(--muted); }

/* forms */
.panel { background: var(--surface); border-radius: var(--radius-m); padding: 16px; margin: 0 0 16px; box-shadow: inset 0 0 0 1px var(--line); }
label.field { display: block; margin: 0 0 14px; }
label.field > span { display: block; font-size: 14.5px; color: var(--muted); margin-bottom: 5px; }
input[type="text"], input[type="email"] {
  width: 100%; min-height: 46px; padding: 10px 12px; font: inherit; color: var(--ink);
  background: var(--bg); border: 1.5px solid var(--line); border-radius: 10px;
}
.choice { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.choice label {
  flex: 1 1 0; min-width: 120px; display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 11px 12px; border-radius: 10px; box-shadow: inset 0 0 0 1.5px var(--line);
}
.choice input { accent-color: var(--spruce); width: 18px; height: 18px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 12px; cursor: pointer; }
.check input { accent-color: var(--spruce); width: 20px; height: 20px; margin: 2px 0 0; flex: none; }

/* call forwarding */
.fwd { list-style: none; padding: 0; margin: 0 0 18px; }
.fwd li { background: var(--surface); border-radius: var(--radius-m); padding: 14px 16px; margin-bottom: 10px; box-shadow: inset 0 0 0 1px var(--line); }
.fwd h2 { margin: 0 0 2px; font-size: 17.5px; }
.fwd p { color: var(--muted); font-size: 15px; margin: 0 0 10px; }
.fwd .row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.code { font: 600 16px/1.3 var(--mono); letter-spacing: 0.02em; padding: 6px 10px; background: var(--bg); border-radius: 8px; user-select: all; }
.fwd .row .btn { min-height: 42px; padding: 0 16px; margin-left: auto; }

/* voice */
.voice-state { display: flex; align-items: center; gap: 12px; margin: 0 0 18px; }
.voice-state .mark { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex: none; }
.voice-state.on .mark { background: var(--spruce); }
.readtext { font-size: 16.5px; line-height: 1.6; max-height: 260px; overflow: auto; padding-right: 6px; }
.readtext p { margin: 0 0 10px; }
.recorder { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 10px 0 4px; }
.rec {
  width: 92px; height: 92px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--urgent); box-shadow: 0 0 0 6px var(--surface), 0 0 0 8px var(--line);
  display: grid; place-items: center;
}
.rec::after { content: ""; width: 30px; height: 30px; border-radius: 50%; background: #fff; transition: border-radius 0.2s, width 0.2s, height 0.2s; }
.rec.on::after { width: 28px; height: 28px; border-radius: 6px; }
.rec.on { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px var(--surface), 0 0 0 14px rgba(180, 35, 24, 0.25); } }
.timer { font: 600 22px/1 var(--text); font-variant-numeric: tabular-nums; }
audio { width: 100%; margin: 8px 0; }

#toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 10;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); padding: 12px 16px; border-radius: 12px;
  background: var(--ink); color: var(--bg); font-size: 15px; transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.steps { padding-left: 22px; margin: 0 0 20px; }
.steps li { margin-bottom: 10px; padding-left: 4px; }
.welcome-home { margin-top: 18px; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .slip { transform: none; }
}
