/* Lab Racik — mengikuti KV House of Riwaya (riwaya-blueprint): night + dinar, Galdeano / Chivo / Barlow Condensed / Averia Libre */
:root {
  --bg: #151413; --paper: #1c1a17; --paper2: #221f1b; --ink: #EDE6D8; --muted: #A39A8C; --faint: #6f675c;
  --line: rgba(237,230,216,.18); --line2: rgba(237,230,216,.08);
  --accent: #C19C4C; --accent-text: #C19C4C; --accent-ink: #151413; --accent-soft: rgba(193,156,76,.14);
  --seg-on: #EDE6D8; --seg-ink: #151413;
  --ok: #7DBB90; --ok-soft: rgba(125,187,144,.13); --warn: #D48938; --warn-soft: rgba(212,137,56,.15); --bad: #E3806F; --bad-soft: rgba(227,128,111,.14);
  --top: #E6E7E9; --heart: #4E9A9A; --base: #C19C4C; --other: #6f675c;
  --radius: 4px;
  --f-display: "Galdeano", "Palatino Linotype", Palatino, Georgia, serif;
  --f-body: "Chivo", "Helvetica Neue", Arial, sans-serif;
  --f-ui: "Barlow Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;
  --f-script: "Averia Libre", Georgia, serif;
  color-scheme: dark;
}
:root[data-theme="paper"] {
  --bg: #F4EEE3; --paper: #FBF7EF; --paper2: #EFE7D9; --ink: #212121; --muted: #5E574C; --faint: #8f8676;
  --line: #D8CCB6; --line2: #E7DDCB;
  --accent: #C19C4C; --accent-text: #8A6A24; --accent-ink: #151413; --accent-soft: rgba(193,156,76,.18);
  --seg-on: #212121; --seg-ink: #F4EEE3;
  --ok: #2E6B45; --ok-soft: rgba(41,84,56,.12); --warn: #9A5A14; --warn-soft: rgba(212,137,56,.16); --bad: #A8372A; --bad-soft: rgba(168,55,42,.1);
  --top: #9a9ca2; --heart: #418181; --base: #C19C4C; --other: #b5ab99;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 300 15px/1.55 var(--f-body); padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
b, strong { font-weight: 500; }
a { color: var(--accent-text); text-decoration: none; }
h1, h2 { font-family: var(--f-display); font-weight: 400; line-height: 1.15; margin: 0 0 .5rem; letter-spacing: .01em; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.3rem; }
h3 { font: 500 .78rem/1.3 var(--f-ui); text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 0 0 8px; }
.eyebrow { font: 500 .74rem/1.3 var(--f-ui); text-transform: uppercase; letter-spacing: .12em; color: var(--accent-text); margin: 0 0 6px; }
.code { font: 500 .72rem/1.3 var(--f-ui); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.script { font-family: var(--f-script); font-style: italic; font-weight: 400; }
.headline { font: 600 clamp(1.7rem, 6vw, 2.6rem)/1.02 var(--f-ui); text-transform: uppercase; letter-spacing: .005em; margin: 0; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 18px 16px; }
.pad { padding: 16px; } .muted { color: var(--muted); } .small { font-size: .86rem; } .tiny { font-size: .76rem; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; } .grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 14px; }
.grid2 { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid2 { grid-template-columns: 1.35fr 1fr; align-items: start; } .sticky { position: sticky; top: 76px; } }

/* header & nav */
.appbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line2); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); }
.brand { display: flex; gap: 10px; align-items: center; color: var(--ink); }
.brand svg { width: 22px; height: 28px; }
.brand .wm { font: 400 15px/1 var(--f-display); letter-spacing: .34em; }
.brand .sub { font: 500 .7rem/1 var(--f-ui); letter-spacing: .14em; text-transform: uppercase; color: var(--accent-text); border-left: 1px solid var(--line); padding-left: 10px; }
.nav { display: none; gap: 2px; border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.nav a { padding: 6px 14px; border-radius: 999px; color: var(--ink); font: 500 .8rem/1.2 var(--f-ui); text-transform: uppercase; letter-spacing: .1em; }
.nav a.on { background: var(--seg-on); color: var(--seg-ink); }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line2); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { flex: 1; text-align: center; padding: 9px 0 8px; color: var(--muted); font: 500 .7rem/1.2 var(--f-ui); text-transform: uppercase; letter-spacing: .12em; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tabbar a svg { width: 20px; height: 20px; }
.tabbar a.on { color: var(--accent-text); }
@media (min-width: 760px) { .nav { display: flex; } .tabbar { display: none; } body { padding-bottom: 28px; } }

/* cards & controls */
.card { background: var(--paper); border: 1px solid var(--line2); border-radius: var(--radius); padding: 16px; }
.card h2 { margin-bottom: .7rem; }
.card + .card { margin-top: 14px; }
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.stat { display: flex; flex-direction: column; } .stat b { font: 400 1.55rem/1.2 var(--f-display); }
button, .btn { font: 500 .8rem/1 var(--f-ui); text-transform: uppercase; letter-spacing: .1em; border: 1px solid var(--line); background: transparent; color: var(--ink);
  border-radius: 999px; padding: 10px 16px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; }
button:hover, .btn:hover { border-color: var(--muted); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.light, .btn.light { background: var(--seg-on); border-color: var(--seg-on); color: var(--seg-ink); }
button.ghost { border-color: transparent; background: transparent; color: var(--accent-text); padding-left: 6px; padding-right: 6px; }
button.danger { color: var(--bad); }
button:disabled { opacity: .45; cursor: default; }
button.icon { min-height: 34px; padding: 4px 10px; letter-spacing: 0; }
input, select, textarea { font: 300 15px/1.4 var(--f-body); color: var(--ink); background: var(--paper2); border: 1px solid var(--line2); border-radius: var(--radius); padding: 9px 11px; width: 100%; min-height: 42px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 26px; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }
textarea { min-height: 84px; resize: vertical; }
label { display: block; font: 500 .72rem/1.3 var(--f-ui); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 5px; }
.field { margin-bottom: 13px; }
.fields { display: grid; gap: 0 12px; grid-template-columns: 1fr 1fr; }
.fields .full { grid-column: 1 / -1; }
@media (max-width: 520px) { .fields { grid-template-columns: 1fr; } }
.check { display: flex; gap: 9px; align-items: center; font: 300 .95rem/1.4 var(--f-body); text-transform: none; letter-spacing: 0; color: var(--ink); }
.check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }

/* segmented & chips (gaya "THE STORY | SCENT INDEX") */
.chips { display: inline-flex; gap: 2px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 22px; padding: 3px; }
.chip { border: 0; border-radius: 999px; padding: 6px 13px; font: 500 .76rem/1.2 var(--f-ui); text-transform: uppercase; letter-spacing: .1em; background: transparent; color: var(--ink); cursor: pointer; min-height: 32px; }
.chip.on { background: var(--seg-on); color: var(--seg-ink); }
.chips.loose { border: 0; padding: 0; gap: 6px; }
.chips.loose .chip { border: 1px solid var(--line); }
.chips.loose .chip.on { border-color: var(--seg-on); }
.badge { display: inline-block; font: 500 .68rem/1.5 var(--f-ui); text-transform: uppercase; letter-spacing: .08em; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.ok { border-color: transparent; background: var(--ok-soft); color: var(--ok); } .badge.warn { border-color: transparent; background: var(--warn-soft); color: var(--warn); }
.badge.bad { border-color: transparent; background: var(--bad-soft); color: var(--bad); } .badge.acc { border-color: transparent; background: var(--accent-soft); color: var(--accent-text); }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--line2); }
.list > li:first-child { border-top: 0; }
.list a.item, .list .item { display: flex; gap: 11px; align-items: center; padding: 12px 2px; color: var(--ink); }
.list button.item { border-radius: 0; text-transform: none; letter-spacing: 0; font: 300 15px/1.45 var(--f-body); justify-content: flex-start; }
.item .t { font-weight: 400; } .item .s { font-size: .82rem; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--other); }
.dot.top { background: var(--top); } .dot.heart { background: var(--heart); } .dot.base { background: var(--base); }

/* tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font: 500 .7rem/1.3 var(--f-ui); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding: 6px; border-bottom: 1px solid var(--line); }
td { padding: 8px 6px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
.tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }

/* formula editor rows */
.rows .frow { display: grid; grid-template-columns: 1fr 104px 108px 36px; gap: 6px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line2); }
.frow .nm { min-width: 0; } .frow .nm .t { font-weight: 400; display: flex; gap: 8px; align-items: center; }
.frow input, .frow select { min-height: 40px; padding: 6px 9px; }
.frow select { padding-right: 24px; }
.frow .meta { font-size: .76rem; color: var(--muted); margin-top: 2px; }
.frow .pc { font-variant-numeric: tabular-nums; }
@media (max-width: 600px) { .rows .frow { grid-template-columns: 1fr 1fr 40px; row-gap: 6px; } .frow .nm { grid-column: 1 / -1; } }

/* bars & segmen */
.bar { display: flex; height: 8px; overflow: hidden; background: var(--line2); gap: 2px; }
.bar i { display: block; height: 100%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font: 500 .72rem/1.3 var(--f-ui); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-top: 8px; }
.legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--c); vertical-align: 0; }
.meter { height: 3px; background: var(--line2); overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; background: var(--ok); }
.meter i.warn { background: var(--warn); } .meter i.bad { background: var(--bad); } .meter i.acc { background: var(--accent); }
.segs { display: flex; gap: 3px; margin: 8px 0 4px; }
.segs i { flex: 1; height: 3px; background: var(--line); }
.segs i.on { background: var(--accent); }
.fam { display: grid; grid-template-columns: 104px 1fr 52px; gap: 10px; align-items: center; font-size: .86rem; margin: 6px 0; }
.fam .meter { margin: 0; }

