/* hip-interface: the pass desk.
   Cool slate paper, blue-black ink; teal/plum pencil marks for diffs;
   indigo reserved for the Voice Model's Rounds. */

:root {
  --paper: #eef1f4;
  --sheet: #fafbfc;
  --rule: #d6dde4;
  --ink: #1d2a3a;
  --graphite: #5d6b7a;
  --round: #3847b8;
  --round-soft: #e3e6fa;
  --insert: #1f6d61;
  --insert-bg: #d3eee7;
  --delete: #983256;
  --delete-bg: #f5dce5;
  --warn: #8a5a00;
  --warn-bg: #fbefd4;
  --focus: #3847b8;

  --font-prose: "Newsreader", "Iowan Old Style", Georgia, serif;
  --font-ui: "Instrument Sans", system-ui, sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, monospace;

  --radius: 6px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12181f;
    --sheet: #1a222b;
    --rule: #2c3845;
    --ink: #e2e8ee;
    --graphite: #93a1af;
    --round: #9aa6ff;
    --round-soft: #262d5a;
    --insert: #86d9c7;
    --insert-bg: #1b3d37;
    --delete: #f2a7c0;
    --delete-bg: #43202d;
    --warn: #f0c56a;
    --warn-bg: #3b2f14;
    --focus: #9aa6ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.5 var(--font-ui);
}

a { color: inherit; text-underline-offset: 3px; }
a:hover { color: var(--round); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}

/* -- Top bar ------------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px max(16px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid var(--rule);
}
.brand {
  font: italic 500 21px/1 var(--font-prose);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.brand span { color: var(--round); font-style: normal; }
.topnav { display: flex; gap: 18px; flex: 1; }
.topnav a { text-decoration: none; color: var(--graphite); font-weight: 500; }
.topnav a[aria-current="page"], .topnav a:hover { color: var(--ink); }
.whoami { display: flex; align-items: center; gap: 12px; color: var(--graphite); font-size: 14px; }

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 16px 64px;
}

/* -- Type ----------------------------------------------------------------- */

h1 {
  font: 500 30px/1.15 var(--font-prose);
  letter-spacing: -0.015em;
  margin: 0 0 6px;
}
h2 {
  font: 600 13px/1.3 var(--font-ui);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--graphite);
  margin: 0 0 10px;
}
.lede { color: var(--graphite); margin: 0 0 24px; max-width: 60ch; }
.data { font-family: var(--font-data); font-size: 13px; }
.muted { color: var(--graphite); }

/* -- Controls ------------------------------------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--sheet);
  color: var(--ink);
  font: 600 14px/1 var(--font-ui);
  text-decoration: none;
  cursor: pointer;
}
.button:hover { border-color: var(--graphite); color: var(--ink); }
.button.primary { background: var(--round); border-color: var(--round); color: var(--sheet); }
.button.primary:hover { filter: brightness(1.1); color: var(--sheet); }
.button.quiet { background: none; border-color: transparent; color: var(--graphite); padding: 0 8px; }
.button.quiet:hover { color: var(--ink); }
.button.danger:hover { border-color: var(--delete); color: var(--delete); }
.button[disabled] { opacity: 0.5; cursor: not-allowed; }

label { font-weight: 600; font-size: 14px; }
input[type="email"], input[type="password"], select, textarea {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--sheet);
  color: var(--ink);
  font: inherit;
  padding: 9px 11px;
}
textarea {
  font: 400 18px/1.6 var(--font-prose);
  padding: 16px 18px;
  resize: vertical;
}
select { width: auto; padding-right: 28px; }
.field { display: grid; gap: 6px; margin-bottom: 16px; }

.flash, .error-box {
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 20px;
}
.flash { background: var(--round-soft); }
.error-box { background: var(--delete-bg); color: var(--delete); }

/* -- Login ---------------------------------------------------------------- */

.login {
  max-width: 380px;
  margin: 12vh auto 0;
}
.login h1 { font-size: 40px; font-style: italic; }
.login form { margin-top: 28px; }
.login .button { width: 100%; margin-top: 4px; }

