/* Link Share — paper & ink */

@font-face {
  font-family: "Instrument Serif";
  src: url("/fonts/instrument-serif.woff2") format("woff2");
  font-style: normal; font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("/fonts/instrument-serif-italic.woff2") format("woff2");
  font-style: italic; font-weight: 400; font-display: swap;
}

:root {
  --paper: #f4f1ea;
  --paper-raised: #faf8f3;
  --ink: #1a1916;
  --ink-2: #4a4741;
  --muted: #8a857a;
  --rule: #ddd7ca;
  --a: #56632f;          /* moss  — person A */
  --b: #a4462a;          /* brick — person B */
  --danger: #b3261e;
  --scrim: rgb(26 25 22 / .38);

  --serif: "Instrument Serif", ui-serif, "Iowan Old Style", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --gutter: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141311; --paper-raised: #1b1a17; --ink: #ece7dc; --ink-2: #bcb6a9; --muted: #8a8477;
    --rule: #2d2b27; --a: #a9b874; --b: #e0906b; --danger: #f2867c; --scrim: rgb(0 0 0 / .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #141311; --paper-raised: #1b1a17; --ink: #ece7dc; --ink-2: #bcb6a9; --muted: #8a8477;
  --rule: #2d2b27; --a: #a9b874; --b: #e0906b; --danger: #f2867c; --scrim: rgb(0 0 0 / .55);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}
[hidden] { display: none !important; }
a { color: inherit; }
button { font: inherit; color: inherit; }
::selection { background: var(--ink); color: var(--paper); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 2px; }

.mono { font-family: var(--mono); font-size: 12px; letter-spacing: .02em; }
.eyebrow, .label {
  font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted); margin: 0;
}
.label em { font-style: normal; text-transform: none; letter-spacing: .02em; opacity: .8; margin-left: .4em; }
.error { color: var(--danger); font-size: 14px; min-height: 1.3em; margin: 6px 0 0; }
.fine { font-size: 14px; color: var(--muted); margin: 0; }
.spacer { flex: 1; }

/* ---------- controls ---------- */
.btn-ink {
  appearance: none; border: 0; background: var(--ink); color: var(--paper);
  font-weight: 600; font-size: 15px; letter-spacing: .01em;
  min-height: 48px; padding: 0 22px; border-radius: 4px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform .12s var(--ease), opacity .2s;
}
.btn-ink:active { transform: translateY(1px); }
.btn-ink:disabled { opacity: .45; cursor: default; }
.btn-ink.wide { width: 100%; }
.btn-line {
  appearance: none; background: transparent; border: 1px solid var(--ink); color: var(--ink);
  min-height: 42px; padding: 0 16px; border-radius: 4px; font-weight: 600; font-size: 14px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}
.text-btn {
  appearance: none; background: none; border: 0; padding: 8px 2px; cursor: pointer;
  font-size: 14px; color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--rule);
  text-underline-offset: 4px; text-decoration-thickness: 1px; transition: color .15s, text-decoration-color .15s;
}
.text-btn:hover { color: var(--ink); text-decoration-color: currentColor; }
.text-btn.danger { color: var(--danger); }

.line-input {
  width: 100%; font: inherit; font-size: 17px; color: var(--ink);
  background: transparent; border: 0; border-bottom: 1px solid var(--rule); border-radius: 0;
  padding: 8px 0 10px; transition: border-color .2s;
}
.line-input::placeholder { color: var(--muted); opacity: .7; }
.line-input:focus { outline: none; border-bottom-color: var(--ink); }
textarea.line-input { resize: none; min-height: 2.6em; field-sizing: content; max-height: 40vh; }

/* ---------- boot / login ---------- */
.boot { position: fixed; inset: 0; }
.login {
  min-height: 100%; display: grid; align-items: center; justify-items: center;
  padding: calc(40px + var(--safe-t)) var(--gutter) 40px;
}
.login-inner { width: min(380px, 100%); display: flex; flex-direction: column; }
.wordmark {
  font-family: var(--serif); font-weight: 400; font-size: clamp(56px, 16vw, 76px);
  line-height: .95; letter-spacing: -.01em; margin: 14px 0 48px;
}
.wordmark em, .brand em { font-style: italic; color: var(--muted); }
.login .label { margin-bottom: 2px; }
.login .line-input { font-size: 20px; letter-spacing: .12em; margin-bottom: 28px; }
.who { margin-top: 28px; }
.who-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.who-btns button {
  appearance: none; background: transparent; border: 1px solid var(--rule); border-radius: 4px;
  min-height: 64px; cursor: pointer; font-family: var(--serif); font-size: 28px; color: var(--pc, var(--ink));
  transition: border-color .15s;
}
.who-btns button:hover { border-color: var(--pc, var(--ink)); }

