/* PREPORTER — after-action-report (20th distinct aesthetic).
 *
 * Visual language: military-debrief / declassified-document.
 *   - Olive-drab + warm cardstock paper background
 *   - Redaction bars as classification markings
 *   - Monospace primary (IBM Plex Mono); Familjen Grotesk for body
 *     prose only inside the rendered draft
 *   - Heavy uppercase + numbered section headers ("01 MISSION SPEC")
 *   - Diagonal "DRAFT" watermark on the draft panel
 *   - High contrast: text #1b1d18 on #e7e1cd background; WCAG AAA
 *
 * Mobile-first (single column < 720), 2-column at >= 720, 3-column at >= 1280.
 */

:root {
  --paper:      #e7e1cd;      /* cardstock background */
  --paper-dim:  #d8d2bd;      /* sub-panel background */
  --ink:        #1b1d18;      /* body text */
  --ink-dim:    #4a4d42;
  --olive:      #4f5b3a;      /* primary accent */
  --olive-deep: #2f3724;
  --redact:     #1b1d18;      /* classification bars */
  --stamp:      #8a2a1f;      /* red stamp ink */
  --warn:       #b3712a;      /* amber */
  --ok:         #4f7a3e;
  --paper-edge: #c7c2af;

  --mono:  "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --sans:  "Familjen Grotesk", system-ui, -apple-system, sans-serif;
  --disp:  "Major Mono Display", "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background:
    /* subtle paper-grain texture via diagonal noise */
    repeating-linear-gradient(
      45deg,
      transparent 0 4px,
      rgba(0,0,0,0.012) 4px 5px
    ),
    var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--olive-deep); text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: var(--stamp); }

/* ---------- header ---------- */

.hdr {
  border-bottom: 2px solid var(--ink);
  padding: 16px 20px 12px;
}

.hdr-row { display: flex; align-items: center; gap: 16px; }

.classmark {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}
.classmark .bar {
  flex: 1;
  height: 18px;
  background: var(--redact);
}
.classmark .cls-text {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 11px;
  padding: 0 12px;
  white-space: nowrap;
  color: var(--ink);
}

.title-row {
  margin-top: 14px;
  align-items: flex-start;
}

.brand {
  margin: 0;
  font-family: var(--disp);
  font-size: clamp(28px, 5vw, 48px);
  letter-spacing: 0.18em;
  color: var(--ink);
  flex: 1;
}

.stamp {
  border: 2px solid var(--stamp);
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--stamp);
  background: rgba(138, 42, 31, 0.04);
  transform: rotate(-1deg);
  min-width: 240px;
}
.stamp-line { white-space: nowrap; letter-spacing: 0.04em; }
.stamp-line + .stamp-line { margin-top: 2px; }
#svc-status { font-weight: 700; }

.subtitle {
  margin: 14px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-dim);
  letter-spacing: 0.04em;
}

/* ---------- grid ---------- */

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 16px 20px 24px;
}
@media (min-width: 720px) {
  .grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "input    pipeline"
      "draft    draft"
      "recent   recent";
  }
  .input-panel    { grid-area: input; }
  .pipeline-panel { grid-area: pipeline; }
  .draft-panel    { grid-area: draft; }
  .recent-panel   { grid-area: recent; }
}
@media (min-width: 1280px) {
  .grid {
    grid-template-columns: 1.2fr 0.8fr 1.4fr;
    grid-template-areas:
      "input    pipeline draft"
      "recent   recent   draft";
  }
}

/* ---------- panels ---------- */

.panel {
  background: var(--paper-dim);
  border: 1.5px solid var(--ink);
  padding: 14px 16px 16px;
  position: relative;
}
.panel::before {
  /* corner stamp tab */
  content: "";
  position: absolute;
  top: -1.5px;
  right: -1.5px;
  width: 22px;
  height: 22px;
  background:
    linear-gradient(135deg, transparent 50%, var(--ink) 50%);
}

.panel-title {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  border-bottom: 1px dashed var(--ink-dim);
  padding-bottom: 6px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.panel-title .num {
  font-family: var(--disp);
  color: var(--olive-deep);
  font-size: 15px;
}

.hint {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--ink-dim);
  letter-spacing: 0.02em;
}
.hint.small { font-size: 11px; margin-top: 8px; }

/* ---------- form fields ---------- */

.field { display: block; margin-bottom: 10px; }
.lab {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--olive-deep);
  margin-bottom: 4px;
}
textarea, input[type="text"] {
  width: 100%;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  border-radius: 0;
  resize: vertical;
}
textarea:focus, input[type="text"]:focus {
  outline: 2px solid var(--olive);
  outline-offset: 1px;
}

.opt-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 540px) {
  .opt-row { grid-template-columns: 1fr 1fr; }
}

/* ---------- buttons ---------- */

