/* ══════════════════════════════════════════════════════════════════════
   CLOFFEDIA — 8-bit RPG UI
   Four themes chosen at cafe setup: vintage (default) · loft · nature · minimal.
   Every colour is a token; body.theme-<name> swaps the whole set.
   The legacy --pixel-* names are mapped onto the tokens so older templates
   that use them inline follow the theme automatically.
   ══════════════════════════════════════════════════════════════════════ */

:root,
.theme-vintage {
  --bg: #1f140d;
  --panel: #2f2117;
  --panel-2: #24180f;
  --frame: #d9a95b;
  --frame-hi: #6b4a2a;
  --shadow: #0f0905;
  --ink: #f3e4c4;
  --muted: #b59c7a;
  --accent: #f29b38;
  --accent-ink: #2a1608;
  --gold: #ffd166;
  --good: #9cc36b;
  --bad: #e2643f;
  --info: #7fb8c9;
  --line: #4a3524;
  --glow: none;
  --bg-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' shape-rendering='crispEdges'%3E%3Cpath fill='%23281a11' d='M11 4h2v2h2v2h2v2h2v4h-2v2h-2v2h-2v2h-2v-2H9v-2H7v-2H5v-4h2V8h2V6h2z'/%3E%3Cpath fill='%231f140d' d='M11 9h2v2h2v2h-2v2h-2v-2H9v-2h2z'/%3E%3C/svg%3E");
}

.theme-loft {
  --bg: #2a1614;
  --panel: #221b1a;
  --panel-2: #171211;
  --frame: #9aa1a8;
  --frame-hi: #3b3433;
  --shadow: #0c0807;
  --ink: #efe7de;
  --muted: #a8988e;
  --accent: #ff4f5e;
  --accent-ink: #1a0b0b;
  --gold: #ffb347;
  --good: #7fd1a6;
  --bad: #ff6b5b;
  --info: #6fb7c9;
  --line: #3d302d;
  --glow: 0 0 6px rgba(255, 79, 94, .75);
  --bg-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='16' shape-rendering='crispEdges'%3E%3Crect width='32' height='16' fill='%23231210'/%3E%3Crect x='1' y='1' width='14' height='6' fill='%23301815'/%3E%3Crect x='17' y='1' width='14' height='6' fill='%232d1714'/%3E%3Crect x='-7' y='9' width='14' height='6' fill='%232d1714'/%3E%3Crect x='9' y='9' width='14' height='6' fill='%23301815'/%3E%3Crect x='25' y='9' width='14' height='6' fill='%23301815'/%3E%3C/svg%3E");
}

.theme-nature {
  --bg: #1b2817;
  --panel: #2a3f2c;
  --panel-2: #213322;
  --frame: #b98b57;
  --frame-hi: #4f3a24;
  --shadow: #0d150b;
  --ink: #eef3df;
  --muted: #a9b99a;
  --accent: #a6d26a;
  --accent-ink: #17240f;
  --gold: #f2d16b;
  --good: #a6d26a;
  --bad: #e3775a;
  --info: #8ccbd6;
  --line: #3d5a3f;
  --glow: none;
  --bg-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' shape-rendering='crispEdges'%3E%3Crect width='24' height='24' fill='%231b2817'/%3E%3Cpath fill='%23223320' d='M4 6h2v2h2v2H6v2H4V8H2V6h2zM16 15h2v2h2v2h-2v2h-2v-2h-2v-2h2z'/%3E%3C/svg%3E");
}

.theme-minimal {
  --bg: #d9d9d3;
  --panel: #f8f8f5;
  --panel-2: #ecece7;
  --frame: #2a2a2a;
  --frame-hi: #c9c9c2;
  --shadow: #a3a39c;
  --ink: #1f1f1f;
  --muted: #66665f;
  --accent: #2a2a2a;
  --accent-ink: #f8f8f5;
  --gold: #9a6a1c;
  --good: #2f7a45;
  --bad: #b8392b;
  --info: #2b6a99;
  --line: #d3d3cb;
  --glow: none;
  --bg-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' shape-rendering='crispEdges'%3E%3Crect width='24' height='24' fill='%23d9d9d3'/%3E%3Crect width='24' height='1' fill='%23d0d0c9'/%3E%3Crect width='1' height='24' fill='%23d0d0c9'/%3E%3C/svg%3E");
}

