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

/* ── Theme variables ─────────────────────────────────────────────────────── */
:root {
  --fade-duration: 200ms;
  --bg: #f5f5f5;
  --text: #333;
  --card-bg: #fff;
  --card-shadow: 0 2px 8px rgba(0,0,0,0.08);
  --border: #e0e0e0;
  --input-bg: #fff;
  /* #5558db gives ≥5.1:1 on #f5f5f5 and ≥5.6:1 for white text — WCAG AA */
  --accent: #5558db;
  /* #6e6e6e gives ≥4.67:1 on #f5f5f5 — WCAG AA for normal text */
  --muted: #6e6e6e;
  /* #b33000 gives ≥5.25:1 on #f5f5f5 and ≥5.70:1 on #fff — WCAG AA */
  --danger: #b33000;
  --toast-bg: #222;
  --toast-color: #fff;
  --on-accent: #fff;
}
[data-theme="dark"] {
  --bg: #0f0f1a;
  --text: #e2e2e2;
  --card-bg: #1a1a2e;
  --card-shadow: 0 2px 12px rgba(0,0,0,0.4);
  --border: #2d2d4a;
  --input-bg: #1e1e35;
  /* accent (#8a9ef5) is light — dark text (--on-accent) is needed on it */
  --accent: #8a9ef5;
  /* #9aa3b2 gives ≥6.7:1 on --card-bg (#1a1a2e) — WCAG AA */
  --muted: #9aa3b2;
  --danger: #e06c6c;
  --toast-bg: #e2e2e2;
  --toast-color: #111;
  /* buttons/links use --accent as background — dark text needed for contrast */
  --on-accent: #0f0f1a;
}

/* ── Base ────────────────────────────────────────────────────────────────── */
body {
  font-family: system-ui, -apple-system, sans-serif;
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
  background: var(--bg);
  color: var(--text);
  transition: background 0.3s, color 0.3s;
}
h1 { margin-bottom: 20px; color: var(--text); }
.hidden { display: none; }
.error { text-align: center; color: var(--danger); padding: 40px; }

/* ── Nav ─────────────────────────────────────────────────────────────────── */
nav { display: flex; gap: 16px; margin-bottom: 24px; align-items: center; }
nav a { color: var(--accent); text-decoration: none; font-size: 14px; font-weight: 500; }
nav a:hover { text-decoration: underline; }
nav a.active { color: var(--text); font-weight: 700; pointer-events: none; }
.theme-toggle {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  transition: background 0.2s;
}
.theme-toggle:hover { background: var(--card-bg); }

/* ── Hero ────────────────────────────────────────────────────────────────── */
@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.hero {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 260px;
  padding: 48px 20px 36px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #667eea, #764ba2, #f093fb, #4facfe);
  background-size: 300% 300%;
  animation: gradientShift 8s ease infinite;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(102,126,234,0.35);
  cursor: pointer;
  user-select: none;
  position: relative;
}
.hero .fullscreen-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  padding: 5px 10px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  transition: background 0.15s;
}
.hero .fullscreen-btn:hover { background: rgba(255,255,255,0.35); }
/* Fullscreen state */
.hero:fullscreen,
.hero:-webkit-full-screen,
.hero:-moz-full-screen {
  border-radius: 0;
  margin-bottom: 0;
  min-height: 100vh;
  width: 100vw;
}
.hero:fullscreen .tagline,
.hero:-webkit-full-screen .tagline,
.hero:-moz-full-screen .tagline { font-size: clamp(3rem, 10vw, 7rem); }
.hero:fullscreen .lang-label,
.hero:-webkit-full-screen .lang-label,
.hero:-moz-full-screen .lang-label { font-size: 1.25rem; }
.hero .tagline {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  transition: opacity var(--fade-duration) ease;
  text-shadow: 0 2px 8px rgba(0,0,0,0.2);
  text-align: center;
}
.hero .lang-label {
  margin-top: 8px;
  font-size: 0.95rem;
  color: rgba(255,255,255,0.85);
  letter-spacing: 0.04em;
  min-height: 1.4em;
  transition: opacity var(--fade-duration) ease;
}
/* Language progress dots */
.progress-dots { display: flex; gap: 6px; margin-top: 14px; }
.progress-dots .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  transition: background 0.2s, transform 0.2s;
}
.progress-dots .dot.active {
  background: rgba(255,255,255,0.95);
  transform: scale(1.4);
}
/* Auto-cycle and copy buttons */
.hero-controls {
  position: absolute;
  bottom: 10px;
  left: 12px;
  display: flex;
  gap: 6px;
}
.hero-controls button {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 4px;
  /* color: #fff is intentional — these buttons sit on the translucent hero
     overlay and must remain legible regardless of the page theme. */
  color: #fff;
  cursor: pointer;
  padding: 4px 9px;
  font-size: 0.7rem;
  font-weight: 500;
  transition: background 0.15s;
}
.hero-controls button:hover { background: rgba(255,255,255,0.35); }
.hero-controls button.is-active { background: rgba(255,255,255,0.42); }

