:root {
  color-scheme: light;
  --bg: #f6f3ed;
  --panel: #fffdf8;
  --ink: #191816;
  --muted: #6b665e;
  --line: #ded8cc;
  --accent: #1f7668;
  --accent-strong: #12483f;
  --warn: #9d4d24;
  --code: #23211e;
  --shadow: 0 18px 60px rgba(42, 35, 24, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.82), rgba(246, 243, 237, 0.96)),
    radial-gradient(circle at top left, rgba(31, 118, 104, 0.12), transparent 34rem);
  color: var(--ink);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button,
.file-button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  border-radius: 7px;
  min-height: 2.4rem;
  padding: 0 0.9rem;
  cursor: pointer;
}

button:hover,
.file-button:hover {
  border-color: var(--accent);
}

.shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
  margin: 0 0 6px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4.8rem);
  line-height: 0.95;
  margin-bottom: 0;
}

h2 {
  font-size: 1.2rem;
  margin-bottom: 0;
}

h3 {
  font-size: 0.92rem;
  margin-bottom: 12px;
}

.actions,
.step-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.file-button {
  display: inline-flex;
  align-items: center;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 118px;
  margin-bottom: 16px;
  border: 1px dashed #b9b0a1;
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.7);
  text-align: center;
}

.dropzone.dragging {
  border-color: var(--accent);
  background: rgba(31, 118, 104, 0.08);
}

.dropzone span {
  display: block;
  color: var(--muted);
  margin-top: 6px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.summary-grid article,
.timeline-panel,
.detail-panel,
.source-card,
.cap-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.summary-grid article {
  padding: 14px;
  min-width: 0;
}

.summary-grid span,
dt {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 4px;
}

.summary-grid strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(310px, 400px) 1fr;
  gap: 16px;
  min-height: 620px;
}

.timeline-panel,
.detail-panel {
  padding: 16px;
  min-width: 0;
}

.panel-heading,
.event-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.search {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.search span {
  color: var(--muted);
  font-size: 0.78rem;
}

.search input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  min-height: 2.35rem;
  padding: 0 0.75rem;
  background: #ffffff;
}

.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
  max-height: 530px;
  overflow: auto;
}

.timeline button {
  width: 100%;
  height: auto;
  text-align: left;
  padding: 10px;
  display: grid;
  gap: 4px;
}

.timeline button.active {
  border-color: var(--accent);
  background: #eaf5f2;
}

.timeline-meta {
  color: var(--muted);
  font-size: 0.76rem;
}

.timeline-op {
  font-weight: 700;
}

.checksum {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  max-width: 18rem;
  overflow-wrap: anywhere;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.source-card,
.cap-card {
  padding: 14px;
  box-shadow: none;
}

dl {
  margin: 0;
  display: grid;
  gap: 10px;
}

dd {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.empty-state {
  color: var(--muted);
}

.cap-line,
.kv-row,
.audit-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 9px 0;
}

.cap-line:last-child,
.kv-row:last-child,
.audit-row:last-child {
  border-bottom: 0;
}

.cap-timeline {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.cap-timeline button,
.source-row {
  width: 100%;
  height: auto;
  text-align: left;
  display: grid;
  gap: 4px;
  padding: 10px;
}

.cap-timeline span,
.source-row span,
.source-row em {
  color: var(--muted);
  font-size: 0.76rem;
  font-style: normal;
}

.source-map {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.source-row.active {
  border-color: var(--accent);
  background: #eaf5f2;
}

.why-panel {
  display: grid;
  gap: 2px;
}

.kv-row strong,
.cap-line strong {
  overflow-wrap: anywhere;
  text-align: right;
}

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.tab {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: 0;
}

.tab.active {
  color: #ffffff;
  border-color: var(--accent);
  background: var(--accent);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

pre {
  overflow: auto;
  max-height: 340px;
  padding: 14px;
  border-radius: 8px;
  background: var(--code);
  color: #f8f4ec;
  font-size: 0.82rem;
}

@media (max-width: 860px) {
  .topbar,
  .panel-heading,
  .event-title {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .timeline {
    max-height: 320px;
  }
}

@media (max-width: 520px) {
  .shell {
    width: min(100vw - 20px, 1440px);
    padding-top: 16px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .actions,
  .step-controls,
  .tabs {
    flex-wrap: wrap;
  }
}