/* -- New Job --------------------------------------------------------------- */

.compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 28px;
  align-items: start;
}
.compose textarea { min-height: 440px; }
.counter { display: flex; justify-content: space-between; margin-top: 8px; }
.counter .over { color: var(--delete); font-weight: 600; }

.plan {
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 20px;
  position: sticky;
  top: 20px;
}
.plan fieldset { border: 0; padding: 0; margin: 0 0 18px; }
.plan legend { font-weight: 600; font-size: 14px; margin-bottom: 8px; padding: 0; }
.pause-options { display: flex; flex-wrap: wrap; gap: 6px; }
.pause-options label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 500 13px/1 var(--font-data);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
}
.pause-options label:has(input:checked) { border-color: var(--round); background: var(--round-soft); }
.pause-options label[hidden] { display: none; }
.estimate { border-top: 1px solid var(--rule); padding-top: 14px; margin-bottom: 16px; }
.estimate dl { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 0; }
.estimate dt { color: var(--graphite); }
.estimate dd { margin: 0; font-family: var(--font-data); font-size: 13px; text-align: right; }
.plan .button { width: 100%; }

/* -- The pass track ------------------------------------------------------- */

.track {
  list-style: none;
  display: flex;
  align-items: flex-start;
  gap: 0;
  margin: 22px 0 30px;
  padding: 0 0 6px;
  overflow-x: auto;
}
.track li { position: relative; flex: 0 0 auto; min-width: 72px; }
/* The line joining each pass to the one before it. */
.track li + li::before {
  content: "";
  position: absolute;
  top: 11px;
  right: calc(50% + 12px);
  width: calc(100% - 24px);
  height: 2px;
  background: var(--rule);
}
.track li.done + li.done::before { background: var(--graphite); }
.track a, .track .pending {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  padding: 0 6px;
}
.track .dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--graphite);
  background: var(--sheet);
  display: grid;
  place-items: center;
  font: 600 10px/1 var(--font-data);
}
.track .kind-round .dot { border-color: var(--round); background: var(--round); color: var(--sheet); }
.track .kind-edit .dot { border-color: var(--insert); background: var(--insert-bg); }
.track .kind-original .dot { background: var(--ink); border-color: var(--ink); }
.track .pending .dot { border-style: dashed; border-color: var(--rule); background: none; }
.track .running .dot { animation: breathe 1.6s ease-in-out infinite; }
.track .label { font: 500 12px/1.2 var(--font-data); color: var(--graphite); white-space: nowrap; }
.track [aria-current="true"] .label { color: var(--ink); font-weight: 700; }
.track [aria-current="true"] .dot { box-shadow: 0 0 0 4px var(--round-soft); }
/* A planned Checkpoint sits on the line after its Round, as a pause mark. */
.track li.pause-after::after {
  content: "‖";
  position: absolute;
  top: 1px;
  right: -7px;
  font: 700 16px/1 var(--font-data);
  color: var(--round);
  z-index: 1;
}

@keyframes breathe {
  50% { box-shadow: 0 0 0 6px var(--round-soft); }
}
@media (prefers-reduced-motion: reduce) {
  .track .running .dot { animation: none; }
}

/* -- Job page ------------------------------------------------------------- */

.job-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px 16px; }
.status {
  font: 600 12px/1 var(--font-data);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 5px 8px;
  border-radius: 4px;
  background: var(--rule);
}
.status.running, .status.queued { background: var(--round-soft); color: var(--round); }
.status.checkpoint { background: var(--warn-bg); color: var(--warn); }
.status.finished { background: var(--insert-bg); color: var(--insert); }

.desk {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 32px;
  align-items: start;
}

.sheet {
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 26px 30px 30px;
}
.sheet-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}
.sheet-head h2 { margin: 0; }
.compare { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--graphite); }

