/* =========================================================
   AI Text Summarizer — Design tokens
   Palette: deep indigo/black base, violet→cyan gradient accent,
   amber highlight. Display: Space Grotesk. Body: Inter.
   Data/mono: JetBrains Mono.
   ========================================================= */
:root {
  --bg-deep: #0b0e1a;
  --bg-elevated: #121728;
  --bg-elevated-2: #171d33;
  --glass: rgba(255, 255, 255, 0.055);
  --glass-strong: rgba(255, 255, 255, 0.09);
  --glass-border: rgba(255, 255, 255, 0.12);

  --accent-violet: #7c5cff;
  --accent-cyan: #22d3ee;
  --accent-amber: #fbbf24;
  --accent-gradient: linear-gradient(135deg, var(--accent-violet), var(--accent-cyan));

  --text-primary: #edeff7;
  --text-muted: #9aa3c0;
  --text-dim: #6b7394;

  --success: #34d399;
  --danger: #fb7185;

  --font-display: "Space Grotesk", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "Consolas", monospace;

  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;

  --shadow-soft: 0 20px 60px -20px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 0 1px rgba(124, 92, 255, 0.25), 0 0 40px -8px rgba(124, 92, 255, 0.45);

  --transition-fast: 160ms ease;
  --transition-med: 320ms cubic-bezier(0.16, 1, 0.3, 1);

  --header-h: 72px;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg-deep: #f3f4fb;
  --bg-elevated: #ffffff;
  --bg-elevated-2: #f8f9fe;
  --glass: rgba(18, 23, 42, 0.035);
  --glass-strong: rgba(18, 23, 42, 0.06);
  --glass-border: rgba(18, 23, 42, 0.09);

  --text-primary: #131a2e;
  --text-muted: #4b5372;
  --text-dim: #7b849f;

  --shadow-soft: 0 20px 50px -24px rgba(20, 24, 50, 0.25);
  color-scheme: light;
}

/* =========================== Reset =========================== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: radial-gradient(ellipse 120% 80% at 50% -10%, rgba(124, 92, 255, 0.16), transparent 60%), var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition-med), color var(--transition-med);
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; margin: 0 0 0.5em; }
p { margin: 0 0 1em; color: var(--text-muted); }
a { color: inherit; }
img { max-width: 100%; display: block; }
button { font-family: inherit; }

.visually-hidden {
  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: 12px; top: -48px;
  background: var(--accent-violet); color: #fff; padding: 10px 16px;
  border-radius: var(--radius-sm); z-index: 1000; transition: top var(--transition-fast);
  text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 12px; }

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

/* =========================== Header =========================== */
.site-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  background: rgba(11, 14, 26, 0.72);
  border-bottom: 1px solid var(--glass-border);
}
[data-theme="light"] .site-header { background: rgba(255, 255, 255, 0.78); }

.header-inner {
  max-width: 1240px; margin: 0 auto; height: 100%;
  padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-text { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: var(--text-primary); }
.logo-accent {
  background: var(--accent-gradient); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.main-nav { display: flex; gap: 28px; }
.main-nav a {
  text-decoration: none; color: var(--text-muted); font-size: 0.92rem; font-weight: 500;
  transition: color var(--transition-fast);
}
.main-nav a:hover { color: var(--text-primary); }

.theme-toggle {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--glass-border); background: var(--glass);
  color: var(--text-primary); display: grid; place-items: center; cursor: pointer;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}
.theme-toggle:hover { border-color: var(--accent-violet); transform: translateY(-1px); }
.theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }

/* =========================== Breadcrumb =========================== */
.breadcrumb-bar { max-width: 1240px; margin: 0 auto; padding: 20px 24px 0; }
.breadcrumb { list-style: none; display: flex; gap: 8px; padding: 0; margin: 0; font-size: 0.82rem; color: var(--text-dim); }
.breadcrumb li:not(:last-child)::after { content: "/"; margin-left: 8px; color: var(--text-dim); }
.breadcrumb a { text-decoration: none; color: var(--text-dim); }
.breadcrumb a:hover { color: var(--accent-cyan); }
.breadcrumb li[aria-current="page"] { color: var(--text-muted); }

/* =========================== Hero =========================== */
.hero { max-width: 1240px; margin: 0 auto; padding: 40px 24px 80px; }
.hero-intro { text-align: center; max-width: 640px; margin: 0 auto 44px; }
.eyebrow {
  display: inline-block; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent-cyan); border: 1px solid rgba(34, 211, 238, 0.35); padding: 6px 14px; border-radius: 999px;
  margin-bottom: 18px; background: rgba(34, 211, 238, 0.06);
}
.hero h1 { font-size: clamp(2.2rem, 4.4vw, 3.4rem); margin-bottom: 0.4em; letter-spacing: -0.02em; }
.hero-sub { font-size: 1.08rem; color: var(--text-muted); }

/* ---- Tool shell layout ---- */
.tool-shell {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 20px;
  align-items: stretch;
}

