/* ============================================================
   style.css — Lattyayy, Recognize page
   Extends the Collector App design system.
   :root variables are NEVER modified.
   Only recognizer-specific additions are declared here.
   ============================================================ */

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

:root {
  --bg: #0c0d10;
  --surface: #14161b;
  --surface2: #1c1e26;
  --border: #252830;
  --border2: #32363f;
  --accent: #1895ff;
  --accent-dim: #1058a0;
  --accent2: #e05a2b;
  --text: #e2e4ea;
  --text2: #9aa0b0;
  --muted: #50566a;
  --canvas-bg: #181a20;
  --radius: 10px;
  --mono: "IBM Plex Mono", monospace;
  --myanmar: "Noto Sans Myanmar", sans-serif;
  --status-complete: #22c55e;
  --status-over: #eab308;
  --control-w: 300px;
  --bento-gap: 10px;
  --bento-pad: 10px;
}

:root.light {
  --bg: #f0f1f4;
  --surface: #ffffff;
  --surface2: #f4f5f8;
  --border: #d8dae0;
  --border2: #bec2cc;
  --accent: #1895ff;
  --accent2: #e05a2b;
  --text: #0f1117;
  --text2: #505870;
  --muted: #8890a4;
  --canvas-bg: #e8eaee;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  overscroll-behavior: none;
  touch-action: none;
  -webkit-font-smoothing: antialiased;
}

/* ── App shell ────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* Mobile: desktop panel fully hidden — canvas-panel owns the whole screen */
#control-panel  { display: none; }
.bento-info     { display: none; }
.bento-controls { display: none; }

/* ── Header ───────────────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
}
.logo {
  font-size: 16px;
  font-weight: 600;
}
.logo-accent { color: var(--accent); }

.header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.18s, color 0.18s;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Candidates list ──────────────────────────────────────────────────────── */
#candidates-wrap {
  padding: 8px 14px 12px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#candidates-label {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
  flex-shrink: 0;
}
.candidate-empty {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  padding: 24px 0;
}
.candidate-row {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  margin-bottom: 5px;
}
.candidate-row:hover { border-color: var(--accent-dim); }
.candidate-row.top-1 {
  border-color: var(--accent);
  background: transparent;
}
.candidate-rank {
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}
.candidate-text {
  font-family: var(--myanmar);
  font-size: 24px;
  line-height: 1.5;
  color: var(--text);
  min-height: 32px;
  display: flex;
  align-items: center;
}
.candidate-row.top-1 .candidate-text { color: var(--accent); }

.candidate-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
}
.candidate-bar-wrap {
  width: 100px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.candidate-bar {
  height: 100%;
  background: var(--muted);
  border-radius: 2px;
  transition: width 0.3s ease;
}
.candidate-row.top-1 .candidate-bar { background: var(--accent); }

.candidate-pct {
  font-size: 9px;
  font-weight: 700;
  color: var(--text2);
  letter-spacing: 0.04em;
}
.candidate-logp {
  font-size: 8px;
  color: var(--muted);
  letter-spacing: 0.03em;
}

/* ── Model status bar ─────────────────────────────────────────────────────── */
#model-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
}
#model-status-info,
#mobile-status-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  min-width: 0;
}
#model-status-text,
#mobile-status-text {
  font-size: 9px;
  font-weight: 600;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#model-status-arch,
#mobile-status-arch {
  font-size: 8px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.04em;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.3s;
}
.dot-idle    { background: var(--muted); }
.dot-ready   { background: var(--status-complete); }
.dot-loading { background: var(--status-over); }
.dot-error   { background: var(--accent2); }

/* ── Result panel ────────────────────────────────────────────────────────── */
#result-panel {
  flex-shrink: 0;
  padding: 10px 14px 12px;
  border-bottom: 1px solid var(--border);
}
#result-label {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
#result-text {
  font-family: var(--myanmar);
  font-size: 52px;
  line-height: 1.2;
  color: var(--accent);
  text-align: center;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.02em;
  transition: opacity 0.2s;
}
#result-text.empty { color: var(--muted); font-family: var(--mono); font-size: 28px; }
#result-confidence-wrap { margin-top: 8px; }
#result-confidence-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
#result-confidence-pct {
  font-size: 9px;
  font-weight: 700;
  color: var(--status-complete);
  background: color-mix(in srgb, var(--status-complete) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--status-complete) 30%, transparent);
  border-radius: 20px;
  padding: 1px 7px;
  letter-spacing: 0.04em;
}
#result-latency-pill {
  font-size: 8px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 1px 7px;
  letter-spacing: 0.04em;
}
#result-confidence-bar-wrap {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
#result-confidence-bar {
  height: 100%;
  background: var(--status-complete);
  border-radius: 2px;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* meta pills removed — arch shown inline in status bar */

