/* PUNPAE Keycap — Glassmorphism 2.0 · ธีมหลัก Ocean Breeze · สำรอง Midnight Neon */
:root, [data-theme="ocean"] {
  --bg: #E8F6FF;
  --ink: #0A2A5E;
  --muted: #3A5A86;
  --primary: #0B3D91;
  --primary-2: #2A6BD3;
  --accent: #1F6FC4;
  --accent-soft: rgba(59, 167, 242, 0.18);
  --accent-line: rgba(31, 111, 196, 0.5);
  --mint: #7FE7D6;
  --glass: rgba(255, 255, 255, 0.55);
  --glass-strong: rgba(255, 255, 255, 0.78);
  --glass-line: rgba(255, 255, 255, 0.9);
  --line: rgba(11, 61, 145, 0.14);
  --shadow: 0 16px 40px rgba(11, 61, 145, 0.14);
  --blob-1: rgba(59, 167, 242, 0.5);
  --blob-2: rgba(127, 231, 214, 0.7);
  --blob-3: rgba(11, 61, 145, 0.16);
  --warn-bg: rgba(251, 191, 36, 0.22);
  --warn-line: rgba(180, 110, 0, 0.45);
  --warn-ink: #7A4B00;
  --bad: #B42318;
  --good: #067647;
  --input: rgba(255, 255, 255, 0.72);
}
[data-theme="midnight"] {
  --bg: #0F172A;
  --ink: #F5F3FF;
  --muted: #C4B5FD;
  --primary: #7C3AED;
  --primary-2: #8B5CF6;
  --accent: #22D3EE;
  --accent-soft: rgba(34, 211, 238, 0.16);
  --accent-line: rgba(34, 211, 238, 0.6);
  --mint: #22D3EE;
  --glass: rgba(255, 255, 255, 0.07);
  --glass-strong: rgba(15, 23, 42, 0.78);
  --glass-line: rgba(255, 255, 255, 0.16);
  --line: rgba(255, 255, 255, 0.12);
  --shadow: 0 16px 40px rgba(2, 6, 23, 0.45);
  --blob-1: rgba(124, 58, 237, 0.55);
  --blob-2: rgba(34, 211, 238, 0.3);
  --blob-3: rgba(167, 139, 250, 0.3);
  --warn-bg: rgba(251, 191, 36, 0.14);
  --warn-line: rgba(251, 191, 36, 0.45);
  --warn-ink: #FDE68A;
  --bad: #FCA5A5;
  --good: #6EE7B7;
  --input: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Anuphan', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
.num, .brand { font-family: 'Bricolage Grotesque', 'Anuphan', sans-serif; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }

.blobs { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.blobs i { position: absolute; border-radius: 50%; display: block; }
.blobs i:nth-child(1) { width: 380px; height: 380px; left: -140px; top: -90px; background: radial-gradient(circle, var(--blob-1), transparent 70%); }
.blobs i:nth-child(2) { width: 340px; height: 340px; right: -150px; top: 40%; background: radial-gradient(circle, var(--blob-2), transparent 70%); }
.blobs i:nth-child(3) { width: 300px; height: 300px; left: -80px; bottom: -120px; background: radial-gradient(circle, var(--blob-3), transparent 70%); }

#app { position: relative; z-index: 1; max-width: 480px; margin: 0 auto; padding: 24px 20px 120px; min-height: 100vh; }

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  backdrop-filter: blur(22px) saturate(170%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), var(--shadow);
  border-radius: 24px;
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: var(--glass-strong); }
}

.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.card { padding: 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
h1 { margin: 0; font-size: 28px; line-height: 1.25; }
h2 { margin: 0; font-size: 20px; }
h3 { margin: 0; font-size: 16px; }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }

.header { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.logo img { width: 48px; height: 42px; object-fit: contain; }
.logo b { font-size: 26px; font-weight: 800; letter-spacing: 0.04em; line-height: 1; }
.logo small { display: block; font-size: 11px; letter-spacing: 0.12em; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 22px; border-radius: 999px; border: 0; cursor: pointer;
  text-decoration: none; font-weight: 600; font-size: 16px;
}
.btn-primary {
  background: linear-gradient(180deg, var(--primary-2), var(--primary)); color: #fff;
  box-shadow: 0 12px 28px rgba(11, 61, 145, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn-ghost { background: var(--glass); color: var(--ink); border: 1px solid var(--glass-line); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.btn-link { background: none; color: var(--accent); min-height: 44px; }
.btn-danger { background: transparent; color: var(--bad); border: 1px solid currentColor; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; cursor: pointer; text-decoration: none; color: var(--ink); }
.btn:focus-visible, .icon-btn:focus-visible, .chip:focus-visible, .seg button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--glass); cursor: pointer; font-size: 14px; color: var(--muted);
}
.chip.on { border-color: var(--accent-line); background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.chip .badge { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--line); font-size: 12px; font-weight: 700; color: var(--ink); }
.chip.on .badge { background: var(--primary); color: #fff; }

.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.seg button {
  min-height: 56px; border-radius: 16px; border: 1px solid var(--line); background: var(--glass); cursor: pointer; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 6px;
}
.seg button.on { border-color: var(--accent-line); background: var(--accent-soft); color: var(--ink); font-weight: 600; }

label.lbl { font-size: 15px; font-weight: 600; display: block; margin-bottom: 6px; }
.input {
  width: 100%; min-height: 52px; padding: 0 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--input); color: var(--ink);
}
textarea.input { padding: 12px 16px; min-height: 90px; }
.input.big { font-family: 'Bricolage Grotesque', sans-serif; font-size: 24px; font-weight: 700; letter-spacing: 0.16em; }

.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--input); font-size: 22px; cursor: pointer; }
.stepper .num { min-width: 28px; text-align: center; font-size: 22px; font-weight: 800; }

