@font-face {
  font-family: "LaGaligoSureq";
  src: url("../fonts/LaGaligoSureq-Regular.woff2") format("woff2"),
       url("../fonts/LaGaligoSureq-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0000-1A1D, U+1A1F-10FFFF;
}

@font-face {
  font-family: "LaGaligoScript";
  src: url("../fonts/LaGaligoScript-Regular.woff2") format("woff2"),
       url("../fonts/LaGaligoScript-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0000-1A1D, U+1A1F-10FFFF;
}

@font-face {
  font-family: "Noto Sans Buginese";
  src: url("../fonts/NotoSansBuginese-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  unicode-range: U+1A00-1A1F, U+200C, U+200D;
}

:root {
  --duo-green: #58CC02;
  --duo-green-dark: #58A700;
  --duo-green-shadow: #1f4900;
  --duo-blue: #1CB0F6;
  --duo-blue-dark: #0E7BB0;
  --duo-gold: #FFC800;
  --duo-gold-dark: #c99700;
  --duo-red: #FF4B4B;
  --duo-red-dark: #EA2B2B;
  --ink: #3c3c3c;
  --muted: #777777;
  --paper: #ffffff;
  --paper-deep: #f7f7f7;
  --rule: #E5E5E5;
  --rule-dark: #d0d0d0;
  --accent: var(--duo-green);
  --accent-dark: var(--duo-green-dark);
  --accent-soft: #e7f8d9;
  --good: var(--duo-green);
  --good-soft: #e7f8d9;
  --warn: var(--duo-red);
  --warn-soft: #ffe6e6;
  --topbar: #ffffff;
  --topbar-text: #3c3c3c;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  --ui: "Nunito", "Segoe UI", system-ui, sans-serif;
  --display: "Baloo Bhaijaan 2", "Nunito", system-ui, sans-serif;
  --lontara: "LaGaligoSureq", "Noto Sans Buginese", "Noto Sans", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --topbar-h: calc(44px + var(--safe-t));
  --app-h: 100dvh;
}

body[data-lontara-font="script"] {
  --lontara: "LaGaligoScript", "Noto Sans Buginese", "Noto Sans", sans-serif;
}
body[data-lontara-font="noto"] {
  --lontara: "Noto Sans Buginese", "Noto Sans", sans-serif;
}

[data-theme="night"] {
  --ink: #e5e7eb;
  --muted: #9ca3af;
  --paper: #0b1220;
  --paper-deep: #121a2a;
  --rule: #1f2a3f;
  --rule-dark: #0c1320;
  --accent-soft: #14361a;
  --good-soft: #14361a;
  --warn-soft: #3a141a;
  --topbar: #0b1220;
  --topbar-text: #e5e7eb;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: var(--app-h, 100dvh);
  max-height: var(--app-h, 100dvh);
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
}
body {
  display: flex;
  flex-direction: column;
  padding: 0;
  padding-bottom: var(--safe-b);
  min-height: 0;
}
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--duo-blue-dark); }
[data-theme="night"] a { color: var(--duo-blue); }
[hidden] { display: none !important; }

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  min-height: 44px;
  height: var(--topbar-h);
  padding: var(--safe-t) 8px 0 calc(6px + var(--safe-l));
  padding-right: calc(6px + var(--safe-r));
  background: var(--topbar);
  color: var(--topbar-text);
  border-bottom: 2px solid var(--rule);
}
.icon-btn {
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  width: 40px; height: 40px;
  color: var(--topbar-text);
  border-radius: 12px;
}
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
  text-decoration: none;
  color: inherit;
}
.brand-logo {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  object-fit: contain;
  display: block;
}
.topbar-title { min-width: 0; }
.brand {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: 15px;
  line-height: 1.1;
  color: var(--duo-green);
  letter-spacing: -0.02em;
}
.brand-sub { display: none; }
.topbar-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.stats-pills { display: flex; gap: 6px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 0 8px 0 4px;
  border-radius: 12px;
  background: var(--paper-deep);
  border: 2px solid var(--rule);
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.pill img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  display: block;
}
.pill b { font-weight: 900; font-size: 14px; }
.pill small {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.pill-xp b { color: var(--duo-blue-dark); }
.pill-streak b { color: #ff9600; }
.lang-toggle {
  display: flex;
  height: 32px;
  border: 2px solid var(--rule);
  border-radius: 12px;
  overflow: hidden;
  background: var(--paper-deep);
}
.lang-toggle button {
  min-width: 32px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  padding: 0 6px;
}
.lang-toggle button.is-active {
  background: var(--duo-green);
  color: #fff;
}

.progress {
  position: relative;
  top: auto;
  z-index: 15;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.round-bar {
  flex: 1 1 auto;
  height: 10px;
  border-radius: 999px;
  background: var(--rule);
  overflow: hidden;
}
.round-bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--duo-green);
  box-shadow: inset 0 -3px 0 var(--duo-green-dark);
  transition: width 0.25s ease;
}
.round-label {
  margin: 0;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  white-space: nowrap;
}

.stage {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 6px 10px 8px;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
body.is-play .stage,
body.has-overlay .stage { overflow: hidden; }

.hero {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 12px;
}
.hero-mascot {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  object-fit: contain;
  display: block;
}
.hero-kicker { display: none; }
.hero h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.hero-sub {
  margin: 2px 0 0;
  font-size: 13px;
  line-height: 1.3;
  font-weight: 700;
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 12px;
}
.tabs button {
  flex: 1 1 0;
  min-height: 44px;
  padding: 6px 10px;
  border: 2px solid var(--rule);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 3px 0 var(--rule-dark);
  font-size: 13px;
  font-weight: 800;
}
.tabs button:active { transform: translateY(3px); box-shadow: none; }
.tabs button.is-active {
  background: var(--duo-green);
  color: #fff;
  border-color: var(--duo-green-dark);
  box-shadow: 0 3px 0 var(--duo-green-shadow);
}

.name-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 12px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.name-row input {
  border: 2px solid var(--rule);
  border-radius: 16px;
  background: var(--paper);
  color: var(--ink);
  padding: 10px 12px;
  font-size: 15px;
  font-weight: 700;
}

.path {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
}
.unit {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: 100%;
  text-align: left;
  padding: 10px 12px 12px;
  border: 2px solid var(--rule);
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 4px 0 var(--rule-dark);
}
.unit:active:not(:disabled) { transform: translateY(4px); box-shadow: none; }
.unit.is-locked { opacity: 0.55; cursor: default; box-shadow: none; }
.unit.is-open { border-color: var(--duo-green); box-shadow: 0 4px 0 var(--duo-green-dark); }
.unit.is-done { border-color: var(--duo-green-dark); background: var(--accent-soft); }
.unit-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.unit-num {
  font-size: 15px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--duo-green-dark);
}
.unit.is-locked .unit-num { color: var(--muted); }
.unit-status {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}
.unit strong {
  display: block;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
}
.unit-glyphs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.syl-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 4px 6px 3px;
  border-radius: 12px;
  background: var(--paper-deep);
  border: 2px solid var(--rule);
  line-height: 1;
}
.syl-chip .lg {
  font-family: var(--lontara);
  font-size: 1.45rem;
  font-weight: 400;
  color: var(--ink);
}
.syl-chip small {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  margin-top: 2px;
}

