/* ─── CSS Variables ──────────────────────────────────────── */
:root {
  /* Dark theme (default) */
  --bg:           #0b0c10;
  --surface:      rgba(255,255,255,0.04);
  --surface-hover:rgba(255,255,255,0.08);
  --border:       rgba(255,255,255,0.08);
  --text:         #e8e6e1;
  --text-muted:   rgba(232,230,225,0.45);
  --accent:       #c9a96e;
  --accent-glow:  rgba(201,169,110,0.25);
  --pill-active-bg: #c9a96e;
  --pill-active-text: #0b0c10;
  --card-bg:      rgba(255,255,255,0.035);
  --card-border:  rgba(255,255,255,0.1);
  --card-shadow:  0 32px 80px rgba(0,0,0,0.6);
  --orb1: #1a1060;
  --orb2: #0f2a1a;
  --orb3: #2a1008;
  --btn-ghost-border: rgba(255,255,255,0.14);
  --input-bg: rgba(255,255,255,0.06);

  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
  --radius: 20px;
  --radius-sm: 10px;
  --transition: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg:           #f5f0e8;
  --surface:      rgba(0,0,0,0.04);
  --surface-hover:rgba(0,0,0,0.07);
  --border:       rgba(0,0,0,0.09);
  --text:         #1a1612;
  --text-muted:   rgba(26,22,18,0.5);
  --accent:       #9b6f2f;
  --accent-glow:  rgba(155,111,47,0.2);
  --pill-active-bg: #9b6f2f;
  --pill-active-text: #fff;
  --card-bg:      rgba(255,255,255,0.7);
  --card-border:  rgba(0,0,0,0.08);
  --card-shadow:  0 24px 64px rgba(0,0,0,0.12);
  --orb1: #d4e0f5;
  --orb2: #d5eedd;
  --orb3: #f5e4d0;
  --btn-ghost-border: rgba(0,0,0,0.15);
  --input-bg: rgba(0,0,0,0.05);
}

/* ─── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background var(--transition), color var(--transition);
}

/* ─── Ambient Background ─────────────────────────────────── */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  pointer-events: none;
  z-index: 0;
  transition: background var(--transition);
  animation: orbDrift 18s ease-in-out infinite alternate;
}
.orb1 { width: 520px; height: 520px; top: -140px; left: -120px; background: var(--orb1); animation-delay: 0s; }
.orb2 { width: 420px; height: 420px; bottom: -100px; right: -80px; background: var(--orb2); animation-delay: -6s; }
.orb3 { width: 300px; height: 300px; top: 50%; left: 50%; transform: translate(-50%,-50%); background: var(--orb3); animation-delay: -12s; }

@keyframes orbDrift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(30px, 20px) scale(1.07); }
}
.orb3 { animation-name: orb3Drift; }
@keyframes orb3Drift {
  from { transform: translate(-50%,-50%) scale(0.95); }
  to   { transform: translate(calc(-50% + 20px), calc(-50% + 15px)) scale(1.05); }
}

.noise-overlay {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px 256px;
}

/* ─── App Shell ──────────────────────────────────────────── */
.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px 48px;
}

/* ─── Top Bar ────────────────────────────────────────────── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0 20px;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.brand-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.6; transform: scale(0.8); }
}
.brand-name {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 11px;
  width: 15px; height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}
#searchInput {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 40px;
  padding: 8px 14px 8px 34px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  color: var(--text);
  width: 190px;
  outline: none;
  transition: border-color var(--transition), width var(--transition);
}
#searchInput::placeholder { color: var(--text-muted); }
#searchInput:focus {
  border-color: var(--accent);
  width: 240px;
}

.icon-btn {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); border-color: var(--accent); }
.icon-btn svg { width: 16px; height: 16px; }

/* Moon/Sun toggle */
.icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

.badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.6rem;
  font-weight: 600;
  border-radius: 20px;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
}
.badge.hidden { display: none; }

/* ─── Controls Row ───────────────────────────────────────── */
.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin-bottom: 28px;
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 40px;
  padding: 6px 15px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.pill:hover { background: var(--surface-hover); color: var(--text); }
.pill.active {
  background: var(--pill-active-bg);
  color: var(--pill-active-text);
  border-color: transparent;
}

