:root {
  --paper: #f3f6f5;
  --surface: #fbfdfc;
  --ink: #10282f;
  --deep: #173c47;
  --muted: #697b7e;
  --line: #ccd9d8;
  --scan: #128e92;
  --scan-soft: #d7eeee;
  --amber: #e29a31;
  --danger: #b5483f;
  --shadow: 0 18px 60px rgb(16 40 47 / 10%);
  color: var(--ink);
  background: var(--paper);
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgb(18 142 146 / 3%) 1px, transparent 1px) 0 0 / 42px 42px,
    linear-gradient(rgb(18 142 146 / 3%) 1px, transparent 1px) 0 0 / 42px 42px,
    var(--paper);
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid rgb(18 142 146 / 28%);
  outline-offset: 3px;
}
[hidden] { display: none !important; }

.shell {
  width: min(1480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  border-inline: 1px solid rgb(204 217 216 / 72%);
  background: rgb(243 246 245 / 88%);
}

.topbar {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px clamp(20px, 4vw, 58px);
  border-bottom: 1px solid var(--line);
  background: rgb(251 253 252 / 86%);
  backdrop-filter: blur(14px);
}

.brand, .engine-state, .upload-footer, .pane-heading, .job-row,
.detail-header, .artifact-actions, .metric-grid {
  display: flex;
  align-items: center;
}
.brand { gap: 14px; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid var(--deep);
  color: var(--deep);
  font: 700 0.78rem/42px ui-monospace, "SFMono-Regular", Consolas, monospace;
  text-align: center;
}
.brand-mark span:last-child { color: white; background: var(--deep); }
.eyebrow {
  margin: 0 0 4px;
  color: var(--scan);
  font: 700 0.68rem/1.2 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0.14em;
}
.brand h1, .pane-heading h2, .detail-header h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
}

.engine-state { gap: 10px; min-width: 190px; justify-content: flex-end; }
.engine-state strong, .engine-state small { display: block; }
.engine-state strong { font-size: 0.82rem; }
.engine-state small {
  margin-top: 2px;
  color: var(--muted);
  font: 0.68rem/1.2 ui-monospace, "SFMono-Regular", Consolas, monospace;
}
.state-dot, .job-status {
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgb(226 154 49 / 16%);
}
.state-dot { width: 9px; height: 9px; }
.state-dot.ready, .job-status.succeeded {
  background: var(--scan);
  box-shadow: 0 0 0 4px rgb(18 142 146 / 14%);
}
.state-dot.offline, .job-status.failed {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgb(181 72 63 / 13%);
}

.intro-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(440px, 1.2fr);
  gap: clamp(28px, 6vw, 90px);
  align-items: center;
  padding: clamp(42px, 6vw, 92px) clamp(20px, 6vw, 92px);
  border-bottom: 1px solid var(--line);
}
.intro-copy h2 {
  max-width: 650px;
  margin: 12px 0 24px;
  font: 500 clamp(2.2rem, 5vw, 5rem)/0.98 "Iowan Old Style", Baskerville, Georgia, serif;
  letter-spacing: -0.045em;
}
.intro-copy h2 em { color: var(--scan); font-weight: 500; }
.intro-note {
  max-width: 610px;
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.75;
}
code {
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--deep);
  background: var(--scan-soft);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.86em;
}

