/* vpl · vc — compliance, on the same desk.
 *
 * The left pane is two piles — the rules and the proofs — and the right is the
 * report. Above the report a strip counts PASS, FAIL and UNKNOWN in words and
 * numbers: the only thing this app reads out of its own text.
 */

:root {
  --rule: #e2dbcf;
  --rule-strong: #c9bfae;
  --ok: #3f6b4f;
  --paper-sheet: #fffdf9;
}

[data-theme='dark'] {
  --rule: #3a332a;
  --rule-strong: #574c3d;
  --ok: #8fc4a2;
  --paper-sheet: #211e1b;
}

body {
  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; }

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; }

/* ── the rail of jobs ─────────────────────────────────────────────── */
.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 .tpl {
  font-family: var(--mono); font-size: 0.62rem; color: var(--ink-3);
  padding-right: 0.15rem; letter-spacing: 0.02em;
}
.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; }

/* ── the desk ─────────────────────────────────────────────────────── */
.spec { padding: 1.1rem 1.4rem 3rem; min-width: 0; }
.title {
  width: 100%; border: none; border-bottom: 1px solid transparent;
  background: none; font-family: var(--serif); font-size: 1.5rem; padding: 0.2rem 0;
}
.title:hover { border-bottom-color: var(--rule); }
.title:focus { outline: none; border-bottom-color: var(--ink); }
.title:read-only { cursor: default; }

.brief {
  width: 100%; margin: 0.15rem 0 0; border: none; border-bottom: 1px dashed transparent;
  background: none; color: var(--ink-2); font-size: 0.9rem; resize: none;
  padding: 0.2rem 0; line-height: 1.45;
}
.brief:hover { border-bottom-color: var(--rule); }
.brief:focus { outline: none; border-bottom-color: var(--ink); }

.pick-row {
  display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap;
  margin: 0.9rem 0 0; padding: 0.55rem 0.7rem;
  border: 1px solid var(--rule-strong); border-radius: 4px; background: var(--paper-2);
}
.pick-row label {
  font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink-3);
}
.pick-row select { width: auto; min-width: 13rem; }
.pick-row .muted { font-size: 0.78rem; }

.spec-tools { display: flex; align-items: center; gap: 0.4rem; margin: 0.7rem 0 0; flex-wrap: wrap; }
.proj-meta { margin: 0; font-size: 0.76rem; }
.spec-tools button { font-size: 0.76rem; }
.guest-banner {
  margin: 0.6rem 0 0; padding: 0.45rem 0.6rem; font-size: 0.78rem;
  border-left: 3px solid var(--tone-read); background: var(--paper-2); color: var(--ink-2);
}

.work {
  display: grid; grid-template-columns: minmax(15rem, 21rem) minmax(0, 1fr);
  gap: 1.4rem; align-items: start; margin-top: 1rem;
}
.side { min-width: 0; }
.side-head { display: flex; align-items: baseline; gap: 0.45rem; }
.side-head h2 {
  font-family: var(--mono); font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.16em; color: var(--ink-2); font-weight: 600; margin: 0;
}
.side-head .count { font-size: 0.72rem; }
.side-head button { font-size: 0.74rem; padding: 0.15rem 0.4rem; }
.side-note { margin: 0.2rem 0 0.6rem; font-size: 0.74rem; line-height: 1.4; }

/* ── the pile of inputs ───────────────────────────────────────────── */
.artifacts { list-style: none; margin: 0; padding: 0; }
.art {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.1rem 0.5rem; align-items: baseline;
  padding: 0.42rem 0.3rem; border-bottom: 1px solid var(--rule);
}
.art:hover { background: var(--paper-2); }
.art .kind {
  font-family: var(--mono); font-size: 0.6rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-3);
  border: 1px solid var(--rule-strong); border-radius: 2px; padding: 0 0.2rem;
  white-space: nowrap;
}
.art .what { min-width: 0; }
.art .name {
  display: block; width: 100%; text-align: left; border: none; background: none;
  padding: 0; font-size: 0.84rem; color: var(--ink); cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.art .line {
  display: block; font-size: 0.72rem; color: var(--ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.art .tools { display: flex; gap: 0.1rem; opacity: 0; }
.art:hover .tools, .art:focus-within .tools { opacity: 1; }
.art .tools button { border: none; background: none; font-size: 0.72rem; color: var(--ink-3); padding: 0.05rem 0.25rem; }
.art .tools button:hover { color: var(--ink); }

/* ── two piles ─────────────────────────────────────────────────────── */
.side-head.gap-top { margin-top: 1rem; }
.none-line { font-size: 0.76rem; margin: 0.1rem 0 0; }

/* ── the findings strip ────────────────────────────────────────────── */
.findings {
  display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap;
  margin-top: 0.55rem; padding: 0.45rem 0.6rem;
  border: 1px solid var(--rule-strong); border-radius: 3px; background: var(--paper-2);
  font-size: 0.8rem;
}
.verdict {
  font-family: var(--mono); font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.08em; padding: 0.05rem 0.35rem; border-radius: 2px;
  border: 1px solid var(--rule-strong);
}
.verdict b { font-size: 0.82rem; margin-right: 0.15rem; }
.verdict.pass { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--rule-strong)); }
.verdict.fail { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--rule-strong)); }
.verdict.unknown { color: var(--ink-2); }
.findings .muted { font-size: 0.74rem; }

