:root {
  color-scheme: dark;
  --bg: #050302;
  --surface: rgba(18, 10, 6, .92);
  --raised: #15100d;
  --hover: rgba(31, 18, 10, .96);
  --line: rgba(255, 255, 255, .12);
  --line2: rgba(255, 115, 0, .36);
  --text: #faf8f6;
  --muted: #a29b96;
  --dim: #6f655e;
  --accent: #ff7300;
  --accent2: #ff8c1a;
  --ink: #180b03;
  --success: #ff9b4a;
  --danger: #ff707d;
  --focus: rgba(255, 115, 0, .36);
  --radius: 0;
}

html { background: var(--bg); }

html,
body { font-family: var(--font-ui); }

[lang="th"] {
  --type-caption: .75rem;
  --type-label: .75rem;
  --type-body: 1rem;
  --type-subheading: 1rem;
  --type-heading: 1.125rem;
  --type-section: 1.625rem;
  --type-display: 4.25rem;
}

body {
  min-height: 100vh;
  background: radial-gradient(circle at 68% 23%, #241208 0, #0d0805 31%, #050302 64%);
  color: var(--text);
  letter-spacing: 0;
}

body::before { content: none; }

.ambient { z-index: -2; }
.ambient i:first-child { width: 520px; height: 520px; right: -190px; top: -210px; background: #ff73000d; border-color: #ff730012; filter: none; }
.ambient i:last-child { width: 260px; height: 260px; left: -90px; bottom: 8%; background: #ff9d4508; border-color: transparent; filter: none; }

.topbar,
footer { width: min(1320px, calc(100% - 48px)); max-width: 1320px; margin-inline: auto; }

.topbar {
  position: relative;
  min-height: 78px;
  margin-top: 12px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  background: rgba(18, 10, 6, .72);
  backdrop-filter: none;
}

body:has(#login-view:not(.hidden)) .topbar,
body:has(#login-view:not(.hidden)) footer,
body:has(#login-view:not(.hidden)) .intro,
body:has(#login-view:not(.hidden)) .ambient { display: none; }

.brand { gap: 12px; }
.brand-mark { width: 32px; height: 32px; padding: 4px; border: 1px solid #ff73004d; border-radius: 0; background: transparent; transform: skew(-8deg); box-shadow: none; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; transform: skew(8deg); }
.brand b { font: 600 15px/1 var(--font-code); letter-spacing: .1em; }
.brand small { margin-top: 5px; color: var(--accent); font: 500 8px/1 var(--font-code); letter-spacing: .13em; }

.topbar nav { gap: 12px; }
.icon-button,
.language,
.online { border-radius: 0; background: #100a06b3; border: 1px solid var(--line); }
.icon-button { min-height: 36px; padding-inline: 12px; }
.language { padding: 3px; }
.language button { min-width: 42px; min-height: 30px; padding: 7px 10px; border-radius: 0; color: #82908d; font: 500 10px/1 var(--font-code); letter-spacing: .08em; }
.language button.active { color: var(--ink); background: var(--accent); }
.online { min-height: 36px; padding: 0 12px; color: #aab5b2; font: 500 9px/1 var(--font-code); letter-spacing: .09em; }
.online i { background: var(--accent); box-shadow: 0 0 14px var(--accent); }

main {
  width: min(1215px, calc(100% - 48px)) !important;
  max-width: 1215px;
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(330px, 440px) minmax(520px, 610px);
  gap: clamp(60px, 10vw, 165px);
  align-items: center;
  min-height: calc(100vh - 172px);
  padding: 88px 0 96px;
}

body:has(#login-view:not(.hidden)) main {
  width: min(500px, calc(100% - 32px)) !important;
  grid-template-columns: 1fr;
  gap: 0;
  padding: 24px 0;
}

.intro {
  position: relative;
  display: flex;
  flex-direction: column;
  align-self: center;
  max-width: 440px;
  min-width: 0;
  padding: 12px 0;
}
.intro::after { display: none; }
.node-badge { margin: 0 0 30px; color: #aab5b2; font: 500 9px/1 var(--font-code); letter-spacing: .12em; }
.node-badge .pulse { width: 7px; height: 7px; background: var(--accent); box-shadow: 0 0 15px var(--accent); }
.node-badge span + span::before { color: #53605d; }
.intro h1,
[lang="th"] .intro h1 { max-width: 440px; margin: 0; font-size: 64px; line-height: 1.02; letter-spacing: -.035em; font-weight: 600; }
.intro h1 > span:first-child { color: var(--text); }
.intro h1 > span:last-child { color: #aebbb7; }
.lead { max-width: 440px; margin: 24px 0 28px; color: var(--muted); font-size: 14px; line-height: 1.72; }
.trust-row { width: 440px; display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; border: 1px solid var(--line); background: rgba(9, 14, 13, .72); }
.trust-row > span { min-width: 0; padding: 15px 17px; border: 0; border-radius: 0; color: var(--accent); background: transparent; }
.trust-row > span + span { border-left: 1px solid var(--line); }
.trust-row small { display: block; margin: 0 0 5px; color: #66736f; font: 400 9px/1 var(--font-code); text-transform: uppercase; }

.gateway-visual,
.product-guide {
  position: relative;
  width: 440px;
  margin-top: 28px;
  padding: 18px 22px;
  border: 1px solid #ff730038;
  background: linear-gradient(145deg, #1a100bc9, #0d0805d9);
  box-shadow: none;
}
.gateway-visual::before,
.gateway-visual::after,
.product-guide::before,
.product-guide::after { content: ""; position: absolute; width: 14px; height: 14px; border-color: var(--accent); opacity: .75; }
.gateway-visual::before,
.product-guide::before { top: -1px; left: -1px; border-top: 2px solid; border-left: 2px solid; }
.gateway-visual::after,
.product-guide::after { right: -1px; bottom: -1px; border-right: 2px solid; border-bottom: 2px solid; }
.gateway-topline,
.gateway-labels,
.guide-head { display: flex; align-items: center; justify-content: space-between; color: #82908d; font: 500 8px/1 var(--font-code); letter-spacing: .13em; }
.signal { display: flex; align-items: end; gap: 3px; height: 12px; }
.signal i { width: 3px; height: 5px; background: var(--accent); }
.signal i:nth-child(2) { height: 8px; }.signal i:nth-child(3) { height: 11px; }
.gateway-core { position: relative; display: grid; place-items: center; height: 150px; }
.gateway-ring { position: absolute; width: 92px; height: 92px; border: 1px solid #ff730040; border-radius: 50%; box-shadow: inset 0 0 30px #ff73000b; }
.gateway-ring::before,
.gateway-ring::after { content: ""; position: absolute; inset: -19px; border: 1px dashed #7b928835; border-radius: 50%; animation: nexus-spin 18s linear infinite; }
.gateway-ring::after { inset: 14px; animation-direction: reverse; animation-duration: 11s; }
.gateway-mark { color: var(--accent); font: 400 54px/1 var(--font-code); text-shadow: 0 0 30px #ff730055; transform: rotate(-15deg); }
.gateway-route { display: flex; align-items: center; padding-inline: 3px; }
.gateway-route i { width: 7px; height: 7px; border: 1px solid #72817d; border-radius: 50%; }
.gateway-route i:first-child { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.gateway-route span { flex: 1; height: 1px; background: linear-gradient(90deg, var(--accent), #42504c); }
.gateway-labels { margin-top: 11px; }

.product-guide { display: none; }
body[data-product="yq"] .gateway-visual,
body[data-product="zf"] .gateway-visual { display: none; }
body[data-product="yq"] .yq-guide,
body[data-product="zf"] .zf-guide { display: block; }
.guide-head strong { color: var(--accent); font-size: 9px; }
.mouse-map,
.numpad-map { display: grid; grid-template-columns: 145px 1fr; gap: 20px; align-items: center; min-height: 172px; margin-top: 10px; }
.mouse-shell { position: relative; display: block; width: 72px; height: 132px; margin: auto; border: 1px solid #ff730055; border-radius: 38px; }
.mouse-map .mouse-shell { grid-row: 1 / span 2; }
.mouse-shell i { position: absolute; left: 50%; top: 9px; width: 1px; height: 36px; background: #ff730055; }
.mouse-shell b,
.mouse-shell em { position: absolute; left: -13px; display: grid; place-items: center; width: 22px; height: 24px; border: 1px solid var(--line2); color: var(--accent); background: #0d0805; font: 500 9px/1 var(--font-code); }
.mouse-shell b { top: 51px; }.mouse-shell em { top: 81px; font-style: normal; }
.mouse-map p,
.numpad-map p { margin: 0 0 14px; color: #889590; font-size: 11px; line-height: 1.55; }
.mouse-map p:last-child,
.numpad-map p:last-child { margin-bottom: 0; }
.mouse-map p kbd,
.numpad-map p kbd { display: block; width: fit-content; margin-bottom: 5px; color: var(--accent); font: 500 9px/1 var(--font-code); }
.numpad-map { grid-template-columns: 158px 1fr; }
.numpad-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.numpad-grid kbd { display: grid; place-items: center; min-height: 30px; border: 1px solid var(--line); color: #c8bfba; background: #0d0805; font: 500 9px/1 var(--font-code); }

.glass {
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(18, 10, 6, .92);
  box-shadow: none;
  backdrop-filter: none;
}

body:has(#login-view:not(.hidden)) .auth-card,
.auth-card {
  width: 100%;
  max-width: none;
  min-height: 0;
  margin: 0;
  padding: 48px;
  align-self: center;
  border-color: #ff730045;
}
.auth-card::before,
.auth-card::after { content: none; }
.card-head { padding-bottom: 18px; border-bottom: 1px solid var(--line); color: #82908d; font: 500 10px/1 var(--font-code); letter-spacing: .09em; }
.card-head > i { background: var(--line); }
.access-icon,
.panel-icon { color: var(--accent); border-color: var(--line2); background: #0d0805; }
.auth-card h2 { margin: 28px 0 5px; color: var(--text); font-size: 26px; line-height: 1.2; font-weight: 700; letter-spacing: 0; }
.auth-card > p { margin: 0 0 24px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.auth-card form { margin-top: 0; }
.auth-card form > label { margin-bottom: 8px; color: #b8b0ab; font: 500 12px/1.35 var(--font-ui); letter-spacing: 0; text-transform: none; }
.key-field { min-height: 54px; border-radius: 0; border-color: var(--line); background: #0b0704; }
.key-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px #ff730013; }
.key-field span { color: var(--accent); border-right-color: var(--line); }
.key-field input { color: var(--text); font-family: Consolas, "Cascadia Mono", var(--font-code); font-size: 14px; letter-spacing: 0; }
.auth-actions { gap: 10px; margin-top: 18px; }
.primary,
.secondary,
.ghost,
.step,
.preset { border-radius: 0; }
.primary { color: var(--ink); background: var(--accent); box-shadow: none; }
.primary:hover:not(:disabled) { background: #ff8c1a; box-shadow: none; transform: none; }
.auth-actions .primary,
.auth-actions .secondary { min-height: 44px; font-size: 12px; font-weight: 700; }
.secondary { border-color: var(--line); color: #c8bfba; background: #100a06; }
.secondary:hover { border-color: var(--line2); background: #1d120b; }

.console {
  position: relative;
  min-width: 0;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--surface);
}
.console-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 0; padding: 34px 150px 18px 34px; }
.console-heading h2 { margin: 12px 0 0; color: var(--text); font-size: 28px; line-height: 1.08; font-weight: 650; letter-spacing: -.025em; }
.console-kicker { color: var(--accent); font: 500 9px/1 var(--font-code); letter-spacing: .17em; }
.product-chip { display: none; }
.license-strip { display: grid; grid-template-columns: 1.15fr 1fr 1.1fr; gap: 0; align-items: stretch; margin: 0 34px 18px; padding: 0; overflow: hidden; border: 1px solid var(--line); background: #0d0805; }
.license-strip > * { min-width: 0; padding: 14px 15px; border-right: 1px solid var(--line); }
.license-strip > *:nth-child(3) { border-right: 0; }
.license-state { gap: 8px; }
.status-dot { background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.license-strip strong,
.expiry { color: #b7c2be; font: 500 9px/1.45 var(--font-code); }
.expiry small { color: #61706b; }
.license-strip .ghost { position: absolute; top: 34px; right: 34px; min-height: 38px; padding: 10px 14px; border: 1px solid var(--line); background: #100a06; }

.console-grid { display: grid; grid-template-columns: 1fr; gap: 0; padding: 0 34px; }
.visual-system-grid { display: block; min-width: 0; }
.panel { min-width: 0; padding: 18px 0 22px; border: 0; }
.console .glass { box-shadow: none; }
.preview-panel { display: none !important; }
.panel-title { margin-bottom: 16px; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.panel-title h2 { color: var(--text); font-size: 15px; font-weight: 560; }
.panel-title p { color: #63706d; }
.aim-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.aim-group + .aim-group { margin-top: 0; padding-top: 0; border-top: 0; }
.aim-group-title { margin-bottom: 18px; }
.aim-group-title > span,
.preset-index { color: var(--accent); }
.range-row { margin-bottom: 20px; }
.range-head { color: #aab5b2; }
.range-head output { color: var(--accent); }
.range-line { grid-template-columns: 34px 1fr 34px; gap: 9px; }
.step { min-width: 34px; min-height: 34px; border-color: var(--line); color: #938982; background: #0d0805; }
.step:hover { color: var(--accent); border-color: var(--line2); }
input[type="range"] { accent-color: var(--accent); }
input[type="range"]::-webkit-slider-runnable-track { background: #28352f; }
input[type="range"]::-webkit-slider-thumb { background: var(--accent); box-shadow: 0 0 0 4px #ff730017; }
.presets { margin-top: 6px; padding-top: 20px; border-top-color: var(--line); }
#preset-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.preset { min-height: 54px; border-color: var(--line); background: #0d0805; }
.preset:hover,
.preset.selected { color: var(--ink); border-color: var(--accent); background: var(--accent); }
.visual-settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 26px; border-top: 1px solid var(--line); }
.visual-cell { min-width: 0; min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.visual-cell label { display: block; color: #b2bdb9; font-size: 12px; line-height: 1.35; }
.visual-cell small { display: block; margin-top: 6px; color: #596762; font: 500 8px/1 var(--font-code); letter-spacing: .05em; }
.color-value { display: flex; align-items: center; gap: 10px; }
.color-value output { min-width: 54px; color: #66736f; font: 500 8px/1 var(--font-code); text-align: right; }
.visual-cell input[type="color"] { width: 34px; height: 34px; padding: 3px; border-radius: 0; border-color: var(--line); background: #0d0805; }
.switch { border-color: #44534e; background: #101716; }
.switch::before { background: #66736f; }
.switch:checked { border-color: var(--accent); background: #ff730022; }
.switch:checked::before { background: var(--accent); box-shadow: 0 0 13px #ff730077; }
body[data-product="zf"] .aim-panel { display: none; }
body[data-product="zf"] .console-grid { grid-template-columns: 1fr; }
body[data-product="zf"] .visual-panel { max-width: none; }
.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0 34px 34px; padding: 0; border: 0; background: transparent; }
.change-state { grid-column: 1 / -1; margin: 0; padding: 9px 0; border-bottom: 0; color: #66736f; }
.actions .primary,
.actions .secondary { width: 100%; min-width: 0; min-height: 46px; margin: 0; }
.actions .primary:last-child { grid-column: 2; }
.actions .secondary { border-color: var(--line2); }

footer { min-height: 62px; padding: 18px 0; border-top: 1px solid var(--line); color: #53605d; font: 400 9px/1.6 var(--font-code); letter-spacing: .08em; }
.footer-brand img { filter: grayscale(1); opacity: .65; }
dialog { width: min(620px, calc(100% - 32px)); border-radius: 0; border-color: #ff730045; background: #120c08; box-shadow: 0 30px 100px #000b; }
dialog::backdrop { background: #020403cc; backdrop-filter: blur(8px); }
.dialog-kicker { color: var(--accent); }
.dialog-close { border-radius: 0; border-color: var(--line); background: #0d0805; }
.hotkey-list p { border-color: var(--line); background: #0d0805; }
.hotkey-list kbd { color: var(--accent); border-color: var(--line2); background: #17100b; }
body[data-product="yq"] .zf-only,
body[data-product="zf"] .yq-only { display: none; }
.toast { border-radius: 0; border-color: var(--line2); background: #15100d; }

@keyframes nexus-spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
  body:has(#login-view:not(.hidden)) main,
  main { width: min(720px, calc(100% - 48px)) !important; grid-template-columns: 1fr; gap: 44px; padding: 64px 0 80px; }
  body:has(#login-view:not(.hidden)) main { width: min(500px, calc(100% - 32px)) !important; gap: 0; padding: 24px 0; }
  .intro { max-width: 720px; }
  .intro h1, [lang="th"] .intro h1 { max-width: 720px; }
  .lead { max-width: 680px; }
  .gateway-visual, .product-guide, .trust-row { width: 100%; max-width: 680px; }
}

@media (max-width: 700px) {
  .topbar, main, footer { width: min(100% - 36px, 1320px); }
  .topbar { min-height: 74px; padding: 12px 14px; }
  .topbar nav { gap: 7px; }
  .online { display: none; }
  .icon-button { font-size: 0; }
  .icon-button span:first-child { font-size: 15px; }
  main { width: min(100% - 36px, 720px) !important; min-height: auto; padding: 44px 0 58px; }
  body:has(#login-view:not(.hidden)) main { width: min(500px, calc(100% - 32px)) !important; min-height: 100vh; padding: 24px 0; }
  .intro h1, [lang="th"] .intro h1 { font-size: 43px; }
  .auth-card { min-height: 0; padding: 48px; }
  .auth-actions { grid-template-columns: 1fr; }
  .console-heading { padding: 26px 26px 16px; }
  .license-strip { grid-template-columns: 1fr 1fr; margin-inline: 26px; }
  .license-strip > *:nth-child(2) { border-right: 0; }
  .license-strip > *:nth-child(3) { grid-column: 1 / -1; border-top: 1px solid var(--line); }
  .license-strip .ghost { position: static; grid-column: 1 / -1; min-height: 42px; border: 0; border-top: 1px solid var(--line); }
  .console-grid { grid-template-columns: 1fr; }
  .console-grid { padding-inline: 26px; }
  .visual-settings-grid { grid-template-columns: 1fr; }
  .aim-groups { grid-template-columns: 1fr; }
  .mouse-map, .numpad-map { grid-template-columns: 1fr; }
  .numpad-grid { max-width: 250px; }
  .actions { grid-template-columns: 1fr; margin: 0 26px 26px; }
  .actions .primary:last-child { grid-column: 1; }
  .actions .primary { width: 100%; }
  footer { flex-direction: column; }
}

@media (max-width: 532px) {
  body:has(#login-view:not(.hidden)) main { width: calc(100% - 24px) !important; }
  body:has(#login-view:not(.hidden)) .auth-card,
  .auth-card { padding: 28px 22px; }
  .card-head { gap: 7px; }
  .card-head > i { min-width: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .gateway-ring::before, .gateway-ring::after { animation: none; }
}
