* { box-sizing: border-box; margin: 0; padding: 0; }
html { overflow-x: hidden; }
body { font-family: system-ui, -apple-system, sans-serif; max-width: 800px; margin: 0 auto; padding: 20px; background: #f5f5f5; min-width: 320px; overflow-x: hidden; }
nav { display: flex; gap: 16px; margin-bottom: 24px; }
nav a { color: #4a90d9; text-decoration: none; font-size: 14px; font-weight: 500; }
nav a:hover { text-decoration: underline; }
nav a.active { color: #333; font-weight: 700; pointer-events: none; }
.hidden { display: none; }
.error { text-align: center; color: #d9534f; padding: 40px; }

/* ── Theme variables ─────────────────────────────────────────────────────── */
:root {
  --fade-duration: 220ms;
  --bg: #f5f5f5;
  --text: #333;
  --card-bg: #fff;
  --card-shadow: 0 2px 8px rgba(0,0,0,0.08);
  --border: #e0e0e0;
  --input-bg: #fff;
  --accent: #667eea;
  --accent-fg: #fff;
  --muted: #888;
  --toast-bg: #222;
  --toast-color: #fff;
  --danger: #d9534f;
}
[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;
  --accent-fg: #000;
  --muted: #6b7280;
  --toast-bg: #e2e2e2;
  --toast-color: #111;
  --danger: #f87171;
}
body { background: var(--bg); color: var(--text); transition: background 0.3s, color 0.3s; }

/* ── Nav additions ───────────────────────────────────────────────────────── */
nav a { color: var(--accent); }
nav a.active { color: var(--text); }
.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, var(--accent), var(--accent-mid), var(--accent-end));
  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, transform 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, transform 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; }
  body { padding: 16px; }
  nav { gap: 12px; }
}
@media (max-width: 480px) {
  body { padding: 14px; }
  nav { gap: 10px; }
  .hero { padding: 32px 14px 24px; min-height: 200px; }
  .note-form { padding: 14px; }
}
@media (max-width: 360px) {
  body { padding: 10px; }
  nav { gap: 8px; }
  nav a { font-size: 12px; }
  .theme-toggle { padding: 3px 8px; font-size: 12px; }
  .color-picker-btn { padding: 3px 8px 3px 6px; font-size: 12px; }
  .note-form { padding: 12px; }
  .note-form button.hidden { display: none; }
}
.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(--accent-fg);
  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(--accent-fg);
  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); }

/* ── Colour picker ───────────────────────────────────────────────────────── */
.color-picker-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.color-picker-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px 4px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text);
  transition: background 0.2s;
}
.color-picker-btn:hover { background: var(--card-bg); }
.color-picker-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(0,0,0,0.15);
  flex-shrink: 0;
  background: var(--accent);
}
.color-picker-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: var(--card-shadow);
  z-index: 100;
}
.color-picker-heading {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
  white-space: nowrap;
}
.color-swatches { display: flex; gap: 7px; }
.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s, border-color 0.15s;
  outline: none;
  background: var(--swatch-light);
}
[data-theme="dark"] .color-swatch { background: var(--swatch-dark); }
.color-swatch:hover { transform: scale(1.15); }
.color-swatch:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.color-swatch.active { border-color: var(--text); transform: scale(1.1); }

/* ── Notetaker page ──────────────────────────────────────────────────────── */
.notetaker-title { margin-bottom: 20px; color: var(--text); }
.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); }
.note-form input:focus:not(:focus-visible),
.note-form textarea:focus:not(:focus-visible) { outline: none; }
.note-form input:focus-visible,
.note-form textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.note-form textarea { height: 100px; resize: vertical; }
.note-form-actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.note-form button {
  padding: 10px 20px;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: filter 0.15s;
  flex: 1;
}
.note-form button:hover { filter: brightness(0.9); }
.note-form button.cancel { background: var(--muted); color: var(--text); }
.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(--muted); 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, color 0.15s;
}
.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; }

/* ── Ensure hero content sits above the particle canvas (z-index:0) ─────── */
/* z-index works on flex items even without explicit position, and on         */
/* positioned children (fullscreen-btn, hero-controls) without changing them. */
.hero > *:not(canvas) { z-index: 1; }

/* ── Audio controls ─────────────────────────────────────────────────────── */
.audio-controls {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-left: 2px;
}
.audio-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 9px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  line-height: 1;
  transition: background 0.2s, border-color 0.15s;
}
.audio-btn:hover { background: var(--card-bg); }
.audio-btn.is-active { background: var(--card-bg); border-color: var(--accent); }
.audio-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Hero hint (easter egg tooltip) ─────────────────────────────────────── */
.hero-hint {
  position: absolute;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: rgba(255,255,255,0.55);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  text-align: center;
  letter-spacing: 0.02em;
  max-width: calc(100% - 24px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.hero:hover .hero-hint { opacity: 1; }

/* ── Rainbow text ────────────────────────────────────────────────────────── */
@keyframes rainbow {
  0%   { color: #ff595e; text-shadow: 0 0 18px #ff595e88; }
  16%  { color: #ffca3a; text-shadow: 0 0 18px #ffca3a88; }
  33%  { color: #8ac926; text-shadow: 0 0 18px #8ac92688; }
  50%  { color: #1982c4; text-shadow: 0 0 18px #1982c488; }
  66%  { color: #6a4c93; text-shadow: 0 0 18px #6a4c9388; }
  83%  { color: #4ecdc4; text-shadow: 0 0 18px #4ecdc488; }
  100% { color: #ff595e; text-shadow: 0 0 18px #ff595e88; }
}
.hero .rainbow-text { animation: rainbow 0.5s linear infinite; }

/* ── Ultra mode ──────────────────────────────────────────────────────────── */
@keyframes ultraPulse {
  0%,100% { box-shadow: 0 0 40px rgba(255,89,94,0.7), 0 0 80px rgba(255,202,58,0.5); }
  50%     { box-shadow: 0 0 60px rgba(26,130,196,0.7), 0 0 120px rgba(138,201,38,0.5); }
}
.hero.ultra-mode {
  animation: gradientShift 0.4s ease infinite, ultraPulse 0.6s ease infinite;
}

/* ── Disco mode ──────────────────────────────────────────────────────────── */
/* Overlay-based approach: mix-blend-mode avoids the CPU filter pipeline used by
   body filter, but still composites the full viewport — acceptable for a
   short-lived easter-egg mode. */
@keyframes discoSpin {
  from { background: hsl(0,   100%, 50%); }
  to   { background: hsl(360, 100%, 50%); }
}
.disco-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9996;
  mix-blend-mode: hue;
  background: hsl(0, 100%, 50%);
  animation: discoSpin 0.35s linear infinite;
}

/* ── Wiggle animation (hello easter egg) ─────────────────────────────────── */
@keyframes wiggle {
  0%,100% { transform: rotate(0deg)  scale(1); }
  20%     { transform: rotate(-6deg) scale(1.06); }
  40%     { transform: rotate(6deg)  scale(1.06); }
  60%     { transform: rotate(-4deg) scale(1.04); }
  80%     { transform: rotate(4deg)  scale(1.04); }
}
.hero .wiggle-anim { animation: wiggle 0.35s ease-in-out 3; }

/* ── Cat parade ──────────────────────────────────────────────────────────── */
@keyframes catWalk {
  from { transform: translateX(-80px); }
  to   { transform: translateX(calc(100vw + 80px)); }
}

/* ── Reduced-motion overrides ────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .hero .rainbow-text,
  .hero.ultra-mode,
  .disco-overlay,
  .hero .wiggle-anim,
  #cat-parade * {
    animation: none;
  }
}
