/* vpl · shell — the part every app looks like.
 *
 * One palette, one type scale, one page foundation. An app adds its own
 * workspace on top; it does not invent colours. The variables below are the
 * shell's: apps read them, apps do not redefine them.
 *
 * Copied into apps/<name>/vendor/ by ./stage (which ./serve and ./deploy run),
 * so every app ships with a copy and never with a link back into this folder.
 * Runtime independence is the point of the suite.
 */

/* vpl — one stylesheet, CSS variables (§4.4).
 * Warm paper, not a dashboard. Light is the default; dark is a variable swap. */
:root {
  --paper:        #faf8f4;
  --paper-2:      #f2eee6;   /* list pane */
  --paper-3:      #e9e3d8;   /* hairlines, hover */
  --ink:          #1f1d1a;
  --ink-2:        #55504a;
  --ink-3:        #8a8378;
  --line:         #e0d9cd;
  --mark:         #b4531f;   /* the only accent, used sparingly */
  --danger:       #a3352b;

  /* one colour language for sharing, in the list and at the top of the note:
   * anyone with the link / someone may edit / someone may only read */
  --tone-public: #a4553c;   /* terracotta, next to the accent */
  --tone-shared: #4a6b52;   /* moss */
  --tone-read:   #4a5f76;   /* slate */

  --sans: 'Manrope', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Newsreader', ui-serif, Georgia, 'Times New Roman', serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --list-w: 15rem;
  --radius: 8px;
  --bar-h: 2.75rem;
  --line-strong: #cdc3b2;
}

[data-theme='dark'] {
  --paper:        #1a1816;
  --paper-2:      #232120;
  --paper-3:      #33302c;
  --ink:          #f7f3ec;
  --ink-2:        #ddd6cb;
  --ink-3:        #b5ada1;   /* 7.97:1 on --paper */
  /* Edges must be obvious, not merely present. #8a8177 is 4.63:1 on
   * --paper and 4.19:1 on the sidebar surface. */
  --line:         #8a8177;
  --line-strong:  #a39a8f;
  --mark:         #ffb06b;
  --danger:       #ff9084;
  --tone-public: #dda07a;
  --tone-shared: #9fc4a8;
  --tone-read:   #a8c4e0;
}

/* In dark mode a hairline on a near-black surface vanishes, so inputs and
 * pane dividers get an explicit, visible border. Structural dividers are
 * drawn in --line-strong and made 2px: at 1px even a strong colour reads
 * as "faint" on a large dark field. */
[data-theme='dark'] input,
[data-theme='dark'] textarea {
  border-color: var(--line);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

button, input, textarea, select { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--mark);
  outline-offset: 2px;
}

/* ── buttons ────────────────────────────────────────────────────── */
/* Base controls belong to the shell: an app that forgets them falls back to the
 * browser's beige buttons, which is what vi did until this was added. */