.contrib-card {
  margin: 0 0 12px;
  padding: 12px;
  border: 2px solid var(--duo-gold);
  border-radius: 20px;
  background: #fffbeb;
}
[data-theme="night"] .contrib-card { background: #2a2108; }
.contrib-card h2 {
  margin: 0 0 2px;
  font-family: var(--display);
  font-size: 1.15rem;
}
.contrib-badge-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--paper);
  border: 2px solid var(--rule);
  font-size: 11px;
  font-weight: 800;
}
.contrib-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.sheet-note { font-size: 13px; color: var(--muted); line-height: 1.4; margin: 6px 0 0; font-weight: 700; }

.text-btn, .choice, .listen, .primary {
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 16px;
  border: 2px solid var(--rule);
  background: var(--paper);
  box-shadow: 0 4px 0 var(--rule-dark);
  font-weight: 800;
}
.text-btn:active, .choice:active, .listen:active, .primary:active {
  transform: translateY(4px);
  box-shadow: none;
}
.primary, .text-btn.primary {
  background: var(--duo-green);
  color: #fff;
  border-color: var(--duo-green-dark);
  box-shadow: 0 4px 0 var(--duo-green-shadow);
  font-weight: 800;
  font-size: 16px;
}

.card-prompt {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 800;
  color: var(--muted);
}
.glyph {
  font-family: var(--lontara);
  font-size: 3.4rem;
  line-height: 1.3;
  text-align: center;
  margin: 4px 0 12px;
}
.latin-prompt {
  text-align: center;
  font-family: var(--display);
  font-size: 2.2rem;
  font-weight: 800;
  margin: 4px 0 12px;
}
.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.choices.stack { grid-template-columns: 1fr; }
.choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
  font-size: 20px;
  font-weight: 800;
  min-height: 76px;
  padding: 10px 8px;
}
.choice .lg {
  font-family: var(--lontara);
  font-size: 2.1rem;
  display: block;
  font-weight: 400;
  line-height: 1.2;
}
.choice .lt {
  display: block;
  font-size: 14px;
  font-weight: 800;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.choice.is-right {
  background: var(--good-soft);
  border-color: var(--duo-green-dark);
  box-shadow: 0 4px 0 var(--duo-green-shadow);
}
.choice.is-wrong {
  background: var(--warn-soft);
  border-color: var(--duo-red);
  box-shadow: 0 4px 0 var(--duo-red-dark);
}
.choice.is-unclear {
  grid-column: 1 / -1;
  color: var(--muted);
  min-height: 48px;
  font-size: 15px;
}
.listen {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 12px;
}

.build-target {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 800;
  margin: 0 0 12px;
}
.build-preview {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 0 12px;
  border: 2px dashed var(--rule);
  border-radius: 16px;
  font-family: var(--lontara);
  font-size: 2.4rem;
  background: var(--paper-deep);
}
.build-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 0 0 10px;
}
.build-row button {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 64px;
  padding: 6px 10px;
  border: 2px solid var(--rule);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 3px 0 var(--rule-dark);
  font-weight: 800;
}
.build-row button:active { transform: translateY(3px); box-shadow: none; }
.build-row button .lg {
  font-family: var(--lontara);
  font-size: 1.8rem;
  font-weight: 400;
  line-height: 1.2;
}
.build-row button.is-on {
  border-color: var(--duo-green-dark);
  background: var(--accent-soft);
  box-shadow: 0 3px 0 var(--duo-green-shadow);
}

.scan-frame {
  position: relative;
  width: 100%;
  height: 160px;
  margin: 0 0 12px;
  border-radius: 16px;
  overflow: hidden;
  background: #1a140e;
  border: 2px solid var(--rule);
}
.scan-frame canvas { width: 100%; height: 100%; display: block; }