/* callouts */
.callout { border-radius: var(--radius); padding: 11px 13px; font-size: .9rem; border-left: 2px solid currentColor; }
.callout.ok { background: var(--ok-soft); color: var(--ok); } .callout.bad { background: var(--bad-soft); color: var(--bad); }
.callout.warn { background: var(--warn-soft); color: var(--warn); } .callout.info { background: var(--accent-soft); color: var(--ink); border-left-color: var(--accent); }
.callout b { color: inherit; }

/* version tabs */
.vtabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.vtab { border: 1px solid var(--line); border-radius: 999px; padding: 6px 15px; background: transparent; color: var(--ink); white-space: nowrap; min-height: 36px; cursor: pointer; }
.vtab.on { border-color: var(--seg-on); background: var(--seg-on); color: var(--seg-ink); }

/* formula cards (gaya Scent Index) */
.fcard { display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--line2); border-radius: var(--radius); color: var(--ink); overflow: hidden; }
.fcard:hover { border-color: var(--line); }
.fcard .vis { background: color-mix(in srgb, var(--bg) 60%, #000 40%); height: 120px; display: flex; align-items: center; justify-content: center; }
:root[data-theme="paper"] .fcard .vis { background: var(--paper2); }
.fcard .vis svg { width: 52px; height: 64px; }
.fcard .body { padding: 14px 15px 16px; }
.fcard .name { font: italic 400 1.25rem/1.25 var(--f-script); margin: 0 0 6px; }
.fcard.empty { border-style: dashed; border-color: var(--line); background: transparent; align-items: center; justify-content: center; min-height: 200px; color: var(--muted); }

/* evaluations */
.eval { border-left: 1px solid var(--accent); padding: 4px 0 4px 12px; margin: 12px 0; }
.stars { color: var(--accent); letter-spacing: 2px; }
.rate { display: flex; gap: 4px; flex-wrap: wrap; } .rate button { min-height: 36px; padding: 4px 11px; }
.rate button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* modal & toast */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(10,9,8,.6); display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
.sheet { background: var(--paper); border: 1px solid var(--line2); width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; border-radius: 14px 14px 0 0; padding: 18px; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
@media (min-width: 760px) { .modal { align-items: center; } .sheet { border-radius: var(--radius); } }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 60; background: var(--seg-on); color: var(--seg-ink); padding: 10px 16px; border-radius: 999px; max-width: calc(100% - 32px); font: 500 .8rem/1.3 var(--f-ui); text-transform: uppercase; letter-spacing: .08em; }
.toast.err { background: var(--bad); color: #fff; }
.login { max-width: 380px; margin: 12vh auto; text-align: center; }
.login .bottle { width: 64px; height: 80px; margin: 0 auto 18px; display: block; }
.login form { text-align: left; margin-top: 22px; }
.empty { text-align: center; padding: 28px 10px; color: var(--muted); }
.sep { height: 1px; background: var(--line2); margin: 16px 0; }
details > summary { cursor: pointer; color: var(--accent-text); font: 500 .78rem/1.3 var(--f-ui); text-transform: uppercase; letter-spacing: .1em; list-style: none; }
details > summary::before { content: "▸ "; } details[open] > summary::before { content: "▾ "; }
.hero { padding: 6px 0 4px; }
.hero .headline { margin: 4px 0 6px; }
.fcard.empty svg { width: 40px; height: 50px; }
body.guest .tabbar, body.guest .nav { display: none; }
