/* ───────────────────────────────────────────────────────────
   YT Downloader — Glassmorphism dark UI
   ─────────────────────────────────────────────────────────── */

:root {
  --bg-0: #0a0a0f;
  --bg-1: #11111a;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.06);
  --surface-3: rgba(255, 255, 255, 0.10);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  --text-1: #f4f4f5;
  --text-2: #a1a1aa;
  --text-3: #71717a;

  --brand: #ff1744;
  --brand-2: #ff4569;
  --brand-soft: rgba(255, 23, 68, 0.16);
  --brand-glow: rgba(255, 23, 68, 0.55);

  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #60a5fa;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-brand: 0 12px 40px rgba(255, 23, 68, 0.35);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --t-quick: 150ms;
  --t-base: 220ms;
  --t-slow: 360ms;
}

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

/* Ensure `hidden` attr wins over display:flex / display:grid / etc. */
[hidden] { display: none !important; }

html {
  background: var(--bg-0);
  color-scheme: dark;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(1100px 600px at 75% -10%, rgba(255, 23, 68, 0.10), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(120, 60, 255, 0.08), transparent 60%),
    var(--bg-0);
  color: var(--text-1);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  padding: 20px;
  padding-bottom: 48px;
}

/* Background decoration */
.bg-grid {
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at 50% 30%, black, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
  opacity: .5;
}
.bg-glow-1 {
  width: 480px; height: 480px;
  background: var(--brand-glow);
  top: -200px; right: -120px;
  animation: glow1 14s ease-in-out infinite alternate;
}
.bg-glow-2 {
  width: 380px; height: 380px;
  background: rgba(120, 60, 255, .35);
  bottom: -160px; left: -100px;
  animation: glow2 18s ease-in-out infinite alternate;
}

@keyframes glow1 { to { transform: translate(-40px, 30px) scale(1.1); } }
@keyframes glow2 { to { transform: translate(40px, -30px) scale(1.15); } }

/* ───────── Topbar ───────── */
.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1180px;
  margin: 0 auto 28px;
  padding: 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand) 0%, #d50000 100%);
  display: grid;
  place-items: center;
  color: white;
  box-shadow: 0 6px 20px rgba(255, 23, 68, 0.4);
}
.brand-mark svg { width: 20px; height: 20px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11.5px; color: var(--text-3); font-family: 'JetBrains Mono', monospace; }

.ghost-btn {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 9px 14px;
  border-radius: 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all var(--t-quick) var(--ease);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.ghost-btn:hover { background: var(--surface-2); color: var(--text-1); border-color: var(--border-strong); }
.ghost-btn:active { transform: scale(0.97); }
.ghost-btn svg { width: 14px; height: 14px; }
.ghost-btn.small { padding: 6px 10px; font-size: 12px; }
.ghost-btn.icon-only { padding: 7px; }
.ghost-btn.icon-only svg { width: 14px; height: 14px; }

.badge {
  background: var(--brand);
  color: white;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}

/* ───────── Layout ───────── */
.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  max-width: 1180px;
  margin: 0 auto;
  align-items: start;
}

.main-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.history-col { display: flex; flex-direction: column; gap: 18px; }

/* ───────── Glass card base ───────── */
.glass {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(28px) saturate(140%);
  -webkit-backdrop-filter: blur(28px) saturate(140%);
  box-shadow: var(--shadow);
}

.card { padding: 24px; animation: fade-in 320ms var(--ease); }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ───────── Hero ───────── */
.hero-head { margin-bottom: 22px; }
.hero-head h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  background: linear-gradient(135deg, #fff 0%, #a1a1aa 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-head p { color: var(--text-2); font-size: 13.5px; }

/* ───────── Form fields ───────── */
.field { display: flex; flex-direction: column; gap: 8px; }
.field + .field, .field + .row, .row + .field, .row + .row { margin-top: 14px; }

.flex-1 { flex: 1; min-width: 0; }
.row { display: flex; gap: 12px; align-items: flex-end; }

label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 14px;
  display: grid; place-items: center;
  color: var(--text-3);
  pointer-events: none;
}
.input-icon svg { width: 16px; height: 16px; }

