/* ===== Tokens ===== */
:root {
  --bg: #fef7f4;
  --surface: #ffffff;
  --surface-2: #fbf0eb;
  --border: #f3dcd1;
  --border-strong: #e8c6b6;
  --text: #2b1d18;
  --text-soft: #6b5249;
  --text-muted: #9a8579;
  --accent: #e35a4b;
  --accent-hover: #cd4636;
  --accent-soft: #fde2dc;
  --accent-strong: #b53626;
  --success: #2f8a5f;
  --shadow-sm: 0 1px 2px rgba(60, 20, 10, 0.06);
  --shadow: 0 4px 14px rgba(60, 20, 10, 0.08), 0 1px 3px rgba(60, 20, 10, 0.05);
  --shadow-lg: 0 18px 40px rgba(60, 20, 10, 0.12), 0 4px 10px rgba(60, 20, 10, 0.06);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --radius-pill: 999px;
  --container: 720px;
  --font-ui: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-em: "Lora", Georgia, serif;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-theme="dark"] {
  --bg: #1a1311;
  --surface: #251c19;
  --surface-2: #2f231f;
  --border: #3a2a25;
  --border-strong: #4a3631;
  --text: #f5ece8;
  --text-soft: #c4b0a8;
  --text-muted: #8d7770;
  --accent: #ff7a6b;
  --accent-hover: #ff9385;
  --accent-soft: #3d2520;
  --accent-strong: #ffa394;
  --success: #4fb380;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.5), 0 4px 10px rgba(0, 0, 0, 0.3);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1311;
    --surface: #251c19;
    --surface-2: #2f231f;
    --border: #3a2a25;
    --border-strong: #4a3631;
    --text: #f5ece8;
    --text-soft: #c4b0a8;
    --text-muted: #8d7770;
    --accent: #ff7a6b;
    --accent-hover: #ff9385;
    --accent-soft: #3d2520;
    --accent-strong: #ffa394;
    --success: #4fb380;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 14px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.5), 0 4px 10px rgba(0, 0, 0, 0.3);
  }
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; color: inherit; }
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ===== Layout ===== */
.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 20px;
}

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(254, 247, 244, 0.78);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
[data-theme="dark"] .site-header { background: rgba(26, 19, 17, 0.78); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .site-header { background: rgba(26, 19, 17, 0.78); }
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--accent);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.logo span { color: var(--text); }
.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-pill);
  display: grid;
  place-items: center;
  color: var(--text-soft);
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}

/* ===== Hero ===== */
.hero {
  padding: 56px 20px 24px;
  text-align: center;
}
.hero-title {
  font-size: clamp(36px, 7vw, 56px);
  line-height: 1.05;
  letter-spacing: -0.025em;
  font-weight: 800;
  margin-bottom: 12px;
}
.hero-title-em {
  display: block;
  font-family: var(--font-em);
  font-style: italic;
  font-weight: 500;
  color: var(--accent);
  margin-top: 4px;
}
.hero-sub {
  color: var(--text-soft);
  font-size: 17px;
  max-width: 460px;
  margin: 0 auto 32px;
}

/* ===== Result card ===== */
.result-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 24px;
  margin: 0 auto 24px;
  max-width: 540px;
  min-height: 160px;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.4s var(--ease-spring), border-color 0.3s var(--ease), background-color 0.3s var(--ease);
}
.result-card[data-state="picking"] {
  border-color: var(--accent);
}
.result-card[data-state="done"] {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--surface) 0%, var(--accent-soft) 100%);
  transform: scale(1.01);
}
.result-inner { position: relative; z-index: 2; }
.result-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}
.result-card[data-state="done"] .result-label { color: var(--accent-strong); }
.result-value {
  font-family: var(--font-em);
  font-style: italic;
  font-weight: 600;
  font-size: clamp(32px, 6vw, 48px);
  line-height: 1.1;
  color: var(--text);
  letter-spacing: -0.01em;
  word-break: break-word;
  transition: transform 0.2s var(--ease);
}
.result-card[data-state="picking"] .result-value {
  animation: pulse 0.5s var(--ease) infinite alternate;
}
.result-card[data-state="done"] .result-value {
  animation: pop 0.5s var(--ease-spring);
}
@keyframes pulse {
  from { opacity: 0.85; }
  to { opacity: 1; }
}
@keyframes pop {
  0% { transform: scale(0.7); opacity: 0; }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* Confetti dots */
.result-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}
.confetti-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  opacity: 0;
}
.result-card[data-state="done"] .confetti-dot {
  animation: confetti-fly 1.2s var(--ease) forwards;
}
@keyframes confetti-fly {
  0% { opacity: 1; transform: translate(0, 0) scale(0.6); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1); }
}

/* ===== Action row ===== */
.action-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--accent);
  color: #fff;
  padding: 15px 32px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.005em;
  box-shadow: 0 6px 18px rgba(227, 90, 75, 0.32);
  transition: background-color 0.2s var(--ease), transform 0.15s var(--ease), box-shadow 0.2s var(--ease);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 10px 22px rgba(227, 90, 75, 0.4); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 11px 18px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text-soft);
  font-weight: 600;
  font-size: 14px;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--accent); }

