:root {
  color-scheme: light;
  --paper: #f6f0e3;
  --ink: #1b1a18;
  --brick: #8e4b3f;
  --pine: #2a5a4c;
  --gold: #b98a3b;
  --panel: rgba(255, 252, 246, 0.94);
  --border: rgba(27, 26, 24, 0.12);
  --muted: rgba(27, 26, 24, 0.7);
  --shadow: 0 24px 60px rgba(51, 37, 20, 0.16);
  --field: rgba(255, 255, 255, 0.9);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(185, 138, 59, 0.3), transparent 35%),
    radial-gradient(circle at right 20%, rgba(42, 90, 76, 0.16), transparent 28%),
    linear-gradient(180deg, #efe3c6 0%, var(--paper) 45%, #f9f5ed 100%);
}

.page-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 20px 72px;
}

.hero {
  padding: 16px 0 32px;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.hero-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brick);
  font-size: 0.82rem;
  font-weight: 700;
}

.hero h1 {
  margin: 0;
  max-width: 15ch;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.5rem, 5vw, 4.4rem);
  line-height: 0.95;
}

.lede {
  max-width: 62ch;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.panel-status {
  grid-column: span 4;
}

.panel-lookup {
  grid-column: span 8;
}

.panel-ops,
.panel-notes {
  grid-column: span 12;
}

.panel-tax {
  grid-column: span 12;
}

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

.panel-header h2,
.tool-card h3 {
  margin: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: rgba(27, 26, 24, 0.08);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 700;
}

.badge-soft {
  background: rgba(185, 138, 59, 0.18);
  color: #785612;
}

.badge-good {
  background: rgba(42, 90, 76, 0.16);
  color: var(--pine);
}

.badge-bad {
  background: rgba(142, 75, 63, 0.16);
  color: var(--brick);
}

.facts {
  margin: 0;
  display: grid;
  gap: 16px;
}

.facts div {
  display: grid;
  gap: 4px;
}

.facts dt {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.facts dd {
  margin: 0;
  font-size: 1rem;
  line-height: 1.5;
}

.tool-form {
  display: grid;
  gap: 14px;
}

.tool-form label {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.action-row,
.submit-row,
.field-action {
  display: flex;
  gap: 12px;
  align-items: end;
}

.grow {
  flex: 1;
}

input,
textarea {
  width: 100%;
  border: 1px solid rgba(27, 26, 24, 0.16);
  border-radius: 14px;
  padding: 0.92rem 1rem;
  background: var(--field);
  font-size: 1rem;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

.button {
  border: 0;
  border-radius: 14px;
  padding: 0.92rem 1.1rem;
  background: var(--ink);
  color: white;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.button-secondary {
  background: rgba(27, 26, 24, 0.12);
  color: var(--ink);
}

.ops-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.tool-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid rgba(27, 26, 24, 0.08);
}

.results {
  margin: 0;
  min-height: 70px;
  padding: 16px;
  border-radius: 16px;
  background: rgba(27, 26, 24, 0.04);
  white-space: pre-wrap;
  overflow-x: auto;
  line-height: 1.5;
}

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

.fact-list {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 10px;
  color: var(--muted);
  line-height: 1.6;
}

.result-stack {
  display: grid;
  gap: 12px;
}

.result-card {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(27, 26, 24, 0.08);
}

.result-card h4,
.result-card p,
.result-card dl {
  margin: 0;
}

.result-card p {
  color: var(--muted);
  margin-top: 6px;
  margin-bottom: 12px;
}

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

.result-card dt {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.result-card dd {
  margin: 4px 0 0;
}

.scanner-dialog {
  border: 0;
  border-radius: 22px;
  padding: 0;
  max-width: min(92vw, 720px);
  width: 100%;
  background: transparent;
}

.scanner-dialog::backdrop {
  background: rgba(27, 26, 24, 0.45);
}

.scanner-shell {
  background: rgba(248, 243, 233, 0.98);
  border: 1px solid rgba(27, 26, 24, 0.12);
  border-radius: 22px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.scanner-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

#scanner-video {
  width: 100%;
  min-height: 280px;
  max-height: 60vh;
  border-radius: 18px;
  background: #161412;
  object-fit: cover;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

@media (max-width: 980px) {
  .hero-top {
    flex-direction: column;
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .panel-status,
  .panel-lookup,
  .panel-tax,
  .panel-ops,
  .panel-notes {
    grid-column: span 12;
  }

  .ops-grid,
  .field-grid,
  .result-card dl {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .action-row,
  .field-action,
  .submit-row,
  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }
}