.prose {
  font: 400 19px/1.65 var(--font-prose);
  max-width: 68ch;
}
.para {
  position: relative;
  margin: 0 0 1.1em;
  white-space: pre-wrap;
}
.para-num {
  position: absolute;
  left: -30px;
  top: 0.35em;
  font: 500 11px/1 var(--font-data);
  color: var(--graphite);
}
.para.untouched { color: var(--graphite); }
ins, del { text-decoration: none; border-radius: 2px; padding: 0 1px; }
ins { background: var(--insert-bg); color: var(--insert); }
del { background: var(--delete-bg); color: var(--delete); text-decoration: line-through; text-decoration-thickness: 1px; }
.para-notes { margin: -0.6em 0 1.2em; display: flex; flex-wrap: wrap; gap: 6px; }
.note {
  font: 500 12px/1.3 var(--font-ui);
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--warn-bg);
  color: var(--warn);
}
.note.plain { background: var(--rule); color: var(--graphite); }

.clean { margin-top: 22px; border-top: 1px solid var(--rule); padding-top: 14px; }
.clean summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.clean .prose { margin-top: 14px; }

.editor { margin-top: 28px; }
.editor textarea { min-height: 320px; }
.editor-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }

.rail { display: grid; gap: 18px; position: sticky; top: 20px; }
.card {
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 18px;
}
.card p { margin: 0 0 10px; }
.card p:last-child { margin-bottom: 0; }
.card .actions { display: grid; gap: 8px; margin-top: 14px; }
.card form { margin: 0; }
.card .actions .button { width: 100%; }
.progress {
  height: 6px;
  border-radius: 3px;
  background: var(--rule);
  overflow: hidden;
  margin: 12px 0 8px;
}
.progress span { display: block; height: 100%; background: var(--round); transition: width 0.4s ease; }
.score { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.score b { font: 600 26px/1 var(--font-data); }
.score .verdict-preserved { color: var(--insert); }
.score .verdict-review { color: var(--warn); }
.score .verdict-drift { color: var(--delete); }
.warnings { margin: 0; padding-left: 18px; font-size: 14px; }
.warnings li { margin-bottom: 4px; }

/* -- History --------------------------------------------------------------- */

.history { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.history li {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 16px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--rule);
}
.history .excerpt {
  font: 400 17px/1.4 var(--font-prose);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
}
.history .meta { color: var(--graphite); font-size: 13px; white-space: nowrap; }
.empty { padding: 48px 0; text-align: center; color: var(--graphite); }

/* -- Small screens ------------------------------------------------------- */

@media (max-width: 880px) {
  .compose, .desk { grid-template-columns: minmax(0, 1fr); }
  .plan, .rail { position: static; }
  /* Status and Checkpoint actions first: the editor below can be long. */
  .rail { order: -1; }
  .sheet { padding: 20px 18px 22px; }
  .para-num { position: static; display: block; margin-bottom: 2px; }
  .topbar { gap: 14px; flex-wrap: wrap; }
  .history li { grid-template-columns: minmax(0, 1fr) auto; }
  .history .num, .history .meta.when { display: none; }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.hint { font-size: 13px; margin: 10px 0 0; }

/* -- Fix Proposals --------------------------------------------------------- */

.track .kind-fix .dot { border-color: var(--delete); background: var(--delete-bg); }

.proposal {
  margin: 0 0 26px;
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--delete);
  background: var(--paper);
}
.proposal h2 { margin-bottom: 12px; }
.proposal p { margin: 0 0 10px; }
.proposal-wait { display: flex; align-items: center; gap: 10px; }
.pulse {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--delete);
  animation: breathe-fix 1.6s ease-in-out infinite;
}
@keyframes breathe-fix { 50% { box-shadow: 0 0 0 6px var(--delete-bg); } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

.fixes { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.fix {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--sheet);
  border: 1px solid var(--rule);
  cursor: pointer;
  font-weight: 400;
}
.fix:has(input:not(:checked)) { opacity: 0.55; }
.fix input { margin-top: 5px; }
.fix-body { display: grid; gap: 3px; }
.fix-where { color: var(--graphite); font-size: 11px; }
.fix-diff { font: 400 17px/1.5 var(--font-prose); }
.fix-reason { color: var(--graphite); font-size: 14px; }
.proposal-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.proposal-actions form { margin: 0; }