input[type="url"],
input[type="text"] {
  width: 100%;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 42px 13px 42px;
  color: var(--text-1);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color var(--t-quick) var(--ease), box-shadow var(--t-quick) var(--ease), background var(--t-quick);
}
input[type="url"]::placeholder { color: var(--text-3); }
input[type="url"]:hover { border-color: var(--border-strong); background: rgba(0,0,0,0.4); }
input[type="url"]:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
  background: rgba(0,0,0,0.4);
}

.clear-btn {
  position: absolute;
  right: 10px;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 0;
  background: var(--surface-3);
  color: var(--text-2);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 11px;
  transition: all var(--t-quick) var(--ease);
}
.clear-btn:hover { background: var(--brand); color: white; }

/* Field hint with thumbnail */
.field-hint {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: fade-in 260ms var(--ease);
}
.field-hint img {
  width: 64px; height: 36px;
  border-radius: 6px;
  object-fit: cover;
  background: #000;
}
.info-meta { min-width: 0; flex: 1; }
.info-title {
  font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.info-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

/* Segment toggle */
.segment {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.seg-btn {
  flex: 1;
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--text-2);
  padding: 9px 12px;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: all var(--t-base) var(--ease);
}
.seg-btn:hover { color: var(--text-1); }
.seg-btn svg { width: 15px; height: 15px; }

.seg-btn.active {
  background: linear-gradient(135deg, var(--brand) 0%, #d50000 100%);
  color: white;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(255, 23, 68, 0.32);
}

/* Quality pills (segmented control) */
.label-row {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 8px;
}
.quality-hint {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--brand-2);
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
}

.quality-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 8px;
}

.quality-pill {
  position: relative;
  appearance: none;
  background: rgba(0,0,0,0.3);
  border: 1.5px solid var(--border);
  color: var(--text-2);
  padding: 10px 6px;
  border-radius: var(--radius);
  font: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all var(--t-base) var(--ease);
  overflow: hidden;
}
.quality-pill:hover {
  border-color: var(--border-strong);
  background: rgba(0,0,0,0.4);
  color: var(--text-1);
  transform: translateY(-1px);
}
.quality-pill:active { transform: translateY(0) scale(0.98); }

.quality-pill.active {
  border-color: var(--brand);
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255,23,68,0.25), transparent 70%),
    rgba(255,23,68,0.08);
  color: var(--text-1);
  box-shadow: 0 0 0 4px rgba(255, 23, 68, 0.10), 0 6px 18px rgba(255, 23, 68, 0.2);
}
.quality-pill.active .quality-num { color: var(--brand-2); }

.quality-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.quality-sub {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
  opacity: 0.85;
}
.quality-pill.active .quality-sub { color: var(--text-2); }

.quality-tag {
  position: absolute;
  top: 4px; right: 4px;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 2px 5px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--brand) 0%, #d50000 100%);
  color: white;
  line-height: 1;
}
.quality-pill:not(.active) .quality-tag { opacity: 0.7; }

@media (max-width: 400px) {
  .quality-num { font-size: 14px; }
  .quality-sub { font-size: 9px; }
  .quality-pill { padding: 8px 4px; }
}

/* Primary button */
.btn-primary {
  width: 100%;
  margin-top: 18px;
  border: 0;
  background: linear-gradient(135deg, var(--brand) 0%, #d50000 100%);
  color: white;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  padding: 14px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  display: block;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: transform var(--t-quick) var(--ease), box-shadow var(--t-base) var(--ease);
  box-shadow: 0 8px 24px rgba(255, 23, 68, 0.28);
}
.btn-primary:hover { box-shadow: var(--shadow-brand); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0) scale(0.99); }
.btn-primary:disabled { opacity: 0.6; cursor: wait; transform: none; }

.btn-content {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}
.btn-content svg { width: 16px; height: 16px; }