/* legacy names used inline by older templates */
:root, body {
  --pixel-black: var(--panel-2);
  --pixel-dark: var(--bg);
  --pixel-panel: var(--panel);
  --pixel-border: var(--line);
  --pixel-green: var(--good);
  --pixel-yellow: var(--gold);
  --pixel-red: var(--bad);
  --pixel-blue: var(--info);
  --pixel-white: var(--ink);
  --pixel-gray: var(--muted);

  --font-display: 'Pixelify Sans', 'Chakra Petch', system-ui, sans-serif;
  --font-body: 'Chakra Petch', 'Pixelify Sans', system-ui, sans-serif;
  --font-digits: 'Press Start 2P', 'Pixelify Sans', monospace;
  --px: 4px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--bg);
  background-image: var(--bg-pattern);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); }
img, canvas { image-rendering: pixelated; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.25; }
h1 { font-size: 30px; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }

:focus-visible { outline: 3px dashed var(--gold); outline-offset: 3px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--panel-2); }
::-webkit-scrollbar-thumb { background: var(--frame); }

/* ── Pixel frame: the notched-corner border every window uses ───────────── */
.px-frame,
.pixel-card,
.stat-card,
.news-card,
.window {
  position: relative;
  background: var(--panel);
  box-shadow:
    0 calc(var(--px) * -1) 0 0 var(--frame),
    0 var(--px) 0 0 var(--frame),
    calc(var(--px) * -1) 0 0 0 var(--frame),
    var(--px) 0 0 0 var(--frame),
    inset 0 0 0 2px var(--frame-hi),
    calc(var(--px) * 2) calc(var(--px) * 2) 0 0 var(--shadow);
}

/* ── NAV (top HUD) ─────────────────────────────────────────────────────── */
.pixel-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--panel-2);
  border-bottom: var(--px) solid var(--frame);
  box-shadow: 0 var(--px) 0 var(--shadow);
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
}
.nav-brand canvas { width: 28px; height: 28px; }
.nav-brand small { display: block; font-size: 11px; font-weight: 400; color: var(--muted); font-family: var(--font-body); }
.nav-links {
  display: flex;
  gap: 6px;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  color: var(--muted);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 15px;
  white-space: nowrap;
  border: 2px solid transparent;
}
.nav-link:hover { color: var(--ink); border-color: var(--line); }
.nav-link.active { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.nav-link .ico { width: 16px; height: 16px; image-rendering: pixelated; }
.nav-link.save { color: var(--gold); border-color: var(--gold); }

/* ── LANGUAGE SWITCH ───────────────────────────────────────────────────── */
.lang-switch { display: inline-flex; align-items: center; border: 2px solid var(--line); margin-left: 4px; flex-shrink: 0; }
.lang-switch a { padding: 5px 9px; font-family: var(--font-display); font-size: 13px; color: var(--muted); text-decoration: none; }
.lang-switch a.active { background: var(--frame); color: var(--accent-ink); }
.lang-switch a:hover:not(.active) { color: var(--ink); }
.guest-bar { display: flex; justify-content: flex-end; max-width: 1160px; width: 100%; margin: 0 auto; padding: 12px 20px 0; }

/* ── BUTTONS ───────────────────────────────────────────────────────────── */
.pixel-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  background: var(--panel-2);
  color: var(--ink);
  border: 3px solid var(--frame);
  box-shadow: 3px 3px 0 var(--shadow);
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.pixel-btn:hover { background: var(--frame-hi); }
.pixel-btn:active { transform: translate(3px, 3px); box-shadow: none; }
.pixel-btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); text-shadow: none; }
.pixel-btn.primary:hover { filter: brightness(1.08); }
.pixel-btn.danger { color: var(--bad); border-color: var(--bad); }
.pixel-btn.ghost { border-color: var(--line); color: var(--muted); box-shadow: none; }
.pixel-btn.small { padding: 5px 10px; font-size: 13px; border-width: 2px; box-shadow: 2px 2px 0 var(--shadow); }
.pixel-btn[disabled] { opacity: .45; cursor: not-allowed; }
.agent-btn, .hq-btn { color: var(--info); border-color: var(--info); }
.logout-btn { color: var(--bad); border-color: var(--bad); }

