/* ═══════════════════════════════════════════════════════════════
   SpeedRead — Design System
   Sky Blue · Apple Design Language · Dark + Light
   ═══════════════════════════════════════════════════════════════ */

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

/* ─── TOKENS ─── */
:root {
  /* Backgrounds */
  --bg:          #060d1a;
  --bg-card:     #0d1f35;
  --bg-elevated: #132a48;
  --bg-glass:    rgba(6,13,26,0.72);

  /* Borders */
  --border:      rgba(56,189,248,0.14);
  --border-strong: rgba(56,189,248,0.28);

  /* Text */
  --text:        #e8f4fd;
  --text-muted:  #6b8fad;
  --text-subtle: #3d5f7a;

  /* Accent — Sky Blue */
  --accent:       #38bdf8;
  --accent-hover: #7dd3fc;
  --accent-dim:   rgba(56,189,248,0.12);
  --accent-glow:  rgba(56,189,248,0.24);
  --accent-rgb:   56,189,248;

  /* Semantic */
  --green:  #34d399;
  --red:    #f87171;
  --yellow: #fbbf24;

  /* Interactive */
  --btn-bg:    rgba(255,255,255,0.06);
  --btn-hover: rgba(255,255,255,0.1);

  /* Shape */
  --radius:    10px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  /* Shadow */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow:    0 4px 16px rgba(0,0,0,0.5), 0 1px 4px rgba(0,0,0,0.3);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.6), 0 4px 16px rgba(0,0,0,0.4);
  --shadow-accent: 0 0 20px rgba(56,189,248,0.18), 0 4px 16px rgba(0,0,0,0.5);

  /* Motion */
  --ease-spring: cubic-bezier(0.34,1.4,0.64,1);
  --ease-out:    cubic-bezier(0.22,1,0.36,1);
  --duration:    0.18s;
}

/* ─── LIGHT THEME ─── */
[data-theme="light"] {
  --bg:          #f0f9ff;
  --bg-card:     #ffffff;
  --bg-elevated: #e0f2fe;
  --bg-glass:    rgba(240,249,255,0.82);

  --border:       rgba(2,132,199,0.15);
  --border-strong: rgba(2,132,199,0.3);

  --text:        #0c1a2e;
  --text-muted:  #4b7a9e;
  --text-subtle: #93b8d4;

  --accent:       #0284c7;
  --accent-hover: #0369a1;
  --accent-dim:   rgba(2,132,199,0.1);
  --accent-glow:  rgba(2,132,199,0.2);
  --accent-rgb:   2,132,199;

  --green:  #059669;
  --red:    #dc2626;
  --yellow: #d97706;

  --btn-bg:    rgba(0,0,0,0.05);
  --btn-hover: rgba(0,0,0,0.08);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.12), 0 4px 16px rgba(0,0,0,0.06);
  --shadow-accent: 0 0 20px rgba(2,132,199,0.16), 0 4px 16px rgba(0,0,0,0.06);
}

/* ─── BASE ─── */
html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text',
               'Helvetica Neue', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition:
    background var(--duration) var(--ease-out),
    border-color var(--duration) var(--ease-out),
    box-shadow var(--duration) var(--ease-out),
    transform 0.12s var(--ease-spring);
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.btn:hover {
  background: var(--btn-hover);
  border-color: var(--border-strong);
}
.btn:active { transform: scale(0.96); }
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(var(--accent-rgb),0.4), 0 0 0 0 rgba(var(--accent-rgb),0);
}
[data-theme="light"] .btn-primary { color: #fff; }
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: transparent;
  box-shadow: var(--shadow-accent);
}
.btn-primary:active { transform: scale(0.96); }

.btn-outline {
  background: var(--accent-dim);
  border-color: var(--border-strong);
  color: var(--accent);
}
.btn-outline:hover {
  background: rgba(var(--accent-rgb),0.2);
  border-color: var(--accent);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  background: var(--btn-hover);
  border-color: var(--border);
  color: var(--text);
}

.btn-lg { font-size: 16px; padding: 13px 28px; border-radius: var(--radius-lg); }
.btn-sm { font-size: 12px; padding: 5px 12px; }
.btn-danger { border-color: transparent; color: var(--red); }
.btn-danger:hover { background: rgba(248,113,113,0.1); border-color: rgba(248,113,113,0.3); }

/* ─── INPUTS ─── */
input, textarea, select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 14px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--duration), box-shadow var(--duration);
}
input::placeholder, textarea::placeholder { color: var(--text-subtle); }
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb),0.18);
}

/* ─── CARDS ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.28s var(--ease-spring);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.93) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal h2 { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; }

/* ─── TOAST ─── */
#toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: 90vw;
  max-width: 440px;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 13px 18px;
  font-size: 14px;
  color: var(--text);
  pointer-events: all;
  animation: toastIn 0.3s var(--ease-spring);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes fadeOut {
  to { opacity: 0; transform: translateY(8px) scale(0.97); }
}

/* ─── SPINNER ─── */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── RANGE SLIDER ─── */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-elevated);
  outline: none;
  cursor: pointer;
  border: none;
  padding: 0;
  box-shadow: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm);
  transition: transform 0.12s var(--ease-spring);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }

/* ─── CONFETTI ─── */
@keyframes confettiFall {
  0%   { transform: translateY(-100vh) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}
.confetti-piece {
  position: fixed;
  width: 8px; height: 8px;
  top: -10px;
  z-index: 3000;
  animation: confettiFall 3s ease-in forwards;
  pointer-events: none;
  border-radius: 2px;
}

/* ─── RESPONSIVE ─── */
@media (max-width: 640px) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }
  .hide-mobile { display: none !important; }
}
