:root {
  --bg: #fffcf6;
  --surface: #ffffff;
  --surface-soft: #fdf7ec;
  --text: #1f2421;
  --muted: #5a655e;
  --border: #e9dfd1;
  --green: #1b6b47;
  --green-dark: #145236;
  --green-soft: #e8f5ee;
  --red: #c63d3d;
  --red-soft: #fdeeee;
  --gold: #d98c10;
  --gold-soft: #fff4d8;
  --shadow: 0 4px 18px rgba(31, 36, 33, 0.06);
  --radius: 16px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: ui-rounded, "Nunito", "Quicksand", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.48;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.hidden {
  display: none !important;
}

.container {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 16px;
}

.festive-ribbon {
  height: 7px;
  background: repeating-linear-gradient(
    90deg,
    #1b6b47 0 28px,
    #c63d3d 28px 56px,
    #e5a11a 56px 84px
  );
}

.hero {
  background: linear-gradient(180deg, #fff6e8 0%, #fffcf6 100%);
  padding: 22px 0 16px;
  border-bottom: 1px solid var(--border);
}

.hero-badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--green-dark);
  background: var(--green-soft);
  border: 1px solid #c6e3d3;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.55rem, 4.4vw, 2.2rem);
  line-height: 1.18;
  color: #163b2a;
}

.gratitude {
  margin: 0 0 14px;
  font-size: 1rem;
  color: var(--muted);
}

.note-callout {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--gold-soft);
  border: 1px solid #f0d799;
  border-left: 5px solid var(--gold);
  border-radius: 12px;
  padding: 11px 14px;
  margin-bottom: 12px;
}

.note-callout p {
  margin: 0;
  font-size: 0.96rem;
  color: #4f3808;
}

.note-icon {
  font-size: 1.15rem;
  line-height: 1.3;
  flex-shrink: 0;
}

.how-it-works {
  margin: 0 0 14px;
  font-size: 0.93rem;
  color: var(--muted);
}

.stats-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
}

.stat-needed {
  background: var(--red-soft);
  color: #8f2222;
  border: 1px solid #f5c6c6;
}

.stat-bought {
  background: var(--green-soft);
  color: var(--green-dark);
  border: 1px solid #bde0cc;
}

.stat-num {
  font-weight: 800;
  font-size: 0.96rem;
}

.refresh-btn {
  margin-left: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

.refresh-btn:hover {
  background: var(--surface-soft);
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 252, 246, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
}

.search-row {
  margin-bottom: 8px;
}

#search-input {
  width: 100%;
  padding: 10px 14px;
  font-size: 1rem;
  border: 1.5px solid #dccfbe;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

#search-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(27, 107, 71, 0.14);
}

.jump-pills {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.jump-pills::-webkit-scrollbar {
  display: none;
}

.jump-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.jump-pill:hover {
  background: var(--surface-soft);
  border-color: #cbbba5;
}

.jump-pill-count {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--muted);
}

.main-content {
  padding-top: 18px;
  padding-bottom: 48px;
}

.status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  margin-bottom: 18px;
}

.status-card.error {
  background: var(--red-soft);
  border-color: #f3bcbc;
  color: #8f2222;
}

.categories-grid {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.category-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  scroll-margin-top: 112px;
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}

.category-title-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
}

.category-emoji {
  font-size: 1.25rem;
}

.category-header h2 {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.25;
}

.count-badge {
  flex-shrink: 0;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: var(--text);
}

