/* ==========================================================================
   Comparative Character Analysis — design system
   Dark, glassy, data-dashboard aesthetic. Vanilla CSS only.
   ========================================================================== */

:root {
  /* Palette */
  --bg-0: #070b18;
  --bg-1: #0b1020;
  --surface: rgba(17, 24, 45, 0.62);
  --surface-2: rgba(30, 41, 72, 0.55);
  --surface-solid: #111a31;
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #e6ebf5;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --blue: #3b82f6;
  --blue-soft: #60a5fa;
  --indigo: #6366f1;
  --violet: #8b5cf6;
  --emerald: #10b981;
  --emerald-soft: #34d399;
  --teal: #14b8a6;
  --amber: #f59e0b;
  --rose: #f43f5e;

  --slot-1: var(--blue-soft);
  --slot-2: var(--emerald-soft);

  --grad-brand: linear-gradient(120deg, #60a5fa 0%, #818cf8 38%, #2dd4bf 72%, #34d399 100%);
  --grad-primary: linear-gradient(135deg, #3b82f6 0%, #6366f1 55%, #8b5cf6 100%);

  /* Type */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Outfit", "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Shape & motion */
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.55), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, 0.7);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(59, 130, 246, 0.16), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(16, 185, 129, 0.12), transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* Floating blurred orbs */
.bg-orbs { position: fixed; inset: 0; pointer-events: none; z-index: -1; overflow: hidden; }
.bg-orbs span {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.28;
  animation: float 22s ease-in-out infinite;
}
.bg-orbs span:nth-child(1) { width: 420px; height: 420px; background: #3b82f6; top: 12%; left: -120px; }
.bg-orbs span:nth-child(2) { width: 360px; height: 360px; background: #8b5cf6; top: 48%; right: -120px; animation-delay: -7s; }
.bg-orbs span:nth-child(3) { width: 320px; height: 320px; background: #10b981; bottom: -120px; left: 35%; animation-delay: -14s; }
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(40px, -30px) scale(1.08); }
  66% { transform: translate(-30px, 25px) scale(0.95); }
}

.container { width: min(1280px, 100% - 40px); margin-inline: auto; }

h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.01em; margin: 0; }
p { margin: 0; }
code { font-family: var(--font-mono); }
.muted { color: var(--text-muted); font-weight: 400; }

::selection { background: rgba(99, 102, 241, 0.45); }

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

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  background: rgba(7, 11, 24, 0.66);
  border-bottom: 1px solid var(--border);
}
.topbar__inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-family: var(--font-display); font-size: 1.2rem; }
.brand__text strong { background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand__logo { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); }