.btn-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.btn-text:hover { color: var(--accent); background: var(--accent-soft); }

/* Error banner */
.error-banner {
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  max-width: 420px;
  margin: 0 auto;
  text-align: center;
  animation: slideDown 0.3s var(--ease);
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Modes ===== */
.modes-section {
  padding: 28px 20px 8px;
  text-align: center;
}
.modes-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.modes-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.mode-chip {
  padding: 9px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-soft);
  transition: all 0.18s var(--ease);
}
.mode-chip:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
  transform: translateY(-1px);
}

/* ===== Sections ===== */
.section-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.options-section {
  padding: 40px 20px 16px;
}
.options-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}
.count-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

/* Chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 44px;
  padding: 14px;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px dashed var(--border-strong);
  margin-bottom: 12px;
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.chips:empty::after {
  content: "Your options will appear here. Add some below or try a quick pick above.";
  color: var(--text-muted);
  font-size: 14px;
  font-style: italic;
  font-family: var(--font-em);
  padding: 6px 4px;
  align-self: center;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 7px 6px 7px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  animation: chipIn 0.2s var(--ease-spring);
  max-width: 100%;
}
.chip-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 240px;
}
.chip.is-highlighting {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: scale(1.08);
  z-index: 2;
  position: relative;
  box-shadow: 0 4px 14px rgba(227, 90, 75, 0.4);
  transition: all 0.08s var(--ease);
}
.chip.is-winner {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  animation: winnerPulse 0.6s var(--ease-spring);
}
@keyframes winnerPulse {
  0% { transform: scale(0.9); }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
@keyframes chipIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}
.chip-remove {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}
.chip-remove:hover { background: var(--accent-soft); color: var(--accent); }
.chip.is-highlighting .chip-remove,
.chip.is-winner .chip-remove { color: rgba(255, 255, 255, 0.85); }
.chip.is-highlighting .chip-remove:hover,
.chip.is-winner .chip-remove:hover { background: rgba(255, 255, 255, 0.18); color: #fff; }

/* Add form */
.add-form {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.add-input {
  flex: 1;
  padding: 13px 16px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 15px;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.add-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.add-input::placeholder { color: var(--text-muted); }
.btn-add {
  width: 48px;
  height: 48px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  transition: background-color 0.18s var(--ease), transform 0.15s var(--ease);
}
.btn-add:hover { background: var(--accent-hover); }
.btn-add:active { transform: scale(0.96); }

/* Bulk details */
.bulk-details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}
.bulk-details summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
  list-style: none;
  transition: background-color 0.18s var(--ease);
}
.bulk-details summary::-webkit-details-marker { display: none; }
.bulk-details summary:hover { background: var(--surface-2); }
.bulk-details summary svg {
  transition: transform 0.25s var(--ease);
}
.bulk-details[open] summary svg { transform: rotate(180deg); }
.bulk-body {
  padding: 4px 16px 16px;
}
.bulk-help {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.bulk-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  resize: vertical;
  min-height: 100px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.bulk-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.bulk-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* Settings row */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
  flex-wrap: wrap;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
}
.check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* History */
.history-section { padding: 40px 20px 16px; }
.history-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.history-list {
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14.5px;
  animation: slideIn 0.25s var(--ease);
}
.history-item:last-child { border-bottom: none; }
.history-item-value {
  font-family: var(--font-em);
  font-style: italic;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-item-time {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* FAQ */
.faq-section {
  padding: 56px 20px 40px;
}
.faq-section .section-title { margin-bottom: 18px; }
.faq-section details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
  transition: border-color 0.2s var(--ease);
}
.faq-section details[open] {
  border-color: var(--border-strong);
}
.faq-section summary {
  padding: 16px 48px 16px 18px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  position: relative;
  transition: background-color 0.18s var(--ease);
}
.faq-section summary::-webkit-details-marker { display: none; }
.faq-section summary:hover { background: var(--surface-2); }
.faq-section summary::after {
  content: "+";
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 22px;
  font-weight: 400;
  color: var(--accent);
  line-height: 1;
  transition: transform 0.25s var(--ease);
}
.faq-section details[open] summary::after {
  content: "−";
  transform: translateY(-50%) rotate(180deg);
}
.faq-section details p {
  padding: 0 18px 18px;
  color: var(--text-soft);
  font-size: 15px;
  line-height: 1.6;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 20px;
  text-align: center;
  margin-top: 40px;
}
.site-footer p {
  font-family: var(--font-em);
  font-style: italic;
  color: var(--text-muted);
  font-size: 14px;
}

/* Mobile */
@media (max-width: 540px) {
  .hero { padding-top: 36px; }
  .hero-sub { font-size: 16px; }
  .result-card { padding: 28px 18px; min-height: 140px; }
  .btn-primary { padding: 14px 26px; font-size: 15px; }
  .modes-section { padding-top: 20px; }
  .options-section { padding-top: 32px; }
  .settings-row { align-items: flex-start; flex-direction: column; }
  .chip-text { max-width: 180px; }
}

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

.site-footer .footer-sub {
  font-size: 12.5px;
  margin-top: 6px;
  opacity: 0.75;
}