/* shimmer overlay on primary when loading */
.btn-primary.loading::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 20%, rgba(255,255,255,0.18) 50%, transparent 80%);
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ───────── Progress card ───────── */
.progress-card { padding: 18px 20px; }
.progress-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.progress-title {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 13.5px; font-weight: 600;
}

.dot-live {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 0 var(--brand);
  animation: pulse-dot 1.6s ease-out infinite;
}
@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(255, 23, 68, 0.6); }
  100% { box-shadow: 0 0 0 12px rgba(255, 23, 68, 0); }
}

.progress-bar {
  height: 8px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  border-radius: 999px;
  transition: width 280ms var(--ease);
  position: relative;
  overflow: hidden;
}
.progress-fill::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: shimmer 1.6s linear infinite;
}

.progress-stats {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
}
.progress-stats #stat-percent { color: var(--text-1); font-weight: 600; }
.stat-sep { opacity: 0.4; }

/* ───────── Terminal card ───────── */
.terminal-card { padding: 0; overflow: hidden; }

.terminal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: rgba(0,0,0,0.3);
  border-bottom: 1px solid var(--border);
}
.terminal-dots { display: flex; gap: 6px; }
.td { width: 10px; height: 10px; border-radius: 50%; }
.td-r { background: #ff5f56; } .td-y { background: #ffbd2e; } .td-g { background: #27c93f; }
.terminal-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  color: var(--text-3);
  flex: 1;
}

.terminal-body {
  padding: 14px 16px;
  max-height: 220px;
  overflow-y: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.7;
  color: #86b884;
  background: #050507;
}
.terminal-body::-webkit-scrollbar { width: 6px; }
.terminal-body::-webkit-scrollbar-track { background: transparent; }
.terminal-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 999px; }

.log-line {
  white-space: pre-wrap;
  word-break: break-word;
  animation: log-in 200ms var(--ease);
}
.log-line::before { content: '› '; color: var(--text-3); }
.log-line.warn { color: #e5c07b; }
.log-line.error { color: #f87171; }
.log-line.success { color: #6ee7b7; }

@keyframes log-in {
  from { opacity: 0; transform: translateX(-4px); }
  to { opacity: 1; transform: none; }
}

/* ───────── Result card ───────── */
.result-card {
  text-align: left;
  padding: 24px;
  border: 1px solid rgba(16, 185, 129, 0.18);
  background:
    radial-gradient(600px 200px at 50% 0%, rgba(16,185,129,0.06), transparent 70%),
    var(--surface);
}

.result-success {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(16, 185, 129, 0.12);
  color: #6ee7b7;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.result-success svg { width: 12px; height: 12px; }

.result-title {
  font-size: 18px; font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
  word-break: break-word;
}
.result-meta {
  font-size: 12.5px;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
}
.meta-sep { opacity: 0.4; }

.bpm-block {
  margin-top: 18px;
  padding: 18px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(255,23,68,0.10), rgba(255,23,68,0.02));
  border: 1px solid rgba(255,23,68,0.18);
  display: flex; align-items: center; gap: 16px;
  position: relative; overflow: hidden;
}

.bpm-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand) 0%, #d50000 100%);
  display: grid; place-items: center;
  color: white;
  box-shadow: 0 6px 18px rgba(255,23,68,0.4);
  flex-shrink: 0;
}
.bpm-icon svg { width: 22px; height: 22px; }

.bpm-label {
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-3); margin-bottom: 2px;
}
.bpm-value {
  display: flex; align-items: baseline; gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
}
#bpm-number { font-size: 30px; font-weight: 800; color: var(--text-1); letter-spacing: -0.02em; }
.bpm-unit { font-size: 13px; color: var(--text-3); font-weight: 500; }

/* Secondary "re-download" link inside result card */
.result-redownload {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 16px;
  padding: 8px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 500;
  transition: all var(--t-quick) var(--ease);
}
.result-redownload:hover {
  background: var(--surface-3);
  color: var(--text-1);
  border-color: var(--border-strong);
}
.result-redownload svg { width: 13px; height: 13px; }

