/* ============================================================
   Facet — editorial luxury design system
   Warm paper canvas · ink + emerald + champagne · hairline rules
   ============================================================ */
:root {
  --bone: #f6f2ea;
  --paper: #fffdf9;
  --ink: #17140f;
  --ink-soft: #524d44;
  --ink-faint: #8a8276;
  --line: #e4ddce;
  --line-strong: #d4cab5;
  --emerald: #184a40;
  --emerald-bright: #1f6253;
  --champagne: #a9834e;
  --champagne-soft: #c7a574;
  --pos: #1f6253;
  --neg: #a2502f;
  --bg: var(--bone);
  --surface: var(--paper);
  --shadow: none;
  --maxw: 1180px;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, Segoe UI, sans-serif;
}
:root:not([data-theme="light"]) {
  @media (prefers-color-scheme: dark) {
    --bone: #14120e; --paper: #1b1813; --ink: #f1ebdf; --ink-soft: #c3bbab;
    --ink-faint: #8d8475; --line: #302b22; --line-strong: #40392d;
    --emerald: #6fcaae; --emerald-bright: #8bd9bf; --champagne: #d2ab77;
    --champagne-soft: #c7a574; --pos: #6fcaae; --neg: #e08a63;
  }
}
:root[data-theme="dark"] {
  --bone: #14120e; --paper: #1b1813; --ink: #f1ebdf; --ink-soft: #c3bbab;
  --ink-faint: #8d8475; --line: #302b22; --line-strong: #40392d;
  --emerald: #6fcaae; --emerald-bright: #8bd9bf; --champagne: #d2ab77;
  --champagne-soft: #c7a574; --pos: #6fcaae; --neg: #e08a63;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.08; letter-spacing: -0.01em; margin: 0; }
em { font-style: italic; }
a { color: inherit; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.86em;
  background: color-mix(in srgb, var(--champagne) 14%, transparent); padding: 1px 5px; border-radius: 3px; }

.skip { position: absolute; left: -999px; top: 0; background: var(--emerald); color: #fff; padding: 10px 16px; z-index: 50; }
.skip:focus { left: 8px; top: 8px; }

/* ---------- masthead ---------- */
.masthead {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 24px;
  padding: 14px clamp(16px, 5vw, 48px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.1) blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--emerald); }
.wordmark { font-family: var(--serif); font-size: 1.5rem; font-weight: 600; letter-spacing: 0.01em; color: var(--ink); }
.mark { color: var(--emerald); }
.nav { display: flex; gap: 26px; margin-left: auto; }
.nav a { text-decoration: none; color: var(--ink-soft); font-size: 0.9rem; font-weight: 500;
  padding-bottom: 2px; border-bottom: 1px solid transparent; transition: color .2s, border-color .2s; }
.nav a:hover { color: var(--ink); border-color: var(--champagne); }
.masthead-right { display: flex; align-items: center; gap: 14px; margin-left: 8px; }
.stat-chip { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.02em; color: var(--emerald);
  border: 1px solid var(--line-strong); border-radius: 999px; padding: 5px 11px; white-space: nowrap; }
.theme-toggle { width: 34px; height: 34px; border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: 999px; cursor: pointer; display: grid; place-items: center; }
.theme-dot { width: 14px; height: 14px; border-radius: 999px;
  background: radial-gradient(circle at 32% 32%, var(--champagne-soft), var(--emerald)); }

/* ---------- layout ---------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(16px, 5vw, 48px); }
.band { padding: clamp(56px, 8vw, 104px) 0; border-top: 1px solid var(--line); }
.band-alt { background:
  linear-gradient(var(--bg), var(--bg)) padding-box; position: relative; }
.band-alt::before { content: ""; position: absolute; inset: 0;
  background: color-mix(in srgb, var(--champagne) 5%, transparent); z-index: -1; }
.band-head { max-width: 640px; margin-bottom: clamp(32px, 5vw, 56px); }
.section-no { font-family: var(--serif); font-size: 0.95rem; color: var(--champagne); letter-spacing: 0.1em; }
.band-head h2 { font-size: clamp(1.9rem, 4vw, 2.9rem); margin: 6px 0 14px; }
.band-head p { color: var(--ink-soft); font-size: 1.05rem; max-width: 56ch; }

/* ---------- hero ---------- */
.hero { display: grid; grid-template-columns: 1.6fr 1fr; gap: clamp(32px, 6vw, 72px);
  align-items: center; padding: clamp(48px, 9vw, 120px) 0 clamp(40px, 6vw, 80px); }
.eyebrow { text-transform: uppercase; letter-spacing: 0.22em; font-size: 0.72rem; font-weight: 600;
  color: var(--champagne); margin: 0 0 18px; }
.hero h1 { font-size: clamp(2.6rem, 7vw, 5rem); letter-spacing: -0.02em; }
.hero h1 em { color: var(--emerald); }
.lede { color: var(--ink-soft); font-size: clamp(1.05rem, 1.6vw, 1.28rem); max-width: 54ch; margin: 24px 0 32px; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.hero-metrics { border-left: 1px solid var(--line-strong); padding-left: clamp(20px, 3vw, 36px);
  display: grid; gap: 18px; }
.metric-k { font-family: var(--serif); font-size: clamp(2rem, 4vw, 2.8rem); display: block; line-height: 1; }
.metric-l { color: var(--ink-faint); font-size: 0.8rem; letter-spacing: 0.04em; text-transform: uppercase; }
.rule { height: 1px; background: var(--line); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--sans); font-size: 0.95rem; font-weight: 500; text-decoration: none;
  padding: 13px 24px; border-radius: 2px; cursor: pointer; border: 1px solid transparent;
  transition: transform .15s, background .2s, color .2s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--emerald); color: #fbf8f1; }
.btn-primary:hover { background: var(--emerald-bright); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--champagne); }
.btn-small { padding: 10px 16px; font-size: 0.85rem; background: transparent;
  border-color: var(--line-strong); color: var(--ink); margin-top: 20px; }