.btn {
  background: var(--olive);
  color: #f1eedf;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.14em;
  padding: 9px 14px;
  border: 1.5px solid var(--olive-deep);
  cursor: pointer;
  text-transform: uppercase;
  transition: transform 0.06s ease;
}
.btn:hover:not(:disabled) {
  background: var(--olive-deep);
  transform: translateY(-1px);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.small { padding: 6px 10px; font-size: 11px; }
.btn.primary { background: var(--stamp); border-color: #5d1810; }
.btn.primary:hover:not(:disabled) { background: #5d1810; }

.action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.status {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-dim);
  letter-spacing: 0.06em;
}

.badge {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  padding: 4px 8px;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  text-transform: uppercase;
}
.badge[data-mode="live"]    { color: var(--ok);    border-color: var(--ok); }
.badge[data-mode="fixture"] { color: var(--warn);  border-color: var(--warn); }
.badge[data-mode="error"]   { color: var(--stamp); border-color: var(--stamp); }

/* ---------- pipeline list ---------- */

.pipeline {
  list-style: none;
  padding: 0;
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
}
.pipeline li {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px dotted var(--ink-dim);
}
.pipeline li:last-child { border-bottom: 0; }
.pipeline .dot {
  width: 10px; height: 10px;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  border-radius: 0;
}
.pipeline li[data-state="ok"]      .dot { background: var(--ok); }
.pipeline li[data-state="fail"]    .dot { background: var(--stamp); }
.pipeline li[data-state="running"] .dot {
  background: var(--warn);
  animation: blink 1.1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0.3; } }

.pipeline .step-name {
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 12px;
}
.pipeline .step-detail {
  font-size: 10px;
  color: var(--ink-dim);
  letter-spacing: 0.02em;
}

/* ---------- draft panel ---------- */

.draft-panel { position: relative; overflow: hidden; }
.draft-panel::after {
  content: "DRAFT";
  position: absolute;
  top: 50%;
  left: 50%;
  font-family: var(--disp);
  font-size: clamp(80px, 18vw, 200px);
  color: rgba(138, 42, 31, 0.07);
  letter-spacing: 0.2em;
  transform: translate(-50%, -50%) rotate(-22deg);
  pointer-events: none;
  z-index: 0;
  white-space: nowrap;
}

.draft-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}
.d-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-dim);
  letter-spacing: 0.04em;
}

.draft-view {
  background: var(--paper);
  border: 1.5px solid var(--ink);
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  max-height: 65vh;
  overflow: auto;
  position: relative;
  z-index: 1;
  white-space: pre-wrap;
  word-break: break-word;
}
.draft-view .placeholder {
  color: var(--ink-dim);
  font-style: italic;
}
.draft-view h1, .draft-view h2, .draft-view h3 {
  font-family: var(--mono);
  letter-spacing: 0.06em;
  margin: 14px 0 6px;
}
.draft-view h1 { font-size: 16px; border-bottom: 2px solid var(--ink); padding-bottom: 4px; }
.draft-view h2 { font-size: 14px; color: var(--olive-deep); }
.draft-view h3 { font-size: 13px; }
.draft-view code, .draft-view pre {
  background: var(--paper-dim);
  padding: 1px 4px;
  border: 1px solid var(--paper-edge);
}
.draft-view pre { padding: 8px 10px; overflow-x: auto; }
.draft-view ul { padding-left: 18px; }
.draft-view li { margin: 2px 0; }

/* ---------- recent list ---------- */

.recent {
  list-style: none;
  padding: 0;
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
}
.recent li {
  display: grid;
  grid-template-columns: 60px 80px 1fr 90px;
  gap: 10px;
  align-items: center;
  padding: 7px 4px;
  border-bottom: 1px dotted var(--ink-dim);
  cursor: pointer;
}
.recent li:hover { background: var(--paper); }
.recent li[data-empty="1"], .recent .placeholder {
  grid-template-columns: 1fr;
  color: var(--ink-dim);
  font-style: italic;
  cursor: default;
}
.recent .r-id     { color: var(--olive-deep); font-weight: 700; }
.recent .r-status { letter-spacing: 0.1em; text-transform: uppercase; font-size: 11px; }
.recent .r-snip   { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent .r-date   { color: var(--ink-dim); font-size: 11px; text-align: right; }

/* ---------- footer ---------- */

.ftr {
  border-top: 2px solid var(--ink);
  padding: 12px 20px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-dim);
  letter-spacing: 0.06em;
}
.ftr a { color: var(--olive-deep); }

/* ---------- refine dialog ---------- */

dialog#refine-dialog {
  background: var(--paper-dim);
  border: 2px solid var(--ink);
  padding: 18px;
  min-width: 320px;
  max-width: 90vw;
  color: var(--ink);
  font-family: var(--mono);
}
dialog#refine-dialog::backdrop {
  background: rgba(27, 29, 24, 0.5);
}
.dlg-title {
  margin: 0 0 12px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border-bottom: 1px dashed var(--ink-dim);
  padding-bottom: 6px;
}
.refine-form { margin: 0; }
