/* schoice, pass 2: a quiet phone app with one cheeky colour. See docs/design.md. */
:root {
  --bg: #f6f5f3;          /* canvas */
  --surface: #ffffff;     /* cards, inputs, grouped lists */
  --ink: #1f1d1c;
  --muted: #6b6866;
  --faint: #a9a5a2;
  --line: #e9e6e3;        /* hairlines */
  --edge: #dcd8d4;        /* input borders */
  --accent: #e8255f;      /* raspberry: the one colour that means "go" */
  --accent-ink: #ffffff;
  --accent-wash: #ffe8ee;
  --voice-wash: #ebe5ff;  /* the voice in the call sentence */
  --voice-ink: #4b2bb8;
  --friend-wash: #fff0b3; /* the friend in the call sentence */
  --friend-ink: #6b4b00;
  --gist-wash: #f1edff;
  --bad: #d92d20;
  --good: #12a150;
  --shadow: 0 1px 2px rgb(31 29 28 / 0.05), 0 6px 20px rgb(31 29 28 / 0.06);
  --shadow-lift: 0 12px 40px rgb(31 29 28 / 0.18);

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 36px;
  --gutter: 16px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --tabbar: 64px;

  --sans: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
/* Dark palette, unused for now: the app is light only. Set data-theme="dark" on <html> to bring it back. */
:root[data-theme="dark"] {
  --bg: #121214;
  --surface: #1c1c20;
  --ink: #f3f2f0;
  --muted: #a2a0a6;
  --faint: #6f6d74;
  --line: #2a2a30;
  --edge: #36363d;
  --accent: #f23a6f;
  --accent-ink: #ffffff;
  --accent-wash: #3a1823;
  --voice-wash: #2c2350;
  --voice-ink: #cfc2ff;
  --friend-wash: #3b3215;
  --friend-ink: #ffe28a;
  --gist-wash: #221f33;
  --bad: #ff5c4d;
  --good: #3ddc84;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-lift: 0 12px 40px rgb(0 0 0 / 0.6);
  color-scheme: dark;
}
@media (min-width: 640px) {
  :root { --gutter: 24px; }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--sans);
  font-optical-sizing: auto;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
p { margin: 0; }
h1, h2 { margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
::selection { background: var(--accent-wash); }

/* ---------- wordmark ---------- */
.logo { display: inline-flex; align-items: center; gap: 12px; font-weight: 800; font-size: 27px; letter-spacing: -0.045em; line-height: 0.9; }
.logo .mark { width: 60px; height: 60px; flex: none; transform: rotate(-6deg); } /* home screen icon size, tilted */
.logo .word { display: block; }

/* ---------- sign in ---------- */
.login { max-width: 400px; margin: 0 auto; padding: 18vh var(--gutter) var(--s6); }
.login .logo { font-size: 40px; gap: 16px; }
.login .logo .mark { width: 76px; height: 76px; }
.tagline { color: var(--muted); font-size: 18px; margin: var(--s3) 0 var(--s6); }

/* ---------- header and tabs ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  max-width: 720px; margin: 0 auto; padding: calc(var(--s4) + env(safe-area-inset-top)) var(--gutter) 0;
}
.top nav button {
  background: none; border: 0; color: var(--muted); font-weight: 600; min-height: 44px;
}
.top nav button svg { width: 22px; height: 22px; }
.top nav button.active { color: var(--ink); }

/* Phone: a native-feeling tab bar along the bottom. */
@media (max-width: 639px) {
  .top nav {
    position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
    display: grid; grid-template-columns: repeat(4, 1fr);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
    border-top: 1px solid var(--line);
  }
  .top nav button {
    flex-direction: column; gap: 3px; padding: 4px 0; font-size: 11.5px; font-weight: 600; letter-spacing: 0.01em;
    border-radius: var(--r-sm);
  }
  .top nav button.active { color: var(--accent); }
  body:has(#app:not([hidden])) { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
}
/* Wider: a segmented control beside the wordmark. */
@media (min-width: 640px) {
  .top { padding-top: var(--s5); }
  .top nav { display: flex; gap: 2px; padding: 4px; background: var(--surface); border-radius: 999px; box-shadow: var(--shadow); margin-right: auto; margin-left: var(--s4); }
  .top nav button { padding: 8px 16px; border-radius: 999px; font-size: 15px; min-height: 38px; }
  .top nav button svg { display: none; }
  .top nav button.active { background: var(--ink); color: var(--bg); }
}

.banner {
  display: flex; align-items: center; gap: var(--s2); width: fit-content; max-width: calc(100% - 2 * var(--gutter));
  margin: var(--s3) auto 0; padding: 6px 12px; border-radius: 999px;
  background: var(--friend-wash); color: var(--friend-ink); font-size: 13.5px; font-weight: 600; line-height: 1.3;
}
.banner::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
@media (min-width: 760px) { .banner { margin-left: max(var(--gutter), calc(50% - 360px + var(--gutter))); } }
@media (max-width: 759px) { .banner { margin-left: var(--gutter); } }

/* ---------- layout ---------- */
.panel { max-width: 720px; margin: 0 auto; padding: var(--s5) var(--gutter) var(--s6); display: grid; gap: var(--s6); }
.section { min-width: 0; }
.section h2, .sheet h2 { font-weight: 700; font-size: 24px; line-height: 1.15; letter-spacing: -0.025em; }
.section > h2 { margin-bottom: var(--s3); }
.stack > h2 { margin-bottom: calc(-1 * var(--s2)); }
.aside { display: block; margin-top: 3px; font-size: 14.5px; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.stack { display: grid; gap: var(--s4); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: var(--s3); align-items: start; }

/* ---------- fields ---------- */
label, .field, .group { display: grid; gap: 6px; min-width: 0; }
label, .field-label { font-weight: 600; font-size: 14.5px; color: var(--ink); }
.optional { font-weight: 400; color: var(--muted); margin-left: var(--s1); }
.narrow { max-width: 360px; }
input, select, textarea {
  font: inherit; font-size: 17px; font-weight: 400; color: var(--ink); background: var(--surface);
  border: 1px solid var(--edge); border-radius: var(--r-md); padding: 12px 14px; width: 100%; min-width: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--faint); opacity: 1; }
select {
  appearance: none; padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23888' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right 14px center; background-size: 12px 8px; background-repeat: no-repeat;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hint, .muted { color: var(--muted); font-size: 14px; font-weight: 400; }
.hint:empty { display: none; }

.field-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.head-btns { display: flex; gap: var(--s4); }
button.link {
  background: none; border: 0; border-radius: var(--r-sm); padding: 6px 2px; min-height: 36px; color: var(--accent);
  font-size: 15px; font-weight: 700;
}
button.link svg { width: 13px; height: 13px; }
button.link.quiet { color: var(--muted); font-weight: 500; font-size: 14.5px; }

/* ---------- the call sentence: "[voice] calls [friend]" ---------- */
.madlib {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 10px;
  font-weight: 800; font-size: 30px; line-height: 1.1; letter-spacing: -0.035em;
  padding: var(--s2) 0 var(--s2);
}
.madlib .field { display: flex; align-items: center; gap: 6px; max-width: 100%; }
.madlib select {
  font: inherit; letter-spacing: inherit; width: auto; max-width: calc(100vw - 2 * var(--gutter) - 52px);
  border: 0; border-radius: 16px; padding: 6px 40px 9px 14px; text-overflow: ellipsis;
  background-position: right 15px center; background-size: 13px 9px;
}
.madlib .field:first-child select { background-color: var(--voice-wash); color: var(--voice-ink); }
.madlib .field:last-child select { background-color: var(--friend-wash); color: var(--friend-ink); }
.madlib select:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.madlib .calls { font-weight: 500; color: var(--faint); }
button.plus {
  width: 40px; height: 40px; min-height: 0; padding: 0; border-radius: 50%; border: 0;
  background: var(--surface); color: var(--muted); box-shadow: var(--shadow); flex: none;
}
button.plus svg { width: 14px; height: 14px; }
.pick-empty {
  font: inherit; letter-spacing: inherit; color: var(--muted); background: transparent; min-height: 0;
  border: 2px dashed var(--edge); border-radius: 16px; padding: 4px 14px 7px;
}
.pick-empty::after { content: " +"; color: var(--accent); }
@media (min-width: 640px) { .madlib { font-size: 42px; } }

/* ---------- options: a grouped list like iOS settings ---------- */
.checks { display: grid; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; }
label.check {
  display: flex; align-items: center; gap: var(--s3); padding: 14px var(--s4); cursor: pointer; min-height: 56px;
  font-weight: 500; font-size: 16px; line-height: 1.35; transition: background 0.2s;
}
.checks > label.check + label.check { border-top: 1px solid var(--line); }
label.check strong { font-weight: 700; }
label.check .hint { display: block; margin-top: 2px; }
label.switch > span { flex: 1; min-width: 0; }
label.switch input { order: 2; }
/* The name sits inside the group as a plain row. */
label.name-row { cursor: text; }
label.name-row input { border: 0; background: transparent; padding: 4px 0; text-align: right; box-shadow: none; flex: 1; }
label.name-row input:focus { box-shadow: none; }

/* Switches are still real checkboxes, just drawn differently. */
label.switch input {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0; padding: 0; border: 0; cursor: pointer;
  width: 51px; height: 31px; border-radius: 999px; background: var(--edge); position: relative; transition: background 0.2s;
}
label.switch input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgb(0 0 0 / 0.2); transition: transform 0.2s cubic-bezier(.3,.7,.4,1.2);
}
label.switch input:checked { background: var(--good); }
label.switch input:checked::after { transform: translateX(20px); }
label.switch input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Beast mode lights up its row when it's on. */
label.beast input:checked { background: var(--accent); }
label.beast:has(input:checked) { background: var(--accent-wash); }
label.beast:has(input:checked) strong { color: var(--accent); }

/* Round tick box for consent, in the confirm sheet. */
label.consent {
  background: var(--bg); border-radius: var(--r-md); font-size: 15.5px; align-items: flex-start;
}
label.consent input {
  appearance: none; -webkit-appearance: none; flex: none; width: 26px; height: 26px; margin: 0; padding: 0;
  border: 2px solid var(--edge); border-radius: 50%; background: var(--surface); display: grid; place-items: center; cursor: pointer;
}
label.consent input:checked { background: var(--accent); border-color: var(--accent); }
label.consent input:checked::after {
  content: ""; width: 7px; height: 12px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: translateY(-1px) rotate(45deg);
}

/* ---------- buttons ---------- */
button {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 999px; padding: 11px 20px; min-height: 44px;
  border: 1px solid var(--edge); background: var(--surface); color: var(--ink); line-height: 1.2;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  transition: transform 0.12s, background 0.15s, opacity 0.15s;
}
button:active:not(:disabled) { transform: scale(0.97); }
button svg { width: 13px; height: 13px; flex: none; pointer-events: none; }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
/* Raspberry is saved for the moment you actually ring someone. */
#dial, #confirm-go { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { background: var(--bad); color: #fff; border-color: var(--bad); }
button.ghost { background: transparent; }
button.small { padding: 7px 14px; min-height: 40px; font-size: 14.5px; }
button.icon { width: 40px; padding: 0; }
button.icon svg { width: 12px; height: 12px; }
button.big { min-height: 56px; padding: 14px 28px; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
button.big svg { width: 18px; height: 18px; }
button.block { width: 100%; }
.stack > button { justify-self: start; }
.stack > button.block { justify-self: stretch; }
#dial { box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 35%, transparent); }

.actions { display: flex; gap: var(--s3); justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 519px) {
  .actions { flex-direction: column-reverse; }
  .actions button { width: 100%; }
  .stack > button { justify-self: stretch; }
}

.error { color: var(--bad); font-size: 15px; font-weight: 600; }
.error:empty { display: none; }

/* ---------- bits and presets ---------- */
.scenarios, .presets { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip {
  padding: 8px 15px; min-height: 40px; font-weight: 600; font-size: 15px;
  border: 1px solid var(--edge); background: var(--surface); color: var(--ink);
}
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--bg); }
/* Phone: the bits scroll sideways in one row instead of stacking four deep. */
@media (max-width: 639px) {
  .scenarios {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity;
    margin: 0 calc(-1 * var(--gutter)); padding: 2px var(--gutter) 6px; scroll-padding: 0 var(--gutter);
  }
  .scenarios::-webkit-scrollbar { display: none; }
  .scenarios .chip { flex: none; scroll-snap-align: start; }
}

/* ---------- voice design takes ---------- */
.previews { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: var(--s3); }
.preview {
  background: var(--surface); border: 2px solid transparent; border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: var(--s3) var(--s4) var(--s4); display: grid; gap: var(--s2); cursor: pointer;
}
.preview strong { font-size: 15px; }
.preview.active { border-color: var(--accent); background: var(--accent-wash); }
.preview.active button { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.preview audio { width: 100%; height: 40px; }
.preview button { justify-self: start; }

/* ---------- lists: grouped, hairline rows ---------- */
.list {
  list-style: none; margin: 0; padding: 0; display: grid;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden;
}
.list:empty { display: none; }
.list > li {
  display: flex; gap: var(--s3); align-items: center; justify-content: space-between;
  padding: 14px var(--s4);
}
.list > li + li { border-top: 1px solid var(--line); }
.list > li > div { min-width: 0; }
.list .name { font-weight: 700; font-size: 17px; line-height: 1.25; letter-spacing: -0.01em; }
.list .sub { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; margin-top: 2px; }
.list .btns { display: flex; gap: var(--s2); flex-shrink: 0; }
.list > li.empty { color: var(--muted); padding: var(--s5) var(--s4); justify-content: center; }
#friend-list .sub { font-variant-numeric: tabular-nums; }
.pinned {
  background: var(--surface); padding: var(--s4); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lift); border: 2px solid var(--accent);
}

/* ---------- confirm sheet ---------- */
.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 520px; max-height: 90vh;
  background: var(--surface); color: var(--ink); border-radius: 24px 24px 0 0; box-shadow: var(--shadow-lift);
}
.sheet[open] { animation: sheet-up 0.28s cubic-bezier(.2,.8,.2,1); }
.sheet::backdrop { background: rgb(10 10 12 / 0.45); }
.sheet-body { display: grid; gap: var(--s4); padding: var(--s3) var(--s5) calc(var(--s5) + env(safe-area-inset-bottom)); }
.grabber { width: 40px; height: 5px; position: relative; border-radius: 3px; background: var(--edge); justify-self: center; margin-bottom: var(--s1); }
.sheet h2 { font-size: 26px; }
.sheet h2 + .muted { margin-top: calc(-1 * var(--s3)); font-size: 15px; }
.confirm-flags { display: flex; flex-wrap: wrap; gap: 6px; }
.flag { font-size: 13.5px; font-weight: 600; padding: 4px 11px; border-radius: 999px; background: var(--bg); color: var(--muted); }
.flag.beast { background: var(--accent-wash); color: var(--accent); }
.sheet .actions { margin-top: var(--s1); }
@media (min-width: 640px) {
  .sheet { margin: auto; border-radius: 24px; }
  .sheet .grabber { display: none; }
  .sheet-body { padding-top: var(--s5); }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }

/* ---------- live call ---------- */
.live { display: grid; gap: var(--s5); }
.live-head {
  display: flex; justify-content: space-between; align-items: center; gap: var(--s3); flex-wrap: wrap;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: var(--s5) var(--s4);
}
.live-head > div { min-width: 0; }
#live-who { margin-top: 6px; overflow-wrap: anywhere; font-size: 14.5px; }
.status { display: flex; align-items: center; font-size: 34px; font-weight: 800; line-height: 1; letter-spacing: -0.035em; }
.status::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--faint); margin-right: var(--s3); flex: none;
}
.status.active::before { background: var(--good); animation: pulse 1.6s infinite; }
.status.dialing::before, .status.queued::before, .status.ending::before { background: var(--accent); animation: pulse 1.2s infinite; }
.status.failed::before { background: var(--bad); }
@keyframes pulse { 50% { opacity: 0.35; transform: scale(0.8); } }
#live-body:empty { display: none; }
.live #new-call { justify-self: start; }
@media (max-width: 519px) { .live #new-call, #hangup { width: 100%; } }

/* ---------- transcript (set like a script), summary, recording ---------- */
.transcript { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s4); }
.transcript li { overflow-wrap: anywhere; font-size: 17px; line-height: 1.45; }
.transcript li small { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 1px; letter-spacing: 0; }
.transcript li.agent small { color: var(--voice-ink); }
.transcript li.user { padding-left: var(--s5); }
.transcript li.user small { color: var(--friend-ink); }
.transcript .tag {
  display: inline-block; font-size: 13px; font-weight: 600; color: var(--muted); font-style: italic;
  background: var(--bg); border-radius: 6px; padding: 0 6px; margin: 0 2px;
}
.transcript + .summary, .transcript + .recording, .transcript + .muted { margin-top: var(--s5); }
.summary { background: var(--gist-wash); border-radius: var(--r-md); padding: var(--s3) var(--s4); font-size: 16px; }
.summary::before { content: "The gist"; display: block; font-size: 13px; font-weight: 700; color: var(--voice-ink); margin-bottom: 2px; }
.summary + .recording, .summary + .muted { margin-top: var(--s4); }
.recording { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.recording audio { flex: 1 1 220px; min-width: 0; height: 44px; }
.small-link { color: var(--accent); font-size: 15px; font-weight: 700; text-decoration: none; padding: var(--s2) 2px; }

/* ---------- history ---------- */
.list > li.history-item { display: block; }
.history-head { display: flex; gap: var(--s3); align-items: center; justify-content: space-between; }
.history-head > div:first-child { flex: 1 1 auto; min-width: 0; }
.history-head .calls { font-weight: 400; color: var(--muted); }
.history-head .sub.mono { font-size: 13.5px; }
.history-detail { margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--line); }
/* Once open, the gist below says it better than the one-line summary. */
.history-item:has(.history-detail:not([hidden])) .history-head .sub:not(.mono) { display: none; }
.history-item:has(.history-detail:not([hidden])) { background: color-mix(in srgb, var(--bg) 40%, var(--surface)); }