/* ── the document ─────────────────────────────────────────────────── */
.output { position: relative; }
.doc {
  width: 100%; min-height: 58vh; margin-top: 0.55rem;
  font-family: var(--serif); font-size: 1rem; line-height: 1.62;
  background: var(--paper-sheet); color: var(--ink);
  border: 1px solid var(--rule-strong); border-radius: 3px;
  padding: 1.5rem 1.7rem; resize: vertical;
  box-shadow: 0 1px 0 var(--rule);
}
.out-none {
  margin-top: 0.55rem; padding: 2.2rem 1.4rem;
  border: 1px dashed var(--rule-strong); border-radius: 3px;
  display: grid; gap: 0.8rem; justify-items: start;
}
.out-none p { margin: 0; max-width: 34rem; font-size: 0.86rem; }

.versions {
  width: auto; max-width: 15rem; font-size: 0.74rem; padding: 0.1rem 0.25rem;
  border-color: var(--rule); color: var(--ink-2);
}

.gen { display: flex; gap: 0.45rem; margin-top: 0.75rem; }
.gen .notes { flex: 1; min-width: 0; font-size: 0.84rem; }
.gen-msg { margin: 0.35rem 0 0; }
.gen-msg[data-state='busy']::after {
  content: '';
  display: inline-block; width: 0.55rem; height: 0.55rem; margin-left: 0.35rem;
  border: 1.5px solid var(--ink-3); border-top-color: transparent; border-radius: 50%;
  animation: spin 0.8s linear infinite; vertical-align: -0.05rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── messages, dialogs, gate ──────────────────────────────────────── */
.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 {
  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(42rem, 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 { font-size: 0.76rem; color: var(--ink-3); min-height: 1rem; }
.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; }

.art-title { width: 100%; font-size: 0.95rem; }
.art-text {
  width: 100%; font-family: var(--mono); font-size: 0.78rem; line-height: 1.5;
  margin-top: 0.5rem; resize: vertical;
}
.art-file {
  margin: 0.4rem 0 0; font-family: var(--mono); font-size: 0.74rem;
  color: var(--ink-2); word-break: break-all;
}
.art-file a { color: var(--mark); }

/* ── 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; }

/* ── welcome ─────────────────────────────────────────────────────── */
.welcome { padding: 3rem 1.4rem; display: grid; place-items: center; }
.welcome-card { max-width: 34rem; }
.welcome-mark {
  font-family: var(--serif); width: 2rem; height: 2rem; display: grid; place-items: center;
  background: var(--ink); color: var(--paper); border-radius: 4px; font-size: 1.2rem;
}
.welcome-card h2 { font-family: var(--serif); font-size: 1.5rem; margin: 0.9rem 0 0.5rem; }
.welcome-card p { font-size: 0.9rem; line-height: 1.6; color: var(--ink-2); }
.welcome-fine { font-size: 0.78rem !important; color: var(--ink-3) !important; }

/* ── verbs a role does not have ──────────────────────────────────── */
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'] #proj-title { pointer-events: none; }
body[data-role='view'] .gen { display: none !important; }
body[data-guest='1'] .body { grid-template-columns: minmax(0, 1fr); }
body[data-guest='1'] #projects { display: none; }
body[data-guest='1'] .brief { pointer-events: none; }

/* ── narrow ──────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .work { grid-template-columns: 1fr; gap: 1rem; }
  .side.inputs { border-bottom: 1px solid var(--rule); padding-bottom: 0.8rem; }
}
@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; }
  .title { font-size: 1.25rem; }
  .pick-row select { width: 100%; }
  .doc { min-height: 50vh; padding: 1rem 1rem; font-size: 0.95rem; }
  .art .tools { opacity: 1; }
  /* on a phone the document is long; the way to ask for another one stays
   * within a thumb's reach instead of at the end of the scroll */
  .output { padding-bottom: 3.4rem; }
  .gen {
    position: sticky; bottom: 0; z-index: 5;
    background: var(--paper); padding: 0.5rem 0 0.55rem;
    border-top: 1px solid var(--rule);
  }
  .gen-msg { padding-bottom: 0.2rem; }
}

@media print {
  .bar, .projects, .pick-row, .spec-tools, .guest-banner, .side-head,
  .side-note, .artifacts, .gen, .gen-msg, .welcome, .brief, .versions,
  .out-none, #toast, dialog { display: none !important; }
  .body { display: block; }
  .spec { padding: 0; }
  .work { display: block; margin: 0; }
  .title { font-size: 1.4rem; border: none; }
  #out-body { display: none !important; }
  .print-doc {
    display: block !important; font-family: var(--serif); font-size: 11.5pt;
    line-height: 1.55; white-space: pre-wrap; margin: 1rem 0 0;
  }
}
.print-doc { display: none; }
