/* Package Desk. The tool speaks in Avenir Next; everything a model wrote is set in Charter, so the page
   always shows which words are the product. JEV's picks carry a highlighter stroke; nothing else does. */
:root {
  --paper: #e9ecf2;
  --surface: #ffffff;
  --ink: #161b3d;
  --muted: #5a6280;
  --line: #cfd4e2;
  --mark: #ffe14d;
  --rec: #d93a36;
  --done: #1d7f56;
  --ui: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --display: "Avenir Next Condensed", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --copy: Charter, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 0.9em; }

/* ---------- Top ---------- */
.top {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  padding: 1.1rem 2rem 1rem;
  border-bottom: 2px solid var(--ink);
}
.top h1 { font-family: var(--display); font-weight: 600; font-size: 2rem; letter-spacing: -0.01em; line-height: 1; }
.top-note { color: var(--muted); font-size: 0.95rem; min-width: 0; }
.top-keys { margin-left: auto; display: flex; align-items: center; gap: 0.9rem; font-size: 0.85rem; }
/* When the bar is tight the tagline is what wraps, never the name, the key lights or the buttons. */
.top h1, .top-keys > * { white-space: nowrap; flex-shrink: 0; }
.key-state { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--muted); }
.key-state::before { content: ""; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--rec); }
.key-state.ready::before { background: var(--done); }

/* ---------- Layout ---------- */
.desk { display: grid; grid-template-columns: 23.5rem minmax(0, 1fr); min-height: calc(100vh - 4.4rem); }
.brief { padding: 1.5rem 1.5rem 2rem 2rem; border-right: 1px solid var(--line); }
.stage { padding: 1.5rem 2.5rem 4rem; max-width: 62rem; }