/* คีย์แคป */
.chain { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; padding: 12px; border-radius: 18px; border: 1px solid var(--glass-line); background: var(--glass); min-height: 64px; }
.chain.base-flexible .cap { border-radius: 14px; }
.chain.base-flexible .cap.sm { border-radius: 10px; }
.ring { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #7C93B5; flex-shrink: 0; }
.cap {
  width: 46px; height: 46px; display: inline-flex; align-items: center; justify-content: center; border-radius: 11px;
  font-family: 'Bricolage Grotesque', 'Anuphan', sans-serif; font-weight: 800; font-size: 22px; color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.55), inset 0 -5px 8px rgba(2, 6, 23, 0.18), 0 6px 14px rgba(11, 61, 145, 0.25);
  position: relative; cursor: pointer; padding: 0;
}
.cap.sm { width: 32px; height: 32px; font-size: 16px; border-radius: 8px; }
.cap.led::after { content: ''; position: absolute; inset: -4px; border-radius: inherit; box-shadow: 0 0 14px 3px rgba(255, 236, 140, 0.85); pointer-events: none; }
.cap.sel { outline: 3px solid var(--accent); outline-offset: 2px; }
.swatch { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); cursor: pointer; position: relative; }
.swatch.on { outline: 3px solid var(--accent); outline-offset: 2px; }
.swatch.out { opacity: 0.25; pointer-events: none; }

/* แถบราคา sticky */
.pricebar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 14px; width: calc(100% - 24px); max-width: 456px; z-index: 20;
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 20px; border-radius: 26px; background: var(--glass-strong);
}
.pricebar .total { font-size: 30px; font-weight: 800; line-height: 1; }

.price-lines div { display: flex; justify-content: space-between; padding: 4px 0; font-size: 15px; }
.price-lines .sum { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; font-weight: 700; font-size: 18px; }

.nudge { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: 16px; background: var(--accent-soft); border: 1px solid var(--accent-line); font-size: 14px; }
.warn { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 16px; background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink); font-size: 14px; }
.ok-badge { color: var(--good); font-weight: 600; }
.bad-badge { color: var(--bad); font-weight: 600; }

.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.steps div { display: flex; flex-direction: column; gap: 8px; font-size: 12px; color: var(--muted); }
.steps i { height: 6px; border-radius: 6px; background: var(--line); display: block; }
.steps .done i { background: var(--mint); }
.steps .now i { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.steps .now { color: var(--ink); font-weight: 600; }

.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); flex-shrink: 0; }
.code-big { font-size: 38px; font-weight: 800; letter-spacing: 0.06em; line-height: 1; }

.qr-box { background: #fff; border-radius: 22px; padding: 16px; box-shadow: 0 0 0 6px rgba(59, 167, 242, 0.3), var(--shadow); width: 240px; margin: 0 auto; }
.qr-box img { width: 208px; height: 208px; }
.photos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.photos figure { margin: 0; border-radius: 18px; overflow: hidden; border: 1px solid var(--glass-line); background: var(--glass); }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.photos figcaption { padding: 6px 10px; font-size: 12px; color: var(--muted); }

.sheet-bg { position: fixed; inset: 0; background: rgba(10, 42, 94, 0.25); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 480px; max-height: 85vh; overflow: auto; border-radius: 28px 28px 0 0; padding: 20px 20px 28px; background: var(--glass-strong); }
.toast { position: fixed; left: 50%; top: 18px; transform: translateX(-50%); z-index: 60; padding: 12px 18px; border-radius: 16px; background: var(--ink); color: var(--bg); font-size: 14px; box-shadow: var(--shadow); max-width: 90vw; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.list-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; text-decoration: none; color: var(--ink); }
.word-pill { padding: 6px 12px; border-radius: 10px; background: var(--accent-soft); border: 1px solid var(--accent-line); font-weight: 800; letter-spacing: 0.12em; }
.tabs { display: flex; gap: 8px; overflow-x: auto; margin: 0 -20px; padding: 2px 20px 6px; scrollbar-width: none; }
.tabs .chip { flex-shrink: 0; white-space: nowrap; }
.switch { position: relative; width: 56px; height: 32px; border-radius: 999px; border: 0; padding: 0; cursor: pointer; background: rgba(148, 163, 184, 0.45); flex-shrink: 0; }
.switch span { position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); transition: left 0.2s; }
.switch.on { background: var(--accent); }
.switch.on span { left: 27px; }
.fab { position: fixed; right: max(16px, calc(50% - 224px)); bottom: 20px; z-index: 20; }
table.kv { width: 100%; border-collapse: collapse; font-size: 14px; }
table.kv td { padding: 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.kv td:first-child { color: var(--muted); width: 40%; }
.hidden { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
