/* Call — design tokens (shared by landing page and console).
 *
 * Dark is the default. Light is applied by html[data-theme="light"], which the
 * inline boot script in each page sets before first paint from localStorage or
 * the OS preference — so there is no flash of the wrong theme.
 *
 * Rules of the token set:
 *   --ink-*    surfaces, lightest-to-darkest role order is stable across themes
 *   --film-*   translucent overlays used for cards, chips, hovers
 *   --txt-*    text, 1 = primary
 *   --s1..s6   chart data marks — validated per theme, never reuse the neon set
 *   neon       UI chrome only (gradients, glows, rings)
 */

:root,
html[data-theme="dark"] {
  color-scheme: dark;

  /* surfaces */
  --ink: #080b14;
  --ink-2: #0b101e;
  --ink-3: #0f1626;
  --ink-4: #141d31;
  --ink-5: #1b2540;

  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --line-3: rgba(255, 255, 255, 0.22);

  /* translucent films — the only "white overlay" values in the stylesheets */
  --film-1: rgba(255, 255, 255, 0.025);
  --film-2: rgba(255, 255, 255, 0.04);
  --film-3: rgba(255, 255, 255, 0.06);
  --film-4: rgba(255, 255, 255, 0.09);

  /* composed surfaces */
  --card-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.012));
  --panel-bg: linear-gradient(165deg, rgba(20, 29, 49, 0.9), rgba(11, 16, 30, 0.92));
  --panel-bg-2: linear-gradient(165deg, rgba(20, 29, 49, 0.75), rgba(11, 16, 30, 0.85));
  --featured-bg: linear-gradient(180deg, rgba(124, 92, 255, 0.11), rgba(255, 255, 255, 0.014));
  --header-bg: rgba(8, 11, 20, 0.72);
  --header-bg-2: rgba(8, 11, 20, 0.9);
  --menu-bg: rgba(11, 16, 30, 0.98);
  --scrim: rgba(8, 11, 20, 0.82);
  --bar-bg: rgba(15, 22, 38, 0.94);
  --toast-bg: rgba(20, 29, 49, 0.96);
  --grid-line: rgba(255, 255, 255, 0.028);
  --dot-grid: rgba(255, 255, 255, 0.06);
  --track: rgba(255, 255, 255, 0.12);
  --knob: #ffffff;
  --orb-opacity: 0.5;

  /* ink */
  --txt: #eaf0fb;
  --txt-2: #9daac4;
  --txt-3: #5f6e8c;

  /* neon — UI CHROME ONLY (gradients, glows, rings, pills).
     Never used as a chart data mark: these sit above the dark-mode
     lightness band. Data marks use --s1..--s6 below. */
  --cyan: #38e1ff;
  --violet: #7c5cff;
  --magenta: #ff3d9a;
  --mint: #38f5c2;
  --gold: #ffc24b;
  --coral: #ff6b6b;

  --brand: linear-gradient(120deg, #38e1ff 0%, #7c5cff 52%, #ff3d9a 100%);
  --brand-soft: linear-gradient(120deg, rgba(56, 225, 255, 0.16), rgba(124, 92, 255, 0.16), rgba(255, 61, 154, 0.16));
  --on-brand: #08111d;
  --on-brand-chip: rgba(8, 17, 29, 0.22);

  /* chart series — dark steps of the fixed slot order
     pink · blue · gold · violet · green · red.
     Validated on surface #0F1626: lightness band pass · chroma pass ·
     CVD adjacent ΔE 8.6 · normal-vision ΔE 24.7 · contrast pass.
     A slot keeps its hue family in both themes, so a series does not
     change identity when the theme flips — only its step does. */
  --s1: #e0247f;
  --s2: #0fa6c4;
  --s3: #c98500;
  --s4: #7c5cff;
  --s5: #12aa83;
  --s6: #e24443;

  /* sequential (single hue, light→dark) for magnitude */
  --q1: #8fe8f8;
  --q2: #5fd6ec;
  --q3: #31c0db;
  --q4: #12a9c6;
  --q5: #0d8aa3;
  --q6: #0a6c80;

  /* status — icon + label always accompany these */
  --ok: #12aa83;
  --ok-ink: #38f5c2;
  --warn: #c98500;
  --warn-ink: #ffc24b;
  --bad: #e24443;
  --bad-ink: #ff8b8b;
  --info: #0fa6c4;
  --info-ink: #6fe0f7;

  --grid: rgba(255, 255, 255, 0.07);
  --axis: rgba(255, 255, 255, 0.16);
  --chart-surface: #0f1626;

  --shadow: 0 24px 60px -22px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 40px 90px -30px rgba(0, 0, 0, 0.85);
  --glow-cyan: 0 0 0 1px rgba(56, 225, 255, 0.35), 0 0 40px -8px rgba(56, 225, 255, 0.5);
  --glow-violet: 0 0 0 1px rgba(124, 92, 255, 0.35), 0 0 40px -8px rgba(124, 92, 255, 0.45);

  --scroll-thumb: rgba(255, 255, 255, 0.14);
  --scroll-thumb-hover: rgba(255, 255, 255, 0.24);
  --select-bg: rgba(124, 92, 255, 0.4);
  --select-ink: #fff;

  --font-d: "Space Grotesk", "Noto Sans JP", system-ui, sans-serif;
  --font-b: "Inter", "Noto Sans JP", system-ui, sans-serif;
  --font-m: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 26px;

  --maxw: 1200px;
}

