:root {
  color-scheme: light;
  --ink: #14272c;
  --muted: #566b70;
  --paper: #fffef9;
  --wash: #edf2ef;
  --deep: #102b35;
  --deep-2: #173f49;
  --teal: #2f746f;
  --teal-soft: #dceae5;
  --amber: #a86412;
  --amber-soft: #faecd5;
  --red: #a33b32;
  --red-soft: #f7e0dc;
  --green: #32704c;
  --green-soft: #dfeee4;
  --line: #d7e0dc;
  --shadow: 0 18px 50px rgb(16 43 53 / 8%);
  --radius: 20px;
  --content: 1180px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(circle at 100% 0, rgb(47 116 111 / 11%), transparent 28rem),
    linear-gradient(180deg, #f8faf7 0, var(--wash) 100%);
}
button, input, select { font: inherit; }
a { color: inherit; }
button, .button { min-height: 44px; }
:focus-visible { outline: 3px solid #e59a36; outline-offset: 3px; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  color: white;
  background: var(--deep);
  border-radius: 10px;
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 76px;
  padding: 12px max(20px, calc((100vw - var(--content)) / 2));
  color: #f8fffd;
  background: rgb(16 43 53 / 96%);
  border-bottom: 1px solid rgb(255 255 255 / 12%);
  backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 11px; margin-right: auto; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid rgb(255 255 255 / 30%); border-radius: 14px; color: #e7b566; font-weight: 850; letter-spacing: -.04em; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: .98rem; }
.brand small { color: #aac5c6; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
.primary-nav { display: flex; align-items: center; gap: 4px; }
.primary-nav a { padding: 9px 11px; border-radius: 10px; color: #c9dcda; font-size: .9rem; text-decoration: none; }
.primary-nav a:hover, .primary-nav a[aria-current="page"] { color: #fff; background: rgb(255 255 255 / 10%); }
.menu-button { display: none; padding: 8px 13px; color: #fff; background: transparent; border: 1px solid rgb(255 255 255 / 30%); border-radius: 10px; }

.workspace { width: min(var(--content), calc(100% - 32px)); min-height: calc(100vh - 170px); margin: 0 auto; padding: clamp(32px, 6vw, 76px) 0 80px; }
.loading-panel, .error-panel { padding: 56px; text-align: center; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.loading-dot { width: 18px; height: 18px; margin: 0 auto 14px; border-radius: 50%; background: var(--teal); animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .25; transform: scale(.75); } }

.hero { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr); gap: 24px; align-items: stretch; margin-bottom: 28px; }
.hero-main, .hero-side, .panel, .metric, .station-card, .knowledge-card, .question-card, .source-card {
  background: rgb(255 254 249 / 94%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero-main { position: relative; overflow: hidden; padding: clamp(30px, 6vw, 64px); color: white; background: linear-gradient(135deg, var(--deep), var(--deep-2)); border-color: transparent; }
.hero-main::after { content: ""; position: absolute; right: -100px; bottom: -150px; width: 340px; height: 340px; border: 60px solid rgb(255 255 255 / 5%); border-radius: 50%; }
.eyebrow { margin: 0 0 10px; color: var(--teal); font-size: .77rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.hero-main .eyebrow { color: #e8ba70; }
h1, h2, h3 { margin-top: 0; line-height: 1.12; letter-spacing: -.025em; }
h1 { max-width: 18ch; margin-bottom: 18px; font-size: clamp(2.3rem, 6vw, 4.7rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.15rem); }
h3 { font-size: 1.08rem; }
.hero-copy { max-width: 62ch; color: #d5e6e3; font-size: clamp(1rem, 1.5vw, 1.16rem); }
.hero-side { display: flex; flex-direction: column; justify-content: space-between; padding: 28px; }
.hero-side .big-number { display: block; margin: 10px 0 2px; color: var(--deep); font-size: 3.7rem; font-weight: 850; line-height: 1; }
.muted { color: var(--muted); }
.microcopy { color: var(--muted); font-size: .82rem; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 25px; }
.button, button.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 17px; border: 1px solid transparent; border-radius: 12px; font-weight: 760; text-decoration: none; cursor: pointer; }
.button-primary { color: white; background: var(--teal); }
.button-primary:hover { background: #285f5c; }
.button-secondary { color: var(--deep); background: #fff; border-color: var(--line); }
.button-quiet { color: var(--deep); background: var(--teal-soft); }
.button-danger { color: var(--red); background: var(--red-soft); }
.button[disabled], button[disabled] { opacity: .55; cursor: not-allowed; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 0 0 28px; }
.metric { padding: 20px; }
.metric strong { display: block; color: var(--deep); font-size: 1.8rem; }
.metric span { color: var(--muted); font-size: .85rem; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 42px 0 16px; }
.section-head h2, .section-head p { margin-bottom: 0; }
.section-head p { max-width: 62ch; color: var(--muted); }
.panel { padding: clamp(22px, 4vw, 36px); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.station-card, .knowledge-card, .source-card { padding: 22px; }
.station-card { display: flex; flex-direction: column; min-height: 220px; }
.station-card h3 { margin-bottom: 8px; }
.station-number { color: var(--teal); font-size: .78rem; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.station-card ul { margin: 10px 0 18px; padding-left: 20px; color: var(--muted); font-size: .9rem; }
.station-card .status-row { margin-top: auto; }
.status-row, .tag-row { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.tag, .status { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 9px; border-radius: 999px; font-size: .72rem; font-weight: 800; letter-spacing: .035em; text-transform: uppercase; }
.tag-law { color: #5a3e8b; background: #ece4f8; }
.tag-procedure { color: #7a530e; background: var(--amber-soft); }
.tag-safety { color: #226349; background: var(--green-soft); }
.tag-practice { color: #315d73; background: #dfedf3; }
.status-published, .status-verified { color: var(--green); background: var(--green-soft); }
.status-researching { color: var(--amber); background: var(--amber-soft); }
.status-inventory, .status-draft { color: var(--muted); background: #edf0ee; }
.critical { color: var(--red); background: var(--red-soft); }

.knowledge-card { display: grid; gap: 14px; }
.knowledge-card .canonical { padding: 18px; background: #f1f6f3; border-left: 4px solid var(--teal); border-radius: 0 12px 12px 0; }
.knowledge-card details { border-top: 1px solid var(--line); padding-top: 12px; }
.knowledge-card summary { font-weight: 760; cursor: pointer; }
.knowledge-card ul { padding-left: 22px; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.filter-bar label { display: grid; gap: 5px; color: var(--muted); font-size: .78rem; font-weight: 760; }
.filter-bar select, .filter-bar input { min-width: 190px; min-height: 44px; padding: 9px 11px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 10px; }

.flashcard { min-height: 360px; perspective: 1000px; }
.flashcard-inner { position: relative; display: grid; min-height: 360px; transition: transform .5s; transform-style: preserve-3d; }
.flashcard.is-flipped .flashcard-inner { transform: rotateY(180deg); }
.flash-face { grid-area: 1 / 1; display: flex; flex-direction: column; justify-content: center; padding: clamp(28px, 7vw, 70px); background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); backface-visibility: hidden; }
.flash-back { transform: rotateY(180deg); background: #f2f8f4; }
.flash-face h2 { max-width: 24ch; }

.question-card { padding: clamp(24px, 5vw, 44px); }
.question-meta { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 20px; color: var(--muted); font-size: .82rem; }
.choice-list { display: grid; gap: 10px; margin: 24px 0; }
.choice { display: grid; grid-template-columns: 26px 1fr; gap: 11px; align-items: start; width: 100%; padding: 15px; color: var(--ink); text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.choice:hover { border-color: var(--teal); }
.choice[aria-pressed="true"] { background: var(--teal-soft); border-color: var(--teal); }
.choice-marker { display: grid; place-items: center; width: 26px; height: 26px; border: 1px solid currentColor; border-radius: 50%; font-size: .78rem; font-weight: 800; }
.feedback { margin-top: 20px; padding: 18px; border-radius: 14px; }
.feedback-correct { color: #245b3e; background: var(--green-soft); }
.feedback-incorrect { color: #84332d; background: var(--red-soft); }
.progress-track { height: 9px; overflow: hidden; background: #dfe7e3; border-radius: 999px; }
.progress-track > span { display: block; height: 100%; background: var(--teal); border-radius: inherit; }

.source-card a { color: var(--teal); font-weight: 760; }
.source-card dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 16px 0 0; font-size: .88rem; }
.source-card dt { color: var(--muted); }
.source-card dd { margin: 0; }
.notice { padding: 16px 18px; color: #6a4c18; background: var(--amber-soft); border: 1px solid #e8cc9f; border-radius: 13px; }
.danger-notice { color: #7c312a; background: var(--red-soft); border-color: #e8bab4; }
.empty { padding: 36px; color: var(--muted); text-align: center; border: 1px dashed #bac8c3; border-radius: 15px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; }

.site-footer { display: flex; justify-content: space-between; gap: 24px; width: min(var(--content), calc(100% - 32px)); margin: 0 auto; padding: 26px 0 40px; color: var(--muted); border-top: 1px solid var(--line); font-size: .8rem; }
.site-footer p { margin: 0; max-width: 70ch; }

@media (max-width: 900px) {
  .menu-button { display: inline-flex; }
  .primary-nav { position: absolute; top: 68px; right: 16px; left: 16px; display: none; flex-direction: column; align-items: stretch; padding: 10px; color: white; background: var(--deep); border: 1px solid rgb(255 255 255 / 14%); border-radius: 14px; box-shadow: 0 24px 50px rgb(0 0 0 / 24%); }
  .primary-nav.is-open { display: flex; }
  .hero { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .site-header { min-height: 68px; }
  .brand strong { font-size: .86rem; }
  .brand small { display: none; }
  .workspace { width: min(100% - 22px, var(--content)); padding-top: 26px; }
  .hero-main, .hero-side, .panel, .question-card { border-radius: 16px; }
  .metrics, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .section-head { align-items: start; flex-direction: column; }
  .filter-bar { display: grid; }
  .filter-bar select, .filter-bar input { width: 100%; }
  .site-footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media print {
  .site-header, .site-footer, .actions, .menu-button { display: none !important; }
  body { background: white; }
  .workspace { width: 100%; padding: 0; }
  .panel, .source-card, .knowledge-card { box-shadow: none; break-inside: avoid; }
}
