/* ============================================================
   Christmas List — single-page gift budget tracker
   ============================================================ */

:root {
  --pine-900: #08251c;
  --pine-800: #0f3a2b;
  --pine-700: #17553f;
  --pine-100: #e3ede6;
  --pine-050: #f1f6f2;
  --cream: #f7f2e7;
  --paper: #fffdf8;
  --ink: #182420;
  --ink-soft: #5b6a62;
  --line: #e3dbc9;
  --red-700: #a11f28;
  --red-050: #fbeceb;
  --amber-700: #8a5a0c;
  --amber-050: #fdf3dd;
  --gold: #b3873c;
  --ok-700: #2c6a46;
  --focus: #8a5f18;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 40, 30, .06);
  --shadow-md: 0 1px 2px rgba(16, 40, 30, .05), 0 14px 30px -18px rgba(16, 40, 30, .35);
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background:
    radial-gradient(1200px 420px at 50% -200px, rgba(23, 85, 63, .15), transparent 70%),
    var(--cream);
}

[hidden] { display: none !important; }

h1, h2, h3 { line-height: 1.2; }

button { font-family: inherit; color: inherit; cursor: pointer; }
a { color: var(--pine-700); }

input[type="text"],
input[type="search"],
input[type="number"],
input[type="date"],
select,
textarea {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  font-family: var(--font-body);
  font-size: .92rem;
  font-weight: 500;
  min-width: 0;
}

textarea { resize: vertical; font-weight: 400; }

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

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

/* ============================================================
   Top bar
   ============================================================ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 253, 248, .95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(1.2) blur(8px);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 20px 10px;
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 240px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(160deg, var(--pine-700), var(--pine-900));
  color: #f6e7c8;
  font-size: 1.05rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
}

.brand-text { min-width: 0; }

.brand-text h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2.4vw, 1.6rem);
  letter-spacing: .01em;
  color: var(--pine-900);
  overflow-wrap: anywhere;
}

.brand-sub {
  margin: 2px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  font-size: .78rem;
  color: var(--ink-soft);
}

.brand-sub .dot { opacity: .5; }

.budget-block { display: grid; gap: 4px; }

.field-label {
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.money-input {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.money-input > span { color: var(--ink-soft); font-weight: 700; }

.money-input input {
  width: 92px;
  padding: 8px 0;
  border: 0;
  background: transparent;
  font: 700 .98rem/1 var(--font-body);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.money-input input:focus-visible { outline: none; }

.money-input:focus-within,
.money-field:focus-within {
  border-color: var(--pine-700);
  box-shadow: 0 0 0 3px rgba(23, 85, 61, .14);
}

.stats {
  display: flex;
  gap: 22px;
  margin: 0;
}

.stats dt {
  font-size: .64rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.stats dd {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--pine-900);
  font-variant-numeric: tabular-nums;
}

.stats dd.neg { color: var(--red-700); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1;
  text-decoration: none;
}

.icon-btn:hover { background: var(--pine-050); color: var(--pine-800); }

.icon-btn.danger:hover { background: var(--red-050); color: var(--red-700); }

.progress-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.progress {
  flex: 1 1 200px;
  height: 8px;
  border-radius: 999px;
  background: var(--pine-100);
  overflow: hidden;
}

.progress-label {
  margin: 0;
  font-size: .78rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ============================================================
   Banner
   ============================================================ */

.banner-slot {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 20px 0;
}

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid;
  border-radius: 12px;
  font-size: .9rem;
}