.glass-panel {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow: var(--shadow-soft);
  padding: 22px;
  display: flex;
  flex-direction: column;
}

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 12px; flex-wrap: wrap;
}
.panel-title { font-family: var(--font-display); font-weight: 600; font-size: 0.98rem; color: var(--text-primary); }

.ghost-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--glass-strong); color: var(--text-muted);
  border: 1px solid var(--glass-border); border-radius: var(--radius-sm);
  padding: 7px 12px; font-size: 0.82rem; font-weight: 500; cursor: pointer;
  transition: all var(--transition-fast);
}
.ghost-btn:hover:not(:disabled) { color: var(--text-primary); border-color: var(--accent-violet); transform: translateY(-1px); }
.ghost-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.text-area {
  width: 100%; min-height: 220px; resize: vertical;
  background: rgba(0, 0, 0, 0.18); color: var(--text-primary);
  border: 1px solid var(--glass-border); border-radius: var(--radius-md);
  padding: 16px; font-family: var(--font-body); font-size: 0.98rem; line-height: 1.65;
  transition: border-color var(--transition-fast);
}
[data-theme="light"] .text-area { background: rgba(18, 23, 42, 0.03); }
.text-area:focus { border-color: var(--accent-violet); outline: none; }
.text-area::placeholder { color: var(--text-dim); }

.field-error {
  color: var(--danger); font-size: 0.85rem; margin: 8px 0 0; min-height: 1.2em;
}

.live-stats {
  display: flex; flex-wrap: wrap; gap: 14px;
  margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--glass-border);
  font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-dim);
}
.live-stats strong { color: var(--text-primary); font-weight: 600; }

.controls { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.control-label { display: block; font-size: 0.78rem; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }

.segmented { display: flex; background: var(--glass-strong); border: 1px solid var(--glass-border); border-radius: 999px; padding: 4px; gap: 2px; }
.seg-btn {
  flex: 1; border: none; background: transparent; color: var(--text-muted);
  padding: 8px 10px; border-radius: 999px; font-size: 0.82rem; font-weight: 500; cursor: pointer;
  transition: all var(--transition-fast); white-space: nowrap;
}
.seg-btn.is-active { background: var(--accent-gradient); color: #fff; box-shadow: 0 4px 14px -4px rgba(124, 92, 255, 0.6); }
.seg-btn:hover:not(.is-active) { color: var(--text-primary); }

.primary-btn {
  position: relative; margin-top: 20px; width: 100%;
  background: var(--accent-gradient); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 15px 20px;
  font-size: 1rem; font-weight: 600; font-family: var(--font-display);
  cursor: pointer; box-shadow: 0 12px 30px -10px rgba(124, 92, 255, 0.55);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.primary-btn:hover { transform: translateY(-2px); box-shadow: 0 16px 36px -8px rgba(124, 92, 255, 0.65); }
.primary-btn:active { transform: translateY(0); }
.primary-btn:disabled { opacity: 0.7; cursor: progress; transform: none; }

.btn-spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff;
  display: none; animation: spin 0.7s linear infinite;
}
.primary-btn.is-loading .btn-spinner { display: inline-block; }
.primary-btn.is-loading .btn-label { opacity: 0.85; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Compression meter (signature element) ---- */
.meter-column { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 0 4px; }
.meter-wrap { position: relative; width: 120px; height: 120px; }
.meter-ring { transform: rotate(-90deg); }
.meter-track { fill: none; stroke: var(--glass-border); stroke-width: 8; }
.meter-progress {
  fill: none; stroke: url(#meterGrad); stroke-width: 8; stroke-linecap: round;
  stroke-dasharray: 326.7; stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 900ms cubic-bezier(0.16, 1, 0.3, 1);
}
.meter-readout {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
#meter-value { font-family: var(--font-mono); font-size: 1.3rem; font-weight: 700; color: var(--text-primary); }
.meter-caption { font-size: 0.68rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }

.meter-flow { display: flex; flex-direction: column; gap: 10px; }
.flow-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent-cyan);
  opacity: 0.35; animation: pulse 1.8s ease-in-out infinite;
}
.flow-dot:nth-child(2) { animation-delay: 0.3s; }
.flow-dot:nth-child(3) { animation-delay: 0.6s; }
@keyframes pulse { 0%, 100% { opacity: 0.25; transform: scale(1); } 50% { opacity: 0.9; transform: scale(1.3); } }

@media (prefers-reduced-motion: reduce) {
  .meter-progress { transition: none; }
  .flow-dot { animation: none; }
  html { scroll-behavior: auto; }
}

.output-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.output-content {
  min-height: 220px; background: rgba(0,0,0,0.18); border: 1px solid var(--glass-border); border-radius: var(--radius-md);
  padding: 18px; font-size: 0.98rem; line-height: 1.7; color: var(--text-primary); overflow-y: auto;
}
[data-theme="light"] .output-content { background: rgba(18,23,42,0.03); }
.output-placeholder { color: var(--text-dim); margin: 0; }
.output-content ul { margin: 0; padding-left: 1.2em; }
.output-content li { margin-bottom: 0.6em; }
.output-content p { color: var(--text-primary); }

.output-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
.stat-card {
  background: var(--glass-strong); border: 1px solid var(--glass-border); border-radius: var(--radius-sm);
  padding: 12px 8px; text-align: center;
}
.stat-value { display: block; font-family: var(--font-mono); font-weight: 700; font-size: 1.1rem; background: var(--accent-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-label { display: block; font-size: 0.68rem; color: var(--text-dim); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.04em; }

/* =========================== Article =========================== */
.content-article { max-width: 1240px; margin: 0 auto; padding: 20px 24px 100px; }
.article-grid { display: grid; grid-template-columns: 240px 1fr; gap: 56px; }

.toc-sticky {
  position: sticky; top: calc(var(--header-h) + 24px);
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--radius-md);
  padding: 18px; backdrop-filter: blur(16px);
}
.toc-sticky h2 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin-bottom: 10px; }
.toc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.toc-list a { text-decoration: none; color: var(--text-muted); font-size: 0.86rem; transition: color var(--transition-fast); }
.toc-list a:hover { color: var(--accent-cyan); }

.article-body { max-width: 760px; }
.article-body h2 { font-size: 1.5rem; margin-top: 2.2em; padding-top: 0.2em; scroll-margin-top: calc(var(--header-h) + 20px); }
.article-body h2:first-of-type,
.article-body section:first-child h2 { margin-top: 0; }
.article-body h3 { font-size: 1.12rem; margin-top: 1.5em; color: var(--text-primary); scroll-margin-top: calc(var(--header-h) + 20px); }
.article-body p, .article-body li { color: var(--text-muted); }

.styled-list { padding-left: 1.3em; margin: 0 0 1em; }
.styled-list li { margin-bottom: 0.55em; }
.styled-list.checklist { list-style: none; padding-left: 0; }
.styled-list.checklist li { padding-left: 1.8em; position: relative; }
.styled-list.checklist li::before {
  content: ""; position: absolute; left: 0; top: 0.15em; width: 18px; height: 18px; border-radius: 5px;
  border: 1.5px solid var(--accent-violet); background: rgba(124, 92, 255, 0.08);
}
.styled-list.checklist li::after {
  content: ""; position: absolute; left: 5px; top: 0.5em; width: 8px; height: 4px;
  border-left: 2px solid var(--accent-cyan); border-bottom: 2px solid var(--accent-cyan); transform: rotate(-45deg);
}

.table-wrap { overflow-x: auto; margin-bottom: 1em; border-radius: var(--radius-md); border: 1px solid var(--glass-border); }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--glass-border); }
th { background: var(--glass-strong); color: var(--text-primary); font-family: var(--font-display); font-weight: 600; }
tr:last-child td { border-bottom: none; }
td { color: var(--text-muted); }

.example-card {
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--radius-md);
  padding: 16px 20px; margin-bottom: 16px;
}
.example-card h3 { margin-top: 0; font-size: 0.95rem; color: var(--accent-cyan); }

