/* ============================================================
   Atelier — a quiet-luxury study instrument for Florida BDI.
   Palette: warm ivory paper, espresso ink, muted gold leaf.
   Type: Instrument Serif (display) + Inter (text) + JetBrains Mono (data).
   ============================================================ */

:root {
  --paper:      #f4f0e8;   /* warm ivory */
  --paper-2:    #ece6da;   /* deeper cream */
  --panel:      #faf7f1;   /* raised card */
  --ink:        #1c1a17;   /* espresso */
  --ink-soft:   #4a463f;   /* soft ink */
  --muted:      #8a8478;   /* warm grey */
  --line:       #ddd5c6;   /* hairline */
  --gold:       #9a7b3f;   /* muted gold leaf */
  --gold-soft:  #c4a86a;
  --green:      #5c7a5a;   /* sage — correct */
  --red:        #a4503f;   /* terracotta — incorrect */
  --shadow:     0 1px 2px rgba(28,26,23,.04), 0 8px 30px rgba(28,26,23,.06);
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { background: var(--paper); }

body {
  font-family: var(--sans);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
}

/* film-grain veil */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 9999; opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------------- masthead ---------------- */
.masthead {
  display: flex; align-items: center; justify-content: space-between;
  padding: 26px 5vw 20px;
  border-bottom: 1px solid var(--line);
}
.mast-left { display: flex; align-items: center; gap: 14px; }
.crest {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--gold); color: var(--gold);
  font-family: var(--serif); font-size: 22px; line-height: 1;
  padding-top: 2px;
}
.mast-title {
  font-family: var(--serif); font-size: 22px; letter-spacing: .2px;
  display: flex; flex-direction: column; line-height: 1.05;
}
.mast-title small {
  font-family: var(--sans); font-size: 9.5px; letter-spacing: .32em;
  text-transform: uppercase; color: var(--muted); font-weight: 500; margin-top: 4px;
}
.status {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .04em;
  color: var(--muted); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 999px; background: transparent;
}

/* ---------------- layout ---------------- */
.page { max-width: 920px; margin: 0 auto; padding: 0 5vw 90px; }

/* ---------------- hero ---------------- */
.hero { padding: 64px 0 40px; }
.eyebrow {
  font-size: 11px; letter-spacing: .3em; text-transform: uppercase;
  color: var(--gold); font-weight: 600; margin-bottom: 18px;
}
.display {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(42px, 7vw, 72px); line-height: .98;
  letter-spacing: -.01em; color: var(--ink); margin-bottom: 22px;
}
.display em { font-style: italic; color: var(--gold); }
.lede {
  max-width: 560px; color: var(--ink-soft); font-size: 16px;
  font-weight: 300; line-height: 1.65;
}

/* ---------------- ask panel ---------------- */
.ask-panel {
  margin-top: 40px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 4px;
  box-shadow: var(--shadow); padding: 26px;
  position: relative;
}
.ask-panel::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: linear-gradient(var(--gold), transparent);
}
.ask-top { display: flex; gap: 12px; align-items: flex-start; }
textarea {
  flex: 1; font-family: var(--serif); font-size: 19px; line-height: 1.5;
  color: var(--ink); background: transparent; border: none; resize: vertical;
  padding: 4px 0; min-height: 64px;
}
textarea::placeholder { color: var(--muted); font-style: italic; }
textarea:focus { outline: none; }
.mic {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  cursor: pointer; font-size: 18px; transition: .2s;
}
.mic:hover { border-color: var(--gold); color: var(--gold); }

.opt-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 20px 0 10px;
}
.opt-label {
  font-size: 11px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
}
.opt-label em { text-transform: none; letter-spacing: 0; font-style: italic; color: var(--muted); font-weight: 400; }
.textlink {
  background: none; border: none; color: var(--gold); cursor: pointer;
  font-family: var(--sans); font-size: 13px; font-weight: 500;
}
.textlink:hover { text-decoration: underline; }