/* ---------- app shell ---------- */
.app { display: flex; flex-direction: column; height: 100%; height: 100dvh; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: calc(12px + var(--safe-t)) var(--gutter) 4px;
}
.brand { font-family: var(--serif); font-size: 24px; line-height: 1; }
.sync { width: 6px; height: 6px; border-radius: 50%; background: var(--rule); transition: background .3s; }
.sync.off { background: var(--danger); }
.top-actions { margin-left: auto; display: flex; gap: 16px; }

.p0 { --pc: var(--a); }
.p1 { --pc: var(--b); }

/* tabs (phones) */
.tabs {
  display: grid; grid-template-columns: 1fr 1fr; margin: 10px var(--gutter) 0;
  border-bottom: 1px solid var(--rule);
}
.tab {
  appearance: none; background: none; border: 0; cursor: pointer; text-align: left;
  padding: 6px 0 10px; position: relative; color: var(--muted);
  display: flex; align-items: baseline; gap: 8px; transition: color .2s;
}
.tab .tab-name { font-family: var(--serif); font-size: 28px; line-height: 1.1; }
.tab .tab-count { font-family: var(--mono); font-size: 11px; }
.tab::after {
  content: ""; position: absolute; left: 0; right: 16px; bottom: -1px; height: 2px;
  background: var(--pc); transform: scaleX(0); transform-origin: left; transition: transform .3s var(--ease);
}
.tab[aria-selected="true"] { color: var(--ink); }
.tab[aria-selected="true"]::after { transform: scaleX(1); }
.tab[aria-selected="true"] .tab-count { color: var(--pc); }

.panes {
  flex: 1; min-height: 0; display: flex; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain;
}
.panes::-webkit-scrollbar { display: none; }
.pane::-webkit-scrollbar { width: 8px; }
.pane::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 4px; border: 2px solid var(--paper); }
.pane::-webkit-scrollbar-track { background: transparent; }
.pane {
  flex: 0 0 100%; min-width: 0; scroll-snap-align: start; scroll-snap-stop: always;
  overflow-y: auto; overscroll-behavior-y: contain;
  scrollbar-width: thin; scrollbar-color: var(--rule) transparent;
  padding: 0 var(--gutter) calc(112px + var(--safe-b));
}

/* pane header */
.pane-head { padding: 26px 0 18px; }
.pane-title {
  font-family: var(--serif); font-weight: 400; font-size: 46px; line-height: 1; margin: 8px 0 0;
  letter-spacing: -.01em;
}
.pane-title .poss { font-style: italic; color: var(--muted); }
.tally { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.tally .mono { color: var(--ink-2); white-space: nowrap; }
.tally .bar { flex: 1; height: 1px; background: var(--rule); position: relative; }
.tally .bar > i {
  position: absolute; left: 0; top: -1px; height: 3px; background: var(--pc); width: 0;
  transition: width .6s var(--ease);
}

/* sections */
.section { border-top: 1px solid var(--rule); }
.section:last-child { border-bottom: 1px solid var(--rule); }
.section > summary {
  list-style: none; cursor: pointer; user-select: none; -webkit-user-select: none;
  display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 6px 0;
}
.section > summary::-webkit-details-marker { display: none; }
.sec-label { font-weight: 600; font-size: 16px; letter-spacing: -.005em; }
.sec-count { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.sec-count.has { color: var(--pc); }
.sec-add {
  appearance: none; border: 0; background: none; cursor: pointer; margin-left: auto;
  font-family: var(--mono); font-size: 11px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); padding: 10px 8px; transition: color .15s;
}
.sec-add:hover { color: var(--ink); }
.chev {
  width: 9px; height: 9px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg); transition: transform .25s var(--ease); margin: 0 4px 0 2px; flex: 0 0 auto;
}
.section[open] > summary .chev { transform: rotate(45deg) translate(-2px, -2px); }