.upload-panel {
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.dropzone {
  min-height: 230px;
  display: grid;
  grid-template-columns: 125px 1fr;
  align-items: center;
  gap: 28px;
  padding: 30px;
  border: 1px dashed #96b5b5;
  background: linear-gradient(135deg, rgb(18 142 146 / 5%), transparent 52%), #f8fbfa;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}
.dropzone.dragging { border-color: var(--scan); background: var(--scan-soft); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-copy strong, .drop-copy small { display: block; }
.drop-copy strong { font: 500 1.65rem/1.1 "Iowan Old Style", Baskerville, Georgia, serif; }
.drop-copy small { margin-top: 10px; color: var(--muted); line-height: 1.5; }

.scan-stack { position: relative; width: 108px; height: 126px; }
.scan-stack i {
  position: absolute;
  width: 76px;
  height: 100px;
  border: 1px solid #7da3a5;
  background: repeating-linear-gradient(to bottom, transparent 0 9px, #d8e4e3 9px 10px), white;
}
.scan-stack i:nth-child(1) { top: 0; left: 30px; opacity: 0.42; }
.scan-stack i:nth-child(2) { top: 12px; left: 16px; opacity: 0.68; }
.scan-stack i:nth-child(3) { top: 24px; left: 2px; }
.scan-stack b {
  position: absolute;
  z-index: 2;
  left: -4px;
  top: 34px;
  width: 88px;
  height: 2px;
  background: var(--scan);
  box-shadow: 0 0 12px var(--scan);
  animation: scan 2.4s ease-in-out infinite;
}
@keyframes scan {
  0%, 100% { transform: translateY(0); opacity: 0.35; }
  50% { transform: translateY(78px); opacity: 1; }
}

.upload-footer {
  justify-content: space-between;
  gap: 18px;
  min-height: 62px;
  padding: 12px 6px 0 14px;
}
#selectionLabel {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.button {
  min-height: 39px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: white;
  padding: 8px 15px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 120ms ease, background 120ms ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: 0.45; }
.button.primary { border-color: var(--deep); color: white; background: var(--deep); }
.button.primary:hover:not(:disabled) { background: var(--scan); }
.button.quiet {
  min-height: 34px;
  padding: 6px 11px;
  color: var(--muted);
  background: transparent;
}
.error-text {
  min-height: 1.2em;
  margin: 4px 14px 0;
  color: var(--danger);
  font-size: 0.8rem;
}

.notice-text {
  min-height: 1.2em;
  margin: 0 22px 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.pane-actions { display: flex; align-items: center; gap: 8px; }
select.button.quiet { appearance: auto; padding-right: 8px; }

.workbench {
  min-height: 520px;
  display: grid;
  grid-template-columns: minmax(320px, 40%) minmax(0, 1fr);
  background: var(--surface);
}
.queue-pane { border-right: 1px solid var(--line); }
.pane-heading, .detail-header {
  min-height: 76px;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
}
.job-list { max-height: 680px; overflow: auto; }
.job-row {
  width: 100%;
  min-height: 76px;
  gap: 14px;
  border: 0;
  border-bottom: 1px solid #e3eae9;
  background: transparent;
  padding: 14px 24px;
  text-align: left;
  cursor: pointer;
}
.job-row:hover, .job-row.selected { background: #edf5f4; }
.job-row.selected { box-shadow: inset 3px 0 var(--scan); }
.job-status { width: 8px; height: 8px; }
.job-status.running { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.5); } }
.job-main { min-width: 0; flex: 1; }
.job-main strong, .job-main small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.job-main strong { font-size: 0.88rem; }
.job-main small { margin-top: 5px; color: var(--muted); font-size: 0.74rem; }
.job-progress {
  color: var(--scan);
  font: 700 0.75rem/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
}
.detail-pane { min-width: 0; }
.empty-state {
  min-height: 480px;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 32px;
  color: var(--muted);
  text-align: center;
}
.empty-state span { color: var(--scan); font: 4rem/1 "Iowan Old Style", Georgia, serif; }
.empty-state h2 {
  margin: 12px 0 6px;
  color: var(--ink);
  font: 500 1.5rem/1.2 "Iowan Old Style", Georgia, serif;
}
.empty-state p { margin: 0; }
.detail-body { padding: clamp(24px, 5vw, 60px); }
.progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 99px;
  background: #e1e9e8;
}
.progress-track span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--scan);
  transition: width 300ms ease;
}
.progress-caption {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 9px 0 32px;
  color: var(--muted);
  font-size: 0.78rem;
}
.metric-grid {
  align-items: stretch;
  gap: 1px;
  margin-bottom: 30px;
  border: 1px solid var(--line);
  background: var(--line);
}
.metric { flex: 1; min-width: 0; padding: 18px; background: var(--surface); }
.metric span, .metric strong { display: block; }
.metric span {
  color: var(--muted);
  font: 0.67rem/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: 0.08em;
}
.metric strong { margin-top: 8px; font: 500 1.55rem/1 "Iowan Old Style", Georgia, serif; }
.artifact-card, .failure-card, .warning-card {
  padding: 22px;
  border: 1px solid var(--line);
  background: #f7faf9;
}
.warning-card {
  border-color: #e4c465;
  background: #fdf8ea;
}
.artifact-card h3, .failure-card h3, .warning-card h3 {
  margin: 0 0 8px;
  font: 500 1.2rem/1.2 "Iowan Old Style", Georgia, serif;
}
.artifact-card p, .failure-card p, .warning-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.detail-actions { display: flex; align-items: center; gap: 10px; }
.detail-header h2 { overflow-wrap: anywhere; }

