/* suwoith-dashboard: same family as the FB vault (ink, panel, brass, IBM Plex). */
:root {
  --ink: #0e131b;
  --panel: #141b25;
  --raise: #1b2431;
  --hover: #202b3a;
  --line: #243041;
  --line-strong: #34445c;

  --text: #e8edf4;
  --text-2: #9eafc5;
  --text-3: #6b7d94;

  --brass: #f5a623;
  --brass-hi: #ffb941;
  --brass-ink: #1b1305;
  --brass-wash: rgba(245, 166, 35, 0.12);
  --brass-soft: #d8a75a;

  --ok: #3ecf8e;
  --bad: #ff6b6b;
  --wait: #4d5d73;

  --r-control: 7px;
  --r-socket: 10px;
  --r-panel: 12px;
  --r-sheet: 16px;

  --font-sans: 'IBM Plex Sans Thai', 'Noto Sans Thai', 'Leelawadee UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'Cascadia Mono', Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
svg {
  width: 18px; height: 18px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.mono { font-family: var(--font-mono); font-variant-ligatures: none; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
a { color: inherit; }

/* ---------- controls ---------- */
input, textarea {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-control);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  padding: 10px 12px;
  transition: border-color 0.12s ease;
}
input.mono, textarea.mono { font-family: var(--font-mono); }
input:focus, textarea:focus { outline: none; border-color: var(--brass); }
textarea { resize: vertical; line-height: 1.5; }
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 7px; }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 0 15px;
  border-radius: var(--r-control);
  font-size: 14.5px; font-weight: 600; white-space: nowrap; text-decoration: none;
  transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}
a.btn[aria-disabled='true'] { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--brass); color: var(--brass-ink); }
.btn-primary:hover { background: var(--brass-hi); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-quiet { background: var(--raise); border: 1px solid var(--line); }
.btn-quiet:hover { background: var(--hover); border-color: var(--line-strong); }
.btn-danger { color: var(--bad); border: 1px solid rgba(255, 107, 107, 0.35); }
.btn-danger:hover { background: rgba(255, 107, 107, 0.1); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn-block { width: 100%; min-height: 48px; font-size: 16px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--r-control);
  color: var(--text-2); flex-shrink: 0;
}
.icon-btn:hover { color: var(--text); background: var(--hover); }
.icon-btn[aria-pressed='true'] { color: var(--brass); }
.link-btn {
  color: var(--text-2); font-size: 14px;
  text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px;
  padding: 4px 0;
}
.link-btn:hover { color: var(--text); text-decoration-color: var(--text-3); }

.tag {
  display: inline-flex; align-items: center;
  font-size: 12.5px; font-weight: 500; line-height: 1;
  padding: 4px 9px; border-radius: 999px;
  background: var(--raise); border: 1px solid var(--line); color: var(--text-2);
}
.tag-here { color: var(--brass); border-color: rgba(245, 166, 35, 0.45); background: var(--brass-wash); }

.form-msg { margin: 2px 0 14px; }
.form-error { color: var(--bad); font-size: 14.5px; font-weight: 500; }
.form-hint, .hint { color: var(--text-2); font-size: 13.5px; margin-top: 3px; }
.hint { color: var(--text-3); margin: 6px 0 14px; }
.lead { color: var(--text-2); margin-bottom: 16px; }
.warn {
  color: var(--brass-soft); font-size: 14px;
  border-left: 2px solid var(--brass); padding: 2px 0 2px 12px; margin-bottom: 16px;
}

/* ---------- gate (loading, login, setup) ---------- */
.gate {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center;
  padding: 32px 16px;
}
.gate-card { width: 100%; max-width: 380px; }
.gate-mark { width: 44px; height: 44px; color: var(--brass); stroke-width: 1.4; margin-bottom: 22px; }
.gate h1 { font-size: 27px; font-weight: 700; line-height: 1.25; }
.gate-sub { color: var(--text-2); margin: 6px 0 24px; }
.gate-next {
  font-size: 13.5px; color: var(--text-3);
  margin: -12px 0 22px; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gate-next .mono { color: var(--text-2); }
.gate-form > label { margin-top: 2px; }
.reveal-field { position: relative; margin-bottom: 16px; }
.reveal-field input { padding-right: 48px; min-height: 48px; font-size: 17px; }
.reveal-field .icon-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.code-input { min-height: 52px; font-size: 22px; letter-spacing: 0.28em; }
.code-input[data-mode='backup'] { letter-spacing: 0.08em; font-size: 19px; }
#btnCodeMode { margin: 6px 0 16px; }
.gate-form .btn-block { margin-top: 4px; }
.switch { display: block; margin-top: 22px; }

/* ---------- launcher ---------- */
.home { max-width: 1080px; margin: 0 auto; padding: 18px 24px 56px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-bottom: 16px; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; letter-spacing: 0.01em; }
.brand svg { width: 24px; height: 24px; color: var(--brass); stroke-width: 1.6; }
.chev { width: 15px; height: 15px; color: var(--text-3); }

.menu { position: relative; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  min-width: 236px; padding: 6px;
  background: var(--raise); border: 1px solid var(--line-strong); border-radius: var(--r-panel);
  box-shadow: 0 18px 44px rgba(3, 6, 12, 0.6);
}
.menu-panel button {
  display: block; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: var(--r-control); font-size: 14.5px;
}
.menu-panel button:hover, .menu-panel button:focus-visible { background: var(--hover); outline: none; }
.menu-panel .is-danger { color: var(--bad); }
.menu-panel hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }

.notice {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  margin-top: 18px; padding: 12px 14px;
  border: 1px solid rgba(245, 166, 35, 0.35); border-radius: var(--r-panel);
  background: var(--brass-wash); color: var(--text); font-size: 14.5px;
}
.notice a { color: var(--brass); }

/* status line: the one loud thing on the page */
.status { display: flex; align-items: flex-start; gap: 16px; margin: 30px 0 34px; }
.status .lamp { width: 12px; height: 12px; margin-top: 11px; }
.status-title { font-size: 25px; font-weight: 600; line-height: 1.35; }
.status-down { color: var(--bad); font-size: 15px; margin-top: 2px; }
.status-meta { color: var(--text-3); font-size: 13.5px; margin-top: 4px; }

.lamp {
  display: inline-block; flex-shrink: 0;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--wait);
}
.lamp.is-ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(62, 207, 142, 0.15), 0 0 10px rgba(62, 207, 142, 0.35); }
.lamp.is-bad { background: var(--bad); box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.18), 0 0 10px rgba(255, 107, 107, 0.4); }
.powering .lamp { animation: power-on 0.5s ease-out both; animation-delay: calc(var(--i, 0) * 55ms + 120ms); }
@keyframes power-on {
  0% { opacity: 0; transform: scale(0.4); box-shadow: none; }
  60% { opacity: 1; transform: scale(1.25); }
  100% { opacity: 1; transform: scale(1); }
}

