/* mehk3y.com — Shared design system.
 * Premium minimal, dual theme (light/dark/auto), self-hosted Geist.
 * Loaded once and cached cross-page. Page-specific overrides stay inline.
 */

/* ============================================================
   Fonts — Self-hosted Geist (Apache 2.0, vercel/geist-font)
   ============================================================ */
@font-face {
  font-family: 'Geist';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/Geist-Variable.woff2') format('woff2-variations'),
       url('/fonts/Geist-Variable.woff2') format('woff2');
}
@font-face {
  font-family: 'Geist Mono';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/GeistMono-Variable.woff2') format('woff2-variations'),
       url('/fonts/GeistMono-Variable.woff2') format('woff2');
}

/* ============================================================
   Reset
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ============================================================
   Tokens — Light (default)
   ============================================================ */
:root {
  --bg:         #ffffff;
  --surface:    #f6f6f6;
  --surface-2: #ffffff;  /* nested card / input bg */
  --border:     #ececec;
  --border-2:  #e2e2e2;
  --text:       #0d0d0d;
  --text-2:    #4a4a4a;
  --dim:        #666666;
  --faint:     #909090;

  --orange:  #f7931a;
  --green:   #16a34a;
  --red:     #dc2626;
  --blue:    #2563eb;
  --purple:  #627eea;

  --accent:    #0d0d0d;
  --accent-fg: #ffffff;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 14px -4px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.04);
  --shadow-lg: 0 18px 40px -16px rgba(0,0,0,.12), 0 4px 10px -3px rgba(0,0,0,.05);

  --ring: 0 0 0 3px rgba(13,13,13,.12);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 14px;
  --r-xl: 18px;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  --noise-opacity: 0.025;
  --spot-1: rgba(0, 0, 0, 0.025);
  --spot-2: rgba(0, 0, 0, 0.012);
}

/* ============================================================
   Tokens — Dark
   ============================================================ */
:root[data-theme="dark"] {
  --bg:         #0a0a0a;
  --surface:    #111111;
  --surface-2: #161616;
  --border:     #1f1f1f;
  --border-2:  #2a2a2a;
  --text:       #f5f5f5;
  --text-2:    #c4c4c4;
  --dim:        #707070;
  --faint:     #4a4a4a;

  --orange:  #ffae3d;
  --green:   #34d399;
  --red:     #f87171;
  --blue:    #60a5fa;
  --purple:  #a78bfa;

  --accent:    #ffffff;
  --accent-fg: #0a0a0a;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.40);
  --shadow-md: 0 4px 14px -4px rgba(0,0,0,.55), 0 1px 3px rgba(0,0,0,.30);
  --shadow-lg: 0 22px 50px -20px rgba(0,0,0,.70), 0 6px 14px -4px rgba(0,0,0,.40);

  --ring: 0 0 0 3px rgba(255,255,255,.16);

  --noise-opacity: 0.045;
  --spot-1: rgba(255, 255, 255, 0.04);
  --spot-2: rgba(255, 255, 255, 0.02);

  color-scheme: dark;
}

/* Auto-detect dark mode for users who haven't explicitly chosen light/dark */
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"],
  :root:not([data-theme]) {
    --bg:         #0a0a0a;
    --surface:    #111111;
    --surface-2: #161616;
    --border:     #1f1f1f;
    --border-2:  #2a2a2a;
    --text:       #f5f5f5;
    --text-2:    #c4c4c4;
    --dim:        #707070;
    --faint:     #4a4a4a;
    --orange:  #ffae3d;
    --green:   #34d399;
    --red:     #f87171;
    --blue:    #60a5fa;
    --purple:  #a78bfa;
    --accent:    #ffffff;
    --accent-fg: #0a0a0a;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.40);
    --shadow-md: 0 4px 14px -4px rgba(0,0,0,.55), 0 1px 3px rgba(0,0,0,.30);
    --shadow-lg: 0 22px 50px -20px rgba(0,0,0,.70), 0 6px 14px -4px rgba(0,0,0,.40);
    --ring: 0 0 0 3px rgba(255,255,255,.16);
    --noise-opacity: 0.045;
    --spot-1: rgba(255, 255, 255, 0.04);
    --spot-2: rgba(255, 255, 255, 0.02);
    color-scheme: dark;
  }
}

