* { 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; }
.note .actions a.view {
  display: inline-block;
  padding: 4px 12px;
  margin-right: 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card-bg);
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
  transition: background 0.15s, color 0.15s;
}
.note .actions a.view:hover { background: var(--bg); }

/* ── Note detail page ────────────────────────────────────────────────────── */
.detail-loading { text-align: center; color: var(--muted); padding: 60px 40px; font-size: 0.95rem; }
.note-detail-card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 28px 28px 24px;
  box-shadow: var(--card-shadow);
  transition: background 0.3s, box-shadow 0.3s;
}
.note-detail-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  line-height: 1.3;
}
.note-detail-content {
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.7;
  white-space: pre-wrap;
  margin-bottom: 24px;
  min-height: 1.5em;
}
.note-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.note-detail-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.note-detail-meta-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}
.note-detail-meta-item span:last-child {
  font-size: 0.85rem;
  color: var(--text);
}
.note-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.detail-btn {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: filter 0.15s, background 0.15s;
  border: 1px solid transparent;
}
.detail-btn-back {
  background: var(--card-bg);
  color: var(--text);
  border-color: var(--border);
}
.detail-btn-back:hover { background: var(--bg); }
.detail-btn-edit {
  background: var(--accent);
  color: var(--accent-fg);
}
.detail-btn-edit:hover { filter: brightness(1.1); }
.detail-btn-delete {
  background: none;
  color: var(--danger);
  border-color: var(--danger);
}
.detail-btn-delete:hover { background: var(--danger); color: #fff; }