/* ── LAYOUT ────────────────────────────────────────────────────────────── */
.pixel-main {
  flex: 1;
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-head h1 { font-size: 28px; }
.page-head p { color: var(--muted); margin-top: 4px; max-width: 62ch; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 26px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 26px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 26px; }
.stack > * + * { margin-top: 26px; }
.muted { color: var(--muted); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.gold { color: var(--gold); }

/* ── WINDOWS ───────────────────────────────────────────────────────────── */
.pixel-card, .window { padding: 20px 22px; margin: var(--px) var(--px) 30px; }
.window > :last-child, .pixel-card > :last-child { margin-bottom: 0; }
.pixel-card h2, .pixel-card h3, .window-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 18px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px dashed var(--line);
}
.window-title .spacer { margin-left: auto; }
.window-title a { font-size: 14px; font-family: var(--font-body); color: var(--muted); }
.window.sunken { background: var(--panel-2); }

/* ── STATS ─────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 22px;
  margin: var(--px) var(--px) 30px;
}
.stat-card { padding: 16px 16px 14px; text-align: left; display: block; color: var(--ink); }
a.stat-card:hover { background: var(--panel-2); }
.stat-label { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.stat-value { font-family: var(--font-digits); font-size: 17px; color: var(--good); line-height: 1.35; word-break: break-word; }
.stat-value.revenue { color: var(--gold); }
.stat-value.cost { color: var(--bad); }
.stat-sub { color: var(--muted); font-size: 13px; margin-top: 6px; }

.mini-stats { margin: 0 4px 18px; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 560px) { .mini-stats { grid-template-columns: minmax(0, 1fr); } }

/* ── FORMS ─────────────────────────────────────────────────────────────── */
label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 14px; }
.form-group { margin-bottom: 16px; }
.pixel-input, .pixel-select, .pixel-main input[type=text], .pixel-main input[type=email],
.pixel-main input[type=password], .pixel-main input[type=number], .pixel-main input[type=date],
.pixel-main input[type=month], .pixel-main input[type=week], .pixel-main select, .pixel-main textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--panel-2);
  color: var(--ink);
  border: 3px solid var(--line);
  font-family: var(--font-body);
  font-size: 15px;
  margin-bottom: 12px;
  outline: none;
  border-radius: 0;
}
.pixel-input:focus, .pixel-select:focus, .pixel-main input:focus, .pixel-main select:focus { border-color: var(--frame); }
.pixel-main input[type=checkbox], .pixel-main input[type=radio] { accent-color: var(--accent); width: 18px; height: 18px; }
.pixel-color { height: 44px; width: 64px; padding: 2px; background: var(--panel-2); border: 3px solid var(--line); cursor: pointer; }
.check-row { display: flex; gap: 10px; align-items: flex-start; color: var(--ink); font-size: 15px; cursor: pointer; }
.check-row input { margin-top: 3px; flex-shrink: 0; }
.helptext, .form-help { color: var(--muted); font-size: 13px; margin-top: -6px; margin-bottom: 12px; }
.errorlist { list-style: none; color: var(--bad); font-size: 14px; margin-bottom: 8px; }

.dropzone {
  display: block;
  padding: 26px 18px;
  text-align: center;
  border: 3px dashed var(--frame);
  background: var(--panel-2);
  cursor: pointer;
}
.dropzone:hover, .dropzone.drag { background: var(--frame-hi); }
.dropzone strong { display: block; font-family: var(--font-display); font-size: 19px; color: var(--ink); }
.dropzone span { color: var(--muted); font-size: 14px; }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone .file-name { display: block; margin-top: 8px; color: var(--gold); }

/* ── TABLES ────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.pixel-table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 14px; }
.pixel-table th {
  text-align: left;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14px;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 3px solid var(--line);
  white-space: nowrap;
}
.pixel-table td { padding: 9px 10px; border-bottom: 2px solid var(--line); vertical-align: middle; }
.pixel-table tr:last-child td { border-bottom: none; }
.pixel-table tr:hover td { background: var(--panel-2); }
.pixel-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pixel-table select, .pixel-table input { margin-bottom: 0 !important; }

/* ── TAGS / BADGES ─────────────────────────────────────────────────────── */
.tag {
  display: inline-block;
  padding: 1px 7px;
  font-size: 12px;
  font-family: var(--font-display);
  border: 2px solid currentColor;
  white-space: nowrap;
  line-height: 1.4;
}
.tag.good { color: var(--good); }
.tag.bad { color: var(--bad); }
.tag.gold { color: var(--gold); }
.tag.info { color: var(--info); }
.tag.muted { color: var(--muted); }