.items { list-style: none; margin: 0; padding: 0 0 6px; }
.empty { margin: -6px 0 18px; font-family: var(--serif); font-style: italic; font-size: 18px; color: var(--muted); }

/* item */
.item {
  display: grid; grid-template-columns: 22px 1fr auto; gap: 14px; align-items: start;
  padding: 12px 0 14px; border-top: 1px dashed var(--rule);
}
.items > .item:first-child { border-top: 0; padding-top: 4px; }
.check {
  appearance: none; margin: 2px 0 0; width: 20px; height: 20px; border: 1.5px solid var(--ink);
  border-radius: 3px; background: transparent; cursor: pointer; display: grid; place-items: center;
  transition: background .15s, border-color .15s;
}
.check::after {
  content: ""; width: 5px; height: 10px; border: solid var(--paper); border-width: 0 2px 2px 0;
  transform: translateY(-1px) rotate(45deg) scale(0); transition: transform .18s var(--ease);
}
.check:checked { background: var(--pc); border-color: var(--pc); }
.check:checked::after { transform: translateY(-1px) rotate(45deg) scale(1); }
.check:disabled { cursor: default; border-color: var(--rule); }
.check:disabled:checked { background: var(--pc); border-color: var(--pc); opacity: .55; }

.item-body { min-width: 0; }
.item-title {
  font-size: 16px; font-weight: 500; line-height: 1.35; text-decoration: none; word-break: break-word;
  display: inline;
}
a.item-title { background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size .25s var(--ease); }
a.item-title:hover { background-size: 100% 1px; }
a.item-title .arrow { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-left: 4px; }
.item-note {
  margin: 6px 0 0; font-family: var(--serif); font-size: 19px; line-height: 1.3; color: var(--ink-2);
  white-space: pre-wrap; word-break: break-word;
}
.item-meta {
  margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px 10px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
}
.item-meta .from { color: var(--pc); }
.item-meta .from::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
  margin-right: 6px; vertical-align: 1px;
}
.more {
  appearance: none; border: 0; background: none; cursor: pointer; padding: 2px 0 8px 8px; margin-top: -2px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted);
}
.more:hover { color: var(--ink); }
@media (hover: none) { .more { color: color-mix(in srgb, var(--muted) 70%, var(--paper)); } }
@media (hover: hover) {
  .more { opacity: 0; transition: opacity .15s; }
  .item:hover .more, .more:focus-visible { opacity: 1; }
}
.item.done .item-title, .item.done .item-note { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.item.done a.item-title { background: none; }
.item.fresh { animation: fresh 1.4s var(--ease); }
@keyframes fresh { from { background: color-mix(in srgb, var(--pc) 12%, transparent); } to { background: transparent; } }

.done-group { margin: 2px 0 12px; }
.done-group > summary {
  list-style: none; cursor: pointer; padding: 8px 0; display: inline-block;
  font-family: var(--mono); font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted);
}
.done-group > summary::-webkit-details-marker { display: none; }
.done-group > summary:hover { color: var(--ink); }
.done-group .items { padding-bottom: 0; }

/* audio player */
.player { display: flex; align-items: center; gap: 12px; margin-top: 10px; max-width: 420px; }
.play {
  appearance: none; flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  border: 1.5px solid var(--ink); background: transparent; position: relative;
}
.play::before {
  content: ""; position: absolute; left: 13px; top: 10px;
  border-style: solid; border-width: 7.5px 0 7.5px 11px; border-color: transparent transparent transparent var(--ink);
}
.play.on::before {
  left: 11px; top: 11px; width: 4px; height: 12px; border: 0; background: var(--ink);
  box-shadow: 7px 0 0 var(--ink);
}
.track { flex: 1; height: 24px; position: relative; cursor: pointer; }
.track::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--rule); }
.track > i { position: absolute; left: 0; top: calc(50% - 1px); height: 3px; width: 0; background: var(--pc, var(--ink)); }
.player .time { color: var(--muted); min-width: 4ch; text-align: right; }

