/* vpl · vz — zed, the dictionary.
 *
 * A project is an index card box: a column of keys on the left of the sheet, a
 * value that stays folded until you want it. Monospace keys, hairlines, nothing
 * that jumps. The shell owns palette, buttons and the page foundation
 * (vendor/tokens.css); this file owns the sheet.
 *
 * Colour is never the only signal: a published project says "public" in words
 * as well as in a colour, and a hidden value says "hidden" rather than showing
 * an empty slot.
 */

:root {
  --rule: #e2dbcf;
  --rule-strong: #c9bfae;
  --ok: #3f6b4f;
  --key: #1f1d1a;
  --val: #4a453e;
}

[data-theme='dark'] {
  --rule: #3a332a;
  --rule-strong: #574c3d;
  --ok: #8fc4a2;
  --key: #f7f3ec;
  --val: #ddd6cb;
}

body {
  font-family: var(--sans);
  background:
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--ink) 5%, transparent) 1px, transparent 0)
      0 0 / 1.5rem 1.5rem,
    var(--paper);
  background-attachment: fixed;
}
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.grow { flex: 1 1 auto; }
.muted { color: var(--ink-3); }
.small { font-size: 0.76rem; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

input[type='text'], input[type='password'], input[type='search'], textarea, select {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  padding: 0.28rem 0.42rem;
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:focus, textarea:focus, select:focus { outline: 1px solid var(--ink); outline-offset: 1px; }

/* ── bar ──────────────────────────────────────────────────────────── */
.bar {
  display: flex; align-items: center; gap: 0.55rem;
  height: var(--bar-h); padding: 0 1rem;
  background: var(--paper);
  border-bottom: 1px solid var(--rule-strong);
  position: sticky; top: 0; z-index: 20;
}
.brand-mark {
  display: grid; place-items: center; width: 1.5rem; height: 1.5rem;
  border: 1px solid var(--ink); border-radius: 4px;
  background: var(--ink); color: var(--paper);
  font-family: var(--serif); font-size: 1rem;
}
.brand-word { font-family: var(--mono); font-size: 1.02rem; letter-spacing: 0.04em; }
.brand-sub {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.16em; color: var(--ink-3);
}
.brand-sub::before { content: '/'; margin-right: 0.4rem; color: var(--rule-strong); }
.who {
  font-size: 0.72rem; color: var(--ink-2);
  border: 1px solid var(--rule-strong); border-radius: 999px; padding: 0.08rem 0.5rem;
  max-width: 11rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.only-narrow { display: none; }

.body { flex: 1; display: grid; grid-template-columns: 14rem minmax(0, 1fr); min-height: 0; }

/* ── projects rail ────────────────────────────────────────────────── */
.projects {
  border-right: 1px solid var(--rule-strong);
  background: var(--paper-2);
  display: flex; flex-direction: column; min-height: 0;
}
.proj-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.65rem 0.6rem 0.4rem;
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.16em; color: var(--ink-3);
}
.proj-list { list-style: none; margin: 0; padding: 0 0.4rem 0.6rem; overflow-y: auto; flex: 1; }
.proj-row {
  display: flex; align-items: center; gap: 0.3rem;
  margin: 0 0 0.15rem; border-radius: 4px;
  border-left: 2px solid transparent;
}
.proj-row:hover { background: var(--paper-3); }
.proj-row.on { background: var(--paper); border-left-color: var(--ink); }
.proj-row .pick {
  flex: 1; min-width: 0; text-align: left; border: none; background: none;
  padding: 0.4rem 0.2rem 0.4rem 0.5rem; font-size: 0.84rem; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.proj-row:hover .pick { background: none; }
.proj-row .n {
  font-family: var(--mono); font-size: 0.66rem; color: var(--ink-3); padding-right: 0.3rem;
}
.proj-row .kill { opacity: 0; font-size: 0.72rem; padding: 0.1rem 0.3rem; border: none; background: none; color: var(--ink-3); }
.proj-row:hover .kill, .proj-row.on .kill { opacity: 1; }
.proj-none { padding: 0.2rem 0.8rem; font-size: 0.76rem; line-height: 1.4; }

.bin-rail { border-top: 1px solid var(--rule); padding: 0.35rem; }
.bin-pick {
  width: 100%; display: flex; align-items: center; gap: 0.4rem;
  border: none; background: none; text-align: left;
  font-size: 0.8rem; color: var(--ink-2); padding: 0.35rem 0.4rem; border-radius: 4px;
}
.bin-pick:hover { background: var(--paper-3); color: var(--ink); }
.bin-pick.on { background: var(--paper); box-shadow: inset 2px 0 0 var(--ink); color: var(--ink); }
.bin-n {
  margin-left: auto; font-family: var(--mono); font-size: 0.68rem; color: var(--ink-3);
}

/* ── the sheet ───────────────────────────────────────────────────── */
.spec { padding: 1.1rem 1.4rem 3rem; min-width: 0; }
.spec-head { display: flex; align-items: center; gap: 0.7rem; }
.title {
  flex: 1; min-width: 0; border: none; border-bottom: 1px solid transparent;
  background: none; font-family: var(--serif); font-size: 1.4rem; padding: 0.2rem 0;
}
.title:hover { border-bottom-color: var(--rule); }
.title:focus { outline: none; border-bottom-color: var(--ink); }
.bin-title { font-family: var(--serif); font-size: 1.25rem; margin: 0; flex: 1; }
.proj-meta { font-size: 0.75rem; margin: 0.25rem 0 0.9rem; }
.proj-meta b { font-family: var(--mono); font-weight: 500; color: var(--ink-2); }
.guest-banner {
  font-size: 0.8rem; border: 1px solid var(--rule-strong); border-radius: 4px;
  padding: 0.45rem 0.6rem; margin: 0 0 0.9rem; background: var(--paper-2);
}

/* ── tools ───────────────────────────────────────────────────────── */
.tools {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  padding: 0 0 0.35rem; border-bottom: 1px solid var(--rule-strong);
}
.tools-l { flex: 1 1 14rem; min-width: 9rem; }
.tools-l input[type='search'] { width: 100%; font-size: 0.84rem; padding: 0.28rem 0.5rem; }
.tools-r { margin-left: auto; display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.tools-r .ghost { font-size: 0.76rem; padding: 0.22rem 0.5rem; }
.tools-r .ghost[aria-pressed='true'] { border-color: var(--ink); color: var(--ink); background: var(--paper-3); }
.pager { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.78rem; color: var(--ink-2); }
.pager b { font-family: var(--mono); }
.pager button {
  border: 1px solid var(--rule-strong); background: var(--paper); color: var(--ink-2);
  border-radius: 3px; padding: 0.05rem 0.4rem; font-size: 0.76rem;
}
.pager button:disabled { opacity: 0.35; }

/* ── the pairs: a key, a value that stays folded ──────────────────── */
.pairs { list-style: none; margin: 0.35rem 0 0; padding: 0; }
.pair { border-bottom: 1px solid var(--rule); }
.pair:hover { background: color-mix(in srgb, var(--paper-3) 45%, transparent); }
.pair-line { display: flex; align-items: baseline; gap: 0.6rem; padding: 0.32rem 0.15rem; }

.key {
  flex: 0 1 18rem; min-width: 6rem;
  border: none; background: none; padding: 0; text-align: left;
  font-family: var(--mono); font-size: 0.83rem; color: var(--key);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.key:hover { text-decoration: underline; text-decoration-color: var(--rule-strong); }
.val {
  flex: 1 1 auto; min-width: 0;
  font-family: var(--mono); font-size: 0.8rem; color: var(--val);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.val.folded { color: var(--ink-3); letter-spacing: 0.2em; }
.val.open {
  white-space: pre-wrap; overflow-wrap: anywhere;
  border-left: 2px solid var(--rule-strong); padding: 0.1rem 0 0.1rem 0.55rem;
  margin: 0.1rem 0 0.3rem;
}
.val.empty { color: var(--ink-3); font-style: italic; }
.row-tools { display: flex; gap: 0.05rem; margin-left: auto; opacity: 0; }
.pair:hover .row-tools, .pair.on .row-tools { opacity: 1; }
.row-tools button {
  border: none; background: none; color: var(--ink-3);
  font-size: 0.74rem; padding: 0.05rem 0.3rem; border-radius: 3px;
}
.row-tools button:hover { color: var(--ink); background: var(--paper-3); }

.pair-edit { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.1rem 0.15rem 0.55rem; }
.e-key { font-family: var(--mono); font-size: 0.84rem; max-width: 26rem; }
.e-val {
  width: 100%; font-family: var(--mono); font-size: 0.8rem; line-height: 1.5;
  resize: vertical; min-height: 3.2rem;
}
.e-foot { display: flex; align-items: center; gap: 0.5rem; }
.e-foot .msg { font-size: 0.72rem; }
.e-foot .ghost { font-size: 0.76rem; padding: 0.1rem 0.4rem; }

/* ── adding, by typing or by pasting ─────────────────────────────── */
.add {
  display: grid; grid-template-columns: minmax(8rem, 18rem) minmax(0, 1fr) auto;
  gap: 0.35rem; padding: 0.6rem 0.15rem 0.15rem; border-bottom: 1px solid var(--rule-strong);
}
.add .a-key, .add .a-val { font-family: var(--mono); font-size: 0.84rem; padding: 0.38rem 0.5rem; }
.add-hint { font-size: 0.72rem; margin: 0.35rem 0 0; }
.foot-tools { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0 0; }
.foot-tools .ghost { font-size: 0.76rem; padding: 0.2rem 0.5rem; }

/* ── the bin ─────────────────────────────────────────────────────── */
.bin-list .pair-line { gap: 0.5rem; }
.bin-when { font-family: var(--mono); font-size: 0.72rem; color: var(--ink-3); }
.bin-list .row-tools { opacity: 1; }

/* ── welcome ─────────────────────────────────────────────────────── */
.welcome { display: grid; place-items: center; padding: 2rem; }
.welcome-card {
  max-width: 30rem; border: 1px solid var(--rule-strong); background: var(--paper);
  padding: 1.6rem 1.8rem; border-radius: 4px;
}
.welcome-mark { font-family: var(--serif); font-size: 1.6rem; color: var(--mark); }
.welcome h2 { font-family: var(--serif); font-size: 1.35rem; margin: 0.3rem 0 0.6rem; }
.welcome p { font-size: 0.9rem; line-height: 1.55; color: var(--ink-2); margin: 0 0 1.1rem; }
.welcome-fine { font-size: 0.74rem; margin: 0.9rem 0 0; }

/* ── dialogs ─────────────────────────────────────────────────────── */
dialog {
  border: 1px solid var(--rule-strong); border-radius: 4px;
  background: var(--paper); color: var(--ink);
  padding: 1.1rem 1.25rem; width: min(26rem, calc(100vw - 2rem));
}
dialog::backdrop { background: rgb(20 17 14 / 0.42); }
.dialog-x {
  position: absolute; top: 0.5rem; right: 0.55rem;
  border: none; background: none; font-size: 0.9rem; color: var(--ink-3);
  padding: 0.1rem 0.3rem;
}
.dialog-x:hover { color: var(--ink); }
#toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translate(-50%, 0.5rem);
  background: var(--ink); color: var(--paper); font-size: 0.8rem;
  padding: 0.4rem 0.75rem; border-radius: 4px; opacity: 0; pointer-events: none;
  transition: opacity 0.18s, transform 0.18s; z-index: 60;
}
#toast.on { opacity: 1; transform: translateX(-50%); }
.dialog h2 { font-family: var(--serif); font-size: 1.2rem; margin: 0 0 0.4rem; }
.dialog p { font-size: 0.84rem; line-height: 1.5; color: var(--ink-2); }
.dialog code { font-family: var(--mono); font-size: 0.78rem; background: var(--paper-2); padding: 0 0.2rem; }
.dialog.wide { width: min(34rem, calc(100vw - 2rem)); }
.dialog label { display: block; margin: 0.6rem 0 0.2rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-3); }
.dialog-sep {
  margin: 1rem 0 0.35rem; font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--ink-3); border-top: 1px solid var(--rule); padding-top: 0.55rem;
}
.dialog-foot { display: flex; align-items: center; gap: 0.5rem; justify-content: flex-end; margin-top: 0.8rem; }
.dialog-foot .msg { margin-right: auto; }
.confirm-row { display: flex; gap: 0.5rem; margin-top: 0.9rem; }
.share-msg, .msg { font-size: 0.76rem; color: var(--ink-3); min-height: 1rem; }
.msg[data-state='bad'] { color: var(--danger); }
.msg[data-state='ok'] { color: var(--ok); }
.msg[data-state='busy'] { color: var(--ink-3); }
.dialog-note { font-size: 0.78rem; color: var(--ink-2); }
.publish-row { display: flex; align-items: center; gap: 0.45rem; font-size: 0.82rem; color: var(--ink); margin: 0.4rem 0 0.2rem; }
.publish-row input { width: 1rem; height: 1rem; accent-color: var(--ink); }
.publish-urls { margin-top: 0.5rem; }
.publish-urls input { width: 100%; font-family: var(--mono); font-size: 0.74rem; }

.share-link-row, .share-person-row { display: flex; gap: 0.4rem; }
.share-link-row input { flex: 1; font-family: var(--mono); font-size: 0.76rem; }
.share-person-row input { flex: 1; }
.share-person-row select { width: 8.5rem; }
.share-list { list-style: none; margin: 0.8rem 0 0; padding: 0; }
.share-list li {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.3rem 0; border-bottom: 1px solid var(--rule); font-size: 0.8rem;
}
.share-list .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.share-list .role { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-3); }
.share-list button { font-size: 0.74rem; padding: 0.1rem 0.35rem; }
#share-copy { margin-top: 0.4rem; font-size: 0.76rem; }
#paste-text { width: 100%; font-family: var(--mono); font-size: 0.8rem; }

/* ── gate ────────────────────────────────────────────────────────── */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; }
.gate-form { width: min(21rem, 100%); display: flex; flex-direction: column; gap: 0.35rem; }
.gate-brand { display: flex; align-items: baseline; gap: 0.5rem; margin-bottom: 1.1rem; }
.gate-mark {
  font-family: var(--serif); font-size: 1rem; width: 1.5rem; height: 1.5rem;
  display: grid; place-items: center; background: var(--ink); color: var(--paper); border-radius: 4px;
}
.gate-brand h1 { font-family: var(--mono); font-size: 1.3rem; margin: 0; }
.gate-sub { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.15em; color: var(--ink-3); }
.gate-form label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-3); margin-top: 0.5rem; }
.gate-msg { min-height: 1.1rem; font-size: 0.78rem; color: var(--ink-3); margin: 0.4rem 0 0; }
.gate-msg[data-state='bad'] { color: var(--danger); }
.gate-msg[data-state='ok'] { color: var(--ok); }
.confirm-row .primary { flex: 1; }
.google {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  margin-top: 0.5rem; background: var(--paper); font-size: 0.82rem;
}
.gate-fine { font-size: 0.72rem; color: var(--ink-3); text-align: left; margin: 0.8rem 0 0; }
.corner-theme { position: fixed; top: 0.8rem; right: 0.8rem; }