.btn-small:hover { border-color: var(--champagne); }

/* ---------- appraisal ---------- */
.appraise-grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(24px, 4vw, 56px); align-items: start; }
.controls { display: grid; gap: 26px; }
.field { display: grid; gap: 10px; }
.field > span { display: flex; justify-content: space-between; align-items: baseline;
  font-size: 0.82rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; }
.field > span strong { font-family: var(--serif); font-size: 1.25rem; color: var(--ink);
  text-transform: none; letter-spacing: 0; font-weight: 500; font-variant-numeric: tabular-nums; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 2px;
  background: var(--line-strong); border-radius: 2px; outline-offset: 6px; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px;
  border-radius: 999px; background: var(--surface); border: 1.5px solid var(--emerald); cursor: pointer; }
input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 999px;
  background: var(--surface); border: 1.5px solid var(--emerald); cursor: pointer; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { font-family: var(--sans); font-size: 0.85rem; font-weight: 500; color: var(--ink-soft);
  background: transparent; border: 1px solid var(--line-strong); padding: 8px 13px; border-radius: 2px;
  cursor: pointer; transition: all .15s; font-variant-numeric: tabular-nums; }
.seg button:hover { border-color: var(--champagne); color: var(--ink); }
.seg button[aria-checked="true"] { background: var(--emerald); color: #fbf8f1; border-color: var(--emerald); }

.verdict { border: 1px solid var(--line-strong); background: var(--surface); padding: clamp(24px, 3vw, 38px);
  border-radius: 2px; position: sticky; top: 92px; }
.verdict-label { margin: 0; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--champagne); font-weight: 600; }
.verdict-price { font-family: var(--serif); font-size: clamp(3rem, 7vw, 4.6rem); margin: 8px 0 2px;
  line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.verdict-price .cur { color: var(--ink-faint); font-size: 0.45em; vertical-align: super; margin-right: 4px; }
.verdict-range { color: var(--ink-soft); margin: 0 0 24px; font-size: 0.98rem; }
.verdict-range strong { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }
.drivers { border-top: 1px solid var(--line); padding-top: 22px; }
.drivers-title { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint);
  font-weight: 600; margin: 0 0 16px; }