.group { margin-top: 26px; }
.group-head {
  display: flex; align-items: center; gap: 12px;
  font-size: 14px; font-weight: 600; color: var(--text-2);
  margin-bottom: 12px;
}
.group-head::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.tiles { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); gap: 10px; }
.tile {
  position: relative; display: flex; align-items: flex-start; gap: 14px;
  height: 100%; padding: 16px 30px 16px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-panel);
  text-decoration: none; min-width: 0;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.tile:hover { background: var(--raise); border-color: var(--line-strong); }
.tile:hover .socket { background: var(--brass-wash); border-color: rgba(245, 166, 35, 0.4); }
.tile.is-down { border-color: rgba(255, 107, 107, 0.4); }
.tile > .lamp { position: absolute; top: 18px; right: 15px; }
.socket {
  display: grid; place-items: center;
  width: 44px; height: 44px; flex-shrink: 0;
  border-radius: var(--r-socket); background: var(--raise); border: 1px solid var(--line);
  color: var(--brass);
  transition: background 0.12s ease, border-color 0.12s ease;
}
.socket svg { width: 22px; height: 22px; }
.tile-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile-name { font-size: 16px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.tile-desc { font-size: 13.5px; color: var(--text-2); line-height: 1.5; }
.tile-note { font-size: 12.5px; color: var(--brass-soft); margin-top: 4px; }

/* parked + background: quiet rows at the foot */
.strip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line);
}
.strip + .strip { margin-top: 0; border-top: 0; padding-top: 12px; }
.strip-label { color: var(--text-3); font-size: 13.5px; font-weight: 600; min-width: 112px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  padding: 6px 12px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line);
  color: var(--text-2); font-size: 13.5px; text-decoration: none;
}
.chip svg { width: 16px; height: 16px; color: var(--text-3); }
.chip-note { color: var(--text-3); }
a.chip:hover { color: var(--text); border-color: var(--line-strong); background: var(--raise); }
.chip.is-down { border-color: rgba(255, 107, 107, 0.4); color: var(--text); }
.staff-line { color: var(--text-3); font-size: 14px; margin: 26px 0 0; }