.opt-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.opt-item { display: flex; gap: 8px; align-items: center; }
.opt-item .opt-input {
  flex: 1; font-family: var(--sans); font-size: 14px; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: 3px;
  padding: 11px 13px; transition: .2s;
}
.opt-item .opt-input:focus { outline: none; border-color: var(--gold); background: #fff; }
.opt-remove {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 20px; line-height: 1; padding: 4px 8px; transition: .2s;
}
.opt-remove:hover { color: var(--red); }

.ask-actions { margin-top: 6px; }
.btn-atelier {
  display: inline-flex; align-items: center; gap: 14px;
  background: var(--ink); color: var(--paper);
  border: 1px solid var(--ink); border-radius: 3px;
  padding: 14px 22px; font-family: var(--sans); font-size: 14px; font-weight: 500;
  letter-spacing: .02em; cursor: pointer; transition: .25s;
}
.btn-atelier:hover { background: #2a2723; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(28,26,23,.18); }
.btn-atelier:active { transform: translateY(0); }
.btn-atelier kbd {
  font-family: var(--mono); font-size: 10px; opacity: .6;
  border: 1px solid rgba(255,255,255,.2); padding: 2px 6px; border-radius: 3px;
}
.btn-atelier.sm { padding: 11px 18px; font-size: 13px; }

/* answer reveal */
.answer {
  margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line);
  animation: reveal .5s cubic-bezier(.2,.7,.2,1);
}
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.answer .verdict {
  font-size: 11px; letter-spacing: .2em; text-transform: uppercase; font-weight: 600;
  display: inline-block; padding: 4px 10px; border-radius: 2px; margin-bottom: 12px;
}
.verdict.consensus { color: var(--green); background: rgba(92,122,90,.1); }
.verdict.kb       { color: var(--green); background: rgba(92,122,90,.1); }
.verdict.llm      { color: var(--gold);  background: rgba(154,123,63,.1); }
.verdict.kb-override { color: var(--gold); background: rgba(154,123,63,.12); }
.verdict.none     { color: var(--red);   background: rgba(164,80,63,.1); }
.answer .big {
  font-family: var(--serif); font-size: 26px; line-height: 1.2; margin-bottom: 8px;
  color: var(--ink);
}
.answer .conf { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.answer .why { color: var(--ink-soft); font-size: 14px; font-weight: 300; margin-top: 4px; }
.answer .disagree {
  margin-top: 14px; padding: 12px 14px; background: rgba(154,123,63,.06);
  border-left: 2px solid var(--gold); font-size: 13px; color: var(--ink-soft);
  border-radius: 2px;
}

/* ---------------- modes ---------------- */
.modes {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  margin: 56px 0 8px; background: var(--line); border: 1px solid var(--line);
  border-radius: 4px; overflow: hidden;
}
.mode {
  display: flex; flex-direction: column; gap: 6px; text-align: left;
  background: var(--paper); border: none; padding: 22px 20px; cursor: pointer;
  font-family: var(--sans); color: var(--ink); transition: .25s; position: relative;
}
.mode:hover { background: var(--panel); }
.mode.active { background: var(--panel); }
.mode.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: var(--gold);
}
.mode-num {
  font-family: var(--serif); font-size: 15px; color: var(--gold); font-style: italic;
}
.mode-body { font-weight: 500; font-size: 14.5px; }
.mode-body small {
  display: block; font-size: 11.5px; color: var(--muted); font-weight: 400;
  margin-top: 3px; letter-spacing: .01em;
}

/* ---------------- cards (exam / results / archive) ---------------- */
.card {
  margin-top: 8px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 4px;
  box-shadow: var(--shadow); padding: 32px;
}
.card-title { font-family: var(--serif); font-size: 30px; font-weight: 400; line-height: 1.1; }
.meta { color: var(--muted); font-size: 13px; margin-top: 6px; }
.rule { height: 1px; background: var(--line); margin: 22px 0; }

.exam-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.timer-wrap { text-align: right; }
.timer-label {
  display: block; font-size: 10px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; margin-bottom: 4px;
}
.timer {
  font-family: var(--mono); font-size: 26px; font-weight: 500; color: var(--ink);
  letter-spacing: .02em;
}
.timer.low { color: var(--red); }

.progress { height: 2px; background: var(--line); border-radius: 2px; margin: 0 0 8px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: var(--gold); transition: width .4s cubic-bezier(.2,.7,.2,1); }

/* questions */
.q { padding: 22px 0; border-bottom: 1px solid var(--line); }
.q:last-of-type { border-bottom: none; }
.q .qtext {
  font-family: var(--serif); font-size: 19px; line-height: 1.4; margin-bottom: 14px;
  color: var(--ink);
}
.q .qnum {
  font-family: var(--mono); font-size: 11px; color: var(--gold); margin-right: 10px;
  vertical-align: middle;
}
.q .opts { display: flex; flex-direction: column; gap: 7px; }
.q label {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px; background: var(--paper); border: 1px solid var(--line);
  border-radius: 3px; cursor: pointer; transition: .2s; font-size: 14px;
}
.q label:hover { border-color: var(--gold-soft); background: #fff; }
.q label input {
  appearance: none; width: 16px; height: 16px; border: 1px solid var(--muted);
  border-radius: 50%; margin-top: 1px; flex: none; position: relative; transition: .2s;
}
.q label input:checked { border-color: var(--gold); }
.q label input:checked::after {
  content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--gold);
}
.q label.correct { border-color: var(--green); background: rgba(92,122,90,.06); }
.q label.wrong { border-color: var(--red); background: rgba(164,80,63,.06); }
.q label .hint-glow { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(154,123,63,.12); }

.exam-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; gap: 14px; }
.btn-line {
  background: none; border: 1px solid var(--line); color: var(--ink-soft);
  padding: 11px 16px; border-radius: 3px; cursor: pointer; font-family: var(--sans);
  font-size: 13px; font-weight: 500; transition: .2s;
}
.btn-line:hover { border-color: var(--gold); color: var(--gold); }