/* ── Buttons ──────────────────────────────────────────────────────────────── */
#controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 7px;
}
.btn {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 11px 4px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.btn:active { transform: scale(0.94); }
.btn.danger  { border-color: #ef4444; color: #ef4444; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 700;
}
.btn.primary.loading {
  opacity: 0.7;
  pointer-events: none;
}
:root.light .btn.primary { color: #fff; }
.btn-kbd {
  display: none;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.06em;
  opacity: 0.5;
  line-height: 1;
  margin-top: -2px;
  border: 1.5px solid var(--border2);
  border-radius: 4px;
  padding: 1px 4px;
}

/* ── Canvas panel ─────────────────────────────────────────────────────────── */
#canvas-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  position: relative;
}
#canvas-wrap {
  flex: 1;
  position: relative;
  padding: 4px 10px;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
#draw-canvas {
  flex: 1;
  display: block;
  width: 100%;
  height: 100%;
  background: var(--canvas-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: crosshair;
  touch-action: none;
  min-height: 0;
}
#stroke-count {
  position: absolute;
  top: 16px;
  right: 32px;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  pointer-events: none;
}

/* ── Mobile header ────────────────────────────────────────────────────────── */
#mobile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  flex-shrink: 0;
}

/* ── Mobile model status ──────────────────────────────────────────────────── */
#mobile-status-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 16px 8px;
  padding: 7px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 9px;
  font-weight: 500;
  color: var(--text2);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

/* ── Mobile candidates label + 2+3 grid ──────────────────────────────────── */
#mobile-candidates-wrap {
  flex-shrink: 0;        /* never squeeze — canvas above absorbs space */
  padding: 4px 10px 4px;
  /* Fixed height so canvas size never shifts when cards appear/disappear */
  min-height: 170px;
}
#mobile-candidates-label {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
#mobile-candidates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
/* Row 2: cards 3, 4, 5 — spans both columns, internal 3-col grid */
#mobile-cand-row2 {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.mobile-cand-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 8px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  transition: border-color 0.15s;
  overflow: hidden;
}
.mobile-cand-card.top-1 {
  border-color: var(--accent);
  background: var(--surface2);
}
.mobile-cand-text {
  font-family: var(--myanmar);
  font-size: 26px;
  line-height: 1.35;
  color: var(--text);
  text-align: center;
}
/* Smaller text for row-2 cards (3 per row = less space) */
#mobile-cand-row2 .mobile-cand-text {
  font-size: 20px;
}
.mobile-cand-card.top-1 .mobile-cand-text { color: var(--accent); }
.mobile-cand-card.skeleton {
  opacity: 0.3;
  pointer-events: none;
}
.mobile-cand-card.skeleton .mobile-cand-text { color: var(--muted); }
.mobile-cand-pct {
  font-size: 9px;
  font-weight: 700;
  color: var(--text2);
  letter-spacing: 0.03em;
}

/* ── Mobile bottom controls ───────────────────────────────────────────────── */
#mobile-controls {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr;
  gap: 7px;
  padding: 8px 10px 16px;
  flex-shrink: 0;
}
#mobile-controls .btn {
  flex-direction: row;
  justify-content: center;
  gap: 6px;
  padding: 14px 4px;
  font-size: 11px;
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
#toast {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--accent);
  color: #000;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 8px 20px;
  border-radius: 20px;
  opacity: 0;
  transition: opacity 0.18s, transform 0.18s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 200;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--accent2); color: #fff; }

/* ── Settings overlay ─────────────────────────────────────────────────────── */
#settings-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 100;
  align-items: flex-end;
  justify-content: center;
}
#settings-overlay.open { display: flex; }