.faq-item { margin-bottom: 1.4em; }
.faq-item h3 { margin-bottom: 0.35em; }

/* =========================== Footer =========================== */
.site-footer { border-top: 1px solid var(--glass-border); padding: 48px 24px 24px; }
.footer-inner { max-width: 1240px; margin: 0 auto; display: flex; justify-content: space-between; gap: 40px; flex-wrap: wrap; }
.footer-brand p { max-width: 320px; margin-top: 10px; font-size: 0.88rem; }
.footer-links h2 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin-bottom: 12px; }
.footer-links { display: flex; flex-direction: column; }
.footer-links a { text-decoration: none; color: var(--text-muted); font-size: 0.9rem; margin-bottom: 8px; transition: color var(--transition-fast); }
.footer-links a:hover { color: var(--accent-cyan); }
.footer-bottom { max-width: 1240px; margin: 32px auto 0; font-size: 0.8rem; color: var(--text-dim); }

/* =========================== Responsive =========================== */
@media (max-width: 1080px) {
  .tool-shell { grid-template-columns: 1fr; }
  .meter-column { flex-direction: row; padding: 8px 0; }
  .meter-flow { flex-direction: row; }
  .article-grid { grid-template-columns: 1fr; }
  .toc-rail { display: none; }
}

@media (max-width: 640px) {
  .header-inner { padding: 0 16px; }
  .main-nav { display: none; }
  .hero { padding: 28px 16px 56px; }
  .glass-panel { padding: 16px; }
  .controls { gap: 12px; }
  .output-stats { grid-template-columns: repeat(2, 1fr); }
  .content-article { padding: 8px 16px 72px; }
  .breadcrumb-bar { padding: 16px 16px 0; }
}

/* =========================== Print =========================== */
@media print {
  .site-header, .breadcrumb-bar, .hero-intro, .input-panel, .meter-column,
  .output-actions, .output-stats, .content-article, .site-footer, .skip-link { display: none !important; }
  .output-panel { border: none; box-shadow: none; padding: 0; }
  .output-content { border: none; background: none; color: #000; }
  body { background: #fff; color: #000; }
}
