/* ==========================================================================
   Xearch design system — tokens & primitives shared by every page
   (landing: css/style.css · app: css/dashboard.css build on top of this)
   ========================================================================== */

:root {
  /* Two channels drive the whole palette: ink (foreground) and paper (background).
     Translucent fills are written as rgb(var(--ink) / a), so a theme flips them in one place. */
  --ink: 255 255 255;
  --paper: 0 0 0;
  --bg: #000;
  --bg-2: #07080a;
  --surface: rgb(var(--ink) / .035);
  --surface-2: rgb(var(--ink) / .06);
  --line: rgb(var(--ink) / .08);
  --line-2: rgb(var(--ink) / .14);
  --hi: rgb(var(--ink) / .07);
  --text: #f5f5f7;
  --muted: #a1a1a6;
  --dim: #6e6e73;
  /* ink does the work; blue is a rare accent (live state, the visitor's selection, ▼ fall); red marks alerts and ▲ rise */
  --accent-rgb: 29 155 240;
  --accent: rgb(var(--accent-rgb));
  --accent-2: #47aef5;
  --red-rgb: 255 69 58;
  --red: rgb(var(--red-rgb));
  /* direction follows the Korean convention (stocks, charts): rise red, fall blue */
  --rise-rgb: var(--red-rgb);
  --fall-rgb: var(--accent-rgb);
  --rise: rgb(var(--rise-rgb));
  --fall: rgb(var(--fall-rgb));
  --shadow: rgba(0, 0, 0, .9);
  --device-a: rgba(22, 24, 28, .9);
  --device-b: rgba(10, 11, 13, .92);
  --glass: rgba(22, 22, 26, .66);
  --notif-bg: rgba(38, 38, 42, .72);
  --label-bg: rgba(10, 10, 12, .88);
  --label-accent-bg: rgba(6, 22, 36, .9);
  --label-red-bg: rgba(34, 10, 10, .92);
  --serp-bg: #202124; --serp-bar: #303134; --serp-text: #e8eaed; --serp-sub: #bdc1c6;
  --serp-link: #8ab4f8; --serp-icon: #9aa0a6; --serp-ghost: #3c4043;
  --star-a: 1;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-ios: cubic-bezier(0.32, 0.72, 0, 1);
  --radius: 22px;
  --radius-sm: 14px;
  --gutter: clamp(16px, 4vw, 40px);
  --maxw: 1200px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  -webkit-tap-highlight-color: transparent;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  letter-spacing: -0.01em;
  word-break: keep-all;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
::selection { background: rgb(var(--accent-rgb) / 0.35); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }

.mono { font-family: var(--mono); letter-spacing: 0.02em; }
.dim { color: var(--dim); }
/* Colour discipline (X-like): everything is ink by default.
   Direction follows the Korean convention — ▲ rise red, ▼ fall blue.
   Otherwise blue only marks live state and the visitor's own selection; red also marks alerts. */
.up { color: var(--rise); }
.down { color: var(--fall); }
.dot-rise { background: var(--rise); }
.dot-fall { background: var(--fall); }
.flat { color: var(--dim); }
.accent-text { color: var(--accent-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }

.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot-me { background: var(--text); box-shadow: 0 0 10px var(--text); }
.dot-red { background: var(--red); box-shadow: 0 0 10px rgb(var(--red-rgb) / .7); }
.dot-white, .dot-a { background: var(--text); box-shadow: 0 0 10px rgb(var(--ink) / .5); }
.dot-b { background: var(--muted); }
.dot-c { background: var(--dim); }

.live-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); margin-right: 8px; vertical-align: 1px;
  box-shadow: 0 0 0 0 rgb(var(--accent-rgb) / .7);
  animation: pulse 2s var(--ease-out) infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgb(var(--accent-rgb) / .6); }
  70% { box-shadow: 0 0 0 9px rgb(var(--accent-rgb) / 0); }
  100% { box-shadow: 0 0 0 0 rgb(var(--accent-rgb) / 0); }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 24px; border-radius: 999px;
  font-weight: 620; font-size: 16px; letter-spacing: -0.01em;
  transition: transform 160ms var(--ease-out), background-color 200ms, box-shadow 300ms, color 200ms;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:active { transform: scale(0.96); transition-duration: 80ms; }
.btn-sm { height: 36px; padding: 0 16px; font-size: 14px; }
.btn-lg { height: 56px; padding: 0 30px; font-size: 17px; }
.btn-light { background: var(--text); color: var(--bg); box-shadow: 0 0 0 0 rgb(var(--ink) / 0); }
.btn-light:hover { background: var(--text); box-shadow: 0 0 40px rgb(var(--ink) / .25); }
.btn-ghost { color: var(--text); background: rgb(var(--ink) / .06); box-shadow: inset 0 0 0 1px var(--line-2); }
.btn-ghost:hover { background: rgb(var(--ink) / .1); }

.theme-toggle {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  color: var(--muted); box-shadow: inset 0 0 0 1px var(--line-2);
  transition: color 200ms, background-color 200ms, transform 120ms;
}
.theme-toggle:hover { color: var(--text); background: rgb(var(--ink) / .06); }
.theme-toggle:active { transform: scale(.92); }
.theme-toggle svg { width: 18px; height: 18px; }
.ic-moon { display: none; }
.card {
  position: relative;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgb(var(--ink) / .045), rgb(var(--ink) / .02));
  box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 var(--hi);
  padding: 22px;
  overflow: hidden;
}
/* pointer spotlight */
.card::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, -200px), rgb(var(--ink) / .06), transparent 60%);
  opacity: 0; transition: opacity 300ms;
}
@media (hover: hover) { .card:hover::before { opacity: 1; } }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); margin-bottom: 16px; flex-wrap: wrap; }
.card-head b { color: var(--text); }
.legend { display: inline-flex; align-items: center; gap: 8px; font-size: 11.5px; }
.legend { font-size: 12.5px; }
.legend .dot ~ .dot { margin-left: 8px; }

/* Light theme tokens — only when the visitor picks it (html[data-theme="light"]); dark is the default */
:root[data-theme="light"] {
  --ink: 0 0 0;
  --paper: 255 255 255;
  --bg: #fdfdfd;
  --bg-2: #f3f3f4;
  --hi: rgba(255, 255, 255, .7);
  --text: #111113;
  --muted: #5c5c63;
  --dim: #8b8b92;
  --accent-2: #0c7abf;
  --red-rgb: 215 0 21;
  --shadow: rgba(0, 0, 0, .14);
  --device-a: #ffffff;
  --device-b: #f8f8f9;
  --glass: rgba(255, 255, 255, .78);
  --notif-bg: rgba(255, 255, 255, .86);
  --label-bg: rgba(255, 255, 255, .95);
  --label-accent-bg: rgba(232, 244, 253, .97);
  --label-red-bg: rgba(255, 240, 240, .97);
  --serp-bg: #fff; --serp-bar: #f1f3f4; --serp-text: #202124; --serp-sub: #4d5156;
  --serp-link: #1a0dab; --serp-icon: #5f6368; --serp-ghost: #e8eaed;
  --star-a: .45;
  color-scheme: light;
}
:root[data-theme="light"] .ic-sun { display: none; }
:root[data-theme="light"] .ic-moon { display: block; }
:root[data-theme="light"] .btn-light:hover { box-shadow: 0 10px 28px -10px rgba(0, 0, 0, .4); }
