/* =========================================================================
 * Context Window Usage Visualizer — styles. Animated modern UI.
 * All motion disabled under prefers-reduced-motion.
 * Accent: cyan #06b6d4 (unused by sibling tools).
 * ========================================================================= */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef1f8;
  --ink: #141a2e;
  --ink-soft: #4b5573;
  --ink-faint: #8a93ad;
  --line: #e2e7f2;
  --brand: #06b6d4;
  --brand-2: #0e7490;
  --brand-soft: #e6f7fb;
  --ok: #0f9d58;
  --ok-soft: #e5f6ec;
  --warn: #b45309;
  --warn-soft: #fef3e2;
  --err: #dc2626;
  --err-soft: #fdecec;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(20, 26, 46, 0.08);
  --shadow-lg: 0 18px 50px rgba(6, 182, 212, 0.16);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  background: #f6f7fb;
  color: #141a2e;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.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;
}
.skip-link {
  position: absolute; left: 16px; top: -60px; z-index: 100;
  background: #141a2e; color: #fff; padding: 10px 16px; border-radius: 10px;
  text-decoration: none; font-weight: 700; transition: top 0.2s;
}
.skip-link:focus { top: 12px; }

/* ---------------- header ---------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: #ffffff;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid #e2e7f2;
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #141a2e; font-weight: 800; font-size: 1.05rem; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: #06b6d4;
  box-shadow: 0 10px 30px rgba(20, 26, 46, 0.08);
}
.brand-mark svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2; }
.nav { display: flex; gap: 4px; }
.nav a {
  color: #4b5573; text-decoration: none; font-weight: 600; font-size: 0.92rem;
  padding: 8px 12px; border-radius: 10px; transition: background 0.18s, color 0.18s;
}
.nav a:hover, .nav a:focus-visible { background: #eef1f8; color: #141a2e; outline: none; }

/* ---------------- hero ----------------
   Compact by design: one line of headline + one line of promise, so the
   visualizer itself is on the first screen. */