/* ---------- Brief (left) ---------- */
.field { margin-bottom: 1.25rem; }
.field-head { display: flex; align-items: baseline; justify-content: space-between; }
.field-foot { margin-top: 0.35rem; display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem; }
label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.35rem; }
.count { color: var(--muted); font-size: 0.8rem; }
textarea, input[type="search"], input[type="password"], input[type="text"] {
  width: 100%;
  padding: 0.6rem 0.7rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
}
textarea { resize: vertical; font-family: var(--copy); font-size: 0.95rem; line-height: 1.5; }
textarea.dropping { border-color: var(--ink); background: #fffbe0; }
::placeholder { color: #8189a3; font-family: var(--ui); font-size: 0.875rem; }

button { cursor: pointer; border-radius: 3px; }
.primary {
  background: var(--ink);
  color: #fff;
  border: 0;
  padding: 0.75rem 1.1rem;
  font-weight: 600;
  width: 100%;
}
.primary:hover { background: #262d5e; }
.primary.stop { background: var(--rec); }
.primary:disabled { opacity: 0.5; cursor: default; }
.quiet { background: transparent; border: 1px solid var(--ink); padding: 0.3rem 0.8rem; font-weight: 500; }
.quiet:hover { background: var(--ink); color: #fff; }
.link { background: none; border: 0; padding: 0; color: var(--muted); font-size: 0.82rem; text-decoration: underline; text-underline-offset: 2px; }
.link:hover { color: var(--ink); }
.error { color: var(--rec); font-size: 0.875rem; margin-top: 0.6rem; }

.chosen { display: grid; gap: 0.3rem; margin-bottom: 0.5rem; }
.chosen li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.3rem 0.35rem 0.3rem 0.6rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 0.85rem;
}
.chosen .id { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chosen .price { color: var(--muted); font-size: 0.75rem; white-space: nowrap; }
.optional { margin-top: 1rem; padding-top: 0.8rem; border-top: 1px solid var(--line); }
.optional h3 { font-size: 0.85rem; font-weight: 600; }
.optional > p { color: var(--muted); font-size: 0.78rem; line-height: 1.35; margin: 0.15rem 0 0.5rem; }
.optional label { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; font-size: 0.85rem; margin: 0.3rem 0 0; cursor: pointer; }
.optional input { accent-color: var(--ink); width: 1rem; height: 1rem; margin: 0; flex: none; }
.optional input:disabled + span { color: var(--muted); }
.optional .notice-on { font-size: 0.78rem; line-height: 1.35; margin: 0.25rem 0 0.5rem 1.5rem; padding: 0.35rem 0.5rem; background: var(--mark); border-radius: 3px; }
.chosen .data-note { grid-column: 1 / -1; font-size: 0.72rem; line-height: 1.3; padding-bottom: 0.15rem; border-left: 3px solid var(--mark); padding-left: 0.4rem; }
.chosen .gone { color: var(--rec); }
.chosen button { background: none; border: 0; color: var(--muted); padding: 0 0.3rem; font-size: 1rem; line-height: 1; }
.chosen button:hover { color: var(--rec); }
.adder { position: relative; }
.matches {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  max-height: 17rem;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--ink);
  border-radius: 3px;
}
.matches li { padding: 0.4rem 0.6rem; font-size: 0.85rem; cursor: pointer; display: flex; justify-content: space-between; gap: 0.75rem; }
.matches li span:last-child { color: var(--muted); font-size: 0.75rem; white-space: nowrap; }
.matches li:hover, .matches li.active { background: var(--mark); }

.past { margin-top: 2.25rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.past h2 { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.5rem; }
.runs li { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; align-items: start; }
.runs .open {
  text-align: left;
  background: none;
  border: 0;
  padding: 0.4rem 0;
  font-family: var(--copy);
  font-size: 0.92rem;
  line-height: 1.3;
}
.runs .open:hover { text-decoration: underline; }
.runs .open.current { font-weight: 700; }
.runs .when { display: block; font-family: var(--ui); font-size: 0.75rem; color: var(--muted); font-weight: 400; }
.runs .remove { background: none; border: 0; color: var(--muted); padding: 0.45rem 0.2rem; font-size: 0.75rem; }
.runs .remove:hover { color: var(--rec); }
.runs .none { color: var(--muted); font-size: 0.85rem; }

/* ---------- Stage (right) ---------- */
.welcome { max-width: 36rem; padding-top: 1.5rem; }
.welcome h2 { font-family: var(--display); font-weight: 600; font-size: 2.6rem; line-height: 1.05; letter-spacing: -0.015em; margin-bottom: 1.1rem; }
.welcome ol { margin: 0 0 1.25rem; padding-left: 1.25rem; display: grid; gap: 0.55rem; }
.welcome p { color: var(--muted); }
.welcome > p { margin-bottom: 1rem; }
.welcome p button { display: block; margin-top: 0.5rem; }
.welcome a, dialog a { color: inherit; text-underline-offset: 2px; }
.welcome a:hover, dialog a:hover { color: var(--ink); }
.welcome .terms p { color: var(--ink); }
/* What a first-time visitor to the hosted page needs before spending anything. */
.welcome .terms { margin: 0 0 1.25rem; padding: 0.9rem 1.1rem; background: var(--surface); border-left: 4px solid var(--ink); display: grid; gap: 0.5rem; font-size: 0.92rem; }

.notice { border-left: 4px solid var(--rec); background: var(--surface); padding: 0.75rem 1rem; margin-bottom: 1.5rem; }
.notice button { margin-top: 0.6rem; }

.panel { margin-bottom: 2.5rem; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.6rem; }
.panel-head h2, .section h2 { font-family: var(--display); font-weight: 600; font-size: 1.5rem; letter-spacing: -0.005em; }
.panel-head p { color: var(--muted); font-size: 0.85rem; }

/* One lane per writer, like tracks on an edit timeline. */
.lane {
  display: grid;
  grid-template-columns: minmax(9rem, 17rem) minmax(4rem, 1fr) 4.2rem 4.6rem;
  gap: 0.9rem;
  align-items: center;
  padding: 0.3rem 0;
  font-size: 0.85rem;
}
.lane .id { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lane .track { height: 0.7rem; background: #dce0ea; border-radius: 2px; overflow: hidden; }
.lane .fill { height: 100%; width: 0; background: var(--ink); border-radius: 2px; }
.lane.running .fill {
  width: 100%;
  background: repeating-linear-gradient(110deg, var(--ink) 0 14px, #4a5290 14px 28px);
  background-size: 200% 100%;
  animation: roll 1.1s linear infinite;
}
.lane.error .fill { width: 100%; background: var(--rec); opacity: 0.35; }
.lane .time, .lane .cost { text-align: right; color: var(--muted); }
.lane .why { grid-column: 2 / -1; color: var(--rec); font-size: 0.8rem; margin-top: -0.2rem; }
.lane .gap { grid-column: 2 / -1; color: var(--muted); font-size: 0.8rem; margin-top: -0.2rem; }
.judging { margin-top: 0.75rem; color: var(--muted); font-size: 0.875rem; }
@keyframes roll { to { background-position: -56px 0; } }
@media (prefers-reduced-motion: reduce) { .lane.running .fill { animation: none; } }

.section { padding: 1.75rem 0 2rem; border-top: 2px solid var(--ink); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; }
.section-head p { color: var(--muted); font-size: 0.85rem; text-align: right; }

.pick { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.4rem 1.5rem; align-items: start; margin-bottom: 1.4rem; }
.pick:last-of-type { margin-bottom: 0.5rem; }
.pick .body { font-family: var(--copy); font-size: 1.05rem; line-height: 1.6; max-width: 68ch; white-space: pre-wrap; }
.pick .meta { grid-column: 1; color: var(--muted); font-size: 0.8rem; }
.pick .actions { grid-row: 1; grid-column: 2; display: flex; flex-direction: column; gap: 0.35rem; align-items: stretch; }
.copy { background: var(--surface); border: 1px solid var(--line); padding: 0.3rem 0.75rem; font-size: 0.8rem; font-weight: 500; white-space: nowrap; }
.copy:hover { border-color: var(--ink); }
.copy.copied { background: var(--mark); border-color: var(--mark); }

/* The highlighter: only on what JEV picked. */
.marked {
  background: linear-gradient(transparent 12%, var(--mark) 12%, var(--mark) 88%, transparent 88%);
  padding: 0 0.25em;
  margin: 0 -0.25em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.pick.title .body { font-size: 1.7rem; line-height: 1.32; font-weight: 700; letter-spacing: -0.01em; max-width: 30ch; white-space: normal; }
.pick .lead { font-family: var(--ui); font-weight: 600; font-size: 1rem; display: block; margin-bottom: 0.35rem; }
.pick .aside { display: block; font-family: var(--ui); font-size: 0.875rem; color: var(--muted); margin-top: 0.5rem; }
.pick .subject { font-weight: 700; font-size: 1.25rem; line-height: 1.35; display: block; }
.pick .preview { display: block; color: var(--muted); font-style: italic; margin: 0.2rem 0 0.9rem; }

.unjudged { border-left: 4px solid var(--rec); padding: 0.1rem 0 0.1rem 0.9rem; margin-bottom: 1rem; font-size: 0.9rem; }

details.all { margin-top: 0.9rem; }
details.all > summary { cursor: pointer; color: var(--muted); font-size: 0.875rem; width: fit-content; }
details.all > summary:hover { color: var(--ink); }
details.all[open] > summary { margin-bottom: 0.6rem; color: var(--ink); }
.cand {
  display: grid;
  grid-template-columns: 3.2rem minmax(0, 1fr) auto;
  gap: 0.9rem;
  align-items: start;
  padding: 0.55rem 0;
  border-top: 1px solid var(--line);
}
.cand .odds { color: var(--muted); font-size: 0.8rem; padding-top: 0.2rem; }
.cand .text { font-family: var(--copy); font-size: 0.98rem; line-height: 1.5; white-space: pre-wrap; max-width: 68ch; }
.cand .text strong { display: block; }
.cand .who { display: block; font-family: var(--ui); color: var(--muted); font-size: 0.75rem; margin-top: 0.15rem; white-space: normal; }
.cand.picked .odds { color: var(--ink); font-weight: 600; }

.receipt { border-top: 1px solid var(--line); padding-top: 1rem; color: var(--muted); font-size: 0.85rem; }

/* ---------- Keys dialog ---------- */
dialog { border: 2px solid var(--ink); border-radius: 4px; padding: 1.5rem 1.75rem; width: min(30rem, 92vw); background: var(--paper); color: var(--ink); }
dialog::backdrop { background: rgba(22, 27, 61, 0.45); }
dialog h2 { font-family: var(--display); font-weight: 600; font-size: 1.6rem; margin-bottom: 0.4rem; }
dialog p { font-size: 0.875rem; color: var(--muted); margin-bottom: 1rem; }
dialog label { margin-top: 0.85rem; }
dialog .hint { font-size: 0.8rem; margin: 0.35rem 0 0; }
.other-route { margin-top: 1.1rem; }
.other-route summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; }
dialog .saved { font-weight: 400; color: var(--done); font-size: 0.8rem; }
.dialog-actions { display: flex; justify-content: flex-end; align-items: center; gap: 0.75rem; margin-top: 1.4rem; }
.dialog-actions button { white-space: nowrap; }
.dialog-actions .link { margin-right: auto; }
.dialog-actions .primary { width: auto; }
.dialog-actions .quiet { padding: 0.75rem 1.1rem; }

@media (max-width: 60rem) {
  .top { flex-wrap: wrap; padding: 1rem; }
  .top-keys { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .desk { grid-template-columns: 1fr; }
  .brief { border-right: 0; border-bottom: 1px solid var(--line); padding: 1.25rem 1rem; }
  .stage { padding: 1.25rem 1rem 3rem; }
  .lane { grid-template-columns: minmax(0, 1fr) 3.6rem 4.2rem; }
  .lane .track { display: none; }
  .pick { grid-template-columns: 1fr; }
  .pick .actions { grid-row: auto; grid-column: 1; flex-direction: row; }
  .pick.title .body { font-size: 1.35rem; }
}
