@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;500;600;700&display=swap');

/* Dark theme, matching the display editor: navy panels, one blue-to-violet accent. */
:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --bg-2: #0f1219;
  --panel: #141822;
  --panel-2: #1a1f2b;
  --panel-3: #222838;
  --line: #252c3b;
  --line-2: #323b4f;
  --text: #e9ecf3;
  --muted: #8b94a8;
  --faint: #5d6679;
  --accent: #4f8cff;
  --accent-2: #7a5cff;
  --accent-soft: #4f8cff24;
  --grad: linear-gradient(135deg, #4f8cff 0%, #7a5cff 100%);
  --water: #2bb8f0;
  --ok: #34d399;
  --warn: #f5b74e;
  --danger: #f2626f;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 10px 30px #00000059;
  --glow: 0 6px 18px #4f6eff52;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --mono: ui-monospace, 'SFMono-Regular', Consolas, monospace;
  --font: system-ui, -apple-system, 'Segoe UI', 'Leelawadee UI', 'Noto Sans Thai', sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; background: var(--bg); }
body { margin: 0; background: radial-gradient(1200px 600px at 15% -10%, #4f8cff14, transparent 60%), radial-gradient(900px 500px at 100% 0%, #7a5cff12, transparent 60%), var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.7; }
button, input, select { font: inherit; color: inherit; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
button[disabled] { cursor: not-allowed; opacity: .5; }
[hidden] { display: none !important; }
code, pre { font-family: var(--mono); }

.topbar, main, footer { width: min(1180px, calc(100% - 64px)); margin: auto; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 10; height: 64px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: #0b0d12d9; backdrop-filter: blur(12px); width: 100%; padding: 0 max(32px, calc((100% - 1180px) / 2)); }
.brand { text-decoration: none; display: flex; align-items: center; gap: 4px; font-size: 16px; font-weight: 700; letter-spacing: -.3px; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; margin-right: 8px; border-radius: 9px; background: var(--grad); color: #fff; font-size: 22px; line-height: 1; box-shadow: var(--glow); }
.brand-light { font-weight: 400; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.toplink { font-size: 12px; text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 8px; }
.toplink:hover { color: var(--text); background: var(--panel-2); }
.toplink > span[data-i18n] { margin-left: 0; }
.language-toggle { display: flex; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); font-size: 12px; min-height: 34px; }
.language-toggle span { padding: 3px 10px; border-radius: 6px; color: var(--muted); }
.language-toggle span[data-on] { background: var(--panel-3); color: var(--text); }
.language-toggle:hover { border-color: var(--line-2); }

/* Hero */
.intro { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; padding: 54px 0 36px; }
.eyebrow { display: flex; align-items: center; gap: 8px; font-size: 10px; font-weight: 600; letter-spacing: 2px; color: var(--muted); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
h1 { margin: 16px 0 12px; font-size: 46px; line-height: 1.25; letter-spacing: -1.4px; font-weight: 700; }
.lime-period { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.intro-copy { max-width: 520px; font-size: 15px; color: var(--muted); line-height: 1.8; }
.release-label { display: flex; flex-direction: column; gap: 6px; padding: 16px 20px; margin-bottom: 4px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel); }
.release-label span { font-size: 9px; letter-spacing: 1.4px; color: var(--muted); }
.release-label strong { font-size: 34px; font-weight: 600; letter-spacing: -1.5px; line-height: 1.3; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Panels */
.workspace { display: grid; grid-template-columns: 1fr 1.15fr; gap: 20px; align-items: start; }
.playground, .installer, .wiring-section, .phone-section { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel); box-shadow: var(--shadow); }
.playground, .installer { overflow: hidden; }
.section-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
h2 { font-size: 15px; font-weight: 600; }
.tag { padding: 3px 8px; border-radius: 6px; font: 600 9px var(--mono); letter-spacing: 1px; color: var(--accent); background: var(--accent-soft); white-space: nowrap; }
.tag.muted { color: var(--muted); background: var(--panel-3); }

/* Preview stage: the selected display module with the live canvas on its screen */
.device-stage { position: relative; height: 380px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: radial-gradient(circle at 50% 45%, #18203a 0%, var(--bg-2) 55%, #080a0f 100%); color: var(--muted); }
.stage-grid { position: absolute; inset: 0; opacity: .5; background-image: linear-gradient(#4f8cff14 1px, transparent 1px), linear-gradient(90deg, #4f8cff14 1px, transparent 1px); background-size: 24px 24px; mask-image: radial-gradient(ellipse at center, #000 20%, transparent 75%); }
.stage-label { position: absolute; top: 14px; left: 16px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; background: #0b0d12b3; font: 10px var(--mono); letter-spacing: .5px; color: var(--muted); }
.device { position: relative; z-index: 1; transition: transform .2s var(--ease); filter: drop-shadow(0 18px 28px #000a); }
.module-art svg { display: block; width: 100%; height: auto; }
.device-screen { position: absolute; overflow: hidden; background: #030509; box-shadow: 0 0 0 1px #0006, 0 0 28px #2bb8f033; }
.device-screen[data-round] { border-radius: 50%; }
.device-screen::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(135deg, #ffffff14 0%, transparent 38%); }
.device canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.stage-readout { position: absolute; bottom: 14px; left: 16px; right: 16px; display: flex; justify-content: space-between; font: 10px var(--mono); letter-spacing: .6px; color: var(--faint); }
.stage-readout b { font-weight: 500; color: var(--text); }
.stage-readout > span:nth-child(2) { color: var(--accent); }

/* Controls */
.preview-controls, .fluid-controls { padding: 16px 22px; border-bottom: 1px solid var(--line); }
.preview-controls > label, .fluid-controls > label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.preview-controls output, .fluid-controls output { font: 11px var(--mono); color: var(--text); }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; margin: 8px 0 12px; background: transparent; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: var(--panel-3); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--panel-3); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border: 3px solid #fff; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), 0 2px 6px #0008; }
input[type=range]::-moz-range-thumb { width: 10px; height: 10px; border: 3px solid #fff; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
input[type=range]:focus-visible { outline: none; }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 6px #4f8cff55; }
.control-bottom { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.control-bottom label { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.control-bottom input { width: 110px; margin: 0; }
.shake-button { padding: 6px 14px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel-2); font-size: 12px; white-space: nowrap; transition: border-color .15s, background .15s; }
.shake-button:hover { border-color: var(--accent); background: var(--panel-3); }
.shake-button[aria-pressed=true] { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.control-buttons { display: flex; gap: 6px; }
.motion-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 10px 0; font-size: 12px; color: var(--muted); }
.motion-actions .shake-button { min-width: 38px; }
.fluid-bottom { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: 11px; color: var(--faint); }
.fluid-bottom label { display: flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; }
.fluid-bottom input { margin: 0; accent-color: var(--accent); }
.field-label { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }
.mood-select, .driver-select select { width: 100%; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel-2); font-size: 12px; color: var(--text); }
.mood-select { margin: 8px 0 4px; }
.message-text { resize: vertical; min-height: 44px; font-family: inherit; }
.mood-select:hover, .driver-select select:hover { border-color: var(--accent); }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; margin: 8px 0 12px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2); }
.segmented button { padding: 6px 8px; border: 0; border-radius: 7px; background: transparent; font-size: 12px; color: var(--muted); transition: background .15s, color .15s; }
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed=true] { background: var(--panel-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }

/* Theme swatches: the theme's water from surface to deep, with its eye colour */
.theme-controls { padding: 14px 22px 0; }
.theme-swatches { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.theme-swatch { position: relative; width: 34px; height: 34px; padding: 0; border: 2px solid var(--line-2); border-radius: 50%; transition: transform .15s var(--ease), border-color .15s, box-shadow .15s; }
.theme-swatch:hover { transform: translateY(-2px); }
.theme-swatch[aria-pressed=true] { border-color: #fff; box-shadow: 0 0 0 3px var(--accent); }
.swatch-eye { position: absolute; right: -3px; bottom: -3px; width: 12px; height: 12px; border: 2px solid var(--panel); border-radius: 50%; }

/* Mode tiles */
.mode-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding: 16px 18px 6px; }
.mode-button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px 9px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); font-size: 11px; line-height: 1.35; text-align: center; transition: transform .15s var(--ease), border-color .15s, background .15s; }
.mode-button .glyph svg { display: block; width: 44px; height: 44px; }
.mode-button small { font-size: 9px; color: var(--faint); letter-spacing: .3px; }
.mode-button:hover { transform: translateY(-2px); border-color: var(--line-2); background: var(--panel-3); }
.mode-button[aria-pressed=true] { border-color: var(--accent); background: linear-gradient(180deg, #4f8cff1f, #7a5cff12); box-shadow: 0 0 0 1px var(--accent), var(--glow); }
.preview-note { min-height: 48px; padding: 12px 18px 18px; font-size: 11px; color: var(--muted); text-align: center; }
.fluid-credit { margin-top: -8px; padding: 0 18px 18px; font-size: 10px; color: var(--faint); text-align: center; }
.fluid-credit a { color: var(--muted); text-underline-offset: 3px; }

/* Installer steps */
.step { padding: 20px 22px; border-bottom: 1px solid var(--line); }
.step-title { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.step-number { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font: 600 11px var(--mono); }
.step-title h3 { font-size: 14px; font-weight: 600; }
.step-caption { margin-left: auto; font: 9px var(--mono); letter-spacing: 1px; color: var(--faint); }
.board-card { display: flex; align-items: center; gap: 14px; margin-top: 12px; padding: 13px 16px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--panel-2); }
.chip-icon { font-size: 30px; line-height: 1; color: var(--accent); }
.board-card strong { display: block; font-size: 13px; font-weight: 600; }
.board-card small { display: block; margin-top: 2px; font: 10px var(--mono); color: var(--muted); }
.check { display: grid; place-items: center; width: 22px; height: 22px; margin-left: auto; border-radius: 50%; background: #34d39926; color: var(--ok); font-size: 12px; }
.hint { margin-top: 10px; font-size: 11px; color: var(--muted); }
.display-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.display-card { position: relative; display: flex; align-items: center; gap: 12px; min-height: 74px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); text-align: left; transition: border-color .15s, background .15s; }
.display-card:hover { border-color: var(--line-2); background: var(--panel-3); }
.display-card[aria-pressed=true] { border-color: var(--accent); background: linear-gradient(180deg, #4f8cff1f, #7a5cff12); box-shadow: 0 0 0 1px var(--accent); }
.display-card { min-width: 0; }
.display-card > span:last-child { min-width: 0; }
.display-card strong { display: block; font-size: 12px; font-weight: 600; white-space: nowrap; }
.display-card small { display: block; margin-top: 3px; font-size: 10px; color: var(--muted); }
.mini-screen { position: relative; display: block; flex-shrink: 0; width: 30px; height: 30px; overflow: hidden; border: 3px solid var(--line-2); border-radius: 5px; background: #06080c; }
.mini-screen:after { content: ''; position: absolute; top: 15px; left: -10px; width: 60px; height: 25px; background: var(--water); transform: rotate(-14deg); }
.mini-screen.portrait { width: 19px; height: 35px; margin: 0 5.5px; }
.mini-screen.round { border-radius: 50%; }
.mini-screen.wide { width: 35px; height: 20px; margin: 0 -2.5px; }
.mini-screen.wide:after { background: #e9ecf3; }
.driver-select { display: flex; align-items: center; gap: 12px; margin-top: 14px; font-size: 12px; color: var(--muted); }
.driver-select select { flex: 1; min-width: 0; width: auto; }
.profile-note { min-height: 17px; }
.release-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.status-light { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.release-status[data-state=ready] { color: var(--ok); }
.release-status[data-state=ready] .status-light { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.release-status[data-state=error] { color: var(--danger); }
.release-status[data-state=error] .status-light { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.flash-copy { margin: 12px 0 16px; font-size: 12px; color: var(--muted); line-height: 1.8; }
esp-web-install-button { display: block; --mdc-theme-primary: #4f8cff; }
.flash-button { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 14px 20px; border: 0; border-radius: var(--radius-lg); background: var(--grad); color: #fff; font-size: 14px; font-weight: 600; box-shadow: var(--glow); transition: transform .15s var(--ease), box-shadow .15s, filter .15s; }
.flash-button:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.08); box-shadow: 0 10px 26px #4f6eff70; }
.flash-button:disabled { box-shadow: none; }
.flash-button span:last-child { font-size: 22px; line-height: 1; }
.browser-message, .browser-note { display: block; margin-top: 10px; font-size: 11px; color: var(--muted); }
.browser-note { color: var(--warn); }
.release-links { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; font-size: 12px; }
.release-links a { color: var(--accent); text-underline-offset: 3px; }
.release-links span { font: 10px var(--mono); color: var(--faint); }
.hardware-status { margin-top: 12px; font-size: 11px; color: var(--faint); }

/* Disclosure sections */
.wiring, .troubleshooting { padding: 16px 22px; border-bottom: 1px solid var(--line); font-size: 12px; }
.troubleshooting { border: 0; }
.troubleshooting + .troubleshooting, .wiring-jump + .troubleshooting { border-top: 1px solid var(--line); }
summary { display: flex; align-items: center; cursor: pointer; list-style: none; font-size: 13px; font-weight: 500; }
summary::-webkit-details-marker { display: none; }
summary .expand { margin-left: auto; font-size: 18px; color: var(--muted); transition: transform .2s var(--ease); }
summary #wiring-driver { margin-left: 10px; font: 10px var(--mono); color: var(--muted); }
details[open] summary .expand { transform: rotate(45deg); }
details p { margin-top: 12px; color: var(--muted); }
details a { display: inline-block; margin-top: 10px; }
table { width: 100%; margin-top: 15px; border-collapse: collapse; text-align: left; }
th { font-weight: 500; color: var(--muted); }
th, td { padding: 7px 4px; border-bottom: 1px solid var(--line); }
td:nth-child(2) { font-family: var(--mono); color: var(--accent); }
.arduino-ide p { margin-top: 10px; color: var(--muted); line-height: 1.7; }
.arduino-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.arduino-actions a { display: inline-block; margin-top: 0; text-decoration: none; }
#arduino-status { font-size: 11px; color: var(--ok); }
.arduino-steps { margin: 14px 0 0; padding-left: 18px; color: var(--text); line-height: 1.8; }
.arduino-steps li { margin-bottom: 10px; }
.arduino-steps code { display: block; margin-top: 3px; font-size: 11px; color: var(--accent); word-break: break-all; }
.arduino-steps ul { margin: 4px 0 0; padding-left: 16px; font: 11px var(--mono); color: var(--accent); }
.arduino-settings { margin-top: 6px; }
.arduino-settings td { vertical-align: top; font-size: 11px; }
.arduino-settings td:nth-child(2) { white-space: nowrap; }
.arduino-settings small { display: block; font-size: 10px; line-height: 1.5; color: var(--muted); }
.arduino-view { margin-top: 12px; }
.arduino-code { max-height: 340px; overflow: auto; margin: 10px 0 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #06080c; color: #c9d1e3; font-size: 11px; line-height: 1.45; white-space: pre; tab-size: 2; }

/* Phone setup */
.phone-section { display: grid; grid-template-columns: 1fr 1.15fr; gap: 40px; margin: 28px 0 44px; padding: 32px 36px; background: linear-gradient(135deg, #4f8cff12, #7a5cff0d), var(--panel); }
.phone-section .eyebrow { font-size: 9px; letter-spacing: 1.5px; }
.phone-section h2 { margin: 14px 0; font-size: 24px; letter-spacing: -.6px; }
.phone-section h2 > span[data-i18n] { color: inherit; }
.phone-section h2 > span:last-child { color: var(--accent); }
.phone-section > div > p:last-child { font-size: 13px; color: var(--muted); }
.phone-section ol { display: flex; flex-direction: column; gap: 18px; margin: 0; padding: 0; list-style: none; }
.phone-section li { display: flex; align-items: flex-start; gap: 14px; }
.phone-section li > span { display: grid; place-items: center; flex-shrink: 0; width: 26px; height: 26px; margin-top: 1px; border-radius: 8px; background: var(--grad); color: #fff; font: 600 11px var(--mono); box-shadow: var(--glow); }
.phone-section strong { font-size: 13px; font-weight: 600; }
.phone-section li p { margin-top: 3px; font-size: 12px; color: var(--muted); }
.phone-section code { padding: 1px 5px; border-radius: 4px; background: var(--panel-3); font-size: 11px; color: var(--text); }
.phone-section a { color: var(--accent); text-underline-offset: 3px; }

footer { display: flex; justify-content: space-between; align-items: center; padding: 22px 0 30px; border-top: 1px solid var(--line); font-size: 11px; color: var(--faint); }
footer a { text-decoration: none; color: var(--muted); }
footer a:hover { color: var(--text); }
.footer-divider { margin: 0 9px; }

@media (min-width: 1300px) { .workspace { grid-template-columns: 500px 1fr; } }
@media (max-width: 1100px) { .mode-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px) {
  .topbar, main, footer { width: calc(100% - 40px); }
  .topbar { width: 100%; padding: 0 20px; }
  h1 { font-size: 36px; }
  .workspace { gap: 16px; }
  .section-bar, .step { padding-left: 18px; padding-right: 18px; }
  .display-card { gap: 8px; padding: 10px 8px; }
  .display-card strong { font-size: 11px; }
  .display-card small { font-size: 9px; }
  .driver-select { flex-direction: column; align-items: stretch; gap: 5px; }
  .driver-select select { width: 100%; }
  .phone-section { gap: 25px; padding: 28px; }
  .phone-section h2 { font-size: 21px; }
}
@media (max-width: 680px) {
  .topbar { height: 58px; padding: 0 16px; }
  main, footer { width: calc(100% - 32px); }
  .brand { font-size: 15px; }
  .brand-mark { width: 28px; height: 28px; }
  .intro { flex-direction: column; align-items: flex-start; padding: 30px 0 24px; }
  h1 { font-size: 32px; letter-spacing: -1px; }
  .intro-copy { font-size: 13px; }
  .release-label { flex-direction: row; align-items: baseline; gap: 10px; padding: 10px 14px; }
  .release-label span:first-child { display: none; }
  .release-label strong { font-size: 22px; }
  .workspace { grid-template-columns: 1fr; gap: 16px; }
  .playground { order: 1; }
  .installer { order: 0; }
  .section-bar { padding: 14px 18px; }
  .step { padding: 18px; }
  .display-card { gap: 10px; padding: 12px 10px; }
  .display-card strong { font-size: 12px; white-space: normal; }
  .display-card small { font-size: 10px; }
  .driver-select { flex-direction: row; align-items: center; gap: 10px; }
  .driver-select select { width: auto; }
  .wiring, .troubleshooting { padding: 16px 18px; }
  .device-stage { height: 330px; }
  .mode-grid { grid-template-columns: repeat(3, 1fr); padding: 14px 14px 4px; }
  .preview-controls, .fluid-controls { padding: 14px 18px; }
  .control-bottom input { width: 90px; }
  .phone-section { grid-template-columns: 1fr; gap: 24px; margin: 22px 0 30px; padding: 24px; }
  footer { flex-direction: column; align-items: flex-start; gap: 10px; padding-top: 18px; }
}
@media (max-width: 440px) { .topbar-actions .toplink { display: none; } }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .device, .mode-button, .flash-button, summary .expand { transition: none; }
}