.lang-switch { display: inline-flex; align-items: center; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.lang-switch__label { font-size: 0.78rem; color: var(--text-muted); padding: 0 10px 0 12px; font-weight: 600; }
.lang-switch__btn {
  font: 600 0.86rem var(--font-sans);
  color: var(--text-muted);
  background: transparent;
  border: 0;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s, background 0.25s var(--ease), transform 0.2s;
}
.lang-switch__btn:hover { color: var(--text); background: rgba(148, 163, 184, 0.1); }
.lang-switch__btn.is-active { color: #fff; background: var(--grad-primary); box-shadow: 0 6px 18px -6px rgba(99, 102, 241, 0.7); }

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */
.hero { text-align: center; padding: 56px 0 34px; }
.hero__eyebrow {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.hero__title { font-size: clamp(2rem, 4.6vw, 3.4rem); font-weight: 800; line-height: 1.1; margin: 18px auto 14px; max-width: 18ch; }
.gradient-text {
  background: var(--grad-brand);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 8s linear infinite;
}
@keyframes shimmer { to { background-position: 200% center; } }
.hero__subtitle { color: var(--text-muted); font-size: 1.05rem; display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }
.pill { font: 600 0.82rem var(--font-mono); color: var(--text); background: var(--surface-2); border: 1px solid var(--border-strong); padding: 4px 12px; border-radius: 999px; white-space: pre; }

/* --------------------------------------------------------------------------
   Cards & layout
   -------------------------------------------------------------------------- */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.card[data-slot]::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: linear-gradient(90deg, transparent, var(--slot-color), transparent);
  opacity: 0.85;
}
[data-slot="1"] { --slot-color: var(--slot-1); }
[data-slot="2"] { --slot-color: var(--slot-2); }

.card__title { font-size: 1.15rem; font-weight: 700; margin-bottom: 14px; }
.section { margin-top: 36px; }
.section__head { margin-bottom: 14px; }
.section__title { font-size: 1.35rem; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.section__sub { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }

/* Reveal on scroll */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
.reveal.is-visible { opacity: 1; transform: none; }

/* --------------------------------------------------------------------------
   Inputs
   -------------------------------------------------------------------------- */
.inputs { margin-top: 6px; }
.input-card { display: flex; flex-direction: column; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

.select {
  appearance: none;
  font: 500 0.95rem var(--font-sans);
  color: var(--text);
  background: var(--surface-solid) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 14px center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 40px 10px 14px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.select:hover, .select:focus { border-color: var(--slot-color, var(--blue-soft)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--slot-color, #60a5fa) 22%, transparent); outline: none; }

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 150px;
  padding: 20px;
  text-align: center;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(148, 163, 184, 0.04), rgba(148, 163, 184, 0.01));
  cursor: pointer;
  transition: border-color 0.25s, background 0.25s, transform 0.25s var(--ease);
}
.dropzone:hover, .dropzone.is-drag {
  border-color: var(--slot-color);
  background: color-mix(in srgb, var(--slot-color) 8%, transparent);
}
.dropzone.is-drag { transform: scale(1.01); }
.dropzone__icon { color: var(--slot-color); transition: transform 0.3s var(--ease); }
.dropzone:hover .dropzone__icon { transform: translateY(-3px); }
.dropzone__hint { font-weight: 500; }
.dropzone__hint u { color: var(--slot-color); text-underline-offset: 3px; }
.dropzone__types { font: 500 0.78rem var(--font-mono); color: var(--text-dim); }
.dropzone__status { font-size: 0.82rem; color: var(--slot-color); min-height: 1em; }
.dropzone.is-loading { pointer-events: none; }
.dropzone.is-loading .dropzone__icon { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; transform: translateY(-3px); } }

.file-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 8px 8px 12px;
  max-width: 100%;
  border-radius: 999px;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  font-size: 0.86rem;
  cursor: default;
  animation: pop 0.35s var(--ease);
}
.file-chip[hidden] { display: none; }
.file-chip__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip__meta { color: var(--text-dim); font: 500 0.75rem var(--font-mono); white-space: nowrap; }
.file-chip__clear {
  border: 0; width: 24px; height: 24px; border-radius: 50%;
  color: var(--text-muted); background: rgba(148, 163, 184, 0.12);
  cursor: pointer; font-size: 1rem; line-height: 1;
  transition: background 0.2s, color 0.2s;
}
.file-chip__clear:hover { background: rgba(244, 63, 94, 0.2); color: #fda4af; }
@keyframes pop { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: none; } }

.preview {
  font: 0.82rem/1.5 var(--font-mono);
  color: #cbd5e1;
  background: rgba(2, 6, 23, 0.55);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  resize: vertical;
  min-height: 110px;
}
.preview:focus { outline: none; border-color: var(--slot-color); }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  --btn-bg: var(--surface-2);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font: 600 0.95rem var(--font-sans);
  color: var(--text);
  background: var(--btn-bg);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 10px 18px;
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.25s, background 0.25s, border-color 0.2s, opacity 0.2s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); border-color: rgba(148, 163, 184, 0.45); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn--lg { padding: 14px 24px; font-size: 1rem; border-radius: 14px; }
.btn--sm { padding: 7px 12px; font-size: 0.85rem; }
.btn--xs { padding: 5px 10px; font-size: 0.8rem; border-radius: 8px; }
.btn--primary {
  color: #fff;
  border-color: transparent;
  background: var(--grad-primary);
  background-size: 160% 160%;
  box-shadow: 0 12px 30px -12px rgba(99, 102, 241, 0.8);
}
.btn--primary:hover:not(:disabled) { background-position: 100% 50%; box-shadow: 0 18px 38px -12px rgba(99, 102, 241, 0.95); }
.btn--secondary { background: rgba(16, 185, 129, 0.12); border-color: rgba(52, 211, 153, 0.35); color: #a7f3d0; }
.btn--secondary:hover:not(:disabled) { background: rgba(16, 185, 129, 0.2); }
.btn--ghost { background: transparent; }
.btn--ghost:hover:not(:disabled) { background: rgba(148, 163, 184, 0.1); }
.btn--danger:hover:not(:disabled) { color: #fda4af; border-color: rgba(244, 63, 94, 0.45); background: rgba(244, 63, 94, 0.1); }
.btn--glow::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: var(--grad-brand);
  filter: blur(14px);
  opacity: 0.35;
  z-index: -1;
  transition: opacity 0.3s;
}
.btn--glow:hover::after { opacity: 0.6; }

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

/* --------------------------------------------------------------------------
   Actions bar & toggle
   -------------------------------------------------------------------------- */
.actions { margin-top: 20px; display: flex; flex-direction: column; gap: 18px; }
.actions__buttons { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }

.toggle { display: inline-flex; align-items: flex-start; gap: 14px; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle__track {
  flex: none;
  position: relative;
  width: 46px;
  height: 26px;
  margin-top: 2px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.25);
  border: 1px solid var(--border-strong);
  transition: background 0.3s var(--ease);
}
.toggle__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: transform 0.3s var(--ease);
}
.toggle input:checked + .toggle__track { background: var(--grad-primary); border-color: transparent; }
.toggle input:checked + .toggle__track .toggle__thumb { transform: translateX(20px); }
.toggle input:focus-visible + .toggle__track { outline: 2px solid var(--blue-soft); outline-offset: 2px; }
.toggle__text { display: flex; flex-direction: column; gap: 2px; }
.toggle__text small { color: var(--text-muted); font-size: 0.84rem; }

/* --------------------------------------------------------------------------
   Summaries
   -------------------------------------------------------------------------- */
.summaries { margin-top: 36px; }
.summary { display: flex; flex-direction: column; gap: 18px; min-height: 200px; }
.summary__head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.summary__flag {
  font-size: 1.8rem;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: color-mix(in srgb, var(--slot-color) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--slot-color) 35%, transparent);
}
.summary__eyebrow { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600; }
.summary__title { font-size: 1.25rem; }
.summary__head .badge { margin-left: auto; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 600; padding: 5px 11px; border-radius: 999px; white-space: nowrap; }
.badge--ok { color: #6ee7b7; background: rgba(16, 185, 129, 0.12); border: 1px solid rgba(52, 211, 153, 0.35); }
.badge--warn { color: #fcd34d; background: rgba(245, 158, 11, 0.12); border: 1px solid rgba(251, 191, 36, 0.35); }

.stat-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 12px; }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: var(--radius); background: rgba(2, 6, 23, 0.35); border: 1px solid var(--border); }
.stat__label { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; }
.stat__value { font: 700 1.9rem/1.1 var(--font-display); color: var(--slot-color); font-variant-numeric: tabular-nums; }
.stat__value--sm { font-size: 1.35rem; color: var(--text); }

.summary__block { display: flex; flex-direction: column; gap: 10px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.progress { height: 8px; border-radius: 999px; background: rgba(148, 163, 184, 0.14); overflow: hidden; }
.progress span { display: block; height: 100%; width: var(--w); background: linear-gradient(90deg, var(--slot-color), color-mix(in srgb, var(--slot-color) 50%, #fff)); border-radius: inherit; animation: grow 1s var(--ease); }
@keyframes grow { from { width: 0; } }
.missing { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.88rem; }
.letter-chip { font: 600 0.82rem var(--font-mono); padding: 2px 9px; border-radius: 7px; }
.letter-chip--missing { color: #fda4af; background: rgba(244, 63, 94, 0.12); border: 1px solid rgba(244, 63, 94, 0.3); }

.split { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: rgba(148, 163, 184, 0.12); }
.split span { width: var(--w); animation: grow 1s var(--ease); }
.split__v { background: var(--indigo); }
.split__c { background: var(--teal); }
.split-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 0.88rem; color: var(--text-muted); }
.split-legend strong { color: var(--text); font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }
.dot--v { background: var(--indigo); }
.dot--c { background: var(--teal); }
.ratio code { font-size: 0.95rem; font-weight: 600; padding: 4px 10px; border-radius: 8px; background: rgba(99, 102, 241, 0.14); color: #c7d2fe; border: 1px solid rgba(129, 140, 248, 0.3); }

#results.is-empty .summary:empty { display: none; }

/* --------------------------------------------------------------------------
   Data tables
   -------------------------------------------------------------------------- */
.table-card { padding: 18px; }
.table-card__title { font-size: 1.02rem; margin-bottom: 12px; }
.table-wrap { overflow: auto; max-height: 640px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: #121a30;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.data-table th[data-key] { cursor: pointer; transition: color 0.2s; }
.data-table th[data-key]:hover { color: var(--text); }
.data-table td { padding: 8px 12px; border-bottom: 1px solid rgba(148, 163, 184, 0.07); }
.data-table tbody tr { transition: background 0.15s; }
.data-table tbody tr:nth-child(even) { background: rgba(148, 163, 184, 0.03); }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--slot-color, #60a5fa) 9%, transparent); }
.data-table tr.is-zero { opacity: 0.5; }
.num { text-align: right; }
.cell-char { font: 700 1rem var(--font-mono); color: var(--slot-color); width: 56px; text-align: center; }
.cell-prob { position: relative; min-width: 180px; }
.prob-bar { position: absolute; left: 8px; top: 50%; height: 22px; transform: translateY(-50%); width: calc((100% - 16px) * var(--w) / 100); border-radius: 5px; background: color-mix(in srgb, var(--slot-color) 18%, transparent); }
.prob-txt { position: relative; font-family: var(--font-mono); font-size: 0.8rem; }
.rank { display: inline-grid; place-items: center; min-width: 28px; height: 24px; padding: 0 6px; border-radius: 7px; font-weight: 600; font-size: 0.82rem; }
.rank--top { color: #0b1020; }
.rank--1 { background: linear-gradient(135deg, #fde68a, #f59e0b); }
.rank--2 { background: linear-gradient(135deg, #e2e8f0, #94a3b8); }
.rank--3 { background: linear-gradient(135deg, #fed7aa, #ea580c); }

/* --------------------------------------------------------------------------
   Charts
   -------------------------------------------------------------------------- */
.chart-card { margin-bottom: 20px; }
.chart-card__title { font-size: 1rem; color: var(--text-muted); font-weight: 600; margin-bottom: 14px; font-family: var(--font-sans); }
.chart-box { position: relative; padding: 10px; border-radius: var(--radius); background: rgba(2, 6, 23, 0.35); border: 1px solid var(--border); }
.chart-box--zipf { height: 400px; }
.vowel-grid { display: grid; grid-template-columns: 2.5fr 1fr 1fr; gap: 16px; }
.chart-box--bar, .chart-box--donut { height: 330px; }

/* --------------------------------------------------------------------------
   Export & archive
   -------------------------------------------------------------------------- */
.export-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px 24px;
  align-items: center;
  overflow: hidden;
  background:
    radial-gradient(600px 200px at 0% 0%, rgba(99, 102, 241, 0.16), transparent 70%),
    radial-gradient(500px 200px at 100% 100%, rgba(16, 185, 129, 0.12), transparent 70%),
    var(--surface);
}
.recent { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 8px; padding-top: 16px; border-top: 1px solid var(--border); }
.recent__file { min-height: 40px; display: flex; align-items: center; }
.recent-link {
  display: inline-flex; align-items: center; gap: 12px;
  font: 500 0.92rem var(--font-sans); color: var(--text);
  background: var(--surface-solid); border: 1px solid var(--border-strong);
  padding: 8px 16px 8px 8px; border-radius: 12px; cursor: pointer;
  transition: border-color 0.2s, transform 0.2s var(--ease);
  animation: pop 0.4s var(--ease);
  max-width: 100%;
}
.recent-link span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-link:hover { border-color: var(--blue-soft); transform: translateY(-2px); }
.pdf-icon { flex: none; display: inline-grid; place-items: center; font: 700 0.65rem var(--font-mono); color: #fff; background: linear-gradient(135deg, #f43f5e, #be123c); border-radius: 6px; padding: 5px 6px; margin-right: 10px; }
.recent-link .pdf-icon { margin-right: 0; }

.archive-card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.archive-card__actions { display: flex; gap: 8px; }
.count-badge:not(:empty) { font: 600 0.78rem var(--font-mono); padding: 2px 9px; border-radius: 999px; background: rgba(99, 102, 241, 0.18); color: #c7d2fe; }
.archive-table td { vertical-align: middle; }
.archive-table .file-cell { font-family: var(--font-mono); font-size: 0.82rem; word-break: break-all; }
.archive-table .actions { white-space: nowrap; text-align: right; display: flex; gap: 6px; justify-content: flex-end; }
.archive-table .empty { text-align: center; color: var(--text-dim); padding: 28px; }

/* --------------------------------------------------------------------------
   Footer & toasts
   -------------------------------------------------------------------------- */
.footer { margin-top: 64px; padding: 26px 0; border-top: 1px solid var(--border); color: var(--text-dim); font-size: 0.86rem; }
.footer__inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 40px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 12px 12px 14px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--toast-c, var(--blue-soft));
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  font-size: 0.9rem;
  animation: toastIn 0.4s var(--ease);
}
.toast--success { --toast-c: var(--emerald-soft); }
.toast--warning { --toast-c: var(--amber); }
.toast--error { --toast-c: var(--rose); }
.toast__msg { flex: 1; }
.toast__close { border: 0; background: none; color: var(--text-muted); font-size: 1.2rem; line-height: 1; cursor: pointer; padding: 0 4px; }
.toast--out { animation: toastOut 0.3s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 960px) {
  .grid-2 { grid-template-columns: 1fr; }
  .vowel-grid { grid-template-columns: 1fr 1fr; }
  .chart-box--bar { grid-column: 1 / -1; }
  .export-card { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .container { width: calc(100% - 24px); }
  .topbar__inner { justify-content: center; }
  .lang-switch__label { display: none; }
  .lang-switch__btn { padding: 6px 10px; font-size: 0.8rem; }
  .hero { padding: 36px 0 24px; }
  .actions__buttons { grid-template-columns: 1fr; }
  .btn--lg { white-space: normal; }
  .stat-grid { grid-template-columns: 1fr; }
  .vowel-grid { grid-template-columns: 1fr; }
  .chart-box--zipf { height: 340px; }
  .card { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   Print (A4) — mirrors the Gradio CUSTOM_CSS print rules
   -------------------------------------------------------------------------- */
@media print {
  @page { size: A4 portrait; margin: 12mm; }
  body { background: #fff !important; color: #000 !important; }
  .bg-orbs, .topbar, .inputs, .actions, .export-card, .archive-card, .toasts, .footer, button { display: none !important; }
  .card { background: #fff !important; border-color: #cbd5e1 !important; box-shadow: none !important; backdrop-filter: none !important; }
  .reveal { opacity: 1 !important; transform: none !important; }
  .hero__title .gradient-text { color: #1e3a8a !important; -webkit-text-fill-color: #1e3a8a; }
  .data-table th { background: #e2e8f0 !important; color: #000 !important; }
  .table-wrap { max-height: none; overflow: visible; }
}