.settings-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-width: 640px;
  padding: 32px 22px 28px;
  animation: slideUp 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 88dvh;
  overflow-y: auto;
}
@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.settings-dialog h2 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sheet-close {
  margin-left: auto;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  font-weight: 400;
}
.settings-section {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.settings-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.settings-row-label { font-size: 12px; font-weight: 600; color: var(--text); }
.settings-row-desc  { font-size: 10px; color: var(--muted); margin-top: 2px; }

#settings-model-sel,
#settings-user-sel,
#settings-backend-url {
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
#settings-model-sel:focus,
#settings-user-sel:focus,
#settings-backend-url:focus { border-color: var(--accent); }

#hand-pref-section { display: none; }
#hand-pref-section.visible { display: block; }
#kbd-section { display: none; }
#kbd-section.visible { display: block; }

.hand-seg {
  display: flex;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
}
.hand-seg-btn {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 7px 13px;
  border: none;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background 0.14s, color 0.14s;
  -webkit-tap-highlight-color: transparent;
}
.hand-seg-btn + .hand-seg-btn { border-left: 1.5px solid var(--border); }
.hand-seg-btn.active { background: var(--accent); color: #000; }

.kbd-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 12px;
}
.kbd-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  transition: border-color 0.18s;
}
.kbd-row:focus-within { border-color: var(--accent); }
.kbd-action-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text2);
  flex: 1;
  display: flex;
  align-items: center;
  gap: 5px;
}
.kbd-action-label svg { opacity: 0.5; flex-shrink: 0; }
.kbd-input {
  width: 34px;
  height: 30px;
  text-align: center;
  background: var(--surface2);
  border: 1.5px solid var(--border2);
  border-radius: 7px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  outline: none;
  cursor: pointer;
  caret-color: transparent;
  transition: border-color 0.18s, background 0.18s, color 0.18s;
  flex-shrink: 0;
}
.kbd-input:focus { border-color: var(--accent); background: var(--accent-dim); color: #fff; }
.kbd-reset-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 6px 11px;
  border: 1.5px solid var(--border2);
  border-radius: var(--radius);
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.18s, color 0.18s;
  margin-top: 9px;
}
.kbd-reset-btn:hover { border-color: var(--accent2); color: var(--accent2); }

.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  pointer-events: none;
}
.toggle input:checked ~ .toggle-thumb { transform: translateX(20px); }

/* ── Scrollbars ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }


/* ── Data Collection panel ───────────────────────────────────────────────── */
/* ── Collect panel (desktop sidebar) ─────────────────────────────────────── */
#collect-panel {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 10px 12px 10px;
  overflow-y: auto;
}
#collect-header {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
#collect-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.collect-btn {
  font-size: 9px !important;
  padding: 9px 4px !important;
  flex-direction: row !important;
  justify-content: center;
  gap: 5px !important;
}
.correct-btn { border-color: var(--status-complete) !important; color: var(--status-complete) !important; }
.wrong-btn   { border-color: var(--accent2) !important; color: var(--accent2) !important; }
.collect-sub-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--text2);
  margin: 8px 0 6px;
  letter-spacing: 0.03em;
}

/* Fix 2: pick list — 1 on top, then 2+2 grid */
#collect-pick-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
/* First child spans full width (rank #1) */
#collect-pick-list .collect-pick-btn:first-child {
  grid-column: 1 / -1;
}
.collect-pick-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--myanmar);
  font-size: 16px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
  gap: 4px;
}
.collect-pick-btn:hover { border-color: var(--status-complete); color: var(--status-complete); }
.collect-pick-rank {
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
}

/* Fix 3: cancel button */
.collect-cancel-btn {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 6px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  border: 1.5px solid var(--border2);
  border-radius: var(--radius);
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.collect-cancel-btn:hover { border-color: var(--accent2); color: var(--accent2); }

/* Fix 4: type row — equal height, 2:1 ratio */
#collect-type-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
  height: 40px;
}
#collect-input {
  flex: 2;
  padding: 0 10px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--myanmar);
  font-size: 16px;
  outline: none;
  transition: border-color 0.18s;
  height: 100%;
}
#collect-input:focus { border-color: var(--accent); }
#collect-input.invalid { border-color: var(--accent2); }
.collect-save-btn {
  flex: 1;
  height: 100%;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.15s;
}
.collect-save-btn:hover { opacity: 0.85; }
#collect-input-error {
  font-size: 8px;
  color: var(--accent2);
  margin-top: 4px;
  min-height: 12px;
}
#collect-status {
  font-size: 9px;
  font-weight: 600;
  color: var(--status-complete);
  margin-top: 6px;
  min-height: 14px;
}