/* ============================================================
   Base
   ============================================================ */
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  font-feature-settings: "ss01", "ss03", "cv11";
  letter-spacing: -0.005em;
  transition: background-color 0.25s ease, color 0.25s ease;
}

code, kbd, samp, pre, .mono {
  font-family: 'Geist Mono', "SF Mono", "JetBrains Mono", "Fira Code", "Menlo", monospace;
  font-feature-settings: "ss01", "zero";
}

a { color: inherit; }

::selection {
  background: var(--accent);
  color: var(--accent-fg);
}

/* Focus ring (only for keyboard) */
:focus { outline: none; }
:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: 6px;
}

/* Scrollbar */
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-2); border-radius: 99px; border: 2px solid var(--bg);
}
*::-webkit-scrollbar-thumb:hover { background: var(--dim); }

/* ============================================================
   Global chrome — spotlight glow + grain overlay
   ============================================================ */
body::before {
  content: '';
  position: fixed; top: -300px; left: 50%;
  transform: translateX(-50%);
  width: 900px; height: 500px;
  background: radial-gradient(ellipse at center,
    var(--spot-1) 0%,
    var(--spot-2) 35%,
    transparent 70%);
  pointer-events: none;
  z-index: 0;
  filter: blur(20px);
}
body::after {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: var(--noise-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] body::after { filter: invert(1); }
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] body::after,
  :root:not([data-theme]) body::after { filter: invert(1); }
}

/* ============================================================
   Cascade entrance
   ============================================================ */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.wrap > *,
.container > * {
  animation: rise 0.7s var(--ease) both;
}
.wrap > *:nth-child(1),  .container > *:nth-child(1)  { animation-delay: 0.04s; }
.wrap > *:nth-child(2),  .container > *:nth-child(2)  { animation-delay: 0.10s; }
.wrap > *:nth-child(3),  .container > *:nth-child(3)  { animation-delay: 0.16s; }
.wrap > *:nth-child(4),  .container > *:nth-child(4)  { animation-delay: 0.22s; }
.wrap > *:nth-child(5),  .container > *:nth-child(5)  { animation-delay: 0.27s; }
.wrap > *:nth-child(6),  .container > *:nth-child(6)  { animation-delay: 0.32s; }
.wrap > *:nth-child(7),  .container > *:nth-child(7)  { animation-delay: 0.36s; }
.wrap > *:nth-child(8),  .container > *:nth-child(8)  { animation-delay: 0.40s; }
.wrap > *:nth-child(n+9),
.container > *:nth-child(n+9) { animation-delay: 0.44s; }

@media (prefers-reduced-motion: reduce) {
  .wrap > *, .container > * { animation: none !important; }
  html { scroll-behavior: auto; }
  * { transition: none !important; animation-duration: 0.01ms !important; }
}

/* ============================================================
   Layout chrome
   ============================================================ */
.wrap { max-width: 880px; margin: 0 auto; padding: 28px 20px 48px; position: relative; z-index: 1; }
.container { position: relative; z-index: 1; }