.drivers-title .muted { text-transform: none; letter-spacing: 0; color: var(--ink-faint); font-weight: 400; }
.driver-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 13px; }
.driver { display: grid; grid-template-columns: 92px 1fr auto; align-items: center; gap: 12px; font-size: 0.9rem; }
.driver-name { text-transform: capitalize; color: var(--ink-soft); }
.driver-track { height: 6px; background: var(--line); border-radius: 999px; position: relative; overflow: hidden; }
.driver-fill { position: absolute; top: 0; bottom: 0; border-radius: 999px; }
.driver-fill.pos { background: var(--pos); left: 50%; }
.driver-fill.neg { background: var(--neg); right: 50%; }
.driver-val { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 68px; text-align: right; }
.driver-val.pos { color: var(--pos); } .driver-val.neg { color: var(--neg); }

/* ---------- tables / ledger ---------- */
.deal-controls { display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 26px; }
.deal-controls label, .model-grid label { display: grid; gap: 6px; font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); font-weight: 600; }
select { font-family: var(--sans); font-size: 0.95rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); padding: 9px 12px; border-radius: 2px; cursor: pointer; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 2px; }
.ledger { width: 100%; border-collapse: collapse; min-width: 640px; }
.ledger th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-faint); font-weight: 600; padding: 14px 16px; border-bottom: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--champagne) 6%, transparent); white-space: nowrap; }
.ledger th.num { text-align: right; }
.ledger td { padding: 13px 16px; border-bottom: 1px solid var(--line); font-size: 0.92rem;
  color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ledger .cell-carat { font-weight: 600; color: var(--ink); }
.ledger tr:last-child td { border-bottom: none; }
.ledger tbody tr:hover td { background: color-mix(in srgb, var(--emerald) 5%, transparent); }
.ledger td.empty { text-align: center; color: var(--ink-faint); padding: 28px 16px; white-space: normal; }
.num { text-align: right; }
.badge { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  font-variant-numeric: tabular-nums; }
.badge.good { color: var(--pos); background: color-mix(in srgb, var(--pos) 14%, transparent); }
.badge.warn { color: var(--neg); background: color-mix(in srgb, var(--neg) 14%, transparent); }

/* stacked ledger for narrow screens (down to 320px) */
@media (max-width: 560px) {
  .table-wrap { overflow: visible; border: none; border-radius: 0; }
  .ledger { min-width: 0; display: block; }
  .ledger thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .ledger tbody { display: grid; gap: 12px; }
  .ledger tr { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px;
    border: 1px solid var(--line-strong); border-radius: 3px; padding: 14px 16px; }
  .ledger tbody tr:hover td { background: none; }
  .ledger td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    padding: 6px 0; border: none; white-space: nowrap; }
  .ledger td::before { content: attr(data-label); color: var(--ink-faint); font-size: 0.7rem;
    text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
  .ledger td.num { text-align: right; }
  .ledger .cell-carat { grid-column: 1 / -1; padding-bottom: 10px; margin-bottom: 4px;
    border-bottom: 1px solid var(--line); font-size: 1.05rem; }
  .ledger td.empty { grid-column: 1 / -1; display: block; padding: 24px 0; }
  .ledger td.empty::before { content: none; }
}

/* ---------- discover ---------- */
.search { display: flex; gap: 12px; max-width: 680px; }
.search input { flex: 1; font-family: var(--sans); font-size: 1rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); padding: 14px 18px; border-radius: 2px; }
.search input:focus { outline: 2px solid var(--emerald); outline-offset: 1px; border-color: transparent; }
.parsed { color: var(--ink-faint); font-size: 0.86rem; margin: 14px 0 26px; min-height: 1.2em; }
.parsed b { color: var(--emerald); font-weight: 600; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.stone-card { border: 1px solid var(--line-strong); border-radius: 2px; padding: 20px; background: var(--surface);
  display: grid; gap: 10px; transition: border-color .2s; }
.stone-card:hover { border-color: var(--champagne); }
.stone-carat { font-family: var(--serif); font-size: 1.9rem; line-height: 1; }
.stone-spec { font-size: 0.84rem; color: var(--ink-faint); letter-spacing: 0.03em; }
.stone-price { font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 6px; }
.stone-foot { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line);
  padding-top: 10px; font-size: 0.82rem; color: var(--ink-soft); }