/* Mobile collect panel buttons strip */
#mobile-collect-panel {
  flex-shrink: 0;
  padding: 6px 10px 4px;
  border-top: 1px solid var(--border);
}
#mobile-collect-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

/* Fix 5: Mobile collect modal */
#mobile-collect-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.mobile-collect-modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-width: 540px;
  padding: 24px 16px 28px;
  animation: slideUp 0.22s cubic-bezier(0.4,0,0.2,1);
  max-height: 80dvh;
  overflow-y: auto;
}
.mobile-collect-modal-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}
/* Pick list in modal: same 1/2+2 grid */
#mobile-modal-pick-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 4px;
}
#mobile-modal-pick-list .collect-pick-btn:first-child {
  grid-column: 1 / -1;
}
/* Type input in modal */
.mobile-modal-type-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  height: 44px;
  margin-bottom: 6px;
}
.mobile-modal-type-row input {
  flex: 2;
  padding: 0 12px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--myanmar);
  font-size: 18px;
  outline: none;
}
.mobile-modal-type-row input:focus { border-color: var(--accent); }
.mobile-modal-save-btn {
  flex: 1;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

/* ════════════════════════════════════════════════════════════════════════════
   DESKTOP LANDSCAPE  ≥ 768px
   ════════════════════════════════════════════════════════════════════════════ */
@media (min-width: 768px) and (orientation: landscape) {
  #app {
    flex-direction: row;
    max-width: 100%;
    width: 100%;
    height: 100dvh;
    overflow: hidden;
  }

  /* Left panel */
  #control-panel {
    display: flex;
    flex-direction: column;
    width: var(--control-w);
    min-width: 260px;
    max-width: 340px;
    flex-shrink: 0;
    height: 100dvh;
    padding: var(--bento-pad);
    gap: var(--bento-gap);
    background: var(--bg);
  }

  header, .bento-info, .bento-controls { order: unset; }

  .bento-info {
    display: flex;
    flex: 1;
    min-height: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    flex-direction: column;
    overflow: hidden;
  }
  header {
    padding: 10px 14px 6px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
  }
  .logo { font-size: 13px; }
  #candidates-wrap { padding: 8px 12px 10px; }

  .bento-controls {
    display: block;
    flex-shrink: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 10px;
    overflow: hidden;
  }
  #controls {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  #controls #btn-predict { grid-column: 1 / -1; }
  #controls .btn { padding: 9px 4px; }
  .btn-kbd { display: block; }

  /* Right panel: canvas fills remaining space */
  #canvas-panel {
    order: unset;
    flex: 1;
    min-width: 0;
    height: 100dvh;
  }
  #canvas-wrap {
    padding: var(--bento-pad);
    height: 100%;
  }
  #draw-canvas {
    border-radius: 16px;
    border: 1px solid var(--border);
  }
  #stroke-count { right: calc(var(--bento-pad) + 16px); top: calc(var(--bento-pad) + 8px); }

  /* Hide mobile-only elements on desktop */
  #mobile-header          { display: none; }
  #mobile-status-bar      { display: none; }
  #mobile-candidates-wrap { display: none; }
  #mobile-candidates      { display: none; }
  #mobile-controls        { display: none; }
  #mobile-collect-panel   { display: none; }
  #mobile-collect-modal   { display: none !important; }

  /* Hand side flip */
  #app.left-hand { flex-direction: row-reverse; }

  /* Show desktop-only settings sections */
  #hand-pref-section.visible { display: block; }
  #kbd-section.visible { display: block; }

  #toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
  }
  #toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (min-width: 1200px) and (orientation: landscape) {
  :root { --control-w: 340px; }
}


/* ── Refined labels + empty states (shared top bar redesign) ─────────────── */
#result-label, #candidates-label, #collect-label-text, #mobile-candidates-label, #result-confidence-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--text2);
}
#collect-header { text-transform: none; letter-spacing: 0; }
#result-text.empty {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
  padding: 0 12px;
}
.candidate-empty { font-size: 11px; padding: 28px 0; }
.collect-btn:disabled { opacity: 0.4; cursor: default; pointer-events: none; }

/* Phone: space under the top bar; quiet placeholders until there is a reading */
#mobile-status-bar { margin-top: 10px; }
.mobile-cand-card.skeleton .mobile-cand-text,
.mobile-cand-card.skeleton .mobile-cand-pct { visibility: hidden; }