.hdr  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; gap: 12px; }
.hdr-left  { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.hdr-name  { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); text-decoration: none; }
.hdr-sub   { font-size: 12px; color: var(--dim); }
.hdr-back  { color: var(--dim); text-decoration: none; font-size: 13px; margin-right: 8px; transition: color .2s; }
.hdr-back:hover { color: var(--text); }
.hdr-right { display: flex; align-items: center; gap: 8px; }
.hdr-price-wrap { text-align: right; }
.hdr-price { font-size: 28px; font-weight: 800; letter-spacing: -0.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.hdr-chg   { display: inline-block; margin-top: 3px; font-size: 12px; font-weight: 500; color: var(--dim); font-variant-numeric: tabular-nums; }
.divider   { height: 1px; background: var(--border); margin: 0 0 20px; }

/* ============================================================
   Cards / strips
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  transition: border-color .25s ease, background-color .25s ease;
}
.card-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--dim); margin-bottom: 10px; font-weight: 500; }
.card-main  { font-size: 26px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.card-sub   { font-size: 12px; color: var(--dim); line-height: 1.6; }
.card-sub b { color: var(--text); font-weight: 600; }

.strip {
  display: flex; gap: 0; margin-bottom: 20px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  overflow: hidden; background: var(--bg);
}
.strip-item  { flex: 1; padding: 14px 18px; border-right: 1px solid var(--border); }
.strip-item:last-child { border-right: none; }
.strip-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--dim); margin-bottom: 5px; font-weight: 500; }
.strip-val   { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

.section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.10em; color: var(--dim); margin: 22px 0 10px; display: flex; align-items: center; gap: 10px; font-weight: 500; }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* Grids */
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 10px; }

/* ============================================================
   Skeleton
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--border-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
  border-radius: 4px;
  display: inline-block;
  min-width: 60px;
  min-height: 1em;
  color: transparent !important;
}
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ============================================================
   Buttons (refresh + theme toggle)
   ============================================================ */
