/* โทเคนดีไซน์ + พื้นฐาน — โทนเทอร์มินัลเทรด อ่านตัวเลขง่ายในห้องแสงน้อย */

:root {
  --bg:          #0b0f14;
  --bg-grain:    #0e141b;
  --surface:     #131a23;
  --surface-2:   #18212c;
  --line:        #22303f;
  --line-soft:   #1a2531;

  --text:        #e6edf3;
  --text-dim:    #93a4b5;
  --text-mute:   #61748a;

  --up:          #22c993;
  --up-soft:     rgba(34, 201, 147, 0.12);
  --down:        #ff5c6c;
  --down-soft:   rgba(255, 92, 108, 0.12);
  --accent:      #4c8dff;
  --accent-soft: rgba(76, 141, 255, 0.14);
  --warn:        #f0b429;

  --radius:      10px;
  --radius-lg:   14px;
  --shadow:      0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);

  --font-sans:   'IBM Plex Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono:   'JetBrains Mono', ui-monospace, 'Cascadia Mono', monospace;

  --step-sm:     0.8125rem;
  --step-0:      0.9375rem;
  --step-1:      1.125rem;
  --step-2:      1.5rem;
  --step-3:      clamp(1.75rem, 1.2rem + 1.6vw, 2.5rem);

  --gap:         1rem;
  --gap-lg:      1.5rem;
  --shell-w:     1240px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 15% -10%, #16202c 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: var(--step-2); }
h2 { font-size: var(--step-1); }
p  { margin: 0 0 0.5rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- โครงหน้า ---------- */

.shell {
  width: 100%;
  max-width: var(--shell-w);
  margin: 0 auto;
  padding: var(--gap-lg) var(--gap) 3rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--gap-lg);
}

.shell-bare {
  flex: 1;
  display: grid;
  place-items: center;
  padding: var(--gap);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--gap-lg);
  padding: 0.75rem var(--gap);
  background: rgba(11, 15, 20, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand-mark { color: var(--up); margin-right: 0.15rem; }

.topbar nav { display: flex; gap: 0.25rem; flex: 1; }
.topbar nav a {
  color: var(--text-dim);
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius);
  font-size: var(--step-sm);
}
.topbar nav a:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.topbar nav a.on { background: var(--accent-soft); color: #cfe0ff; }

.topbar-actions { display: flex; gap: 0.5rem; align-items: center; }

.foot {
  display: flex;
  justify-content: space-between;
  gap: var(--gap);
  max-width: var(--shell-w);
  width: 100%;
  margin: 0 auto;
  padding: 1rem var(--gap) 2rem;
  color: var(--text-mute);
  font-size: var(--step-sm);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: var(--gap-lg);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--gap);
  flex-wrap: wrap;
}
.page-actions { display: flex; gap: 0.5rem; }

/* ---------- ตัวอักษรช่วย ---------- */

.label {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.muted { color: var(--text-mute); }
.hint  { color: var(--text-dim); font-size: var(--step-sm); }
.help  { color: var(--text-mute); font-size: var(--step-sm); display: block; margin-top: 0.25rem; }
.mono  { font-family: var(--font-mono); font-size: var(--step-sm); }
.nowrap { white-space: nowrap; }

.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.up   { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--text-dim); }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 0.5rem; }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; }
}

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