.front-page {
  overflow: clip;
  overscroll-behavior: none;
  scroll-behavior: auto;
  color-scheme: dark;
}

.front {
  --front-bg: #15100b;
  --front-fg: #fff0dd;
  --front-soft: #d7bfa5;
  --front-accent: #edaa70;
  --front-line: #805634;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
  overflow: clip;
  color: var(--front-fg);
  background: var(--front-bg);
}

.front :focus-visible { outline: 2px solid var(--front-accent); outline-offset: 3px; }
.front button:disabled { cursor: default; opacity: .55; }
.front a, .front button, .front input { -webkit-tap-highlight-color: transparent; }
.desk-header, .desk-footer {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-inline: clamp(16px, 4vw, 68px);
}
.desk-header { min-height: 68px; border-bottom: 1px solid #ffffff22; }
.desk-brand { min-height: 44px; display: inline-flex; align-items: center; gap: 9px; font-size: 23px; letter-spacing: -.045em; }
.desk-brand img { width: 23px; height: 29px; object-fit: contain; }
.desk-brand strong { color: var(--front-accent); font-weight: 650; }
.desk-nav { display: flex; align-items: center; gap: 4px; }
.desk-nav a { display: grid; place-items: center; min-height: 44px; min-width: 60px; padding-inline: 12px; font-size: 14px; border-block-end: 1px solid transparent; }
.desk-nav a[aria-current] { color: var(--front-accent); border-block-end-color: currentColor; }
.desk-family, .desk-footer { color: var(--front-soft); font-size: 12px; }
.desk-footer { border-top: 1px solid #ffffff22; min-height: 36px; }
.desk-footer a { display: inline-grid; align-items: center; min-height: 30px; text-decoration: underline; text-underline-offset: 3px; }

.desk {
  position: relative;
  isolation: isolate;
  min-height: 0;
  overflow: clip;
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(325px, 480px);
  grid-template-rows: minmax(0, 1fr);
  align-items: center;
  gap: clamp(18px, 4.2vw, 82px);
  padding: 24px clamp(16px, 6vw, 100px);
}
.desk-art { position: absolute; inset: 0; z-index: -2; pointer-events: none; overflow: clip; }
.desk-art img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: 50% 48%;
  opacity: .9;
  transition: opacity .42s ease-out;
}
.desk-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #15100bee 0%, #15100bc9 30%, transparent 57%, #15100b75 100%),
    linear-gradient(0deg, #15100bb8, transparent 43%);
}
.desk[data-active="test"] .desk-art img { opacity: .64; }
.desk[data-active="brief"] .desk-art img,
.desk[data-active="research"] .desk-art img { opacity: .74; }
.desk-opening { min-width: 0; max-width: 690px; }
.desk-opening h1 { margin: 0 0 19px; font: 400 clamp(64px, 7vw, 113px)/.89 var(--serif); letter-spacing: -.047em; color: var(--front-fg); }
.desk-opening h1 em { display: block; color: var(--front-accent); }
.desk-opening p { margin: 0; max-width: 37ch; color: var(--front-soft); font-size: 16px; }
.desk-opening .desk-kicker { margin-bottom: 15px; color: var(--front-accent); font: 600 11px/1.5 var(--mono); letter-spacing: .07em; text-transform: uppercase; }

.desk-workspace { min-height: 0; max-height: 100%; overflow: auto; overscroll-behavior: contain; padding: 4px; scrollbar-color: #9b6746 #20160e; }
.desk-panel {
  padding: clamp(18px, 2vw, 29px);
  background: #241911f5;
  border: 1px solid var(--front-line);
  border-top-color: #cc8a59;
  box-shadow: 0 16px 45px #0006;
  font-size: 14px;
  animation: panel-in .23s ease-out both;
}
@keyframes panel-in { from { opacity: .76; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.panel-heading { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 0 12px; margin-bottom: 12px; }
.desk-panel h2, .desk-dialog h2 { font: 400 clamp(30px, 3.1vw, 48px)/.97 var(--serif); letter-spacing: -.025em; margin: 0; }
.desk-panel > p { color: var(--front-soft); margin: 0 0 11px; }
.panel-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 3px 15px; }
.desk-button, .desk-text, .desk-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 44px;
  font-weight: 650;
  font-size: 14px;
  cursor: pointer;
}
.desk-button { color: #21150c; background: #efb784; border: 1px solid #efb784; padding: 8px 12px; }
.desk-button:hover { background: #fbd1a9; }
.desk-text { color: #f5ba89; background: transparent; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 4px; }
.desk-text:hover { color: #ffe0bf; }
.ingredients, .evidence-track { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.ingredients button {
  min-height: 57px;
  padding: 6px 5px;
  background: #2b1d14;
  color: var(--front-fg);
  border: 1px solid #88593b;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.25;
}
.ingredients button[aria-pressed="true"] { color: #21150e; background: #f0ceb1; border-color: #f0ceb1; }
.ingredients.flash button { animation: pieces-in .28s ease-out both; }
.ingredients.flash button:nth-child(2) { animation-delay: .03s; }
.ingredients.flash button:nth-child(3) { animation-delay: .06s; }
@keyframes pieces-in { from { opacity: .6; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.desk-panel .piece-detail { min-height: 3.1em; margin: 9px 0 8px; }
.desk-panel .draw-receipt { font-size: 12px; margin: 8px 0 0; }

.evidence-track { padding: 0; margin: 0; list-style: none; }
.evidence-track li { background: #37251a; border-top: 2px solid #bd8054; padding: 6px; color: var(--front-fg); transition: color .2s ease, background-color .2s ease; }
.evidence-track li span { display: block; color: var(--front-soft); font: 11px/1.4 var(--mono); }
.evidence-track li strong { font-size: 12px; }
.evidence-track .record-missing { border-top-style: dashed; border-color: #a5917c; color: var(--front-soft); background: #2d241d; }
.test-answer[data-support="unknown"] { border-left-color: #ad9d8b; background: #ad9d8b18; }
.evidence-toggle { display: flex; align-items: center; gap: 9px; min-height: 44px; cursor: pointer; }
.evidence-toggle input { flex: none; width: 19px; height: 19px; accent-color: #efb784; margin: 0; }
.test-answer { border-left: 2px solid #d5905e; padding: 6px 9px; background: #ffffff0b; }
.test-answer strong { color: #ffe2c3; }
.test-answer p { font-size: 13px; color: var(--front-soft); margin: 2px 0 0; line-height: 1.45; }
.research-routes { margin: 0 0 12px; }
.research-routes > div { border-top: 1px solid #ffffff26; padding: 7px 0; }
.research-routes dt { color: #f1bc91; font-weight: 700; }
.research-routes dd { margin: 0; color: var(--front-soft); }

.desk-panel form { margin: 0; }
.desk-panel form > label:not(.evidence-toggle), .desk-dialog label { display: block; color: var(--front-soft); margin: 5px 0 3px; font-weight: 600; }
.desk-panel textarea, .desk-dialog textarea, .desk-dialog select {
  display: block;
  width: 100%;
  border: 1px solid #a16c4a;
  background: #17110d;
  color: var(--front-fg);
  font: 400 16px/1.42 var(--sans);
  padding: 7px 9px;
  resize: vertical;
}
.brief-note { font-size: 12px; color: var(--front-soft); }

.front .desk-dialog {
  width: min(640px, calc(100% - 22px));
  max-height: calc(100dvh - 22px);
  padding: 0;
  border: 1px solid #b7825f;
  border-radius: 0;
  color: var(--front-fg);
  background: #261a12;
  overflow: hidden;
  box-shadow: 0 24px 80px #000a;
}
.desk-dialog[open] { display: flex; flex-direction: column; }
.desk-dialog::backdrop { background: #100b08d9; }
.desk-dialog header { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--front-line); padding: 10px 18px; }
.desk-dialog h2 { font-size: clamp(27px, 5vw, 41px); }
.desk-close { min-width: 44px; color: var(--front-fg); background: transparent; border: 1px solid var(--front-line); font-size: 25px; }
.dialog-body { overflow: auto; overscroll-behavior: contain; padding: 13px 18px 18px; color: var(--front-soft); font-size: 14px; }
.dialog-body p:last-child { margin-bottom: 0; }
.dialog-body select { min-height: 44px; margin-bottom: 10px; }
.dialog-body input[type=range] { width: 100%; min-height: 36px; accent-color: #edaa70; }
.dialog-body label output { color: var(--front-accent); }
.math-output { display: block; margin-block: 11px; }
.math-output strong { color: var(--front-fg); font-size: 26px; }
#math-pieces { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
#math-pieces i { width: 10px; height: 10px; background: #513d2d; border: 1px solid #976d50; }
#math-pieces .in-group { background: #edaa70; border-color: #edaa70; }
.desk-dialog .panel-actions { margin-top: 10px; }
.dialog-body .source-note { border-top: 1px solid var(--front-line); padding: 9px 0; }
.dialog-body summary { min-height: 31px; cursor: pointer; color: var(--front-fg); font-weight: 650; }
.dialog-body article { margin-top: 8px; }
.dialog-body .paper .micro-label { color: var(--front-accent); font-size: 10px; }
.dialog-body h2, .dialog-body h3 { margin: 12px 0 6px; }
.dialog-body h3 { color: var(--front-fg); }
.dialog-body a { color: #f5ba89; text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 760px) {
  .desk-header { display: grid; grid-template-columns: auto 1fr; gap: 1px 7px; min-height: 55px; padding-inline: 12px; }
  .desk-brand { gap: 4px; font-size: 16px; }
  .desk-brand img { width: 17px; height: 23px; }
  .desk-family, .desk-footer span:not(.visually-hidden) { display: none; }
  .desk-nav { display: grid; grid-template-columns: repeat(4, minmax(44px, 1fr)); gap: 1px; }
  .desk-nav a { min-width: 44px; padding-inline: 1px; font-size: 12px; }
  .desk { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, .74fr) minmax(0, 1fr); align-items: end; gap: 6px; padding: 12px 13px 7px; }
  .desk-art img { object-position: 62% 35%; }
  .desk-art::after { background: linear-gradient(90deg,#15100bdc,#15100b20 88%),linear-gradient(0deg,#15100b 1%,#15100b83 51%,transparent 90%); }
  .desk-opening { align-self: center; }
  .desk-opening h1 { font-size: clamp(38px, 12vw, 77px); margin-bottom: 8px; }
  .desk-opening p { font-size: 14px; line-height: 1.42; }
  .desk-opening .desk-kicker { margin-bottom: 7px; font-size: 10px; }
  .desk-workspace { align-self: end; }
  .desk-panel { padding: 12px; font-size: 13px; }
  .panel-heading { margin-bottom: 8px; }
  .panel-heading .desk-text { font-size: 12px; }
  .desk-footer { justify-content: end; min-height: 25px; padding-inline: 16px; }
  .desk-footer a { min-height: 26px; }
  .desk[data-active="brief"], .desk[data-active="test"] { grid-template-rows: minmax(0, .52fr) minmax(0, 1fr); }
}
@media (max-width: 760px) and (max-height: 690px) {
  .desk { grid-template-rows: minmax(0, .52fr) minmax(0, 1fr); }
  .desk[data-active="research"], .desk[data-active="brief"] {
    grid-template-rows: minmax(0, .27fr) minmax(0, 1fr);
  }
  .research-routes > div { padding-block: 5px; }
  .desk-opening h1 { font-size: clamp(31px, 9.5vw, 48px); }
  .desk-opening p:not(.desk-kicker) { display: none; }
}
@media (max-height: 475px) {
  .desk-header { min-height: 46px; }
  .desk-footer { display: none; }
  .desk { grid-template-columns: minmax(0, .9fr) minmax(0, 1.35fr); grid-template-rows: minmax(0, 1fr); gap: 9px; padding: 6px 12px; }
  .desk[data-active] { grid-template-rows: minmax(0, 1fr); }
  .desk-opening h1 { font-size: clamp(28px, 6vw, 54px); }
  .desk-panel { padding: 11px 14px; }
  .research-routes > div { padding: 4px 0; }
  .desk-panel h2 { font-size: 34px; }
  .desk-panel textarea { padding-block: 4px; }
}