/* ---------- model ---------- */
.model-grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(24px, 4vw, 48px); }
.panel { border: 1px solid var(--line-strong); border-radius: 2px; padding: clamp(24px, 3vw, 36px); background: var(--surface); }
.panel h3 { font-size: 1.5rem; margin-bottom: 12px; }
.panel p { color: var(--ink-soft); font-size: 0.98rem; }
.panel .muted { color: var(--ink-faint); font-size: 0.85rem; }
.spec { display: grid; gap: 0; margin: 20px 0 0; }
.spec div { display: flex; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line); }
.spec dt { color: var(--ink-faint); font-size: 0.9rem; } .spec dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.bars { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 14px; }
.bar { display: grid; grid-template-columns: 76px 1fr 54px; align-items: center; gap: 12px; font-size: 0.88rem; }
.bar-name { text-transform: capitalize; color: var(--ink-soft); }
.bar-track { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; min-width: 2px;
  background: linear-gradient(90deg, var(--emerald), var(--champagne)); border-radius: 999px; }
.bar-val { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink);
  text-align: right; font-size: 0.82rem; }
@media (max-width: 360px) {
  .bar { grid-template-columns: 62px 1fr 48px; gap: 9px; column-gap: 9px; }
}

/* ---------- footer ---------- */
.foot { max-width: var(--maxw); margin: 0 auto; padding: 40px clamp(16px, 5vw, 48px) 60px;
  border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 16px 32px; align-items: center; }
.foot-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--emerald);
  font-family: var(--serif); font-size: 1.1rem; }
.foot-brand span { color: var(--ink); }
.foot p { color: var(--ink-faint); font-size: 0.85rem; margin: 0; max-width: 60ch; }

/* ---------- assistant ---------- */
.fa-launch {
  position: fixed; right: clamp(16px, 4vw, 32px); bottom: clamp(16px, 4vw, 32px); z-index: 60;
  display: inline-flex; align-items: center; gap: 9px; font-family: var(--sans); font-size: 0.92rem;
  font-weight: 500; color: #fbf8f1; background: var(--emerald); border: 1px solid var(--emerald);
  padding: 12px 18px; border-radius: 999px; cursor: pointer;
  box-shadow: 0 6px 22px color-mix(in srgb, var(--ink) 18%, transparent); transition: background .2s, transform .15s; }
.fa-launch:hover { background: var(--emerald-bright); }
.fa-launch:active { transform: translateY(1px); }
.fa-launch:focus-visible { outline: 2px solid var(--champagne); outline-offset: 3px; }

.fa-panel {
  position: fixed; right: clamp(16px, 4vw, 32px); bottom: calc(clamp(16px, 4vw, 32px) + 62px); z-index: 60;
  width: min(390px, calc(100vw - 32px)); max-height: min(620px, calc(100vh - 120px));
  display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 4px; overflow: hidden;
  box-shadow: 0 16px 48px color-mix(in srgb, var(--ink) 22%, transparent); }
.fa-panel[hidden] { display: none; }

.fa-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--champagne) 6%, transparent); }
.fa-title { display: flex; align-items: center; gap: 9px; font-family: var(--serif); font-size: 1.05rem; color: var(--ink); }
.fa-dot { width: 9px; height: 9px; border-radius: 999px;
  background: radial-gradient(circle at 32% 32%, var(--champagne-soft), var(--emerald)); }