.feedback {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 16px;
  background: var(--good-soft);
  border: 2px solid var(--duo-green);
  font-weight: 800;
}
.feedback.is-careful { background: #fff4d1; border-color: var(--duo-gold); }
[data-theme="night"] .feedback.is-careful { background: #2a2108; }
.feedback.is-miss { background: var(--warn-soft); border-color: var(--duo-red); }
.fb-mascot {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  object-fit: contain;
}
.continue-row {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.continue-row .primary { flex: 1 1 160px; }

.result {
  text-align: center;
}
.result-mascot {
  width: 140px;
  height: 140px;
  object-fit: contain;
  margin: 0 auto 8px;
  display: block;
}
.result-score {
  font-family: var(--display);
  font-size: 2.6rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin: 4px 0;
  color: var(--duo-green-dark);
}
[data-theme="night"] .result-score { color: var(--duo-green); }

@media (max-width: 480px) {
  .hero h1 { font-size: 1.35rem; }
  .hero-mascot { width: 64px; height: 64px; flex-basis: 64px; }
  .glyph { font-size: 2.8rem; }
  .choice { min-height: 72px; }
  .choice .lg { font-size: 1.9rem; }
  .brand { font-size: 15px; }
  .stage { padding: 10px 12px 20px; }
  .scan-frame { height: 140px; }
  .pill b { font-size: 15px; }
}

.marks-strip {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  margin: 0 0 12px;
  padding: 6px 4px;
  border: 2px solid var(--rule);
  border-radius: 16px;
  background: var(--paper-deep);
}
.marks-strip span {
  flex: 1 1 0;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
}
.marks-strip .lg {
  display: block;
  font-family: var(--lontara);
  font-size: 1.4rem;
  color: var(--ink);
  line-height: 1.3;
  font-weight: 400;
}
.honest, .muted { font-size: 13px; color: var(--muted); line-height: 1.4; font-weight: 700; margin: 0 0 10px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 40;
  max-width: min(90vw, 420px);
  padding: 10px 16px;
  border-radius: 16px;
  background: #3c3c3c;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  box-shadow: var(--shadow);
}
.contrib-card .who { margin: 0; font-weight: 800; }
.contrib-card .count { margin: 2px 0 0; font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }

.build-row small { display: block; font-size: 11px; font-weight: 800; color: var(--muted); }
.choice[disabled], .build-row button[disabled] { cursor: default; transform: none; }

a.text-btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: inherit; }

/* First-visit welcome — match duolingo.id buttons */
.welcome-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(12, 18, 32, 0.55);
}
.welcome-card {
  position: relative;
  max-width: 520px;
  width: 100%;
  padding: 22px 20px 18px;
  border-radius: 20px;
  border: 2px solid var(--rule, #E5E5E5);
  background: var(--paper, #fff);
  color: var(--ink, #3c3c3c);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
  font-family: var(--ui, Nunito, sans-serif);
}
.welcome-card h2 {
  margin: 0 22px 12px 0;
  font-family: var(--display, "Baloo Bhaijaan 2", sans-serif);
  font-size: 1.4rem;
  font-weight: 800;
}
.welcome-card ul {
  margin: 0 0 16px;
  padding: 0 0 0 1.15em;
}
.welcome-card li {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.4;
  font-weight: 700;
}
.welcome-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.welcome-primary, .welcome-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 8px 16px;
  border-radius: 16px;
  text-decoration: none;
  font-weight: 800;
  font-size: 15px;
}
.welcome-primary {
  background: var(--duo-green, #58CC02);
  color: #fff;
  box-shadow: 0 4px 0 var(--duo-green-shadow, #1f4900);
  border: 2px solid var(--duo-green-dark, #58A700);
}
.welcome-link {
  border: 2px solid var(--rule, #E5E5E5);
  color: var(--ink, #3c3c3c);
  background: var(--paper, #fff);
  box-shadow: 0 4px 0 var(--rule-dark, #d0d0d0);
}
.welcome-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  border: 0;
  background: none;
  color: inherit;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}
html[data-await-lang] body { visibility: hidden; }

/* ===== v55: labeling game ===== */
.lg { font-family: var(--lontara); font-weight: 400; line-height: 1.15; }
.lg.xl { font-size: 2.6rem; }
.lg.lg2 { font-size: 2.4rem; }
.lg.struck { text-decoration: line-through; text-decoration-thickness: 3px; text-decoration-color: var(--duo-red); }

.modes { display: grid; gap: 10px; margin: 6px 0 12px; }
.mode-card {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 76px; padding: 12px 16px;
  border-radius: 20px; border: 2px solid; text-align: left; color: #fff;
}
.mode-card:active { transform: translateY(4px); box-shadow: none !important; }
.mode-card .lg { font-size: 2.4rem; flex: 0 0 52px; text-align: center; text-shadow: 0 2px 0 rgba(0,0,0,.18); }
.mc-text strong { display: block; font-family: var(--display); font-size: 21px; font-weight: 800; }
.mc-text small { display: block; font-size: 13px; font-weight: 700; opacity: .92; }
.m-green { background: var(--duo-green); border-color: var(--duo-green-dark); box-shadow: 0 5px 0 var(--duo-green-shadow); }
.m-blue { background: var(--duo-blue); border-color: var(--duo-blue-dark); box-shadow: 0 5px 0 #0a5f8a; }
.m-gold { background: var(--duo-gold); border-color: var(--duo-gold-dark); box-shadow: 0 5px 0 #8a6800; color: #3c3c3c; }

.sync-chip { display: inline-block; margin: 6px 0 0; font-size: 12px; font-weight: 800; color: var(--duo-green-dark); }
.sync-chip.is-queued { color: #c97a00; }
.deck-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 22px; }
.deck-top .sync-chip { margin: 0; }
.deck-hint, .ed-hint { margin: 0 0 6px; font-size: 14px; font-weight: 800; color: var(--muted); line-height: 1.25; }

/* scan stage */
.ed-stage, .sw-scan, .ah-mini { display: flex; justify-content: center; width: 100%; }
.scan-stage { position: relative; overflow: hidden; border-radius: 14px; background: #1b1b1b; border: 2px solid var(--rule); touch-action: none; user-select: none; -webkit-user-select: none; }
.scan-stage img { position: absolute; max-width: none; pointer-events: none; display: block; }
.sbox { position: absolute; border: 2px solid var(--duo-green); background: rgba(88,204,2,.12); border-radius: 3px; box-shadow: 0 0 0 1px rgba(255,255,255,.7); }
.sbox.is-editable { cursor: move; touch-action: none; }
.sbox.is-dragging { background: rgba(88,204,2,.2); }
.sh { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--duo-green-dark); touch-action: none; transform: translate(-50%, -50%); }
.sh::after { content: ""; position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; transform: translate(-50%, -50%); }
.sh-nw { left: 0; top: 0; cursor: nwse-resize; } .sh-n { left: 50%; top: 0; cursor: ns-resize; } .sh-ne { left: 100%; top: 0; cursor: nesw-resize; }
.sh-w { left: 0; top: 50%; cursor: ew-resize; } .sh-e { left: 100%; top: 50%; cursor: ew-resize; }
.sh-sw { left: 0; top: 100%; cursor: nesw-resize; } .sh-s { left: 50%; top: 100%; cursor: ns-resize; } .sh-se { left: 100%; top: 100%; cursor: nwse-resize; }
.sh-n, .sh-s, .sh-e, .sh-w { width: 10px; height: 10px; }
.sh-n::after, .sh-s::after { width: 40px; height: 34px; } .sh-e::after, .sh-w::after { width: 34px; height: 40px; }

/* editor */
.ed-overlay { position: fixed; inset: 0; z-index: 60; background: var(--paper); overflow-y: auto; padding: calc(var(--safe-t) + 10px) 12px 0; }
.ed { display: flex; flex-direction: column; max-width: 620px; margin: 0 auto; min-height: 100%; }
.ed-scan { position: relative; }
.ed-reset { position: absolute; right: 6px; top: 6px; z-index: 3; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.92); border: 2px solid var(--rule); font-size: 20px; font-weight: 800; }
.ed-body { padding: 8px 0 8px; flex: 1; }
.ed-foot { position: sticky; bottom: 0; display: flex; gap: 8px; align-items: center; padding: 10px 0 calc(10px + var(--safe-b)); background: var(--paper); border-top: 2px solid var(--rule); margin-top: auto; }
.ed-foot .primary { flex: 1; min-height: 52px; font-size: 18px; }
.ed-foot .primary:disabled { opacity: .45; }
.ed-foot .text-btn { min-height: 52px; min-width: 64px; padding: 8px 10px; font-size: 14px; }
.ed-ragu { color: #8a6800; border-color: var(--duo-gold); box-shadow: 0 4px 0 var(--duo-gold-dark); }
.round .ed-foot { position: static; }
.pk-top { display: flex; align-items: stretch; gap: 8px; margin-bottom: 4px; }
.pk-sugg { display: flex; gap: 6px; flex: 1; }
.pk-chip { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 64px; padding: 14px 6px 4px; border-radius: 14px; border: 2px solid var(--rule); background: var(--paper); box-shadow: 0 3px 0 var(--rule-dark); }
.pk-chip small { position: absolute; top: 2px; left: 8px; font-size: 10px; font-weight: 900; color: var(--muted); }
.pk-chip .lg { font-size: 1.7rem; } .pk-chip b { font-size: 12px; }
.pk-chip.is-top { border-color: var(--duo-blue); } .pk-chip.is-on { background: var(--accent-soft); border-color: var(--duo-green-dark); }
.pk-now { flex: 0 0 96px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 14px; background: var(--paper-deep); border: 2px dashed var(--rule-dark); }
.pk-now b { font-family: var(--display); font-size: 17px; }
.pk-label { margin: 8px 0 4px; font-size: 12px; font-weight: 900; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.pk-bases { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.pk-vowels { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.pk { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 52px; padding: 2px; border-radius: 12px; border: 2px solid var(--rule); background: var(--paper); box-shadow: 0 3px 0 var(--rule-dark); }
.pk:active { transform: translateY(3px); box-shadow: none; }
.pk .lg { font-size: 1.5rem; } .pk small { font-size: 11px; font-weight: 800; color: var(--muted); }
.pk.is-on { background: var(--accent-soft); border-color: var(--duo-green-dark); box-shadow: 0 3px 0 var(--duo-green-dark); }
.pk.is-off { opacity: .45; }
.pk-struck small { font-size: 9px; }

/* swipe deck */
.deck { display: flex; flex-direction: column; gap: 8px; }
.deck-card-wrap { position: relative; }
.deck-ghost { position: absolute; inset: 8px 8px -6px; border-radius: 22px; background: var(--paper-deep); border: 2px solid var(--rule); }
.sw-card { position: relative; z-index: 2; padding: 10px; border-radius: 22px; border: 2px solid var(--rule); background: var(--paper); box-shadow: 0 6px 0 var(--rule-dark); touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.sw-glyph { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.sw-glyph > div { display: flex; flex-direction: column; min-width: 0; }
.sw-latin { font-family: var(--display); font-size: 22px; font-weight: 800; line-height: 1; }
.sw-glyph small { font-size: 12px; font-weight: 800; color: var(--muted); }
.tag { margin-left: auto; padding: 3px 9px; border-radius: 99px; background: var(--paper-deep); border: 2px solid var(--rule); font-size: 11px; font-weight: 900; }
.tag-doubt { background: #fff4d1; border-color: var(--duo-gold); color: #8a6800; }
.sw-stamp { position: absolute; top: 14px; padding: 4px 12px; border-radius: 12px; border: 3px solid; font-family: var(--display); font-weight: 800; font-size: 20px; opacity: 0; pointer-events: none; background: rgba(255,255,255,.88); z-index: 4; }
.st-yes { left: 14px; color: var(--duo-green-dark); border-color: var(--duo-green); transform: rotate(-8deg); }
.st-no { right: 14px; color: var(--duo-red-dark); border-color: var(--duo-red); transform: rotate(8deg); }
.st-ragu { left: 50%; margin-left: -34px; color: #8a6800; border-color: var(--duo-gold); }
.sw-card .listen { position: absolute; right: 10px; bottom: 10px; min-height: 40px; padding: 4px 12px; font-size: 14px; }
.deck-actions { display: grid; grid-template-columns: 56px 1fr 64px 1fr; gap: 8px; align-items: center; margin-top: 6px; }
.act { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 56px; border-radius: 18px; border: 2px solid var(--rule); background: var(--paper); box-shadow: 0 4px 0 var(--rule-dark); font-weight: 900; }
.act span { font-size: 24px; line-height: 1; } .act small { font-size: 11px; font-weight: 800; color: var(--muted); }
.act:active { transform: translateY(4px); box-shadow: none; } .act:disabled { opacity: .35; }
.act-yes { background: var(--duo-green); border-color: var(--duo-green-dark); box-shadow: 0 4px 0 var(--duo-green-shadow); color: #fff; } .act-yes small { color: #fff; }
.act-no { background: var(--duo-red); border-color: var(--duo-red-dark); box-shadow: 0 4px 0 #a31515; color: #fff; } .act-no small { color: #fff; }
.act-ragu { min-height: 48px; border-color: var(--duo-gold); color: #8a6800; box-shadow: 0 4px 0 var(--duo-gold-dark); }
.act-undo { min-height: 48px; }
.deck-kbd { display: none; margin: 0; font-size: 12px; color: var(--muted); font-weight: 700; text-align: center; }
@media (hover: hover) and (pointer: fine) { .deck-kbd { display: block; } .deck { max-width: 460px; margin: 0 auto; } }

.reveal { position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; display: flex; flex-direction: column; gap: 8px; padding: 14px 16px calc(14px + var(--safe-b)); background: var(--good-soft); border-top: 3px solid var(--duo-green); box-shadow: 0 -8px 24px rgba(0,0,0,.15); }
.reveal.is-careful { background: #fff4d1; border-top-color: var(--duo-gold); }
.rv-main { display: flex; align-items: center; gap: 12px; }
.rv-main b { font-family: var(--display); font-size: 24px; display: block; line-height: 1; } .rv-main small { font-weight: 800; color: var(--muted); }
.rv-main .listen { margin-left: auto; min-height: 44px; }
.rv-msg { margin: 0; font-weight: 800; font-size: 15px; }
.reveal .fb-mascot { position: absolute; right: 14px; top: -46px; width: 64px; }

/* Mode Ahli */
.ah-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; margin-bottom: 8px; }
.ah-chip { display: flex; flex-direction: column; align-items: center; min-height: 80px; padding: 6px 2px; border-radius: 16px; border: 2px solid var(--rule); background: var(--paper); box-shadow: 0 4px 0 var(--rule-dark); }
.ah-chip .lg { font-size: 1.6rem; } .ah-chip b { font-size: 13px; } .ah-chip small { font-size: 11px; color: var(--muted); font-weight: 800; }
.ah-chip.is-done { background: var(--accent-soft); border-color: var(--duo-green-dark); }
.ah-viewbar { display: flex; gap: 6px; margin: 0 0 6px; }
.ah-viewbar .text-btn { min-height: 36px; padding: 4px 12px; font-size: 13px; box-shadow: 0 3px 0 var(--rule-dark); }
.ah-viewbar .text-btn.is-on { background: var(--accent-soft); border-color: var(--duo-green-dark); }
.ah-viewbar .text-btn:last-child { margin-left: auto; }
.ah-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.ah-tile { padding: 6px; border-radius: 16px; border: 2px solid var(--rule); background: var(--paper); box-shadow: 0 4px 0 var(--rule-dark); text-align: left; }
.ah-tile .scan-stage { border-width: 1px; border-radius: 10px; }
.ah-mini { min-height: 70px; align-items: center; background: #1b1b1b; border-radius: 10px; }
.ah-tile-foot { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 13px; }
.ah-tile-foot .lg { font-size: 1.3rem; } .ah-state { margin-left: auto; font-weight: 900; color: var(--duo-green-dark); }
.has-overlay { overflow: hidden; }
@media (min-width: 700px) { .ah-grid { grid-template-columns: repeat(4, 1fr); } }

/* ===== v58: one-screen compact + 2-step picker ===== */
.deck-hint, .ed-hint, .pk-label, .deck-kbd, .deck-top { display: none !important; }
.lg.xl { font-size: 1.8rem; }
.lg.lg2 { font-size: 1.6rem; }

.deck, .round, #round-ed, .ed, .ed-overlay {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}
.ed-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  height: var(--app-h, 100dvh);
  max-height: var(--app-h, 100dvh);
  overflow: hidden;
  background: var(--paper);
  padding: 6px 10px 0;
}
.ed { max-width: 620px; margin: 0 auto; width: 100%; }

.ed-scan, .sw-scan {
  position: relative;
  flex: 0 1 auto;
  min-height: 88px;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}
.sw-scan { flex: 1 1 auto; min-height: 140px; max-height: none; }
.ed-scan { flex: 1 1 auto; min-height: 120px; max-height: none; }
.ed-stage { width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; min-height: 88px; }
.ed-reset {
  position: absolute; right: 4px; top: 4px; z-index: 3;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,.92); border: 2px solid var(--rule);
  font-size: 18px; font-weight: 800;
}

.deck-card-wrap { position: relative; flex: 1 1 auto; min-height: 0; display: flex; }
.deck-ghost { display: none; }
.sw-card {
  position: relative; z-index: 2; flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
  padding: 6px; border-radius: 16px;
  border: 2px solid var(--rule); background: var(--paper);
  box-shadow: 0 4px 0 var(--rule-dark);
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab;
}
.sw-glyph { display: flex; align-items: center; flex-wrap: nowrap; gap: 8px; margin-top: 4px; flex: 0 0 auto; }
.sw-latin { font-family: var(--display); font-size: 18px; font-weight: 800; line-height: 1; }
.sw-glyph small { font-size: 11px; font-weight: 800; color: var(--muted); }
.tag { margin-left: auto; padding: 2px 8px; border-radius: 99px; background: var(--paper-deep); border: 2px solid var(--rule); font-size: 10px; font-weight: 900; }
.sw-card .listen { position: absolute; right: 8px; bottom: 8px; min-height: 40px; padding: 4px 10px; font-size: 13px; }
.sync-chip { position: absolute; top: 4px; right: 10px; z-index: 6; margin: 0; font-size: 11px; font-weight: 800; color: var(--duo-green-dark); pointer-events: none; }
.deck { position: relative; }
.deck-actions {
  display: grid;
  grid-template-columns: 40px 1fr 40px 1fr;
  gap: 6px;
  align-items: stretch;
  margin-top: 6px;
  flex: 0 0 auto;
}
.act {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 40px; height: 40px; border-radius: 14px;
  border: 2px solid var(--rule); background: var(--paper);
  box-shadow: 0 3px 0 var(--rule-dark); font-weight: 900;
}
.act span { font-size: 18px; line-height: 1; }
.act small { font-size: 9px; font-weight: 800; color: var(--muted); line-height: 1; }
.act-undo small, .act-ragu small { display: none; } /* icon-only to stay 40px square */
.act-yes { background: var(--duo-green); border-color: var(--duo-green-dark); box-shadow: 0 3px 0 var(--duo-green-shadow); color: #fff; }
.act-yes small { color: #fff; }
.act-no { background: var(--duo-red); border-color: var(--duo-red-dark); box-shadow: 0 3px 0 #a31515; color: #fff; }
.act-no small { color: #fff; }
.act-ragu { border-color: var(--duo-gold); color: #8a6800; box-shadow: 0 3px 0 var(--duo-gold-dark); }

/* 2-step picker */
.ed-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 4px 0 0; overflow: hidden; }
.pk-top { display: flex; align-items: center; gap: 6px; margin: 0 0 4px; flex: 0 0 auto; }
.pk-now {
  flex: 0 0 auto; min-width: 88px; min-height: 40px; padding: 2px 10px;
  display: flex; flex-direction: row; align-items: center; gap: 8px;
  border-radius: 12px; background: var(--paper-deep); border: 2px solid var(--rule-dark);
}
.pk-now .lg { font-size: 1.7rem; }
.pk-now b { font-family: var(--display); font-size: 16px; }
.pk-sugg { display: flex; gap: 4px; flex: 1; min-width: 0; }
.pk-chip {
  position: relative; flex: 1; display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 4px;
  min-height: 40px; height: 40px; padding: 0 6px;
  border-radius: 12px; border: 2px solid var(--rule); background: var(--paper); box-shadow: 0 2px 0 var(--rule-dark);
}
.pk-chip small { position: static; font-size: 9px; font-weight: 900; color: var(--muted); }
.pk-chip .lg { font-size: 1.25rem; }
.pk-chip b { font-size: 11px; }
.pk-chip.is-top { border-color: var(--duo-blue); }
.pk-chip.is-on { background: var(--accent-soft); border-color: var(--duo-green-dark); }

.pk-bases {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  flex: 0 1 auto;
  align-content: start;
  min-height: 0;
  max-height: 132px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px 0;
}
.pk-bases .pk {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 40px; height: 40px; padding: 0;
  border-radius: 10px; border: 2px solid var(--rule); background: var(--paper);
  box-shadow: 0 2px 0 var(--rule-dark);
}
.pk-bases .pk .lg { font-size: 1.25rem; }
.pk-bases .pk small { font-size: 9px; font-weight: 800; color: var(--muted); line-height: 1; }
.pk-bases .pk.is-on { background: var(--accent-soft); border-color: var(--duo-green-dark); box-shadow: 0 2px 0 var(--duo-green-dark); }

.pk-vowels {
  display: flex; gap: 4px; align-items: stretch;
  flex: 0 0 auto;
  margin: 4px 0 0;
  min-height: 44px;
}
.pk-vowel {
  flex: 1 1 0; min-width: 0; min-height: 44px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0 2px; border-radius: 12px;
  border: 2px solid var(--rule); background: var(--paper); box-shadow: 0 3px 0 var(--rule-dark);
}
.pk-vowel .lg { font-size: 1.45rem; line-height: 1.1; }
.pk-vowel small { font-size: 10px; font-weight: 800; color: var(--muted); line-height: 1; }
.pk-vowel.is-on { background: var(--accent-soft); border-color: var(--duo-green-dark); box-shadow: 0 3px 0 var(--duo-green-dark); }
.pk-vowel.is-off { opacity: .35; pointer-events: none; }
.pk-tog {
  flex: 0 0 40px; width: 40px; min-width: 40px; min-height: 44px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 12px; border: 2px solid var(--rule); background: var(--paper); box-shadow: 0 3px 0 var(--rule-dark);
}
.pk-tog .lg { font-size: 1.15rem; }
.pk-tog small { font-size: 8px; font-weight: 800; color: var(--muted); line-height: 1; text-align: center; }
.pk-tog.is-on { background: var(--accent-soft); border-color: var(--duo-green-dark); }
.pk-tog.pk-struck.is-on { background: #ffe6e6; border-color: var(--duo-red); }

.ed-foot {
  position: relative;
  display: flex; gap: 6px; align-items: center;
  flex: 0 0 auto;
  padding: 6px 0 calc(6px + var(--safe-b));
  background: var(--paper);
  border-top: 1px solid var(--rule);
  margin-top: 4px;
}
.ed-foot .primary { flex: 1; min-height: 40px; height: 40px; font-size: 15px; padding: 0 10px; }
.ed-foot .primary:disabled { opacity: .45; }
.ed-foot .text-btn { min-height: 40px; height: 40px; min-width: 40px; padding: 0 10px; font-size: 13px; }
.ed-ragu { color: #8a6800; border-color: var(--duo-gold); box-shadow: 0 3px 0 var(--duo-gold-dark); }

.ah-viewbar { display: flex; gap: 6px; margin: 0 0 4px; flex: 0 0 auto; }
.ah-viewbar .text-btn { min-height: 40px; height: 40px; padding: 0 12px; font-size: 13px; box-shadow: 0 3px 0 var(--rule-dark); }
.ah-grid { flex: 1 1 auto; min-height: 0; overflow: auto; gap: 6px; }
.ah-tile { padding: 4px; }
.ah-mini { min-height: 64px; max-height: 18dvh; }
.ah-tile-foot { margin-top: 2px; font-size: 12px; }

.reveal { padding: 10px 12px calc(10px + var(--safe-b)); }
.rv-main b { font-size: 20px; }
.reveal .fb-mascot { width: 48px; top: -36px; }

@media (max-height: 760px) {
  .pk-vowel .lg { font-size: 1.3rem; }
  .pk-bases { max-height: 132px; }
}

@media (max-width: 480px) {
  .stage { padding: 4px 8px 6px; }
  body.is-play .stage { padding: 4px 8px 6px; }
}


/* ===== v59: 8-grid Mode Ahli + reader-style picker under the crop ===== */
:root { --vowel: #9a3412; }

/* Picker sits directly under the crop (reader character pop-up), not docked at the bottom. */
.ed-body.picker-manual {
  flex: 0 1 auto;
  min-height: 0;
  overflow: visible;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--rule);
}
.ed-scan { flex: 0 1 auto; min-height: 96px; max-height: min(240px, 34dvh); }
.ed-foot { margin-top: 6px; }
.manual-head {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
  min-height: 36px;
  margin-bottom: 4px;
}
.manual-preview { display: inline-flex; align-items: center; gap: 6px; min-width: 0; flex: 0 0 auto; }
.manual-preview .glyph {
  font-family: var(--lontara);
  font-size: 22px;
  line-height: 1.45;
  padding: 2px 0;
  overflow: visible;
}
.manual-preview .lat { font-family: var(--display); font-size: 16px; font-weight: 800; }
.ocr-alts {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  flex: 1;
  min-width: 0;
}
.ocr-alt, .ocr-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-height: 40px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px dashed var(--rule);
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.ocr-alt .glyph, .ocr-chip .glyph { font-family: var(--lontara); font-size: 18px; line-height: 1.45; overflow: visible; }
.ocr-alt .lat, .ocr-chip .lat { font-size: 11px; font-weight: 700; color: var(--muted); }
.ocr-chip.is-best { border-color: var(--duo-blue); border-style: solid; }
.ocr-chip.is-current, .ocr-alt.is-on { background: color-mix(in srgb, var(--accent) 18%, transparent); border-color: var(--accent); border-style: solid; }

.manual-vowels {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
  margin-bottom: 4px;
  overflow: visible;
}
.manual-vowel, .manual-cons {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 3px 0 1px;
  min-width: 0;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: inherit;
  cursor: pointer;
  overflow: visible;
  -webkit-tap-highlight-color: transparent;
}
.manual-vowel { min-height: 44px; }
.manual-vowel .glyph,
.manual-cons .glyph {
  font-family: var(--lontara);
  font-size: 18px;
  line-height: 1.5;
  overflow: visible;
  padding: 2px 0;
}
.manual-vowel .lat, .manual-cons .lat {
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
  line-height: 1.1;
}
.manual-vowel.is-selected, .manual-cons.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}
.manual-vowel.is-sample { opacity: 0.5; }
.manual-cons-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
  overflow: visible;
  padding: 0;
}
.manual-cons { height: 44px; min-height: 40px; }
.manual-cons.pk-struck.is-selected { background: #ffe6e6; border-color: var(--duo-red); }

/* 4×2 class review */
.ah-review { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; height: 100%; }
.ah-head { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; min-height: 44px; }
.ah-head .glyph { font-family: var(--lontara); font-size: 1.8rem; line-height: 1.4; overflow: visible; }
.ah-head .lat { font-family: var(--display); font-size: 20px; font-weight: 800; line-height: 1; }
.ah-head .ah-count { font-size: 13px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.ah-head .ah-head-actions { margin-left: auto; display: flex; gap: 4px; }
.ah-head .text-btn { min-height: 40px; height: 40px; padding: 0 10px; font-size: 13px; }
.ah-grid8 {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 4px;
  overflow: hidden;
}
.ah-tile {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 2px;
  border-radius: 10px;
  border: 2px solid var(--duo-green);
  background: var(--paper);
  box-shadow: 0 2px 0 var(--duo-green-dark);
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
.ah-tile.is-off {
  border-color: var(--rule);
  box-shadow: none;
  opacity: 0.5;
}
.ah-tile .ah-mini {
  width: 100%; height: 100%; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  background: #1b1b1b; border-radius: 8px; overflow: hidden;
}
.ah-check {
  position: absolute; top: 3px; right: 3px; z-index: 3;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--duo-green); color: #fff;
  font-weight: 900; font-size: 12px; line-height: 20px; text-align: center;
  pointer-events: none;
}
.ah-tile.is-off .ah-check { background: #9ca3af; content: none; }
.ah-okbar { flex: 0 0 auto; display: flex; gap: 8px; align-items: center; padding: 6px 0 2px; }
.ah-okbar .primary { flex: 1; min-height: 48px; height: 48px; font-size: 18px; }
.ah-okbar .act-undo, .ah-okbar .text-btn { width: 48px; min-width: 48px; height: 48px; min-height: 48px; }
.ah-grid8 .ah-mini { max-height: none; min-height: 0; height: 100%; }
/* Noto attaches i/u/é/o/e to the base correctly; LaGaligoSureq drops or misfolds some marks (esp. ka). */
.picker-manual .glyph,
.manual-vowel .glyph,
.manual-cons .glyph,
.manual-preview .glyph,
.ocr-chip .glyph,
.ocr-alt .glyph {
  font-family: "Noto Sans Buginese", "LaGaligoSureq", "Noto Sans", sans-serif;
}
.manual-cons .lat, .manual-vowel .lat {
  white-space: nowrap;
  overflow: hidden;
  max-width: 100%;
  font-size: 8px;
}
.ed-foot { margin-top: 4px; padding-top: 4px; }
.manual-cons { height: auto; min-height: 54px; padding: 4px 0 3px; overflow: visible; }
.manual-cons .glyph { font-size: 18px; line-height: 1.7; padding: 2px 0 0; overflow: visible; }
.manual-vowel .glyph { font-size: 16px; line-height: 1.85; padding: 2px 0; overflow: visible; }
.manual-cons .lat, .manual-vowel .lat { font-size: 8px; line-height: 1.15; }
.manual-cons { height: auto !important; min-height: 52px; padding: 4px 0 3px !important; }
.manual-cons .lat { overflow: visible !important; font-size: 8px; line-height: 1.15; }

/* Mode Ahli: N candidates (&n=…) — scrollable 4-column grid */
.ah-grid8.is-many {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: none; grid-auto-rows: 78px;
  overflow-y: auto; -webkit-overflow-scrolling: touch; align-content: start;
  padding-bottom: 4px;
}
.ah-grid8.is-many .ah-tile { height: 78px; }
@media (min-width: 560px) { .ah-grid8.is-many { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

/* Font picker (&view=font) */
.fp { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; height: 100%; }
.fp-head { flex: 0 0 auto; display: grid; grid-template-columns: 1fr auto; gap: 0 8px; align-items: center; padding: 2px 0 6px; }
.fp-head b { font-family: var(--display); font-size: 17px; } .fp-head small { grid-column: 1; color: var(--muted); font-size: 12px; line-height: 1.25; }
.fp-head .text-btn { grid-row: 1 / span 2; grid-column: 2; min-height: 40px; }
.fp-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 6px; padding-bottom: 6px; }
.fp-row { display: grid; grid-template-columns: 54px 1fr; gap: 6px; align-items: center; }
.fp-label { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.fp-label b { font-size: 11px; color: var(--muted); }
.fp-lg { font-family: var(--lontara); font-size: 1.7rem; line-height: 1.5; }
.fp-ring { opacity: 0.35; margin-right: -0.3em; }
.fp-cands { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.fp-tile { position: relative; aspect-ratio: 1 / 1; padding: 3px; border-radius: 10px; border: 2px solid var(--rule); background: #f8f0dd; display: flex; align-items: center; justify-content: center; touch-action: manipulation; }
.fp-tile img { max-width: 100%; max-height: 100%; width: auto; height: auto; image-rendering: auto; }
.fp-score { position: absolute; left: 3px; bottom: 1px; font-size: 9px; font-weight: 800; color: var(--muted); }
.fp-tick { position: absolute; top: 2px; right: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--duo-green); color: #fff; font-size: 11px; line-height: 16px; text-align: center; font-weight: 900; display: none; }
.fp-tile.is-picked { border-color: var(--duo-green); box-shadow: 0 2px 0 var(--duo-green-dark); background: #f1fbe3; } .fp-tile.is-picked .fp-tick { display: block; }
.fp-tile.is-pinned { box-shadow: 0 2px 0 var(--duo-green-dark); }
.fp-pin { position: absolute; left: 3px; bottom: 1px; font-size: 8px; font-weight: 800; letter-spacing: 0.02em; color: #2a6b2a; text-transform: uppercase; }

.fp-bar { flex: 0 0 auto; display: flex; gap: 10px; align-items: center; padding: 6px 0 2px; }
.fp-bar span { font-weight: 800; font-size: 13px; color: var(--muted); min-width: 64px; } .fp-bar .primary { flex: 1; min-height: 48px; height: 48px; font-size: 17px; }

.fp-cands { align-items: stretch; }
.fp-more { min-height: 48px; border-radius: 10px; border: 2px dashed var(--rule); background: transparent; color: var(--muted); font-weight: 800; font-size: 13px; touch-action: manipulation; }
.fp-more:hover, .fp-more:focus { border-color: var(--ink); color: var(--ink); }
.fp-host { position: absolute; right: 3px; bottom: 1px; font-size: 8px; font-weight: 800; color: var(--muted); }
.fp-tile.is-pinned .fp-host { right: 3px; bottom: 12px; }