.hero {
  padding: 26px 0 10px;
  background: #f6f7fb;
}
.hero h1 {
  font-size: clamp(1.65rem, 3.4vw, 2.25rem);
  line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 6px; max-width: none;
}
.hero h1 .grad {
  color: #0e7490;
}
.lede { font-size: 1rem; color: #4b5573; max-width: none; margin: 0 0 12px; }
.trust-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.trust-row li {
  display: inline-flex; align-items: center; gap: 7px;
  background: #ffffff; border: 1px solid #e2e7f2; border-radius: 999px;
  padding: 5px 11px; font-size: 0.82rem; font-weight: 600; color: #4b5573;
  box-shadow: 0 2px 8px rgba(20, 26, 46, 0.05);
}
.trust-row .dot { width: 7px; height: 7px; border-radius: 50%; background: #0f9d58; box-shadow: 0 0 0 3px #e5f6ec; }

/* ---------------- tool card ---------------- */
.tool-section { padding: 8px 0 32px; }
.tool-card {
  background: #ffffff; border: 1.5px solid #c3ccd9;
  border-radius: 22px; box-shadow: 0 18px 50px rgba(6, 182, 212, 0.16);
  padding: clamp(18px, 3vw, 28px);
}
.tool-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: 24px; align-items: start; }
.tool-main { min-width: 0; }
.tool-side { min-width: 0; }
.step-title { font-weight: 800; margin: 0 0 10px; font-size: 1rem; }

/* settings */
.settings { border: 0; margin: 0 0 4px; padding: 0; }
.settings legend { font-weight: 800; margin-bottom: 10px; padding: 0; }
.tool-side .settings {
  background: #f6fdfe; border: 1px solid #e2e7f2; border-radius: 16px;
  padding: 16px 18px;
}
.setting-row { margin: 14px 0; }
.setting-row label { font-weight: 700; display: flex; justify-content: space-between; gap: 12px; }
.setting-row output { font-weight: 800; color: #0e7490; }
.setting-row input[type="range"] { width: 100%; accent-color: #06b6d4; margin-top: 6px; }
.setting-row select, .setting-row input[type="number"] {
  width: 100%; padding: 9px 10px; border: 1px solid #e2e7f2; border-radius: 10px;
  font: inherit; font-size: 0.95rem; background: #ffffff; color: #141a2e;
}
.setting-row select:focus-visible, .setting-row input[type="number"]:focus-visible,
textarea:focus-visible { outline: 3px solid rgba(6, 182, 212, 0.4); outline-offset: 2px; }
.setting-note { font-size: 0.85rem; color: #4b5573; margin: 4px 0 0; }
.setting-label { font-weight: 700; display: block; margin-bottom: 8px; }
.model-note { font-size: 0.85rem; color: #4b5573; margin: 6px 0 0; }

/* textarea */
.paste-area {
  width: 100%; min-height: 220px; resize: vertical;
  border: 1.5px solid #c3ccd9; border-radius: 16px;
  padding: 14px 16px; font: 0.95rem/1.55 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: #141a2e; background: #fbfdff;
}
.paste-area:focus { border-color: #06b6d4; outline: none; }
.input-meta {
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  font-size: 0.85rem; color: #8a93ad; margin: 8px 2px 0;
}
.input-meta b { color: #4b5573; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 12px; cursor: pointer;
  font: inherit; font-weight: 700; font-size: 0.92rem; text-decoration: none;
  padding: 10px 18px; transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.btn-primary { background: #06b6d4; color: #fff; box-shadow: 0 6px 18px rgba(6, 182, 212, 0.35); }
.btn-primary:hover:not(:disabled) { background: #0891b2; transform: translateY(-1px); }
.btn-ghost { background: #ffffff; border-color: #e2e7f2; color: #141a2e; }
.btn-ghost:hover:not(:disabled) { background: #eef1f8; }
.btn-small { padding: 7px 13px; font-size: 0.85rem; border-radius: 10px; }
.btn:focus-visible { outline: 3px solid rgba(6, 182, 212, 0.4); outline-offset: 2px; }
.tool-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.empty-note { color: #8a93ad; font-size: 0.92rem; margin: 14px 0 0; }

/* ---------------- results ---------------- */
.results { margin-top: 20px; animation: card-in 0.35s ease both; }
.results[hidden] { display: none; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.usage-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.usage-head h3 { margin: 0; font-size: 1.05rem; }
.usage-pct { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; }
.usage-pct[data-status="ok"] { color: #0f9d58; }
.usage-pct[data-status="watch"] { color: #92400e; }
.usage-pct[data-status="warning"] { color: #b45309; }
.usage-pct[data-status="critical"], .usage-pct[data-status="over"] { color: #dc2626; }

/* stacked usage bar: message / system / history / reserve segments */
.usage-bar {
  display: flex; height: 26px; border-radius: 99px; overflow: hidden;
  background: #eef1f8; margin-top: 12px; border: 1px solid #e2e7f2;
}
.usage-bar .seg { height: 100%; min-width: 0; transition: width 0.4s ease; }
.seg-message { background: #06b6d4; }
.seg-system { background: #8b5cf6; }
.seg-history { background: #f59e0b; }
.seg-reserve { background: repeating-linear-gradient(45deg, #94a3b8, #94a3b8 6px, #cbd5e1 6px, #cbd5e1 12px); }
.usage-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; margin: 10px 0 0; padding: 0; font-size: 0.85rem; color: #4b5573; }
.usage-legend li { display: inline-flex; align-items: center; gap: 6px; }
.usage-legend .sw { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.sw-message { background: #06b6d4; }
.sw-system { background: #8b5cf6; }
.sw-history { background: #f59e0b; }
.sw-reserve { background: #94a3b8; }

.status-line {
  border-radius: 12px; padding: 10px 14px; margin: 14px 0 0; font-size: 0.93rem;
  background: #e5f6ec; color: #14532d;
}
.status-line[data-status="watch"] { background: #fef9c3; color: #713f12; }
.status-line[data-status="warning"] { background: #fef3e2; color: #b45309; }
.status-line[data-status="critical"], .status-line[data-status="over"] { background: #fdecec; color: #dc2626; }
.status-line strong { display: block; }

/* stat grid */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: 16px; }
.stat { background: #eef1f8; border: 1px solid #e2e7f2; border-radius: 12px; padding: 10px 12px; }
.stat .stat-label { font-size: 0.78rem; font-weight: 700; color: #8a93ad; text-transform: uppercase; letter-spacing: 0.04em; }
.stat .stat-value { font-size: 1.15rem; font-weight: 800; margin-top: 2px; overflow-wrap: anywhere; }
.stat .stat-sub { font-size: 0.8rem; color: #4b5573; }

/* model comparison table */
.compare { margin-top: 20px; }
.compare h3 { font-size: 1rem; margin: 0 0 8px; }
.compare table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.compare th, .compare td { text-align: left; padding: 7px 8px; border-bottom: 1px solid #e2e7f2; }
.compare th { color: #8a93ad; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.compare td.num { text-align: right; font-variant-numeric: tabular-nums; }
.compare th.num { text-align: right; }
.compare tr.current td { font-weight: 700; background: #e6f7fb; }
.compare .mini-bar { display: inline-block; width: 64px; height: 8px; border-radius: 99px; background: #eef1f8; vertical-align: middle; margin-right: 8px; overflow: hidden; }
.compare .mini-bar i { display: block; height: 100%; background: #06b6d4; border-radius: 99px; }
.compare .mini-bar i.hot { background: #dc2626; }
.compare .mini-bar i.warm { background: #b45309; }

/* privacy */
.privacy { padding: 8px 0 44px; }
.privacy-card {
  background: linear-gradient(135deg, #0b2b33, #0e7490);
  color: #e6f7fb; border-radius: 22px; padding: clamp(22px, 3vw, 36px);
  box-shadow: 0 18px 50px rgba(6, 182, 212, 0.16);
}
.privacy-card h2 { color: #fff; margin: 0 0 10px; font-size: 1.4rem; }
.privacy-card p { margin: 0 0 16px; }
.net-meter {
  display: inline-flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px; padding: 9px 16px; font-weight: 700; color: #fff;
}
.net-meter b { font-size: 1.15rem; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: #34d399; animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5); }
  50% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
}
.verify-steps { margin: 16px 0 0; padding-left: 20px; }
.verify-steps li { margin: 6px 0; }
kbd {
  background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px; padding: 1px 7px; font: inherit; font-size: 0.85em;
}
.tool-card kbd, .content kbd {
  background: #eef1f8; border-color: #e2e7f2; color: #141a2e;
}

/* content */
.content { padding: 20px 0 44px; }
.content h2 { font-size: 1.5rem; letter-spacing: -0.01em; margin: 0 0 12px; }
.content h3 { font-size: 1.08rem; margin: 26px 0 8px; }
.content p, .content li { color: #4b5573; }
.content ol, .content ul { padding-left: 22px; }
.content li { margin: 6px 0; }
.prose-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 14px; }
.prose-card { background: #ffffff; border: 1px solid #e2e7f2; border-radius: 16px; padding: 16px 18px; }
.prose-card h3 { margin: 0 0 6px; }
.prose-card p { margin: 0; font-size: 0.93rem; }

.faq details {
  background: #ffffff; border: 1px solid #e2e7f2; border-radius: 14px;
  padding: 14px 18px; margin: 10px 0;
}
.faq summary { font-weight: 700; cursor: pointer; }
.faq summary:focus-visible { outline: 3px solid rgba(6, 182, 212, 0.35); outline-offset: 2px; border-radius: 6px; }
.faq details p { margin: 10px 0 2px; }

/* footer */
.site-footer { border-top: 1px solid #e2e7f2; padding: 18px 0 26px; color: #8a93ad; font-size: 0.85rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; justify-content: space-between; }
.site-footer p { margin: 0; }
.site-footer .footer-note { color: #8a93ad; }
.site-footer a { color: #0e7490; }

/* responsive */
@media (max-width: 860px) {
  .tool-layout { grid-template-columns: 1fr; }
  .tool-side .settings { padding: 14px 16px; }
}
@media (max-width: 640px) {
  .nav { display: none; }
  .hero { padding: 20px 0 8px; }
  .tool-actions { display: grid; grid-template-columns: 1fr; }
  .tool-actions .btn { width: 100%; }
  .site-footer .wrap { flex-direction: column; gap: 2px; }
  .compare .mini-bar { display: none; }
  .usage-pct { font-size: 1.3rem; }
}

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