.bpm-pulse {
  position: absolute; right: 18px; top: 50%;
  transform: translateY(-50%);
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--brand);
  opacity: 0.18;
  animation: pulse-bpm 1.6s ease-out infinite;
}
@keyframes pulse-bpm {
  0%, 100% { transform: translateY(-50%) scale(1); opacity: 0.18; }
  50% { transform: translateY(-50%) scale(1.5); opacity: 0; }
}

/* ───────── History ───────── */
.history-card { padding: 18px; }
.history-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 14px;
}
.history-head h2 { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
.history-sub { font-size: 11.5px; color: var(--text-3); }

.history-list {
  list-style: none;
  display: flex; flex-direction: column;
  gap: 8px;
  max-height: 70vh;
  overflow-y: auto;
}
.history-list::-webkit-scrollbar { width: 5px; }
.history-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 999px; }

.history-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: all var(--t-quick) var(--ease);
  animation: fade-in 220ms var(--ease);
}
.history-item:hover { background: rgba(0,0,0,0.4); border-color: var(--border-strong); }

.hi-icon {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: grid; place-items: center;
  flex-shrink: 0;
  background: var(--surface-2);
  color: var(--text-2);
}
.hi-icon svg { width: 16px; height: 16px; }
.hi-icon.audio { background: linear-gradient(135deg, var(--brand) 0%, #d50000 100%); color: white; }
.hi-icon.video { background: linear-gradient(135deg, #6366f1, #4f46e5); color: white; }

.hi-body { min-width: 0; flex: 1; }
.hi-title {
  font-size: 12.5px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hi-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.hi-meta .bpm-tag {
  display: inline-block;
  padding: 1px 6px;
  background: rgba(255,23,68,0.16);
  color: var(--brand-2);
  border-radius: 4px;
  font-weight: 600;
  margin-left: 4px;
  font-size: 10.5px;
}

.hi-actions { display: flex; gap: 4px; flex-shrink: 0; }
.hi-actions a, .hi-actions button {
  width: 28px; height: 28px;
  border-radius: 7px;
  border: 0;
  background: transparent;
  color: var(--text-3);
  display: grid; place-items: center;
  cursor: pointer;
  transition: all var(--t-quick) var(--ease);
  text-decoration: none;
}
.hi-actions a:hover { background: var(--surface-3); color: var(--text-1); }
.hi-actions button:hover { background: rgba(239,68,68,0.18); color: var(--error); }
.hi-actions svg { width: 13px; height: 13px; }

.history-empty {
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
  padding: 24px 0;
}

/* ───────── Toasts ───────── */
.toast-region {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex; flex-direction: column;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
}
.toast {
  background: rgba(20,20,28,0.95);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-1);
  display: flex; align-items: center; gap: 10px;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  pointer-events: auto;
  animation: toast-in 280ms var(--ease);
  max-width: 320px;
}
.toast.exit { animation: toast-out 220ms var(--ease-in) forwards; }
.toast.success { border-color: rgba(16,185,129,0.4); }
.toast.error { border-color: rgba(239,68,68,0.4); }
.toast-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  display: grid; place-items: center;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(20px); }
}

/* ───────── Responsive ───────── */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .history-col { order: 2; }
}

@media (max-width: 560px) {
  body { padding: 12px; padding-bottom: 32px; }
  .topbar { margin-bottom: 16px; }
  .brand-sub { display: none; }
  .card { padding: 18px; }
  .row { flex-direction: column; align-items: stretch; gap: 14px; }
  .row > .field { min-width: 0 !important; }
  .hero-head h1 { font-size: 19px; }
  .toast-region { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .bg-glow-1, .bg-glow-2, .dot-live, .bpm-pulse, .progress-fill::after { animation: none !important; }
}

/* Focus rings */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}
button:focus-visible, a:focus-visible, .seg-btn:focus-visible {
  outline-offset: 3px;
}