/* ── Feature card grid ───────────────────────────────────────────────────── */
.features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}
@media (max-width: 560px) { .features { grid-template-columns: 1fr; } }
.card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: var(--card-shadow);
  transition: background 0.3s, box-shadow 0.3s;
}
.card h2 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
}

/* ── Time card ───────────────────────────────────────────────────────────── */
.time-emoji { font-size: 1.8rem; margin-bottom: 4px; }
.time-greeting { font-size: 1.2rem; font-weight: 700; color: var(--text); line-height: 1.3; }
.time-greeting .hi-name { color: var(--accent); }
.time-info { margin-top: 5px; font-size: 0.78rem; color: var(--muted); }

/* ── Personalize card ────────────────────────────────────────────────────── */
.name-row { display: flex; gap: 7px; }
.name-row input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--input-bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, background 0.3s, color 0.3s;
}
.name-row input:focus { border-color: var(--accent); }
.name-row input::placeholder { color: var(--muted); }
.name-row button {
  padding: 8px 14px;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: filter 0.15s;
}
.name-row button:hover { filter: brightness(1.1); }
.name-feedback { margin-top: 7px; font-size: 12px; color: var(--accent); min-height: 1.4em; }

/* ── Stats card ──────────────────────────────────────────────────────────── */
.stat-value { font-size: 2.8rem; font-weight: 800; color: var(--accent); line-height: 1; }
.stat-label { margin-top: 2px; font-size: 0.78rem; color: var(--muted); }
.stat-sub { margin-top: 8px; font-size: 0.85rem; color: var(--text); }

/* ── CTA card ────────────────────────────────────────────────────────────── */
.card.cta-card { display: flex; align-items: center; justify-content: center; }
.cta-card a {
  display: inline-block;
  padding: 11px 24px;
  background: var(--accent);
  color: var(--on-accent);
  text-decoration: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  transition: filter 0.15s;
}
.cta-card a:hover { filter: brightness(1.1); }

/* ── Toast notification ──────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--toast-bg);
  color: var(--toast-color);
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 1000;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ── Notetaker page ──────────────────────────────────────────────────────── */
.note-form {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: var(--card-shadow);
  transition: background 0.3s, box-shadow 0.3s;
}
.note-form input,
.note-form textarea {
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 14px;
  background: var(--input-bg);
  color: var(--text);
  transition: border-color 0.15s, background 0.3s, color 0.3s;
}
.note-form input::placeholder,
.note-form textarea::placeholder { color: var(--muted); }
.note-form input:focus,
.note-form textarea:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.note-form textarea { height: 100px; resize: vertical; }
.note-form button {
  padding: 10px 20px;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: filter 0.15s;
}
.note-form button:hover { filter: brightness(1.1); }
.note-form button.cancel {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  margin-left: 8px;
}
.note-form button.cancel:hover { background: var(--card-bg); filter: none; }
.note {
  background: var(--card-bg);
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 12px;
  box-shadow: var(--card-shadow);
  transition: background 0.3s, box-shadow 0.3s;
}
.note h3 { margin-bottom: 8px; color: var(--text); }
.note p { color: var(--text); white-space: pre-wrap; margin-bottom: 8px; }
.note .meta { font-size: 12px; color: var(--muted); }
.note .actions { margin-top: 8px; }
.note .actions button {
  padding: 4px 12px;
  margin-right: 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.note .actions button:hover { background: var(--border); }
.note .actions button.delete { color: var(--danger); border-color: var(--danger); }
.note .actions button.edit { color: var(--accent); border-color: var(--accent); }
#notes-list .empty { text-align: center; color: var(--muted); padding: 40px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
  }
}