/* ── PERIOD TABS ───────────────────────────────────────────────────────── */
.period-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.period-tab {
  padding: 7px 14px;
  background: var(--panel-2);
  color: var(--muted);
  border: 3px solid var(--line);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 15px;
}
.period-tab:hover { color: var(--ink); }
.period-tab.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ── MESSAGES / QUEST LOG ──────────────────────────────────────────────── */
.pixel-messages { margin-bottom: 20px; }
.pixel-message {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 14px;
  margin-bottom: 10px;
  border: 3px solid var(--line);
  background: var(--panel);
  font-size: 15px;
}
.pixel-message.success { border-color: var(--good); }
.pixel-message.error { border-color: var(--bad); }
.pixel-message.warning { border-color: var(--gold); }
.pixel-message.info { border-color: var(--info); }

.quest-list { list-style: none; }
.quest {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 2px dashed var(--line);
  font-size: 15px;
}
.quest:last-child { border-bottom: none; }
.quest .pip { width: 14px; height: 14px; margin-top: 4px; background: var(--muted); box-shadow: 2px 2px 0 var(--shadow); }
.quest.error .pip { background: var(--bad); }
.quest.warning .pip { background: var(--gold); }
.quest.info .pip { background: var(--info); }
.quest.done .pip { background: var(--good); }
.quest a { color: var(--accent); }
.quest small { display: block; color: var(--muted); font-size: 13px; }

/* ── HOME: SCENE + HUD ─────────────────────────────────────────────────── */
.scene-wrap { position: relative; margin: var(--px) var(--px) 30px; padding: 0; overflow: hidden; }
.scene-wrap canvas { display: block; width: 100%; height: auto; aspect-ratio: 320 / 168; background: var(--panel-2); }
.hud {
  position: absolute;
  top: 12px;
  bottom: 12px;               /* level box sits bottom-left so the wall shelf stays visible */
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  pointer-events: none;
}
.hud > .hud-box:first-child { align-self: flex-end; }
.hud-box {
  pointer-events: auto;
  background: rgba(15, 9, 5, .82);
  border: 3px solid var(--frame);
  padding: 8px 12px;
  color: #f3e9d6;
}
.theme-minimal .hud-box { background: rgba(248, 248, 245, .9); color: var(--ink); }
.hud-name { font-family: var(--font-display); font-size: 18px; line-height: 1.2; }
.hud-rank { font-size: 13px; opacity: .8; }
.xp { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-family: var(--font-digits); font-size: 9px; }
.xp-bar { width: 130px; height: 10px; background: var(--shadow); border: 2px solid var(--frame); position: relative; }
.xp-bar i { position: absolute; inset: 0 auto 0 0; background: var(--good); }
.hud-gold { text-align: right; }
.hud-gold .coins { font-family: var(--font-digits); font-size: 15px; color: var(--gold); }
.hud-gold small { display: block; font-size: 12px; opacity: .8; }

.command-menu { list-style: none; }
.command-menu a {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 11px 6px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 17px;
  border-bottom: 2px dashed var(--line);
}
.command-menu li:last-child a { border-bottom: none; }
.command-menu a::before { content: ''; width: 0; height: 0; border: 6px solid transparent; border-left: 8px solid transparent; }
.command-menu a:hover::before, .command-menu a:focus-visible::before { border-left-color: var(--gold); }
.command-menu a:hover { color: var(--gold); }
.command-menu small { color: var(--muted); font-family: var(--font-body); font-size: 13px; }

.unlock { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }
.unlock b { color: var(--ink); font-weight: 600; }

/* ── THEME PICKER ──────────────────────────────────────────────────────── */
.theme-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.theme-option { position: relative; display: block; cursor: pointer; }
.theme-option input { position: absolute; opacity: 0; }
.theme-option .preview {
  display: block;
  border: 3px solid var(--line);
  box-shadow: 4px 4px 0 var(--shadow);
  background: var(--panel-2);
}
.theme-option canvas { display: block; width: 100%; height: auto; aspect-ratio: 320 / 168; }
.theme-option .name { display: block; padding: 8px 10px 2px; font-family: var(--font-display); font-size: 17px; color: var(--ink); }
.theme-option .desc { display: block; padding: 0 10px 10px; font-size: 13px; color: var(--muted); }
.theme-option input:checked + .preview { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold), 6px 6px 0 var(--shadow); }
.theme-option input:focus-visible + .preview { outline: 3px dashed var(--gold); outline-offset: 4px; }

