@font-face {
  font-family: 'Instrument Serif';
  src: url('/assets/InstrumentSerif-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
}

@font-face {
  font-family: 'Instrument Sans';
  src: url('/assets/InstrumentSans-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
}

@font-face {
  font-family: 'Instrument Sans';
  src: url('/assets/InstrumentSans-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
}

:root {
  --ink: #e7dcbe;
  --paper: #1d1a16;
  --dark: #131110;
  --cream: #f5efe0;
  --gold: #b68a2d;
  --gold-soft: #d9b768;
  --line: rgba(250, 236, 190, 0.2);
  --panel: #26201b;
  --panel-alt: #221d19;
  --text: #f6ecdc;
  --muted: #c4bda5;
  --ok: #2ea87c;
  --warn: #d89d2c;
  --bad: #b94a4a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--text);
  font-family: 'Instrument Sans', Arial, sans-serif;
  font-size: 16px;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
}

h1,
h2,
h3,
h4,
.serif {
  font-family: 'Instrument Serif', Georgia, serif;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--gold-soft);
  outline-offset: 2px;
}

#app {
  margin: 0 auto;
  max-width: 1200px;
  padding: 18px 22px 40px;
  min-width: 0;
  overflow-x: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  background: rgba(19, 17, 16, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  margin: 0 auto;
  max-width: 1200px;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 22px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand img {
  width: 132px;
  height: auto;
  max-height: 32px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  letter-spacing: 0.02em;
}

.brand-copy strong {
  font-size: 14px;
  display: inline-block;
}

.brand-copy .muted {
  font-size: 12px;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.period-switch {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  overflow: hidden;
  display: inline-flex;
}

.period-switch button {
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
}

.period-switch button[aria-pressed='true'] {
  background: var(--gold);
  color: var(--paper);
}

section {
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 16px;
}

.section-title {
  margin: 0 0 14px;
  font-size: 22px;
}

.grid {
  display: grid;
  gap: 12px;
}

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

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

.kpi {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-alt);
}

.kpi-value {
  font-size: 23px;
  font-weight: 700;
  color: var(--gold-soft);
}

.kpi-label {
  color: var(--muted);
  margin-top: 4px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-alt);
  color: var(--muted);
  font-size: 12px;
}

.tabs {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.tabs button {
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 9px 12px;
  font-size: 14px;
  cursor: pointer;
}

.tabs button[aria-pressed='true'] {
  background: var(--gold);
  color: var(--paper);
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 880px;
}

.table th,
.table td {
  border-bottom: 1px solid rgba(236, 227, 198, 0.2);
  text-align: left;
  padding: 8px;
  vertical-align: top;
}

.table th {
  color: var(--muted);
  font-weight: 700;
}

.table .mono {
  font-family: 'Courier New', monospace;
  font-size: 13px;
}

.summary-note {
  color: var(--muted);
  margin-top: 8px;
  font-size: 13px;
}

.lane-list {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.lane-list details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-alt);
}

.lane-list summary {
  cursor: pointer;
  padding: 12px;
  list-style: none;
}

.lane-list summary::-webkit-details-marker {
  display: none;
}

.lane-meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.lane-panel {
  padding: 0 12px 12px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

label {
  font-size: 13px;
  color: var(--muted);
}

select,
input {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-alt);
  color: var(--text);
  padding: 8px;
  font: inherit;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-alt);
  overflow: hidden;
}

.card button {
  all: unset;
  cursor: pointer;
  width: 100%;
  text-align: left;
}

.card .thumb {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  display: block;
  background: #000;
}

.card-body {
  padding: 9px;
}

.card-title {
  font-weight: 700;
  font-size: 14px;
}

.card-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.chip-row {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #2a2520;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--muted);
}

.chip.active {
  border-color: rgba(46, 168, 124, 0.65);
  color: #8be4be;
}

.chip.inactive {
  border-color: rgba(185, 74, 74, 0.55);
  color: #ffb5b5;
}

.no-attrib {
  color: var(--warn);
  font-weight: 700;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(12, 10, 9, 0.94);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.lightbox[open] {
  display: flex;
}

.lb-panel {
  width: min(1100px, 100%);
  min-width: 0;
  max-height: 94vh;
  overflow: auto;
  overflow-x: hidden;
  background: #1f1a16;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}

.lb-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.lb-head h2,
.lb-evidence,
.lb-evidence p,
.lb-evidence div {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.lb-media {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 12px;
  min-width: 0;
}

.lb-media > * {
  min-width: 0;
}

.lb-media img {
  width: 100%;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
}

.lb-evidence {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 10px;
}

.lb-evidence h3 {
  margin: 8px 0 6px;
  font-size: 16px;
}

.lb-actions {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.lb-actions button,
button.secondary {
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-alt);
  color: var(--text);
  padding: 8px 11px;
  cursor: pointer;
}

.lb-actions .danger {
  border-color: rgba(185, 74, 74, 0.7);
}

.decisions-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.decision-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-alt);
  padding: 10px;
}

.decision-section summary {
  cursor: pointer;
  font-weight: 700;
}

.row-item {
  border-top: 1px solid rgba(236, 227, 198, 0.18);
  padding: 8px 0;
}

.row-item:first-of-type {
  border-top: none;
}

.row-item-title {
  font-size: 14px;
}

.evidence-note {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.pattern-grid {
  display: grid;
  gap: 10px;
}

.pattern-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px;
  background: var(--panel-alt);
}

.pattern-card h4 {
  margin: 0 0 6px;
}

.pattern-card p {
  margin: 0;
  color: var(--muted);
}

.pattern-links {
  margin-top: 8px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.pattern-link {
  text-decoration: underline;
  color: #f3d9a4;
}

.evidence-section {
  display: grid;
  gap: 8px;
}

.footer {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

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

@media (max-width: 980px) {
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .lb-media {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  #app {
    padding: 12px 12px 28px;
  }

  .topbar-inner {
    padding: 10px 12px;
    align-items: flex-start;
    flex-direction: column;
  }

  .brand {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .brand img {
    width: 118px;
  }

  .grid-3,
  .gallery {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .table {
    min-width: 760px;
  }

  .lb-panel {
    padding: 10px;
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 12px);
  }

  .lightbox {
    padding: 6px;
  }

  .lb-head {
    align-items: flex-start;
  }

  .lb-head h2 {
    font-size: 18px;
    line-height: 1.2;
  }
}
