/* The design system of design/00-design-system.md, as shipped CSS.
   Tokens first; every component reads them, so the two themes stay one set. */
:root {
  --ground: #FAFAF7;
  --card: #FFFFFF;
  --sunk: #F1F1EC;
  --ink: #212B33;
  --muted: #5C6B75;
  --line: #E2E5DE;
  --pine: #196A57;
  --pine-soft: #E7F0EC;
  --slate: #48545E;
  --slate-soft: #EBEEF0;
  --warn: #A4483D;
  --warn-soft: #F6E9E6;
  --display: 'Fraunces', Georgia, serif;
  --body: 'Public Sans', -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  --lift: 0 1px 2px rgba(16, 24, 28, 0.06);
  --step: cubic-bezier(.2,.6,.2,1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #12181D; --card: #1A2228; --sunk: #161D22; --ink: #E4E8E3; --muted: #97A4A9;
    --line: #2A343B; --pine: #4CB79A; --pine-soft: #17322B; --slate: #8A99A4;
    --slate-soft: #212C33; --warn: #D68A7C; --warn-soft: #38221E;
    --lift: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}
:root[data-theme="dark"] {
  --ground: #12181D; --card: #1A2228; --sunk: #161D22; --ink: #E4E8E3; --muted: #97A4A9;
  --line: #2A343B; --pine: #4CB79A; --pine-soft: #17322B; --slate: #8A99A4;
  --slate-soft: #212C33; --warn: #D68A7C; --warn-soft: #38221E;
  --lift: 0 1px 2px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font-family: var(--body); font-size: 16px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  /* The composer must clear the home indicator on a phone. */
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--pine); outline-offset: 2px; border-radius: 4px; }

#app { display: flex; flex-direction: column; height: 100dvh; max-width: 34rem; margin: 0 auto; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: max(.75rem, env(safe-area-inset-top)) 1.1rem .4rem;
}
.title { font-family: var(--display); font-size: 1.45rem; font-weight: 600; margin: 0; }

.scroll { flex: 1; overflow-y: auto; padding: .4rem 1.1rem 1rem; display: flex; flex-direction: column; gap: .75rem; }
/* U1: the composer owns the bottom of the screen. */
.thumb-zone { margin-top: auto; display: flex; flex-direction: column; gap: .6rem; }
.sub { color: var(--muted); font-size: .84rem; margin: 0; }

.pill {
  display: inline-flex; align-items: center; gap: .35rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); padding: .28rem .7rem;
  font-size: .8rem; color: var(--muted); font-weight: 500; white-space: nowrap; flex: none;
}
.pill.pine { color: var(--pine); background: var(--pine-soft); border-color: transparent; }
.pill.slate { color: var(--slate); background: var(--slate-soft); border-color: transparent; }
.pill.mono { font-family: var(--mono); font-size: .74rem; }
.pill.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
button.pill { cursor: pointer; }

.tier { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; background: var(--card); padding: 2px; }
.tier button { border: 0; background: none; border-radius: 999px; padding: .3rem .75rem; font-size: .8rem; font-weight: 600; color: var(--muted); }
.tier button[aria-pressed="true"] { background: var(--pine-soft); color: var(--pine); }
.tier.private button[aria-pressed="true"] { background: var(--slate-soft); color: var(--slate); }

.composer {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: .85rem;
  display: flex; flex-direction: column; gap: .7rem; box-shadow: var(--lift);
  transition: border-color 160ms var(--step), background 160ms var(--step);
}
.composer.private { border-color: var(--slate); background: color-mix(in srgb, var(--slate-soft) 55%, var(--card)); }
.composer textarea { border: 0; background: none; resize: none; min-height: 3.2rem; padding: 0; width: 100%; }
.composer textarea:focus { outline: none; }
.composer textarea::placeholder { color: var(--muted); }

.attach-row { display: flex; align-items: center; gap: .4rem; }
.attach {
  width: 40px; height: 40px; border-radius: 9px; border: 1px solid var(--line); background: var(--card);
  display: grid; place-items: center; color: var(--muted); padding: 0;
}
.attach:hover:not(:disabled) { color: var(--ink); border-color: var(--muted); }
.attach:disabled { opacity: .4; cursor: not-allowed; }
.attach svg { width: 19px; height: 19px; }
.capacity { font-family: var(--mono); font-size: .72rem; color: var(--muted); margin-left: auto; }
.capacity.full { color: var(--warn); }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  display: flex; align-items: center; gap: .45rem; border: 1px solid var(--line); background: var(--ground);
  border-radius: 9px; padding: .3rem .5rem .3rem .3rem; font-size: .78rem; color: var(--muted); max-width: 100%;
}
.chip img { width: 32px; height: 32px; border-radius: 5px; object-fit: cover; flex: none; }
.chip .mark { width: 32px; height: 32px; border-radius: 5px; background: var(--sunk); display: grid; place-items: center; flex: none; }
.chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .size { font-family: var(--mono); font-size: .72rem; flex: none; }
.chip .drop { border: 0; background: none; color: var(--muted); padding: 0 .15rem; line-height: 1; font-size: 1rem; }
.chip .drop:hover { color: var(--warn); }