/* ---------- dock / send button ---------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 12px var(--gutter) calc(12px + var(--safe-b));
  background: linear-gradient(to top, var(--paper) 70%, transparent);
}
.dock-btn { width: 100%; justify-content: space-between; min-height: 54px; font-size: 16px; }
.plus { position: relative; width: 14px; height: 14px; }
.plus::before, .plus::after { content: ""; position: absolute; background: currentColor; }
.plus::before { left: 0; right: 0; top: 6px; height: 2px; }
.plus::after { top: 0; bottom: 0; left: 6px; width: 2px; }

/* ---------- sheets (dialogs) ---------- */
.sheet {
  border: 0; padding: 0; color: var(--ink); background: var(--paper-raised);
  width: min(560px, 100%); max-height: 92dvh; border-radius: 6px;
  box-shadow: 0 1px 0 var(--rule), 0 30px 80px rgb(0 0 0 / .18);
}
.sheet::backdrop { background: var(--scrim); }
.sheet[open] { animation: sheet-in .28s var(--ease); }
@keyframes sheet-in { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet form { padding: 22px 24px calc(20px + var(--safe-b)); display: flex; flex-direction: column; gap: 22px; }
.sheet-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.sheet-title { font-family: var(--serif); font-weight: 400; font-size: 34px; line-height: 1.05; margin: 0; }
.sheet-title em { color: var(--pc, var(--ink)); }
.sheet-foot { display: flex; align-items: center; gap: 12px; padding-top: 4px; }
.sheet-foot .btn-ink { min-width: 120px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0; min-width: 0; }

.toggle { display: flex; gap: 22px; border-bottom: 1px solid var(--rule); }
.toggle button {
  appearance: none; background: none; border: 0; cursor: pointer; padding: 4px 0 8px; position: relative;
  font-family: var(--serif); font-size: 24px; color: var(--muted);
}
.toggle button[aria-pressed="true"] { color: var(--ink); }
.toggle button[aria-pressed="true"]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--pc);
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  appearance: none; cursor: pointer; border: 1px solid var(--rule); background: transparent; color: var(--ink-2);
  border-radius: 999px; padding: 7px 14px; font-size: 14px; transition: border-color .15s, background .15s, color .15s;
}
.chip:hover { border-color: var(--ink-2); }
.chip[aria-checked="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.rec-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); }
#rec-btn.recording .rec-dot { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.rec-preview { display: flex; align-items: center; gap: 14px; }
.rec-preview #rec-player { flex: 1; min-width: 0; }
.rec-preview .player { margin-top: 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); z-index: 20;
  transform: translate(-50%, 8px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 4px;
  font-size: 14px; max-width: calc(100% - 40px); transition: opacity .2s, transform .25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- phones: sheets come up from the bottom ---------- */
@media (max-width: 639px) {
  .sheet { margin: auto 0 0; width: 100%; max-width: 100%; border-radius: 10px 10px 0 0; }
  .sheet form { padding: 18px var(--gutter) calc(18px + var(--safe-b)); }
  .sheet form::before {
    content: ""; align-self: center; width: 36px; height: 4px; border-radius: 2px; background: var(--rule); margin: -6px 0 -10px;
  }
  .sheet[open] { animation: sheet-up .32s var(--ease); }
  @keyframes sheet-up { from { transform: translateY(40px); } to { transform: none; } }
}

/* ---------- wide screens: both lists side by side ---------- */
@media (min-width: 900px) {
  :root { --gutter: 40px; }
  .tabs { display: none; }
  .topbar { width: 100%; max-width: 1320px; margin: 0 auto; padding-top: 28px; }
  .brand { font-size: 28px; }
  .panes { overflow: hidden; width: 100%; max-width: 1320px; margin: 0 auto; }
  .pane { flex: 1 1 50%; padding-bottom: 120px; }
  .pane + .pane { border-left: 1px solid var(--rule); }
  .pane-head { padding-top: 34px; }
  .pane-title { font-size: 60px; }
  .dock {
    left: auto; right: max(40px, calc((100vw - 1320px) / 2 + 40px)); bottom: 28px; width: auto;
    padding: 0; background: none;
  }
  .dock-btn { width: auto; min-width: 240px; box-shadow: 0 10px 30px rgb(0 0 0 / .16); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