/* ── DECOR EDITOR ──────────────────────────────────────────────────────── */
.decor-preview { position: sticky; top: 84px; align-self: start; }
@media (max-width: 900px) { .decor-preview { position: static; } }
.decor-group { border: 2px dashed var(--line); padding: 8px 12px 10px; margin: 0 0 12px; }
.decor-group legend { font-family: var(--font-display); font-size: 16px; color: var(--gold); padding: 0 6px; }
.decor-group legend small { font-family: var(--font-body); font-size: 12px; margin-left: 6px; }
.slot-row { display: grid; grid-template-columns: 8.5em 1fr; gap: 10px; align-items: center; padding: 5px 0; font-size: 14px; }
.slot-row:hover > span, .slot-row:focus-within > span { color: var(--gold); }
.slot-select { width: 100%; min-width: 0; }
.slot-select:disabled { opacity: .5; }
.cat-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; }
.cat-row .check-row { font-size: 14px; }
.cat-row .locked { opacity: .55; cursor: not-allowed; }
@media (max-width: 520px) { .slot-row { grid-template-columns: 1fr; gap: 4px; } .cat-row { grid-template-columns: 1fr; } }
.roadmap { margin-top: 18px; }
.roadmap summary { cursor: pointer; font-family: var(--font-display); font-size: 16px; color: var(--gold); padding: 6px 0; }
.roadmap tr.todo td { opacity: .62; }
.roadmap tr.next td { opacity: 1; background: color-mix(in srgb, var(--gold, #e8b04a) 12%, transparent); }
.roadmap td:first-child { white-space: nowrap; font-family: var(--font-digits); font-size: 10px; }
.chip { display: inline-block; margin: 2px 4px 2px 0; padding: 1px 7px; font-size: 12.5px; border: 2px solid currentColor; line-height: 1.45; }
.chip-food { color: #e8a24a; } .chip-placed { color: #6fb0e0; } .chip-hanging { color: #7fbf5a; }
.chip-machine { color: #e06a5a; } .chip-cat { color: #e08ac0; }
.levelup-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; padding: 10px 14px;
  background: var(--panel); border: 3px solid var(--gold); color: var(--ink); text-decoration: none; box-shadow: 4px 4px 0 var(--shadow);
  animation: levelup-pulse 1.6s steps(2) infinite; }
.levelup-banner b { color: var(--gold); }
.levelup-tag { font-family: var(--font-digits); font-size: 11px; background: var(--gold); color: #1a120b; padding: 5px 8px; }
.levelup-go { margin-left: auto; font-family: var(--font-display); color: var(--gold); white-space: nowrap; }
@keyframes levelup-pulse { 50% { border-color: var(--accent); } }
@media (prefers-reduced-motion: reduce) { .levelup-banner { animation: none; } }

/* ── BARISTA EDITOR ────────────────────────────────────────────────────── */
.barista-editor { display: grid; grid-template-columns: 220px 1fr; gap: 26px; align-items: start; }
.barista-preview { text-align: center; position: sticky; top: 84px; }
.barista-preview canvas { width: 192px; height: 192px; image-rendering: pixelated; background: var(--panel-2); border: 3px solid var(--line); }
.barista-preview p { font-size: 13px; margin-top: 8px; }
.field-label { font-family: var(--font-display); color: var(--gold); font-size: 15px; margin: 14px 0 8px; }
.field-label:first-child { margin-top: 0; }
.seg { display: inline-flex; border: 3px solid var(--line); }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 7px 18px; font-family: var(--font-display); }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + span { outline: 3px dashed var(--gold); outline-offset: -5px; }
.hair-options { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.hair-option { cursor: pointer; }
.hair-option input { position: absolute; opacity: 0; pointer-events: none; }
.hair-option > span { display: block; text-align: center; border: 3px solid var(--line); background: var(--panel-2); padding: 6px 4px; }
.hair-option canvas { width: 64px; height: 64px; max-width: 100%; image-rendering: pixelated; display: block; margin: 0 auto; }
.hair-option input:checked + span { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.hair-option input:focus-visible + span { outline: 3px dashed var(--gold); outline-offset: 2px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch { cursor: pointer; position: relative; }
.swatch input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.swatch span { display: block; width: 30px; height: 30px; border: 3px solid var(--line); }
.swatch.theme-swatch span { width: auto; padding: 0 8px; line-height: 24px; font-size: 12px; color: var(--muted); background: var(--panel-2); }
.swatch input:checked + span, .swatch.custom input:checked ~ input[type=color] { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.swatch input:focus-visible + span { outline: 3px dashed var(--gold); outline-offset: 2px; }
.swatch.custom input[type=color] { width: 40px; height: 30px; padding: 0; border: 3px solid var(--line); background: var(--panel-2); cursor: pointer; }
@media (max-width: 720px) {
  .barista-editor { grid-template-columns: 1fr; }
  .barista-preview { position: static; }
  .hair-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hair-option canvas { width: 56px; height: 56px; }
}

/* ── CONTACT ───────────────────────────────────────────────────────────── */
.contact-box { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.contact-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 3px solid var(--line); background: var(--panel-2);
  color: var(--ink); text-decoration: none; min-width: 0; }
.contact-item:hover, .contact-item:focus-visible { border-color: var(--gold); }
.contact-item small { display: block; font-size: 12px; color: var(--muted); }
.contact-item b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.contact-ico { flex: none; display: grid; place-items: center; min-width: 38px; height: 38px; padding: 0 4px; background: var(--accent);
  color: var(--accent-ink); font-family: var(--font-digits); font-size: 9px; }
.contact-ico.line { background: #06c755; color: #fff; }
.contact-strip { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 14px; padding: 12px 16px;
  border-top: 3px solid var(--frame); background: var(--panel); font-size: 14px; color: var(--muted); text-decoration: none; }
.contact-strip b { font-family: var(--font-display); color: var(--gold); }
.contact-strip:hover b, .contact-strip:focus-visible b { text-decoration: underline; }
.manual-btn { display: inline-flex; align-items: center; gap: 10px; }
.manual-ico { display: inline-grid; place-items: center; min-width: 34px; height: 22px; padding: 0 4px; background: var(--accent);
  color: var(--accent-ink); font-family: var(--font-digits); font-size: 9px; }

/* ── BILLING ───────────────────────────────────────────────────────────── */
.pay-steps { list-style: none; counter-reset: p; margin-bottom: 12px; }
.pay-steps li { counter-increment: p; position: relative; padding: 7px 0 7px 36px; }
.pay-steps li::before { content: counter(p); position: absolute; left: 0; top: 7px; display: grid; place-items: center; width: 24px; height: 24px;
  font-family: var(--font-digits); font-size: 10px; background: var(--accent); color: var(--accent-ink); }
.pay-steps b { font-family: var(--font-display); }
.thai-qr { background: #fff; color: #1d3557; text-align: center; max-width: 320px; margin: 0 auto; border: 3px solid #1d4f7a; }
.thai-qr-head { background: #1d4f7a; color: #fff; font-family: var(--font-display); font-size: 15px; padding: 8px; letter-spacing: 1px; }
.thai-qr-code svg { width: 100%; height: auto; display: block; padding: 6px 18px 0; }
.thai-qr-amount { font-family: var(--font-digits); font-size: 18px; color: #1d4f7a; padding: 2px 0 6px; }
.thai-qr-name { font-size: 15px; color: #333; padding: 0 10px 4px; }
.thai-qr-note { font-size: 13px; color: #666; padding: 0 10px 10px; }
.review-card { display: grid; grid-template-columns: 220px 1fr; gap: 22px; }
.review-slip img { width: 100%; border: 3px solid var(--line); background: #fff; }
.review-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 20px; margin-bottom: 14px; }
.review-facts dt { color: var(--muted); font-size: 13px; }
.review-facts dd { font-size: 15px; }
.review-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.reject-form { display: flex; gap: 8px; flex: 1; min-width: 260px; }
.reject-form input { margin: 0 !important; }
@media (max-width: 700px) { .review-card { grid-template-columns: 1fr; } }

/* ── LEGAL PAGES ───────────────────────────────────────────────────────── */
.legal { max-width: 760px; margin: 0 auto; }
.legal h2 { font-size: 18px; color: var(--gold); margin: 22px 0 8px; }
.legal p, .legal li { max-width: 72ch; line-height: 1.75; }
.legal ul { padding-left: 22px; margin: 6px 0; }
.legal .meta { color: var(--muted); font-size: 14px; }

/* ── CHARTS ────────────────────────────────────────────────────────────── */
.chart-box { position: relative; height: 280px; }
.chart-box.short { height: 200px; }
.bar-meter { height: 10px; background: var(--panel-2); border: 2px solid var(--line); min-width: 60px; }
.bar-meter i { display: block; height: 100%; background: var(--accent); }

/* ── IMPORT REVIEW ─────────────────────────────────────────────────────── */
.match-method { font-size: 12px; color: var(--muted); }
.row-unresolved td { background: color-mix(in srgb, var(--bad) 12%, transparent); }
.row-guess td { background: color-mix(in srgb, var(--gold, #e8b04a) 14%, transparent); }
.code-box {
  display: block;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 2px solid var(--line);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--ink);
  overflow-x: auto;
  white-space: pre;
}

/* ── NEWS / GROCERY (legacy pages) ─────────────────────────────────────── */
.news-card { padding: 20px; margin: var(--px) var(--px) 26px; }
.news-card h3 { color: var(--gold); margin-bottom: 6px; font-size: 18px; }
.news-card .meta { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.news-card p { color: var(--ink); font-size: 15px; line-height: 1.7; }
.grocery-item { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 2px dashed var(--line); }
.grocery-item:last-child { border-bottom: none; }

/* ── AGENT STATUS (staff pages) ────────────────────────────────────────── */
.agent-status-pending { color: var(--muted); }
.agent-status-running { color: var(--gold); animation: blink 1s step-end infinite; }
.agent-status-done { color: var(--good); }
.agent-status-error { color: var(--bad); }
@keyframes blink { 50% { opacity: 0; } }

/* ── LANDING ───────────────────────────────────────────────────────────── */
.landing { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 34px; align-items: center; padding: 20px 0 10px; }
.landing h1 { font-size: 40px; color: var(--ink); }
.landing .lede { font-size: 18px; color: var(--muted); margin: 14px 0 22px; max-width: 46ch; }
.landing .actions { display: flex; flex-direction: column; gap: 12px; max-width: 360px; }
.feature-list { list-style: none; margin-top: 24px; }
.feature-list li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 8px 0; }
.feature-list li::before { content: ''; width: 12px; height: 12px; margin-top: 6px; background: var(--accent); box-shadow: 2px 2px 0 var(--shadow); }

/* ── FOOTER ────────────────────────────────────────────────────────────── */
.pixel-footer {
  text-align: center;
  padding: 14px;
  background: var(--panel-2);
  border-top: var(--px) solid var(--frame);
  color: var(--muted);
  font-size: 13px;
}
.pixel-footer a { color: var(--muted); }

/* ── THEME ACCENTS ─────────────────────────────────────────────────────── */
.theme-loft .window-title, .theme-loft .pixel-card h2, .theme-loft .pixel-card h3 { color: var(--accent); text-shadow: var(--glow); }
.theme-loft .nav-link.active { box-shadow: var(--glow); }
.theme-nature .window-title::before, .theme-nature .pixel-card h2::before, .theme-nature .pixel-card h3::before {
  content: ''; width: 10px; height: 10px; background: var(--accent);
  box-shadow: 4px -4px 0 var(--good), -2px 4px 0 #6f9a47;
}
.theme-vintage .window-title::before, .theme-vintage .pixel-card h2::before, .theme-vintage .pixel-card h3::before {
  content: ''; width: 8px; height: 8px; background: var(--frame); transform: rotate(45deg);
}
.theme-minimal .pixel-btn { box-shadow: 3px 3px 0 var(--frame); }

/* ── RESPONSIVE ────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .grid-main, .grid-2, .grid-3, .landing { grid-template-columns: minmax(0, 1fr); }
  .theme-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .pixel-nav { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .nav-links { width: 100%; margin-left: 0; }
  .pixel-main { padding: 20px 16px 40px; }
  .hud { position: static; padding: 10px; flex-direction: column; }
  .hud > .hud-box:first-child { align-self: stretch; }
  .hud-gold { text-align: left; }
  .landing h1 { font-size: 30px; }
  .stat-value { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