.mic-row { display: flex; align-items: center; gap: .7rem; }
.mic {
  width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--pine); color: #fff;
  display: grid; place-items: center; flex: none; touch-action: none;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--pine) 32%, transparent);
  transition: transform 120ms var(--step), background 160ms var(--step);
}
.mic.private { background: var(--slate); box-shadow: 0 4px 12px color-mix(in srgb, var(--slate) 32%, transparent); }
.mic[aria-pressed="true"] { background: var(--warn); box-shadow: 0 0 0 6px var(--warn-soft); }
.mic:active { transform: scale(.96); }
.mic:disabled { opacity: .4; }
.mic svg { width: 26px; height: 26px; }
.mic-label { font-size: .82rem; color: var(--muted); }
.mic-label b { display: block; color: var(--ink); font-weight: 600; font-size: .9rem; }

.wave { display: flex; align-items: center; gap: 3px; height: 26px; }
.wave i { width: 3px; border-radius: 2px; background: var(--warn); height: 30%; transition: height 90ms linear; }

.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: .55rem .9rem;
  font-size: .88rem; font-weight: 600; min-height: 44px;
  transition: background 120ms var(--step), border-color 120ms var(--step);
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
/* `.btn` is also used on anchors — the link between the two apps, and the sign-in
   button on the read side. Without this they arrive underlined and mis-aligned. */
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn.primary { background: var(--pine); border-color: var(--pine); color: #fff; }
.btn.primary.slate { background: var(--slate); border-color: var(--slate); }
.btn.danger { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn.quiet { background: none; border-color: transparent; color: var(--muted); }
.btn.quiet:hover { color: var(--ink); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .85rem .95rem; box-shadow: var(--lift); }
.card.invalid { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.card .head { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem; }
.schema-name { font-weight: 700; font-size: .96rem; }
.schema-id { font-family: var(--mono); font-size: .72rem; color: var(--muted); }
.summary { margin: .5rem 0 0; font-size: .92rem; }
.tagline { font-family: var(--mono); font-size: .68rem; color: var(--muted); letter-spacing: .04em; margin-top: .3rem; }

dl.fields { display: grid; grid-template-columns: auto 1fr; gap: .2rem .8rem; margin: .6rem 0 0; font-size: .86rem; }
dl.fields dt { color: var(--muted); }
dl.fields dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
dl.fields dt.group { grid-column: 1 / -1; font-weight: 600; color: var(--ink); margin-top: .4rem; font-size: .82rem; }
dl.fields .nested { padding-left: .8rem; border-left: 1px solid var(--line); }

.expander { border: 0; background: none; padding: .4rem 0 0; font-size: .82rem; font-weight: 600; color: var(--pine); display: flex; align-items: center; gap: .35rem; }
.expander .caret { transition: transform 120ms var(--step); }
.expander[aria-expanded="true"] .caret { transform: rotate(90deg); }

.actions { display: flex; gap: .5rem; margin-top: .85rem; }
.actions .btn { flex: 1; }

.receipt { display: flex; align-items: center; gap: .55rem; font-size: .85rem; color: var(--muted); padding: .6rem .7rem; border-radius: 10px; background: var(--pine-soft); }
.receipt.sealed { background: var(--slate-soft); }
.receipt b { color: var(--ink); font-weight: 600; }
.check { color: var(--pine); font-weight: 700; }
.receipt.sealed .check { color: var(--slate); }

.banner { display: flex; gap: .55rem; align-items: flex-start; padding: .6rem .75rem; border-radius: 10px; font-size: .84rem; background: var(--sunk); color: var(--muted); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.note { background: var(--pine-soft); color: var(--pine); }
.banner svg { width: 16px; height: 16px; flex: none; margin-top: .15rem; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 2; margin: 0 auto; max-width: 34rem;
  background: var(--card); border-top: 1px solid var(--line); border-radius: 16px 16px 0 0;
  padding: 1rem 1.1rem calc(1.2rem + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 24px rgba(16,24,28,.14);
  display: flex; flex-direction: column; gap: .7rem;
  animation: slide 200ms var(--step) both;
}
.scrim { position: fixed; inset: 0; background: rgba(16,24,28,.28); z-index: 1; animation: fade 160ms var(--step) both; }
.sheet h2 { margin: 0; font-family: var(--display); font-size: 1.1rem; font-weight: 600; }
.sheet p { margin: 0; font-size: .88rem; color: var(--muted); }
.sheet input[type="text"] { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--ground); padding: .6rem .7rem; }

/* A labelled form field. The read side's authoring screen had its own copy of this; it
   belongs here, because sign-in needs it too and two copies drift. */
.field { display: flex; flex-direction: column; gap: .25rem; }
.field input {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  background: var(--ground); padding: .55rem .7rem; font: inherit; color: var(--ink);
}
.field input:focus { outline: 2px solid var(--pine); outline-offset: 1px; }

@keyframes slide { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.card, .receipt { animation: rise 200ms var(--step) both; }
.spin { animation: spin 900ms linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