.preview-card {
  padding: 22px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.preview-card h3 {
  margin: 18px 0 10px;
  font: 500 1.05rem/1.2 "Iowan Old Style", Georgia, serif;
}
.preview-card h3:first-of-type { margin-top: 10px; }
.preview-hint { margin: 8px 0 0; color: var(--muted); font-size: 0.82rem; }

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}
.thumb {
  margin: 0;
  border: 1px solid var(--line);
  background: white;
  padding: 4px;
  cursor: zoom-in;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.thumb:hover { border-color: var(--scan); }
.thumb-broken { opacity: 0.4; }

.preview-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.preview-counter { color: var(--muted); font-size: 0.8rem; }
.preview-page-host {
  border: 1px solid var(--line);
  background: white;
  padding: 20px 22px;
  max-height: 560px;
  overflow: auto;
}

.md-preview { font-size: 0.88rem; line-height: 1.7; }
.md-preview .md-heading {
  margin: 14px 0 8px;
  font: 500 1.1em/1.25 "Iowan Old Style", Georgia, serif;
}
.md-preview .md-para { margin: 0 0 10px; overflow-wrap: anywhere; }
.md-preview .md-quote {
  margin: 10px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--amber);
  background: #fdf8ea;
  color: var(--muted);
}
.md-preview .md-code {
  margin: 10px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 0.82em;
  overflow-x: auto;
  white-space: pre-wrap;
}
.md-preview hr { border: 0; border-top: 1px dashed var(--line); margin: 14px 0; }
.md-table-wrap { overflow-x: auto; margin: 10px 0; }
.md-table { border-collapse: collapse; font-size: 0.86em; min-width: 50%; }
.md-table th, .md-table td {
  border: 1px solid var(--line);
  padding: 5px 10px;
  text-align: left;
  vertical-align: top;
}
.md-table th { background: var(--scan-soft); font-weight: 600; }
.md-figure { margin: 12px 0; text-align: center; }
.md-figure img { max-width: 100%; border: 1px solid var(--line); cursor: zoom-in; }
.md-figure figcaption { margin-top: 6px; color: var(--muted); font-size: 0.78rem; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 4vh 4vw;
  background: rgb(16 40 47 / 82%);
  cursor: zoom-out;
}
.lightbox img {
  max-width: 100%;
  max-height: 88%;
  background: white;
  box-shadow: var(--shadow);
}
.lightbox-caption { margin: 0; color: white; font-size: 0.8rem; opacity: 0.85; }
.artifact-actions { flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.auth-gate {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgb(16 40 47 / 72%);
  backdrop-filter: blur(12px);
}
.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  padding: 34px;
  border: 1px solid #9bb5b6;
  background: var(--surface);
  box-shadow: 0 30px 90px rgb(0 0 0 / 24%);
}
.auth-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--deep);
  font: 700 0.8rem/1 ui-monospace, monospace;
}
.auth-card h1 { margin: 6px 0; font: 500 2rem/1.1 "Iowan Old Style", Georgia, serif; }
.auth-card p { margin: 0; color: var(--muted); }
.auth-card label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}
.auth-card input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 9px 11px;
  color: var(--ink);
  background: white;
}
.no-jobs { padding: 44px 24px; color: var(--muted); text-align: center; }

@media (max-width: 850px) {
  .intro-grid, .workbench { grid-template-columns: 1fr; }
  .queue-pane { border-right: 0; border-bottom: 1px solid var(--line); }
  .intro-grid { gap: 36px; }
  .intro-copy h2 br { display: none; }
}
@media (max-width: 560px) {
  .topbar { align-items: flex-start; }
  .engine-state small { display: none; }
  .dropzone { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .upload-footer, .metric-grid { align-items: stretch; flex-direction: column; }
  .button.primary { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