.banner.warn { background: var(--amber-050); border-color: #ecd7a4; color: #6c470a; }
.banner.over { background: var(--red-050); border-color: #efc3c0; color: #7f1a20; }
.banner strong { font-weight: 700; }

.banner-close {
  flex: 0 0 auto;
  padding: 2px 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font-size: 1rem;
  opacity: .75;
}

.banner-close:hover { opacity: 1; background: rgba(0, 0, 0, .05); }

/* ============================================================
   Main layout
   ============================================================ */

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 20px 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.search-wrap { flex: 1 1 240px; }
.search-wrap input { width: 100%; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: .84rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.chip:hover { border-color: #cdd9cf; }

.chip[aria-pressed="true"] {
  background: var(--pine-800);
  border-color: var(--pine-800);
  color: #fdfaf0;
}

.sort-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.sort-wrap select { padding: 8px 10px; font-size: .84rem; }

.result-count {
  margin: 0 0 10px;
  font-size: .78rem;
  color: var(--ink-soft);
}

.group-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  margin: -2px 0 12px;
  padding: 9px 12px;
  border: 1px solid #e2ebe3;
  border-radius: 10px;
  background: var(--pine-050);
  font-size: .8rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.group-summary strong { color: var(--pine-900); font-size: .86rem; }
.group-summary .neg { color: var(--red-700); font-weight: 700; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: .9rem;
  font-weight: 650;
  transition: background .15s ease, border-color .15s ease, transform .06s ease;
}

.btn:hover { background: var(--pine-050); border-color: #cdd9cf; }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--pine-800);
  border-color: var(--pine-800);
  color: #fdfaf0;
}

.btn-primary:hover { background: var(--pine-700); border-color: var(--pine-700); }

.btn-ghost { border-style: dashed; background: transparent; }

.btn-danger-ghost {
  color: var(--red-700);
  border-color: #e6c3c0;
  background: #fff;
}

.btn-danger-ghost:hover { background: var(--red-050); border-color: #d9a8a3; }

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--pine-700);
  font-size: inherit;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-btn:hover { color: var(--pine-900); }

.mini { font-size: .76rem; color: var(--ink-soft); }

.hint {
  margin: 0;
  font-size: .82rem;
  color: var(--ink-soft);
}

/* ============================================================
   Cards
   ============================================================ */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 14px;
}

.card {
  display: grid;
  gap: 10px;
  padding: 15px 15px 13px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .18s ease, border-color .18s ease;
}

.card:hover { box-shadow: var(--shadow-md); }
.card.is-over { border-color: #e4b7b2; }
.card.is-bought { background: linear-gradient(180deg, #fffdf8, #f4f8f2); }

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.card-title {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.card-title h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.14rem;
  color: var(--pine-900);
  overflow-wrap: anywhere;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.card-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }

.tag {
  padding: 2px 7px;
  border: 1px solid #d9e5db;
  border-radius: 999px;
  background: var(--pine-050);
  color: #4f6157;
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.badge {
  padding: 2px 7px;
  border: 1px solid;
  border-radius: 999px;
  font-size: .64rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.badge-red { color: #8a1c22; background: var(--red-050); border-color: #efc9c6; }
.badge-amber { color: #7a4f0b; background: var(--amber-050); border-color: #eedaae; }
.badge-green { color: #1f5a38; background: #e8f3ea; border-color: #c6e0cb; }

.gift-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #e0e9e1;
  border-radius: 11px;
  background: var(--pine-050);
  text-align: left;
}

.gift-row:hover { border-color: #c3d6c8; background: #eaf2eb; }

.gift-name {
  font-size: .92rem;
  font-weight: 600;
  color: var(--pine-900);
  overflow-wrap: anywhere;
}

.gift-name.muted { color: var(--ink-soft); font-weight: 500; font-style: italic; }

.gift-price {
  flex: 0 0 auto;
  font-size: .86rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  white-space: nowrap;
}

.meter {
  height: 6px;
  border-radius: 999px;
  background: var(--pine-100);
  overflow: hidden;
}

.meter-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--pine-700);
  transition: width .3s cubic-bezier(.2, .7, .3, 1);
}

.meter-fill.warn { background: #c2872a; }
.meter-fill.over { background: var(--red-700); }

.meter-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: -2px 0 0;
  font-size: .78rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.meter-label .neg { color: var(--red-700); font-weight: 700; }
.meter-label .pos { color: var(--ok-700); font-weight: 600; }

.card-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 9px;
  border-top: 1px solid #efe9db;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .84rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.check input { width: 16px; height: 16px; accent-color: var(--pine-700); }
.check input:disabled { opacity: .4; cursor: not-allowed; }

.card-foot .link-btn { margin-left: auto; font-size: .84rem; }

.empty {
  padding: 48px 20px;
  border: 1px dashed #d8cfba;
  border-radius: 16px;
  background: rgba(255, 253, 248, .6);
  text-align: center;
}

.empty h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--pine-900);
}

.empty p { margin: 0; font-size: .92rem; color: var(--ink-soft); }

/* ============================================================
   Footer
   ============================================================ */

.page-foot {
  max-width: 1180px;
  margin: 26px auto 0;
  padding: 18px 20px 0;
  border-top: 1px solid rgba(227, 219, 201, .8);
  font-size: .82rem;
  color: var(--ink-soft);
}

.page-foot p { margin: 0 0 4px; }
.page-foot .mini { font-size: .76rem; }

/* ============================================================
   Dialogs
   ============================================================ */

.dialog {
  margin: auto;
  padding: 0;
  border: 0;
  max-width: none;
  max-height: none;
  background: transparent;
}

.dialog::backdrop {
  background: rgba(8, 30, 22, .48);
  backdrop-filter: blur(2px);
}

.dialog-shell {
  width: min(700px, calc(100vw - 24px));
  max-height: min(88vh, 940px);
  overflow: auto;
  background: var(--paper);
  border: 1px solid #d9d0bd;
  border-radius: 18px;
  box-shadow: 0 30px 80px -30px rgba(8, 30, 22, .6);
}

.dialog-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.dialog-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--pine-900);
  overflow-wrap: anywhere;
}

.dialog-body {
  display: grid;
  gap: 14px;
  padding: 18px 20px 20px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field input,
.field textarea {
  font-size: .92rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.field.full { grid-column: 1 / -1; }

.cap-summary {
  display: grid;
  gap: 7px;
  padding: 11px 12px;
  background: var(--pine-050);
  border: 1px solid #e2ebe3;
  border-radius: 12px;
}

.ideas { display: grid; gap: 10px; }

.ideas-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.ideas-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--pine-900);
}

.idea-list { display: grid; gap: 10px; }

.idea {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.idea.is-chosen {
  border-color: #d9bd83;
  background: linear-gradient(180deg, #fffdf6, #fdf6e4);
}

.idea.is-bought { box-shadow: inset 0 0 0 1px #cfe3d4; }

.star-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: #a3926f;
  font-size: 1.05rem;
  line-height: 1;
}

.star-btn:hover { border-color: #dfc48a; background: #fffaf0; }

.star-btn[aria-pressed="true"] {
  color: #8a6219;
  background: #fdf2d5;
  border-color: #dfc48a;
}

.idea-main { display: grid; gap: 6px; min-width: 0; }

.idea-meta {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 6px;
}

.idea-sub {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.money-field {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.money-field > span { color: var(--ink-soft); font-size: .9rem; font-weight: 700; }

.money-field input {
  width: 100%;
  padding: 9px 0;
  border: 0;
  background: transparent;
}

.money-field input:focus-visible { outline: none; }

.idea-side { display: grid; gap: 6px; justify-items: end; }

.dialog-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
}

.empty-inline {
  margin: 0;
  padding: 14px;
  border: 1px dashed #d8cfba;
  border-radius: 12px;
  color: var(--ink-soft);
  font-size: .88rem;
  text-align: center;
}

.data-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}

.data-actions .btn { justify-content: center; }

/* ============================================================
   Toast
   ============================================================ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 100;
  max-width: min(90vw, 480px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--pine-900);
  color: #f6f1e3;
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .5);
  font-size: .86rem;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 16px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

.noscript {
  margin: 40px auto;
  max-width: 480px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  text-align: center;
}

/* ============================================================
   Print
   ============================================================ */

.print-area { display: none; }

.print-head h1 {
  margin: 0 0 4px;
  font-family: var(--font-display);
}

.print-head p { margin: 0; font-size: 10.5pt; }

.print-table {
  width: 100%;
  margin-top: 14px;
  border-collapse: collapse;
  font-size: 10.5pt;
}

.print-table th,
.print-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #ccc;
  text-align: left;
  vertical-align: top;
}

.print-table thead th { border-bottom: 2px solid #333; }
.print-table .num { text-align: right; white-space: nowrap; }
.print-table tfoot td { font-weight: 700; }

.print-foot { margin-top: 14px; font-size: 9pt; color: #555; }

@media print {
  body { background: #fff; }
  .app-shell,
  .toast,
  .dialog,
  .noscript { display: none !important; }
  .print-area { display: block; }
  @page { margin: 16mm; }
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 760px) {
  .topbar { position: static; }

  .topbar-inner { gap: 12px; padding: 12px 16px 8px; }

  .stats { gap: 16px; }
  .stats dd { font-size: .92rem; }

  .progress-wrap { padding: 0 16px 10px; }

  .banner-slot,
  .page,
  .page-foot { padding-left: 16px; padding-right: 16px; }

  .grid { grid-template-columns: 1fr; }

  .search-wrap { flex-basis: 100%; }

  .toolbar .btn-primary { margin-left: auto; }

  .idea { grid-template-columns: auto minmax(0, 1fr); }

  .idea-side {
    grid-column: 2;
    grid-auto-flow: column;
    align-items: center;
    justify-content: space-between;
    justify-items: start;
  }

  .dialog-shell { width: calc(100vw - 16px); max-height: 92vh; }
  .dialog-body { padding: 16px; }
  .dialog-head { padding: 14px 16px; }
}

@media (max-width: 420px) {
  .budget-block { width: 100%; }
  .money-input input { width: 100%; }
  .money-input { width: 100%; }
  .toolbar .btn-primary { margin-left: 0; width: 100%; }
  .idea-sub { grid-template-columns: 1fr; }
}

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