/* ── role: a guest has verbs taken out ────────────────────────────── */
body[data-role='view'] .w-only,
body[data-role='view'] .o-only,
body[data-role='edit'] .o-only { display: none !important; }
body[data-role='view'] .add, body[data-role='view'] .add-hint { display: none !important; }
body[data-guest='1'] .body { grid-template-columns: minmax(0, 1fr); }
body[data-guest='1'] #projects { display: none; }
body[data-role='view'] #proj-title { pointer-events: none; }

/* ── narrow ──────────────────────────────────────────────────────── */
@media (max-width: 780px) {
  .only-narrow { display: inline-grid; }
  .body { grid-template-columns: 1fr; }
  .projects {
    position: fixed; inset: var(--bar-h) auto 0 0; width: 15rem; z-index: 30;
    transform: translateX(-101%); transition: transform 0.18s ease;
    box-shadow: 2px 0 12px rgb(0 0 0 / 0.12);
  }
  body[data-rail='open'] .projects { transform: none; }
  .spec { padding: 0.9rem 0.9rem 3rem; }
  .key { flex-basis: 11rem; }
  .add { grid-template-columns: 1fr; }
  .add .a-val { grid-column: 1; }
  .add button { justify-self: start; }
}

/* On a phone the value belongs under its key: a 390 px row cannot hold a
 * monospace key and a monospace value side by side without clipping one. */
@media (max-width: 640px) {
  .pair-line { flex-wrap: wrap; align-items: baseline; gap: 0.15rem 0.5rem; }
  .key { flex: 1 1 auto; min-width: 0; }
  .val { flex: 1 1 100%; font-size: 0.78rem; padding-left: 0.05rem; }
  .row-tools { opacity: 1; margin-left: auto; }
  .title { font-size: 1.2rem; }
}

@media print {
  .bar, .projects, .tools, .add, .add-hint, .foot-tools, .row-tools, .bin-rail,
  .guest-banner, .welcome { display: none !important; }
  .body { display: block; }
  .spec { padding: 0; }
  .pair { break-inside: avoid; }
  .val.folded { display: block; color: var(--ink); letter-spacing: 0; }
}