/* ---------- sheets (dialogs) ---------- */
dialog.sheet {
  margin: auto; padding: 0; width: min(560px, calc(100vw - 32px)); max-width: none;
  max-height: calc(100dvh - 48px);
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--r-sheet);
  box-shadow: 0 24px 60px rgba(2, 4, 8, 0.7);
}
dialog.sheet-sm { width: min(420px, calc(100vw - 32px)); }
dialog.sheet::backdrop { background: rgba(5, 8, 13, 0.74); }
dialog.sheet[open] { animation: sheet-in 0.16s ease-out; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(8px); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 10px; }
.sheet-head h2 { font-size: 19px; font-weight: 700; }
.sheet-body { padding: 4px 20px 20px; }
.sheet-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.sess-list { list-style: none; }
.sess {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.sess:first-child { border-top: 0; }
.sess-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-weight: 600; }
.sess-meta { color: var(--text-3); font-size: 13.5px; margin-top: 3px; overflow-wrap: anywhere; }
.sess-meta .mono { color: var(--text-2); font-size: 13px; }
.sess-empty { color: var(--text-3); padding: 8px 0; }

.done-line { font-weight: 600; color: var(--ok); margin-bottom: 14px; }
.codes {
  list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px;
  padding: 14px 16px; background: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--r-socket);
  font-family: var(--font-mono); font-size: 17px; letter-spacing: 0.04em;
}
.codes li { white-space: nowrap; }

.toasts {
  position: fixed; top: auto; right: auto; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100;
  margin: 0; padding: 0; border: 0; background: transparent; color: inherit; overflow: visible;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: max-content; max-width: calc(100vw - 32px); pointer-events: none;
}
.toast {
  padding: 10px 16px; border-radius: var(--r-control);
  background: var(--raise); border: 1px solid var(--line-strong);
  font-size: 14.5px; box-shadow: 0 12px 30px rgba(2, 4, 8, 0.6);
  animation: sheet-in 0.16s ease-out;
}
.toast.is-error { border-color: rgba(255, 107, 107, 0.5); color: var(--bad); }
.offscreen { position: fixed; left: -9999px; top: 0; width: 1px; height: 1px; opacity: 0; }

/* ---------- setup ---------- */
.gate-card.wide { max-width: 460px; }
.steps { list-style: none; counter-reset: step; }
.step { counter-increment: step; position: relative; padding: 0 0 26px 44px; }
.step::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--brass); color: var(--brass);
  font-family: var(--font-mono); font-size: 14px;
}
.step:not(:last-child)::after {
  content: ''; position: absolute; left: 14px; top: 34px; bottom: 8px; width: 1px; background: var(--line);
}
.step h2 { font-size: 17px; font-weight: 600; line-height: 1.6; margin-bottom: 12px; }
.qr-box { display: inline-block; padding: 0; background: #fff; border-radius: var(--r-socket); line-height: 0; }
.qr-box canvas { display: block; border-radius: var(--r-socket); }
.secret-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.secret {
  flex: 1; min-width: 0; padding: 9px 12px;
  background: var(--ink); border: 1px solid var(--line); border-radius: var(--r-control);
  font-family: var(--font-mono); font-size: 14.5px; letter-spacing: 0.05em; overflow-wrap: anywhere;
}
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; margin: 16px 0; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brass); }

/* ---------- small screens ---------- */
@media (max-width: 560px) {
  .home { padding: 14px 16px 44px; }
  .status { margin: 22px 0 24px; gap: 12px; }
  .status .lamp { margin-top: 9px; }
  .status-title { font-size: 21px; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tile { flex-direction: column; gap: 10px; padding: 13px 12px 14px; }
  .tile > .lamp { top: 16px; right: 13px; }
  .socket { width: 40px; height: 40px; }
  .tile-name { font-size: 15px; }
  .tile-desc { font-size: 13px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .strip-label { min-width: 0; width: 100%; }
  dialog.sheet, dialog.sheet-sm {
    width: 100%; margin: auto 0 0; max-height: 88dvh;
    border-radius: var(--r-sheet) var(--r-sheet) 0 0; border-bottom: 0;
  }
  .sheet-foot .btn { flex: 1; }
  .codes { gap: 8px 12px; padding: 12px; font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