.mood-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.mood-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-right: 2px;
}
.mood-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 40px;
  padding: 5px 12px;
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.mood-btn:hover { background: var(--surface-hover); color: var(--text); }
.mood-btn.active {
  background: var(--surface-hover);
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── Quote Card ─────────────────────────────────────────── */
.card-wrap { display: flex; flex-direction: column; gap: 14px; }

.quote-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  backdrop-filter: blur(18px) saturate(120%);
  -webkit-backdrop-filter: blur(18px) saturate(120%);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  transition: box-shadow var(--transition);
}
.quote-card:hover { box-shadow: var(--card-shadow), 0 0 0 1px var(--accent-glow); }

.card-inner {
  padding: 48px 52px 36px;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.quote-mark {
  font-family: var(--font-display);
  font-size: 7rem;
  line-height: 0.6;
  color: var(--accent);
  opacity: 0.25;
  position: absolute;
  top: 28px;
  left: 40px;
  pointer-events: none;
  user-select: none;
}

.quote-text {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2.4vw, 1.65rem);
  font-weight: 400;
  font-style: italic;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 22px;
  padding-top: 12px;
  position: relative;
  z-index: 1;

  /* Fade transition */
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.32s ease, transform 0.32s ease;
}
.quote-text.fade-out, .quote-author.fade-out {
  opacity: 0;
  transform: translateY(8px);
}

.quote-author {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 16px;
  transition: opacity 0.32s ease, transform 0.32s ease;
}

.quote-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
}
.meta-cat {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
}
.meta-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag-chip {
  font-size: 0.68rem;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 9px;
}

/* ─── Card Actions ───────────────────────────────────────── */
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 18px 52px 24px;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.08);
}
[data-theme="light"] .card-actions { background: rgba(0,0,0,0.025); }

.btn-primary {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent);
  color: #0b0c10;
  border: none;
  border-radius: 40px;
  padding: 10px 22px;
  font-family: var(--font-body);
  font-size: 0.83rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 18px var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 28px var(--accent-glow); }
.btn-primary:active { transform: translateY(0); }
.btn-primary svg { width: 15px; height: 15px; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--btn-ghost-border);
  border-radius: 40px;
  padding: 9px 17px;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); border-color: var(--accent); }
.btn-ghost svg { width: 14px; height: 14px; }
.btn-ghost.small { padding: 7px 14px; font-size: 0.78rem; }
.btn-ghost.active-save { color: #e05f7f; border-color: #e05f7f; }

/* ─── Auto-refresh strip ─────────────────────────────────── */
.auto-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.toggle-wrap {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; user-select: none;
}
.toggle-wrap input { display: none; }

.toggle-track {
  width: 38px; height: 21px;
  background: var(--border);
  border-radius: 40px;
  position: relative;
  transition: background var(--transition);
}
.toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 15px; height: 15px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.toggle-wrap input:checked + .toggle-track { background: var(--accent); }
.toggle-wrap input:checked + .toggle-track .toggle-thumb { transform: translateX(17px); }

.toggle-lbl { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }

.interval-sel {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--text);
  cursor: pointer;
  outline: none;
}

/* ─── Stats Strip ────────────────────────────────────────── */
.stats-strip {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.6;
  padding: 0 4px;
}
.stats-strip b { color: var(--accent); }

/* ─── Favorites View ─────────────────────────────────────── */
.fav-view { padding-top: 8px; }
.fav-view.hidden { display: none; }

.fav-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.fav-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
}

.fav-list { display: flex; flex-direction: column; gap: 14px; }

.fav-item {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 20px 24px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  animation: fadeIn 0.3s ease;
}
.fav-item-body { flex: 1; }
.fav-item-text {
  font-family: var(--font-display);
  font-size: 1rem;
  font-style: italic;
  line-height: 1.6;
  margin-bottom: 6px;
  color: var(--text);
}
.fav-item-author { font-size: 0.78rem; color: var(--accent); font-weight: 500; letter-spacing: 0.05em; }
.fav-item-cat { font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; }
.fav-remove {
  background: transparent;
  border: 1px solid var(--btn-ghost-border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.72rem;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  flex-shrink: 0;
}
.fav-remove:hover { border-color: #e05f7f; color: #e05f7f; }

.fav-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 48px 0;
  font-style: italic;
}
.fav-empty.hidden { display: none; }

/* ─── Toast ──────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 10px 22px;
  border-radius: 40px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 9999;
  white-space: nowrap;
  max-width: 90vw;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── Animations ─────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 640px) {
  .top-bar { flex-wrap: wrap; }
  #searchInput { width: 140px; }
  #searchInput:focus { width: 170px; }
  .card-inner { padding: 36px 28px 24px; }
  .card-actions { padding: 14px 28px 20px; }
  .controls-row { gap: 10px; }
  .quote-mark { font-size: 5rem; }
}
