/* Khmer Voice Commands — true-black flat (tasteskill app sheet, seed 366931330).
   Elevation by lightness alone: #000 ground, #111 panel, #1a1a1a nested.
   Colour lives on data only: blue = classical SVM, green = quantum VQC.

   Grid (desktop): 12 columns inside a 1180px column, one 16px gap.
     Try it:   input 5 + result 7
     Compare:  KPI strip 12 · chart 8 + per-word table 4 · about 12 */

:root {
  --ground: #000000;
  --surface: #111111;
  --nested: #1a1a1a;
  --raised: #262626;
  --border: #1f1f1f;
  --rule: #262626;
  --control: #444444;
  --text: #ffffff;
  --muted: #b4b4b4;
  --faint: #949494;

  --svm: #5b9bf8;
  --vqc: #3fc27f;
  --negative: #f06a80;
  --negative-bg: #2c1a20;
  --positive: #3fc27f;
  --positive-bg: #13281c;

  --radius-card: 20px;
  --radius-nested: 14px;
  --gap: 16px;
  --pad: 24px;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-km: "Noto Sans Khmer", "Khmer UI", "Leelawadee UI", sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; scrollbar-gutter: stable; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font: 400 15px/22px var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul { padding: 0; list-style: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
[lang="km"] { font-family: var(--font-km); }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
::selection { background: #fff; color: #000; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- top bar ---------- */

.topbar { position: sticky; top: 0; z-index: 10; background: var(--ground); border-bottom: 1px solid var(--border); }
.topbar__inner {
  max-width: calc(1180px + 64px);
  margin: 0 auto;
  height: 60px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; min-width: 0; }
.brand__mark { width: 28px; height: 28px; flex: none; }
.brand__name { font-weight: 600; font-size: 15px; white-space: nowrap; }
.nav { display: flex; gap: 4px; }
.nav__item {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  color: #bbbbbb;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: color .15s var(--ease), background-color .15s var(--ease);
}
.nav__item:hover { color: var(--text); }
.nav__item[aria-current="page"] { color: var(--text); background: var(--raised); }
.nav__short { display: none; }

/* ---------- canvas ---------- */

.canvas { max-width: calc(1180px + 64px); margin: 0 auto; padding: 40px 32px 56px; }
.title-row { margin-bottom: 28px; max-width: 720px; }
h1 { font-size: 26px; line-height: 32px; font-weight: 600; letter-spacing: -0.015em; }
.title-row__sub { margin-top: 8px; color: var(--muted); font-size: 16px; line-height: 24px; }

.panel { background: var(--surface); border-radius: var(--radius-card); padding: var(--pad); min-width: 0; }
h2 { font-size: 17px; line-height: 24px; font-weight: 600; }
.label { color: var(--faint); font-size: 13px; line-height: 18px; margin: 18px 0 8px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot--svm { background: var(--svm); }
.dot--vqc { background: var(--vqc); }

/* ---------- try it ---------- */

.try-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); align-items: stretch; }
.try-grid > :first-child { grid-column: span 5; }
.try-grid > .result { grid-column: span 7; }

.words { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.words li {
  background: var(--nested);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.words [lang="km"] { font-size: 17px; line-height: 26px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.words small { color: var(--faint); font-size: 13px; line-height: 18px; }

/* source switch: a segmented control as wide as the card */
.source {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin: 24px 0 16px;
  padding: 4px;
  background: var(--nested);
  border-radius: 999px;
}
.source button {
  height: 38px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #bbbbbb;
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.source button:hover { color: var(--text); }
.source button[aria-selected="true"] { background: var(--raised); color: var(--text); }

.pane { min-height: 104px; }
.pane__lead { color: var(--muted); font-size: 14px; line-height: 20px; margin-bottom: 12px; }

/* microphone */
.mic { display: flex; align-items: center; gap: 18px; min-height: 104px; padding: 0 4px; }
.mic__btn {
  position: relative;
  flex: none;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 0;
  background: var(--text);
  color: #000;
  display: grid;
  place-items: center;
  transition: transform .12s var(--ease), background-color .15s var(--ease);
}
.mic__btn:hover { transform: scale(1.04); }
.mic__btn:active { transform: scale(.97); }
.mic__icon { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.mic__stop { display: none; width: 22px; height: 22px; border-radius: 5px; background: #fff; }
.mic__btn[aria-pressed="true"] { background: var(--negative); }
.mic__btn[aria-pressed="true"] .mic__icon { display: none; }
.mic__btn[aria-pressed="true"] .mic__stop { display: block; }
.mic__btn[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--negative);
  animation: ring 1.2s var(--ease) infinite;
}
@keyframes ring { from { transform: scale(.92); opacity: 1; } to { transform: scale(1.18); opacity: 0; } }
.mic__status { font-weight: 600; font-size: 16px; line-height: 24px; font-variant-numeric: tabular-nums; }
.mic__hint { color: var(--faint); font-size: 13px; line-height: 19px; margin-top: 2px; }
.mic__hint.is-error { color: var(--negative); }

/* upload */
.drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 104px;
  padding: 16px;
  text-align: center;
  border: 1px dashed var(--control);
  border-radius: var(--radius-nested);
  cursor: pointer;
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.drop:hover, .drop.is-over { border-color: #8a8a8a; background: var(--nested); }
.drop:focus-within { outline: 2px solid var(--text); outline-offset: 2px; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop__icon { width: 22px; height: 22px; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 4px; }
.drop__main { font-weight: 500; overflow-wrap: anywhere; }
.drop__main.is-error { color: var(--negative); }
.drop__limit { color: var(--faint); font-size: 13px; }

/* samples */
.samples { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.sample {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 60px;
  padding: 8px 12px;
  border: 1px solid var(--control);
  border-radius: 12px;
  background: transparent;
  text-align: left;
  transition: background-color .15s var(--ease), border-color .15s var(--ease);
}
.sample:hover { background: var(--nested); border-color: #5a5a5a; }
.sample[aria-pressed="true"] { border-color: var(--text); background: var(--nested); }
.sample [lang="km"] { font-weight: 600; font-size: 16px; line-height: 24px; white-space: nowrap; }
.sample small { color: var(--faint); font-size: 13px; line-height: 18px; }

/* the chosen clip */
.clip {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding: 12px 14px 12px 12px;
  background: var(--nested);
  border-radius: var(--radius-nested);
}
.clip__play {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: var(--raised);
  display: grid;
  place-items: center;
  transition: background-color .15s var(--ease);
}
.clip__play:hover { background: #333; }
.clip__play svg { width: 18px; height: 18px; fill: var(--text); margin-left: 2px; }
.clip__body { flex: 1; min-width: 0; }
.clip__wave { display: block; width: 100%; height: 40px; }
.clip__meta { color: var(--faint); font-size: 12px; line-height: 16px; margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.primary {
  width: 100%;
  height: 48px;
  margin-top: 20px;
  background: var(--text);
  color: #000;
  border: 0;
  border-radius: 999px;
  font-weight: 600;
  font-size: 16px;
  transition: opacity .15s var(--ease), transform .1s var(--ease);
}
.primary:hover:not(:disabled) { opacity: .88; }
.primary:active:not(:disabled) { transform: scale(.99); }
.primary:disabled { background: var(--raised); color: var(--faint); cursor: not-allowed; }
.predict-hint { color: var(--faint); font-size: 13px; line-height: 18px; margin-top: 10px; text-align: center; }

/* result */
.result { display: flex; flex-direction: column; }
.result__empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 12px 16px;
  min-height: 280px;
}
.result__empty-icon { width: 48px; height: 48px; fill: none; stroke: #4a4a4a; stroke-width: 2.4; stroke-linecap: round; margin-bottom: 14px; }
.result__empty-title { font-weight: 600; font-size: 16px; }
.howto {
  margin-top: 14px;
  padding-left: 20px;
  text-align: left;
  color: var(--muted);
  font-size: 14px;
  line-height: 20px;
  display: grid;
  gap: 6px;
  max-width: 340px;
}
.howto li::marker { color: var(--faint); }

.result__body { margin-top: 16px; display: flex; flex-direction: column; gap: 16px; }
.result.is-loading .result__body { opacity: .4; transition: opacity .2s; }


.answers { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.answer { background: var(--nested); border-radius: var(--radius-nested); padding: 16px 18px 18px; min-width: 0; }
.answer__head { display: flex; align-items: center; gap: 8px; min-height: 24px; }
.answer__head h3 { font-size: 14px; line-height: 20px; font-weight: 600; }
.answer__tag { color: var(--faint); font-size: 12px; }
.answer__status { margin-left: auto; }
.pill { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill--ok { background: var(--positive-bg); color: var(--positive); }
.pill--bad { background: var(--negative-bg); color: var(--negative); }
.answer__word { margin-top: 14px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.answer__word [lang="km"] { font-size: 30px; line-height: 44px; font-weight: 600; }
.answer[data-model="svm"] .answer__word [lang="km"] { color: var(--svm); }
.answer[data-model="vqc"] .answer__word [lang="km"] { color: var(--vqc); }
.answer__en { color: var(--muted); font-size: 15px; }
.answer__conf { color: var(--muted); font-size: 13px; line-height: 18px; margin-bottom: 14px; }
.answer__conf b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: baseline; font-size: 13px; line-height: 18px; }
.bar__name { color: var(--muted); }
.bar__name [lang="km"] { color: var(--text); margin-right: 6px; }
.bar__value { font-variant-numeric: tabular-nums; color: var(--muted); }
.bar__track { grid-column: 1 / -1; height: 6px; border-radius: 999px; background: #2a2a2a; overflow: hidden; }
.bar__fill { display: block; height: 100%; border-radius: 999px; background: #5a5a5a; transform-origin: left; transform: scaleX(0); transition: transform .5s var(--ease); }
.bar.is-top .bar__value { color: var(--text); font-weight: 600; }
.answer[data-model="svm"] .bar.is-top .bar__fill { background: var(--svm); }
.answer[data-model="vqc"] .bar.is-top .bar__fill { background: var(--vqc); }

.details { border-top: 1px solid var(--rule); padding-top: 4px; }
.details summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  font-weight: 500;
  font-size: 14px;
  color: var(--muted);
}
.details summary::-webkit-details-marker { display: none; }
.details summary::after {
  content: "";
  width: 8px; height: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-3px);
  transition: transform .2s var(--ease);
}
.details[open] summary::after { transform: rotate(-135deg) translateY(-1px); }
.details summary:hover { color: var(--text); }
.details__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 8px 0 4px; }
.details__title { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.details__text { color: var(--muted); font-size: 13px; line-height: 19px; margin-top: 10px; }
.details__meta { color: var(--faint); font-size: 12px; line-height: 17px; margin-top: 8px; }
.strip { display: block; width: 100%; height: 44px; }
.dials { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.dial { display: flex; flex-direction: column; gap: 2px; }
.dial svg { width: 56px; height: 32px; }
.dial span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dial b { color: var(--text); font-weight: 500; }

.result__error {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-nested);
  background: var(--negative-bg);
  color: #f6c9d1;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.link-btn { background: none; border: 0; padding: 8px 0; color: var(--text); font-weight: 600; font-size: 14px; white-space: nowrap; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- compare ---------- */

.compare-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); }
.kpis { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); padding: 0; }
.kpi { padding: 22px 24px; }
.kpi + .kpi { border-left: 1px solid var(--rule); }
.kpi__label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.kpi__value { font-size: 34px; line-height: 42px; font-weight: 600; margin-top: 6px; letter-spacing: -0.01em; }
.chart-card { grid-column: span 8; }
.table-card { grid-column: span 4; }
.about { grid-column: 1 / -1; }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.legend { display: flex; gap: 16px; color: var(--muted); font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font); font-variant-numeric: tabular-nums; }
.defs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--rule); }
.defs dt { font-size: 13px; font-weight: 600; }
.defs dd { color: var(--faint); font-size: 12px; line-height: 17px; margin-top: 2px; }

.table { width: 100%; border-collapse: collapse; margin-top: 12px; font-variant-numeric: tabular-nums; }
.table th { color: var(--faint); font-size: 13px; font-weight: 400; text-align: left; padding: 0 0 10px; }
.table td { padding: 14px 0; border-top: 1px solid var(--rule); font-size: 15px; }
.table .num { text-align: right; padding-left: 12px; }
.table td [lang="km"] { font-weight: 600; margin-right: 8px; }
.table td small { color: var(--faint); font-size: 13px; }
.table td.is-best { font-weight: 600; }
.table td { padding: 16px 0; }
.table tfoot td { border-top: 1px solid var(--control); color: var(--muted); font-weight: 600; }
.table tfoot td.num { color: var(--text); }
.table-note { color: var(--faint); font-size: 12px; line-height: 17px; margin-top: 14px; }

.about__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 12px; }
.about__grid p { color: var(--muted); font-size: 14px; line-height: 21px; }
.about__grid b { color: var(--text); font-weight: 600; }

.foot { max-width: calc(1180px + 64px); margin: 0 auto; padding: 0 32px 40px; color: var(--faint); font-size: 12px; line-height: 18px; }

/* ---------- tablet ---------- */

@media (max-width: 1000px) {
  .try-grid > :first-child, .try-grid > .result { grid-column: 1 / -1; }
  .result__empty { min-height: 0; padding: 20px 8px 8px; }
  .chart-card, .table-card { grid-column: 1 / -1; }
}

/* ---------- phone ---------- */

@media (max-width: 640px) {
  :root { --pad: 18px; --gap: 12px; }
  .topbar__inner { height: 56px; padding: 0 16px; }
  .brand__name { display: none; }
  .nav__long { display: none; }
  .nav__short { display: inline; }
  .nav__item { height: 40px; padding: 0 16px; }
  .canvas { padding: 24px 16px 36px; }
  h1 { font-size: 22px; line-height: 28px; }
  .title-row { margin-bottom: 20px; }
  .title-row__sub { font-size: 15px; line-height: 22px; }
  .panel { border-radius: 18px; }
  .words, .samples { grid-template-columns: 1fr 1fr; }
  .source button { height: 40px; font-size: 13px; }
  .mic { gap: 16px; }
  .answers, .details__grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr; }
  .kpi { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; }
  .kpi + .kpi { border-left: 0; border-top: 1px solid var(--rule); }
  .kpi__value { font-size: 24px; line-height: 30px; margin-top: 0; }
  .defs { grid-template-columns: 1fr 1fr; }
  .about__grid { grid-template-columns: 1fr; gap: 12px; }
  .foot { padding: 0 16px 32px; }
}

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