/* ---------- voice library ---------- */
.lib-search { display: grid; grid-template-columns: 1fr auto auto; gap: var(--s2); }
.lib-search select { width: auto; }
@media (max-width: 519px) {
  .lib-search { grid-template-columns: 1fr auto; }
  .lib-search button { grid-column: 1 / -1; }
}
.lib-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* Row actions stay light so the names keep the room. */
.list button.ghost { border-color: transparent; color: var(--muted); padding-inline: 10px; }
.stack > h2 { margin-bottom: 0; }

.theme-toggle { display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 999px; background: transparent; color: var(--muted); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle:hover { color: var(--ink); }
.grabber::after { content: ""; position: absolute; inset: -14px -40px; } /* bigger grab zone */

/* ---------- toast + new-row flash ---------- */
.toast {
  position: fixed; z-index: 40; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: var(--s4); max-width: calc(100% - 32px); width: max-content;
  padding: 12px 18px; border-radius: 999px; background: var(--ink); color: var(--bg);
  font-weight: 600; font-size: 15px; box-shadow: var(--shadow-lift);
}
.toast span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast .link { color: var(--bg); text-decoration: underline; text-underline-offset: 3px; font-size: 15px; white-space: nowrap; padding: 4px 0; }
.toast.show { animation: toast-in 0.25s cubic-bezier(.2,.8,.2,1); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }
@media (max-width: 639px) {
  .toast { bottom: calc(var(--tabbar) + 12px + env(safe-area-inset-bottom)); }
}
.list > li.just-added { animation: just-added 2.4s ease-out; }
@keyframes just-added { 0%, 35% { background: var(--accent-wash); } 100% { background: transparent; } }

/* Keep the brand and Sign out on one line on the narrowest phones. */
.logo, #logout { white-space: nowrap; }

/* Pinned header: stays at the top while the page scrolls. The background (::before) runs edge to edge even though the
   header itself is centred, without clip-path, which would clip the tab bar, and a hairline appears once the page has scrolled. No backdrop-filter here: it would
   trap the phone tab bar (a fixed child of the header) inside it. */
.top { position: sticky; top: 0; z-index: 15; padding-bottom: var(--s3); }
.top::before, .top.scrolled::after { content: ""; position: absolute; left: 50%; width: 100vw; transform: translateX(-50%); }
.top::before { z-index: -1; top: 0; bottom: 0; background: var(--bg); }
.top.scrolled::after { bottom: 0; height: 1px; background: var(--line); }
html { overflow-x: clip; } /* desktop scrollbars make 100vw a hair wider than the page */

/* ---------- add to home screen hint ---------- */
.install {
  display: flex; align-items: center; gap: var(--s3); max-width: calc(720px - 2 * var(--gutter)); margin: 0 auto var(--s2);
  padding: var(--s3) var(--s2) var(--s3) var(--s3); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow);
}
@media (max-width: 759px) { .install { margin: 0 var(--gutter) var(--s2); } }
.install img { width: 44px; height: 44px; flex: none; }
.install div { flex: 1; min-width: 0; }
.install strong { display: block; font-size: 15px; }
.install p { color: var(--muted); font-size: 14px; line-height: 1.35; margin-top: 2px; }
.install b { color: var(--ink); font-weight: 600; }
.share-ico { display: inline-flex; vertical-align: -3px; color: #0a84ff; }
.share-ico svg { width: 17px; height: 17px; }
.install-close { flex: none; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; }

/* ---------- install guide sheet ---------- */
.install-head { display: flex; align-items: center; gap: var(--s3); }
.install-head img { width: 52px; height: 52px; flex: none; transform: rotate(-6deg); }
.install-head div { flex: 1; min-width: 0; }
.install-head h2 { font-size: 21px; line-height: 1.15; }
.install-head .muted { font-size: 14px; margin-top: 2px; }
#install-sheet { overflow-y: auto; overscroll-behavior: contain; }
#install-sheet h2 + .muted { margin-top: 2px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s5); counter-reset: step; }
.steps li { counter-increment: step; display: grid; gap: var(--s2); padding-left: 40px; position: relative; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: -2px; width: 28px; height: 28px; border-radius: 999px;
  display: grid; place-items: center; background: var(--ink); color: var(--bg); font-weight: 700; font-size: 14px;
}
.steps li > p { font-weight: 600; font-size: 16px; line-height: 1.35; }
.steps li > p.muted { font-weight: 400; font-size: 14px; margin-top: -4px; }
.steps svg { width: 1em; height: 1em; vertical-align: -0.12em; }

/* Drawn mock-ups of the browser screens, close to the real iOS / Android UI; .hi rings the thing to tap. */
.mock { --mk-bg: #e9e8ec; --mk-fill: #ffffff; --mk-ink: #1c1c1e; --mk-dim: #8a8a8e; --mk-sep: #d9d8dd;
  border-radius: 18px; background: var(--mk-bg); padding: 16px 14px; overflow: hidden; display: grid; gap: 10px; color: var(--mk-ink); }
.mock svg { width: 20px; height: 20px; flex: none; }
.mock .hi { position: relative; color: var(--accent) !important; }
.mock .hi::after { content: ""; position: absolute; inset: -7px; border: 2.5px solid var(--accent); border-radius: 999px; animation: tap-ring 1.6s ease-in-out infinite; pointer-events: none; }
@keyframes tap-ring { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* bars */
.mk-bar { display: flex; align-items: center; gap: 8px; }
.mk-btn { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 999px; background: var(--mk-fill); box-shadow: 0 1px 3px rgb(0 0 0 / 0.08); }
.mk-url { flex: 1; min-width: 0; height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 14px; border-radius: 999px; background: var(--mk-fill); box-shadow: 0 1px 3px rgb(0 0 0 / 0.08); }
.mk-url i { flex: 1; font-style: normal; font-size: 15px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mk-url b, .mk-plain, .mk-tools b { display: inline-grid; place-items: center; font-weight: 400; }
.mk-url > svg { color: var(--mk-ink); }
.mk-solo { flex: none; }
.mk-plain { width: 28px; flex: none; }
.mk-tools { display: flex; justify-content: space-around; align-items: center; height: 46px; padding: 0 6px; border-radius: 16px; background: var(--mk-fill); color: #0a84ff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.08); }
.mk-tools svg { width: 22px; height: 22px; }

/* pop-up menu: label left, icon right, like iOS context menus */
.mk-menu { width: min(270px, 100%); justify-self: center; border-radius: 14px; background: var(--mk-fill); box-shadow: 0 6px 24px rgb(0 0 0 / 0.12); }
.mk-menu > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 16px; font-size: 15px; border-top: 1px solid var(--mk-sep); }
.mk-menu > div:first-child { border-top: 0; }
.mk-menu > div.hi { font-weight: 600; }
.mk-menu > div.hi::after { inset: 3px; border-radius: 10px; }

/* share sheet */
.mk-sheet { border-radius: 18px; background: var(--mk-fill); padding: 14px 12px 12px; display: grid; gap: 14px; box-shadow: 0 6px 24px rgb(0 0 0 / 0.1); }
.mk-sheet-head { display: flex; align-items: center; gap: 10px; padding: 0 4px 12px; border-bottom: 1px solid var(--mk-sep); }
.mk-sheet-head img { width: 40px; height: 40px; border-radius: 10px; }
.mk-sheet-head b { display: block; font-size: 14px; }
.mk-sheet-head span { font-size: 12.5px; color: var(--mk-dim); }
.mk-apps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding-bottom: 14px; border-bottom: 1px solid var(--mk-sep); }
.mk-apps > div { display: grid; justify-items: center; gap: 5px; font-size: 11.5px; }
.mk-app { width: 46px; height: 46px; border-radius: 12px; }
.mk-app.airdrop { background: radial-gradient(circle at 50% 60%, #fff 0 14%, transparent 15%), radial-gradient(circle at 50% 60%, transparent 0 30%, rgb(255 255 255 / .7) 31% 37%, transparent 38%), linear-gradient(#45a3ff, #1a74f0); }
.mk-app.messages { background: radial-gradient(ellipse 34% 28% at 50% 48%, #fff 98%, transparent 100%), linear-gradient(#6ee36a, #2fc24a); }
.mk-app.mail { background: linear-gradient(160deg, transparent 0 46%, rgb(255 255 255 / .85) 47% 53%, transparent 54%) 50% 45% / 60% 44% no-repeat, linear-gradient(#fff, #fff) 50% 50% / 60% 44% no-repeat, linear-gradient(#4aa6ff, #1c72ee); }
.mk-app.notes { background: linear-gradient(#fbd54c 0 26%, #fff 26%); box-shadow: inset 0 0 0 1px #e6e4dc; }
.mk-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 6px; }
.mk-actions > div { display: grid; justify-items: center; align-content: start; gap: 6px; font-size: 11.5px; line-height: 1.2; text-align: center; }
.mk-actions span { width: 50px; height: 50px; border-radius: 999px; display: grid; place-items: center; background: var(--mk-bg); color: var(--mk-ink); }
.mk-actions span svg { width: 22px; height: 22px; }
.mk-actions > div.hi { color: var(--accent); font-weight: 600; }
.mk-actions > div.hi::after { inset: -5px 50% auto auto; width: 60px; height: 60px; margin-right: -30px; }

/* ---------- voices: one list, Yours / Library filter ---------- */
.voice-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--line); }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 8px 16px; border-radius: 999px; font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; gap: 6px; }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg .count { font-size: 12px; color: var(--muted); font-weight: 600; }
.seg .count:empty { display: none; }
#make-voice { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
#make-voice svg { width: 14px; height: 14px; }
.list .del { font-size: 13px; margin-top: 6px; color: var(--faint); }
.sheet-title { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
#design-sheet, #lib-save { overflow-y: auto; overscroll-behavior: contain; }
#design-sheet .previews { grid-template-columns: 1fr; }
.mock > * { min-width: 0; }
.mk-url i { min-width: 0; }

/* ---------- first-run tour ---------- */
.top-btns { display: inline-flex; align-items: center; gap: var(--s3); }
.help-btn { width: 32px; height: 32px; padding: 0; border-radius: 999px; border: 1.5px solid var(--edge); background: transparent; color: var(--muted); font-weight: 700; font-size: 15px; line-height: 1; }
.tour { position: fixed; inset: 0; z-index: 60; }
.tour-spot { position: fixed; border-radius: 18px; box-shadow: 0 0 0 200vmax rgb(10 10 12 / 0.55); transition: all 0.3s cubic-bezier(.2,.8,.2,1); pointer-events: none; }
.tour.centered .tour-spot { top: 50%; left: 50%; width: 0; height: 0; }
.tour-card {
  position: fixed; left: 50%; transform: translateX(-50%); width: min(340px, calc(100vw - 32px));
  background: var(--surface); border-radius: 20px; padding: var(--s4) var(--s5); box-shadow: var(--shadow-lift);
  display: grid; gap: var(--s2); transition: top 0.3s cubic-bezier(.2,.8,.2,1);
}
.tour.centered .tour-card { top: 50% !important; transform: translate(-50%, -50%); }
.tour-card h3 { margin: 0; font-size: 19px; letter-spacing: -0.02em; }
.tour-card p { color: var(--muted); font-size: 15px; line-height: 1.4; }
.tour-dots { display: flex; gap: 5px; }
.tour-dots i { width: 6px; height: 6px; border-radius: 999px; background: var(--edge); }
.tour-dots i.on { width: 16px; background: var(--accent); }
.tour-btns { display: flex; align-items: center; justify-content: space-between; margin-top: var(--s2); }
.tour-btns span { display: inline-flex; gap: var(--s2); }
body.touring { overflow: hidden; }