html[data-theme="light"] {
  color-scheme: light;

  /* surfaces — page is tinted so white cards lift off it */
  --ink: #f4f7fc;
  --ink-2: #ffffff;
  --ink-3: #ffffff;
  --ink-4: #eef2f9;
  --ink-5: #e3eaf5;

  --line: rgba(15, 26, 48, 0.1);
  --line-2: rgba(15, 26, 48, 0.16);
  --line-3: rgba(15, 26, 48, 0.28);

  --film-1: rgba(15, 26, 48, 0.025);
  --film-2: rgba(15, 26, 48, 0.04);
  --film-3: rgba(15, 26, 48, 0.06);
  --film-4: rgba(15, 26, 48, 0.09);

  --card-bg: linear-gradient(180deg, #ffffff, #fbfcfe);
  --panel-bg: linear-gradient(165deg, #ffffff, #f2f6fc);
  --panel-bg-2: linear-gradient(165deg, #ffffff, #f5f8fd);
  --featured-bg: linear-gradient(180deg, rgba(124, 92, 255, 0.09), #ffffff);
  --header-bg: rgba(244, 247, 252, 0.78);
  --header-bg-2: rgba(244, 247, 252, 0.94);
  --menu-bg: rgba(255, 255, 255, 0.98);
  --scrim: rgba(23, 34, 58, 0.42);
  --bar-bg: rgba(255, 255, 255, 0.95);
  --toast-bg: rgba(255, 255, 255, 0.97);
  --grid-line: rgba(15, 26, 48, 0.045);
  --dot-grid: rgba(15, 26, 48, 0.07);
  --track: rgba(15, 26, 48, 0.14);
  --knob: #ffffff;
  --orb-opacity: 0.3;

  --txt: #0e1626;
  --txt-2: #4a5876;
  --txt-3: #71809b;

  /* accents, darkened until they carry text weight on white */
  --cyan: #06718a;
  --violet: #5b3ee0;
  --magenta: #c01a68;
  --mint: #0b8467;
  --gold: #8a5f00;
  --coral: #c93b3b;

  --brand: linear-gradient(120deg, #0fa6c4 0%, #7c5cff 52%, #e0247f 100%);
  --brand-soft: linear-gradient(120deg, rgba(15, 166, 196, 0.12), rgba(124, 92, 255, 0.12), rgba(224, 36, 127, 0.12));
  --on-brand: #ffffff;
  --on-brand-chip: rgba(255, 255, 255, 0.26);

  /* chart series — light steps of the same slot order.
     Validated on surface #FFFFFF: lightness band pass · chroma pass ·
     CVD adjacent ΔE 9.1 · normal-vision ΔE 24.7 · contrast pass. */
  --s1: #c2185b;
  --s2: #2a78d6;
  --s3: #8a6d00;
  --s4: #7a4fd0;
  --s5: #0f8a6a;
  --s6: #d2601a;

  /* sequential — light end holds 2.08:1 against white */
  --q1: #8ab8e8;
  --q2: #6fa2de;
  --q3: #4f86cf;
  --q4: #2f6ab8;
  --q5: #1e5090;
  --q6: #153a68;

  --ok: #12925f;
  --ok-ink: #0a7048;
  --warn: #b07300;
  --warn-ink: #8a5b00;
  --bad: #d13a3a;
  --bad-ink: #a92222;
  --info: #1173a8;
  --info-ink: #0a5a84;

  --grid: rgba(15, 26, 48, 0.08);
  --axis: rgba(15, 26, 48, 0.2);
  --chart-surface: #ffffff;

  --shadow: 0 18px 44px -22px rgba(16, 28, 54, 0.3);
  --shadow-lg: 0 32px 72px -30px rgba(16, 28, 54, 0.34);
  --glow-cyan: 0 0 0 1px rgba(15, 166, 196, 0.3), 0 12px 34px -14px rgba(15, 166, 196, 0.45);
  --glow-violet: 0 0 0 1px rgba(124, 92, 255, 0.3), 0 12px 34px -14px rgba(124, 92, 255, 0.4);

  --scroll-thumb: rgba(15, 26, 48, 0.18);
  --scroll-thumb-hover: rgba(15, 26, 48, 0.3);
  --select-bg: rgba(124, 92, 255, 0.22);
  --select-ink: #0e1626;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* The decorative blurred orbs are fixed and deliberately wider than the
     viewport; they are positioned against the viewport, so the clip has to sit
     here rather than on <body>. `clip` (not `hidden`) trims them without
     creating a scroll container, so the sticky headers keep working. */
  overflow-x: clip;
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--txt);
  font-family: var(--font-b);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "palt" 1;
}

:lang(ja) {
  letter-spacing: 0.01em;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

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

::selection {
  background: var(--select-bg);
  color: var(--select-ink);
}

.grad-text {
  background: var(--brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.mono {
  font-family: var(--font-m);
}

.tnum {
  font-variant-numeric: tabular-nums;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------- brand lockup ---------------- */

.brand-lockup {
  display: block;
  width: auto;
}

html[data-theme="light"] .only-dark,
html[data-theme="dark"] .only-light {
  display: none;
}

/* ---------------- theme toggle ---------------- */

.theme-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--film-2);
  color: var(--txt-2);
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.theme-btn:hover {
  color: var(--txt);
  border-color: var(--line-3);
  background: var(--film-4);
}

.theme-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* the toggle shows the mode it switches TO */
html[data-theme="light"] .i-moon,
html[data-theme="dark"] .i-sun {
  display: none;
}

/* scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
  background-clip: content-box;
}

/* language visibility helper — set html[data-lang] */
[data-when-lang] {
  display: none;
}

html[data-lang="ja"] [data-when-lang="ja"],
html[data-lang="en"] [data-when-lang="en"] {
  display: revert;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