/* score */
.score { text-align: center; padding: 12px 0 26px; }
.score .num { font-family: var(--serif); font-size: 64px; line-height: 1; }
.score .num.pass { color: var(--green); }
.score .num.fail { color: var(--red); }
.score .label { color: var(--muted); font-size: 13px; letter-spacing: .06em; margin-top: 8px; text-transform: uppercase; }

.review .ri { padding: 18px 0; border-bottom: 1px solid var(--line); }
.review .ri:last-child { border-bottom: none; }
.ri .riq { font-family: var(--serif); font-size: 17px; margin-bottom: 8px; line-height: 1.4; }
.ri .riq .mark { font-family: var(--mono); margin-right: 8px; }
.ok { color: var(--green); }
.no { color: var(--red); }
.ri .ria { font-size: 13.5px; margin-top: 3px; }
.ri .ri-why { color: var(--muted); font-size: 13px; margin-top: 6px; font-style: italic; }

/* archive */
.archive-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.filter {
  font-family: var(--sans); font-size: 13.5px; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: 3px;
  padding: 11px 14px; min-width: 240px; transition: .2s;
}
.filter:focus { outline: none; border-color: var(--gold); background: #fff; }

.browse-list { display: grid; gap: 1px; background: var(--line); }
.bq { background: var(--panel); padding: 18px 20px; transition: .2s; }
.bq:hover { background: #fff; }
.bq .bq-topic {
  font-size: 10px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--gold); font-weight: 600;
}
.bq .bq-q { font-family: var(--serif); font-size: 18px; margin: 5px 0 6px; line-height: 1.35; }
.bq .bq-a { color: var(--green); font-size: 14px; font-weight: 500; }
.bq .bq-a::before { content: "✓ "; }
.bq .bq-why { color: var(--muted); font-size: 13px; margin-top: 4px; font-style: italic; }

/* colophon */
.colophon {
  border-top: 1px solid var(--line); padding: 32px 5vw;
  display: flex; align-items: center; gap: 14px;
  color: var(--muted); font-size: 12px; max-width: 920px; margin: 0 auto;
}
.colophon-mark {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--line); font-family: var(--serif); font-size: 15px; color: var(--muted);
}

.hidden { display: none !important; }

/* responsive */
@media (max-width: 720px) {
  .modes { grid-template-columns: 1fr; }
  .page { padding: 0 5vw 60px; }
  .hero { padding: 40px 0 28px; }
  .ask-panel { padding: 20px; }
  .btn-atelier kbd { display: none; }
  .exam-foot { flex-direction: column; align-items: stretch; }
  .archive-head { flex-direction: column; align-items: stretch; }
  .filter { min-width: 0; width: 100%; }
  .card { padding: 22px; }
  .masthead { padding: 18px 5vw; }
  .status { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}