/* Colorful category headers */
.accent-emerald .category-header { background: #e8f6ee; border-left: 6px solid #1e7e52; }
.accent-amber .category-header { background: #fff3da; border-left: 6px solid #d48806; }
.accent-rose .category-header { background: #fdecef; border-left: 6px solid #cf3b5a; }
.accent-berry .category-header { background: #fbe9f1; border-left: 6px solid #b8326a; }
.accent-sky .category-header { background: #e8f3ff; border-left: 6px solid #1e73be; }
.accent-violet .category-header { background: #f2ecff; border-left: 6px solid #7242c9; }
.accent-teal .category-header { background: #e6f7f5; border-left: 6px solid #138a7c; }
.accent-indigo .category-header { background: #ebeffe; border-left: 6px solid #3c54c4; }

.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #f2ebe0;
  transition: background-color 0.14s ease;
}

.item-row:last-child {
  border-bottom: none;
}

.item-check-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.item-check-btn:hover {
  background: #faf5eb;
}

.item-check-btn:active {
  background: #f2eadc;
}

.checkbox-visual {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 2px solid #9bb0a3;
  background: #fff;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.item-check-btn:hover .checkbox-visual {
  border-color: var(--green);
  background: var(--green-soft);
}

.item-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.item-main-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.item-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.star-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.76rem;
  font-weight: 800;
  color: #7d4c00;
  background: #ffe8a3;
  border: 1px solid #f0c954;
  border-radius: 999px;
  padding: 2px 8px;
}

.item-note {
  font-size: 0.86rem;
  color: var(--muted);
}

.example-link {
  flex-shrink: 0;
  margin-right: 12px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #15589c;
  background: #ebf4ff;
  border: 1px solid #c3ddfb;
  padding: 6px 10px;
  border-radius: 999px;
  text-decoration: none;
  white-space: nowrap;
}

.example-link:hover {
  background: #dbeafe;
}

.category-done {
  padding: 16px;
  font-size: 0.94rem;
  color: var(--green-dark);
  background: #f5fbf7;
  margin: 0;
}

.purchased-section {
  margin-top: 26px;
  background: #f7f4ee;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  scroll-margin-top: 112px;
}

.purchased-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.purchased-header h2 {
  margin: 0 0 2px;
  font-size: 1.12rem;
  color: var(--green-dark);
}

.purchased-sub {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.purchased-badge {
  background: var(--green-soft);
  color: var(--green-dark);
  border-color: #bde0cc;
}

.purchased-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

@media (min-width: 640px) {
  .purchased-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.purchased-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid #e3dacb;
  border-radius: 11px;
  padding: 9px 12px;
}

.purchased-check {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--green);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 800;
  flex-shrink: 0;
}

.purchased-info {
  min-width: 0;
}

.purchased-name {
  font-size: 0.94rem;
  font-weight: 600;
  color: #4b574f;
  text-decoration: line-through;
}

.purchased-cat {
  font-size: 0.77rem;
  color: var(--muted);
}

.purchased-empty {
  margin: 4px 0 0;
  font-size: 0.92rem;
  color: var(--muted);
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 18px 0 36px;
  text-align: center;
  color: var(--muted);
  font-size: 0.86rem;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(18, 26, 21, 0.52);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
}

@media (min-width: 560px) {
  .modal-backdrop {
    align-items: center;
  }
}

.modal {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.modal-icon {
  font-size: 1.4rem;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.24rem;
  color: #163b2a;
}

.modal-item-box {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
  margin-bottom: 12px;
}

.modal-item-name {
  font-size: 1.04rem;
  font-weight: 700;
}

.modal-item-meta {
  font-size: 0.86rem;
  color: var(--muted);
  margin-top: 2px;
}

.modal-desc {
  margin: 0 0 14px;
  font-size: 0.92rem;
  color: var(--muted);
}

.field-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.optional-tag {
  font-weight: 500;
  color: var(--muted);
}

#buyer-name-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  border: 1.5px solid #d5c7b4;
  border-radius: 10px;
  margin-bottom: 12px;
}

#buyer-name-input:focus {
  outline: none;
  border-color: var(--green);
}

.modal-error {
  margin: 0 0 12px;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--red-soft);
  color: #8f2222;
  font-size: 0.88rem;
  font-weight: 600;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.btn {
  flex: 1;
  min-height: 46px;
  border-radius: 12px;
  font-size: 0.98rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
}

.btn-secondary {
  background: #efe9df;
  color: var(--text);
}

.btn-secondary:hover {
  background: #e5ddd0;
}

.btn-primary {
  background: var(--green);
  color: #fff;
}

.btn-primary:hover {
  background: var(--green-dark);
}

.btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 24px);
  background: #1b2820;
  color: #fff;
  padding: 11px 16px;
  border-radius: 999px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  font-size: 0.92rem;
}

.toast-undo {
  background: #ffd166;
  color: #1f2421;
  border: none;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.toast-undo:hover {
  background: #ffc33b;
}