.refresh-btn, .theme-toggle {
  width: 32px; height: 32px;
  border: 1px solid var(--border); border-radius: 50%;
  background: var(--bg); color: var(--dim);
  font-size: 13px; line-height: 1; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color .2s, border-color .2s, background-color .2s, transform .2s;
}
.refresh-btn:hover, .theme-toggle:hover {
  color: var(--text); border-color: var(--border-2); background: var(--surface);
}
.refresh-btn:active, .theme-toggle:active { transform: scale(0.94); }
.refresh-btn.spinning { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.theme-toggle svg { width: 14px; height: 14px; display: block; }
/* show correct icon per theme */
.theme-toggle .icon-dark,
.theme-toggle .icon-auto { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-light { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-dark  { display: block; }
:root[data-theme="auto"] .theme-toggle .icon-light,
:root[data-theme="auto"] .theme-toggle .icon-dark  { display: none; }
:root[data-theme="auto"] .theme-toggle .icon-auto  { display: block; }

/* ============================================================
   Tint tokens — for alerts, tags, inline accent backgrounds.
   Pastels in light mode, low-saturation in dark mode.
   ============================================================ */
:root {
  --tint-red-bg:    #fef2f2; --tint-red-fg:    #991b1b;
  --tint-green-bg:  #f0fdf4; --tint-green-fg:  #14532d;
  --tint-blue-bg:   #eff6ff; --tint-blue-fg:   #1d4ed8;
  --tint-orange-bg: #fff7ed; --tint-orange-fg: #9a3412;
  --tint-purple-bg: #f3f0ff; --tint-purple-fg: #5b21b6;
  --tint-yellow-bg: #fffbeb; --tint-yellow-fg: #92400e;
  --tint-pink-bg:   #fff0f0; --tint-pink-fg:   #be123c;
  --tint-fuchsia-bg:#fdf4ff; --tint-fuchsia-fg:#86198f;
  --tint-orange-border: #fed7aa;
}
:root[data-theme="dark"] {
  --tint-red-bg:    rgba(248,113,113,.14); --tint-red-fg:    #fca5a5;
  --tint-green-bg:  rgba(52,211,153,.14);  --tint-green-fg:  #6ee7b7;
  --tint-blue-bg:   rgba(96,165,250,.14);  --tint-blue-fg:   #93c5fd;
  --tint-orange-bg: rgba(255,174,61,.14);  --tint-orange-fg: #fdba74;
  --tint-purple-bg: rgba(167,139,250,.14); --tint-purple-fg: #c4b5fd;
  --tint-yellow-bg: rgba(234,179,8,.14);   --tint-yellow-fg: #fcd34d;
  --tint-pink-bg:   rgba(244,114,182,.14); --tint-pink-fg:   #fbcfe8;
  --tint-fuchsia-bg:rgba(217,70,239,.14);  --tint-fuchsia-fg:#f0abfc;
  --tint-orange-border: rgba(253,186,116,.30);
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"], :root:not([data-theme]) {
    --tint-red-bg:    rgba(248,113,113,.14); --tint-red-fg:    #fca5a5;
    --tint-green-bg:  rgba(52,211,153,.14);  --tint-green-fg:  #6ee7b7;
    --tint-blue-bg:   rgba(96,165,250,.14);  --tint-blue-fg:   #93c5fd;
    --tint-orange-bg: rgba(255,174,61,.14);  --tint-orange-fg: #fdba74;
    --tint-purple-bg: rgba(167,139,250,.14); --tint-purple-fg: #c4b5fd;
    --tint-yellow-bg: rgba(234,179,8,.14);   --tint-yellow-fg: #fcd34d;
    --tint-pink-bg:   rgba(244,114,182,.14); --tint-pink-fg:   #fbcfe8;
    --tint-fuchsia-bg:rgba(217,70,239,.14);  --tint-fuchsia-fg:#f0abfc;
    --tint-orange-border: rgba(253,186,116,.30);
  }
}

/* ============================================================
   Floating top-bar (theme toggle on sub-pages)
   ============================================================ */
.site-top {
  position: fixed; top: 16px; right: 16px;
  z-index: 50;
  animation: none !important;
}
@media (max-width: 480px) {
  .site-top { top: 12px; right: 12px; }
}

/* ============================================================
   Error toast
   ============================================================ */
.error-toast {
  position: fixed; bottom: 20px; left: 50%;
  transform: translate(-50%, 16px);
  background: var(--red); color: #fff;
  padding: 10px 20px; border-radius: 10px;
  font-size: 13px; opacity: 0; pointer-events: none; z-index: 99;
  box-shadow: var(--shadow-md);
  transition: opacity .25s, transform .35s var(--ease);
}
.error-toast.show { display: block; opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }

/* ============================================================
   Footer
   ============================================================ */
.footer { margin-top: 32px; text-align: center; font-size: 11px; color: var(--dim); }
.footer a { color: var(--dim); text-decoration: none; transition: color .2s; }
.footer a:hover { color: var(--text); }

/* ============================================================
   Utility primitives used by individual pages
   ============================================================ */
.btn-pill {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 22px;
  border: 1px solid var(--border-2); border-radius: 99px;
  background: var(--bg); color: var(--text);
  font: 600 13px 'Geist', inherit;
  cursor: pointer;
  transition: background-color .2s, border-color .2s, transform .2s;
}
.btn-pill:hover { background: var(--surface); border-color: var(--dim); }
.btn-pill:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-pill:active:not(:disabled) { transform: scale(0.98); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 700px) {
  .wrap { padding: 18px 14px 40px; }
  .grid4 { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .grid3, .grid2 { grid-template-columns: repeat(1, 1fr); gap: 8px; }
  .hdr-price { font-size: 22px; }
  .strip { flex-direction: row; flex-wrap: wrap; }
  .strip-item { flex: 1 1 calc(50% - 1px); border-right: none; border-bottom: 1px solid var(--border); padding: 12px 14px; min-width: 0; }
  .strip-item:last-child { border-bottom: none; }
  .card { padding: 14px 16px; }
  .card-main { font-size: 22px; }
  .card-sub { font-size: 11px; }
}
@media (max-width: 420px) {
  .grid4 { grid-template-columns: repeat(2, 1fr); }
  .strip-item { flex: 1 1 100%; }
  .hdr { flex-direction: column; align-items: flex-start; gap: 8px; }
  .hdr-price-wrap { text-align: left; }
}

/* ============================================================
   Touch-friendly mobile tweaks — minimum 44px tap targets
   ============================================================ */
@media (max-width: 480px) {
  .btn-pill { padding: 10px 22px; }
  .refresh-btn, .theme-toggle { width: 36px; height: 36px; }
}