.fa-mode { font-family: var(--sans); font-size: 0.64rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--emerald); border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px 8px; }
.fa-head-actions { display: flex; gap: 6px; }
.fa-icon { width: 30px; height: 30px; display: grid; place-items: center; cursor: pointer; color: var(--ink-soft);
  background: transparent; border: 1px solid transparent; border-radius: 999px; transition: border-color .15s, color .15s; }
.fa-icon:hover { color: var(--ink); border-color: var(--line-strong); }
.fa-icon[aria-pressed="true"] { color: var(--emerald); border-color: var(--champagne); }

.fa-choices { display: flex; flex-wrap: wrap; gap: 7px; align-self: flex-start; max-width: 92%; margin-top: -4px; }
.fa-choice { font-family: var(--sans); font-size: 0.82rem; font-weight: 500; color: var(--ink-soft);
  background: var(--surface); border: 1px solid var(--line-strong); padding: 7px 12px; border-radius: 999px;
  cursor: pointer; transition: border-color .15s, color .15s, background .15s; }
.fa-choice:hover { border-color: var(--champagne); color: var(--ink); }
.fa-choice:focus-visible { outline: 2px solid var(--emerald); outline-offset: 2px; }

.fa-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.fa-msg { max-width: 86%; font-size: 0.92rem; line-height: 1.5; padding: 11px 14px; border-radius: 12px; }
.fa-msg strong { font-weight: 600; }
.fa-assistant { align-self: flex-start; background: var(--bone); border: 1px solid var(--line);
  color: var(--ink); border-bottom-left-radius: 3px; }
.fa-user { align-self: flex-end; background: var(--emerald); color: #fbf8f1; border-bottom-right-radius: 3px; }
.fa-typing { display: inline-flex; gap: 4px; align-items: center; }
.fa-typing span { width: 6px; height: 6px; border-radius: 999px; background: var(--ink-faint); opacity: 0.5;
  animation: fa-bounce 1s infinite ease-in-out; }
.fa-typing span:nth-child(2) { animation-delay: 0.15s; } .fa-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes fa-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.4; } 40% { transform: translateY(-4px); opacity: 0.9; } }
@media (prefers-reduced-motion: reduce) { .fa-typing span { animation: none; } }

.fa-form { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); background: var(--surface); }
.fa-form input { flex: 1; font-family: var(--sans); font-size: 0.95rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); padding: 11px 14px; border-radius: 999px; }
.fa-form input:focus { outline: 2px solid var(--emerald); outline-offset: 1px; border-color: transparent; }
.fa-send { width: 42px; flex: 0 0 42px; display: grid; place-items: center; cursor: pointer; color: #fbf8f1;
  background: var(--emerald); border: 1px solid var(--emerald); border-radius: 999px; transition: background .2s; }
.fa-send:hover { background: var(--emerald-bright); }
.fa-send:focus-visible { outline: 2px solid var(--champagne); outline-offset: 2px; }

@media (max-width: 480px) {
  .fa-panel { right: 8px; left: 8px; width: auto; bottom: 78px; max-height: calc(100vh - 100px); }
  .fa-launch { right: 12px; bottom: 12px; }
}

/* ---------- responsive ---------- */
@media (max-width: 880px) {
  .hero { grid-template-columns: 1fr; }
  .hero-metrics { border-left: none; border-top: 1px solid var(--line-strong); padding-left: 0; padding-top: 24px;
    grid-template-columns: 1fr 1fr 1fr; }
  .hero-metrics .rule { display: none; }
  .appraise-grid, .model-grid { grid-template-columns: 1fr; }
  .verdict { position: static; }
  .nav { display: none; }
}
@media (max-width: 420px) {
  body { font-size: 15px; }
  .hero-metrics { grid-template-columns: 1fr; gap: 12px; }
  .hero-metrics .metric { display: flex; justify-content: space-between; align-items: baseline; }
  .field-row { grid-template-columns: 1fr; }
  .search { flex-direction: column; }
}