button {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  color: var(--ink-2);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
button:hover { background: var(--paper-3); color: var(--ink); }
button.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
button.primary:hover { background: var(--ink-2); }
button.danger { color: var(--danger); }
button.ghost { border-color: transparent; }
button.ghost:hover { border-color: var(--line); }
button.icon {
  border: none; padding: 0.35rem 0.5rem; font-size: 1.05rem; line-height: 1;
  border-radius: var(--radius);
}

/* ── selects ─────────────────────────────────────────────────────── */
/* A <select> left alone renders as a small native control next to our wide
 * inputs, which reads as "unfinished". Same box, same radius, same height;
 * only the arrow stays native, because a custom one is a dropdown of its own. */
select {
  width: 100%;
  min-height: 2.15rem;
  padding: .45rem .5rem;
  border: 1px solid var(--line-strong, var(--line));
  border-radius: 8px;
  background: var(--paper, #fff);
  color: var(--ink, inherit);
  appearance: auto;
}
[data-theme='dark'] select { border-color: var(--line); }

/* ── themes ───────────────────────────────────────────────────────────
 * A theme is a palette and nothing else: same weights, same meanings. `light`
 * is the default with no attribute at all; anything else is `data-theme` on
 * <html>, written by vendor/settings.js. Adding a theme is a block here and one
 * line in THEMES, and it is then available in every app. */
[data-theme='vi'] {
  --paper:        #fbf6ea;
  --paper-2:      #f3ecdc;
  --paper-3:      #e7dec8;
  --ink:          #1b1712;
  --ink-2:        #4a4238;
  --ink-3:        #857a66;
  --line:         #d8cdb5;
  --line-strong:  #b9ab8d;
  --mark:         #b4531f;
  --danger:       #a3352b;
}

/* ── the settings dialog (vendor/settings.js) ─────────────────────────
 * One dialog, four tabs, three buttons. Deliberately tight: 0.76rem text, no
 * gaps between rows, no paragraph breathing room — a settings panel is a form,
 * not an essay. Typed text stays left-aligned; nothing here is centred. */
dialog.settings { width: min(30rem, 94vw); padding: 0.6rem 0.75rem 0.55rem; }
dialog.settings h2 { font-size: 0.82rem; margin: 0; letter-spacing: 0.04em; text-transform: lowercase; }
dialog.settings .set-head { display: flex; align-items: center; justify-content: space-between; }
dialog.settings .set-tabs {
  display: flex; gap: 0; margin: 0.4rem 0 0.35rem; border-bottom: 1px solid var(--line);
}
dialog.settings .set-tabs [role='tab'] {
  background: none; border: 0; border-bottom: 2px solid transparent; padding: 0.2rem 0.55rem;
  font: inherit; font-size: 0.74rem; color: var(--ink-3); cursor: pointer;
}
dialog.settings .set-tabs [role='tab']:hover { color: var(--ink); }
dialog.settings .set-tabs [role='tab'][aria-selected='true'] {
  color: var(--ink); border-bottom-color: var(--mark); font-weight: 600;
}
/* one cell, four panels: the tallest decides the dialog's height and it stays
 * that height whichever tab is showing */
dialog.settings .set-panels { display: grid; }
dialog.settings .set-panel { grid-area: 1 / 1; display: grid; gap: 0.15rem; padding: 0.15rem 0; }
dialog.settings .set-panel.off { visibility: hidden; }
dialog.settings .set-row {
  display: grid; grid-template-columns: 5.2rem 1fr; gap: 0.4rem; align-items: center;
}
dialog.settings .set-row label {
  font-size: 0.68rem; color: var(--ink-3); letter-spacing: 0.03em; text-transform: lowercase;
}
dialog.settings .set-row input,
dialog.settings .set-row select {
  width: 100%; font-size: 0.76rem; line-height: 1.25; padding: 0.15rem 0.35rem;
  border: 1px solid var(--line); border-radius: 4px; background: var(--paper);
  color: var(--ink); text-align: left;
}
dialog.settings .set-row input:focus,
dialog.settings .set-row select:focus { outline: 2px solid var(--mark); outline-offset: 0; }
dialog.settings .set-note {
  font-size: 0.68rem; line-height: 1.3; color: var(--ink-3); margin: 0.15rem 0 0;
}
dialog.settings .set-acc { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.3rem; }
dialog.settings .set-themes { display: grid; gap: 0.2rem; }
dialog.settings .set-theme {
  display: flex; gap: 0.5rem; align-items: baseline; text-align: left;
  background: var(--paper); border: 1px solid var(--line); border-radius: 5px;
  padding: 0.25rem 0.45rem; font: inherit; cursor: pointer; color: var(--ink);
}
dialog.settings .set-theme[aria-pressed='true'] { border-color: var(--mark); box-shadow: inset 0 0 0 1px var(--mark); }
dialog.settings .set-theme-name { font-size: 0.76rem; font-weight: 600; }
dialog.settings .set-theme-note { font-size: 0.68rem; color: var(--ink-3); }
dialog.settings .set-msg {
  font-size: 0.72rem; line-height: 1.3; margin: 0.3rem 0 0; min-height: 1.1em; color: var(--ink-2);
}
dialog.settings .set-msg[data-state='ok'] { color: #2f6f4f; }
dialog.settings .set-msg[data-state='bad'] { color: var(--danger); }
dialog.settings .set-msg[data-state='busy'] { color: var(--ink-3); }
dialog.settings .set-foot {
  display: flex; gap: 0.3rem; justify-content: flex-end; margin-top: 0.35rem;
  border-top: 1px solid var(--line); padding-top: 0.35rem;
}
dialog.settings .set-foot .ghost,
dialog.settings .set-foot .primary { font-size: 0.74rem; padding: 0.15rem 0.5rem; }
dialog.settings .set-foot [data-a='test'] { margin-right: auto; }
dialog.settings .set-foot [data-a='forget'] { color: var(--danger); }

/* ── the gate: one account for the whole suite ────────────────────────
 * Every app signs in the same way, and every sign-in is a card with an edge.
 * Apps that draw their own frame (vn, vi) override this; the rest inherit it,
 * which is why a login no longer floats on a blank page. */
.gate-form {
  width: min(21rem, 100%);
  display: flex; flex-direction: column; gap: 0.4rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgb(31 29 26 / 9%);
  padding: 1.35rem 1.25rem 1.15rem;
}
.gate-fine { font-size: 0.72rem; line-height: 1.4; color: var(--ink-3); margin: 0.55rem 0 0; }

/* ── who is signed in, in every bar ───────────────────────────────────
 * One chip: the name, the address on hover, and never a long email eating the
 * bar. The glyph is the initial, so an app with no room still says a person. */
.who {
  display: inline-flex; align-items: center; gap: 0.35rem;
  max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 0.78rem; color: var(--ink-2);
}
.who::before {
  content: attr(data-initial);
  display: grid; place-items: center;
  width: 1.35rem; height: 1.35rem; flex: none;
  border-radius: 50%; background: var(--paper-3); color: var(--ink-2);
  font-size: 0.62rem; letter-spacing: 0.02em; text-transform: uppercase;
}

/* ── the notice: one boxed line, centred over the work ────────────────
 * An announcement from whoever runs the suite — a test system, a date, later
 * maybe an offer. It is a box with an edge that sits inside the work column, so
 * it never pushes the bar or the dock and never covers an input. The tone word
 * is always there: colour is never the only signal. */
.notice {
  display: flex; align-items: center; gap: 0.45rem;
  width: fit-content; max-width: min(46rem, 100%);
  margin: 0.55rem auto 0.15rem;
  padding: 0.3rem 0.4rem 0.3rem 0.6rem;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--paper-2); color: var(--ink);
  font-family: var(--sans); font-size: 0.78rem; line-height: 1.3;
  transition: opacity 0.18s ease;
}
.notice.swap { opacity: 0.25; }
.notice[data-tone='heads-up'] { border-color: var(--mark); background: var(--paper); }
.notice[data-tone='offer'] { border-color: var(--line-strong); background: var(--paper-3); }
.notice-tone {
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 0.05rem 0.4rem;
  white-space: nowrap;
}
.notice[data-tone='heads-up'] .notice-tone { color: var(--mark); border-color: var(--mark); }
.notice-text { margin: 0; min-width: 0; }
.notice-text a { color: inherit; text-underline-offset: 2px; }
.notice-x {
  border: 0; background: none; color: var(--ink-3); cursor: pointer;
  font-size: 0.72rem; line-height: 1; padding: 0.25rem 0.35rem;
  min-width: 1.9rem; min-height: 1.9rem; border-radius: 999px;
}
.notice-x:hover { color: var(--ink); background: var(--paper-3); }
@media (max-width: 34rem) {
  .notice { border-radius: 12px; font-size: 0.74rem; margin-left: 0; margin-right: 0; }
}
@media print { .notice { display: none !important; } }

/* ── the dock: a chat line at the bottom of every app ─────────────────
 * Top is who and where the settings are; bottom is the model. The dock is a
 * line until somebody writes in it, then a transcript, and it never covers the
 * page: the body keeps a strip of padding the height of the closed dock. */
:root { --dock-h: 2.5rem; }
/* In the app's own column the dock takes its strip and the work area shrinks;
 * only the fallback (no #app to hang it on) overlays the page. */
body.dock-fixed { padding-bottom: calc(var(--dock-h) + 1px); }
.dock.in-flow { position: relative; flex: 0 0 auto; }
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: var(--paper); border-top: 1px solid var(--line);
  display: flex; flex-direction: column; max-height: 62vh;
}
.dock-line { height: var(--dock-h); display: flex; align-items: center; gap: 0.35rem; padding: 0 0.5rem; }
.dock-badge {
  border: 1px solid var(--line); background: var(--paper-2); color: var(--ink-2);
  width: 1.7rem; height: 1.7rem; border-radius: 5px; cursor: pointer; font-size: 0.8rem;
}
.dock-form { flex: 1; display: flex; gap: 0.3rem; min-width: 0; }
.dock-input {
  flex: 1; min-width: 0; font-size: 0.8rem; line-height: 1.3; padding: 0.2rem 0.45rem;
  border: 1px solid var(--line); border-radius: 5px; background: var(--paper); color: var(--ink);
  text-align: left;
}
.dock-input:focus { outline: 2px solid var(--mark); outline-offset: 0; }
.dock-go, .dock-x {
  font-size: 0.76rem; padding: 0.2rem 0.55rem; border-radius: 5px;
  border: 1px solid var(--line); background: var(--paper-2); color: var(--ink); cursor: pointer;
}
.dock-x { background: none; color: var(--ink-3); }
/* The transcript is a layer above the line, not a growing part of the page:
 * it is capped at about three rows and scrolls inside itself. A conversation
 * that stretched the column pushed the work area up the screen — the dock is a
 * place to glance at, not a page. */
.dock { position: relative; }
.dock.open { z-index: 61; }
.dock-log {
  position: absolute; left: 0; right: 0; bottom: 100%;
  background: var(--paper); border-top: 1px solid var(--line);
  box-shadow: 0 -10px 24px rgb(0 0 0 / 8%);
  display: flex; flex-direction: column; min-height: 0;
}
.dock-thread {
  overflow-y: auto; overscroll-behavior: contain;
  padding: 0.45rem 0.6rem 0.3rem; display: grid; gap: 0.3rem;
  max-height: 6.5rem;                 /* ~3 rows, then it scrolls inside */
}
.dock-row { display: grid; gap: 0.15rem; }
.dock-row .dock-text {
  font-size: 0.8rem; line-height: 1.45; white-space: pre-wrap;
  padding: 0.3rem 0.5rem; border-radius: 6px; background: var(--paper-2); color: var(--ink);
  border-left: 2px solid var(--line-strong);
}
.dock-row.me .dock-text { background: none; border-left: 0; color: var(--ink-2); font-style: italic; }
.dock-row.it .dock-text { border-left-color: var(--mark); }
.dock-acts { display: flex; gap: 0.35rem; align-items: baseline; }
.dock-acts button { font-size: 0.72rem; padding: 0.05rem 0.4rem; }
/* the verb you are meant to reach for looks like a button; drop does not.
 * Both say what they do, because "use it" and "replace selection" are not the
 * same promise. */
.dock-acts [data-use] {
  border: 1px solid var(--line-strong); background: var(--paper-2); color: var(--ink);
  border-radius: 5px;
}
.dock-acts [data-use]:hover { border-color: var(--mark); color: var(--mark); }
.dock-acts [data-drop] { border: 0; background: none; color: var(--ink-3); }
.dock-used { font-size: 0.7rem; color: #2f6f4f; }
.dock-msg { font-size: 0.72rem; line-height: 1.3; margin: 0.1rem 0.6rem 0.35rem; min-height: 1em; color: var(--ink-3); }
.dock-msg[data-state='bad'] { color: var(--danger); }
.dock-msg[data-state='busy'] { color: var(--ink-3); }
@media print { .dock { display: none !important; } body { padding-bottom: 0; } }

/* the sign-in's theme switch, in the same corner in every app */
.gate .corner-theme {
  position: absolute; top: 0.75rem; right: 0.75rem;
  border: 1px solid var(--line); background: var(--paper-2); color: var(--ink-3);
  width: 1.8rem; height: 1.8rem; border-radius: 50%; cursor: pointer;
}
.gate { position: relative; }


/* ── the bar: one order, in all eight ─────────────────────────────────
 * Left to right, always the same: the list, the app's boxed letters, its own
 * name, the one thing you add. Then air. Then who you are, the gear, out.
 * A hand learns this once and it works in every app.
 *
 * The name, not the letters, is what gives way on a phone: the box already
 * says which app this is, so the word can fall back to its first letter.
 */
.bar {
  height: var(--bar-h); flex: 0 0 auto;
  display: flex; align-items: center; gap: 0.25rem;
  padding: 0 0.6rem; background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 30;
}
.bar .grow { flex: 1 1 0; min-width: 0; }
.bar .brand {
  display: inline-flex; align-items: center; gap: 0.45rem; min-width: 0;
  text-decoration: none; color: var(--ink);
}
.bar .brand-mark {
  display: grid; place-items: center; flex: none;
  min-width: 1.9rem; height: 1.6rem; padding: 0 0.28rem;
  border: 1px solid var(--line-strong); border-radius: 4px; background: var(--paper-2);
  font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.03em;
  text-transform: uppercase; color: var(--ink);
}
.bar .brand-word {
  display: inline-block; overflow: hidden; white-space: nowrap;
  font-family: var(--serif); font-size: 0.98rem; color: var(--ink-2);
}
.bar .brand:hover .brand-word { color: var(--ink); }
/* On a phone the word goes rather than shrink to one letter: "[vn] n" reads as
 * a cut-off word, while the box alone still says which app this is. */
@media (max-width: 26rem) {
  .bar .brand-word { display: none; }
}

/* ── the theme, in the settings dialog ────────────────��──────────────
 * ◐ sits next to the word "settings" and means one thing: dark or normal, in
 * one press. The palette tab underneath is where a person goes to choose. */
/* the ✕ is pinned in the corner (it is in every dialog), so the head keeps a
 * strip clear of it: the ◐ sat under the ✕ and could not be pressed */
dialog.settings .set-head { gap: 0.4rem; padding-right: 2.3rem; }
dialog.settings .set-head h2 { margin-right: auto; }
dialog.settings .set-mode {
  border: 1px solid var(--line); background: var(--paper-2); color: var(--ink-2);
  border-radius: 999px; min-width: 1.9rem; min-height: 1.9rem;
  font-size: 0.95rem; line-height: 1; padding: 0 0.3rem; cursor: pointer;
}
dialog.settings .set-mode[aria-pressed='true'] { border-color: var(--line-strong); color: var(--ink); }
dialog.settings .set-mode:hover { border-color: var(--line-strong); color: var(--ink); }

/* ── a control has to be hittable ─────────────────────────────────────
 * Measured, not guessed: ux-sniff found bar buttons at 28px and a dialog's ✕
 * at 20×24. A mouse forgives 20px; a thumb does not. Every tappable thing in
 * the suite now keeps a floor, and the floor grows on a phone. Nothing is
 * centred that was not centred before. */
button.icon, a.icon, .dialog-x, .corner-theme {
  min-width: 1.9rem; min-height: 1.9rem;
  display: inline-grid; place-items: center;
}
@media (max-width: 640px) {
  button.icon, a.icon, .dialog-x, .corner-theme { min-width: 2.4rem; min-height: 2.4rem; }
  .bar { height: 3.1rem; }
}

/* Small tools — the delete, the page arrow, the "show values" — are used with a
 * thumb as often as with a mouse. Same floor as the icons, and the same floor
 * for the brand link, whose only clickable pixels used to be the letter itself. */
.kill, .d-close, .pager button, .views .view, .dock-x, .dock-badge {
  min-width: 1.9rem; min-height: 1.9rem;
  display: inline-grid; place-items: center;
}
/* the brand is a link with two parts side by side, so it keeps its own display:
 * the floor above used to make it an inline-grid, which stacked the box and the
 * word and shrank the whole thing to the width of "ideas" */
.bar .brand { display: inline-flex; align-items: center; min-height: 1.9rem; }
@media (max-width: 640px) {
  .kill, .d-close, .pager button, .dock-x, .dock-badge { min-width: 2.2rem; min-height: 2.2rem; }
  .bar .brand { min-height: 2.2rem; }
}

/* Every button keeps a floor, whatever its own padding says: ux-sniff found
 * "copy" at 45×28 and a list row at 356×21 on a phone. A row is a control too. */
button { min-height: 1.9rem; }
@media (max-width: 640px) { button { min-height: 2.1rem; min-width: 2.1rem; } }

/* Small caps labels were 9.6px — legible on a desk, a rumour on a phone. */
.count, .tag, .stamp, .pill, .eyebrow, .kind, .kicker { font-size: max(0.66rem, 10.5px); }

/* Tool rows wrap on a phone rather than push their last button off the edge —
 * ux-sniff caught a "drawing" button 12px past the screen after the size floor
 * above made every tool bigger. */
@media (max-width: 640px) {
  .side-head, .doc-head, .bar-tools, .row-tools, .draw-bar, .tools { flex-wrap: wrap; }
  .bar { gap: 0.1rem; padding: 0 0.35rem; }
}
