/* Christmas Gift Tracker — hosted build. Dark green theme. */
* { box-sizing: border-box; }
:root {
  --page-bg: #101b16;
  --panel: #1a2921;
  --titlebar: #15221c;
  --row: #16241d;
  --row-expanded: #1c2f26;
  --text: #e8f0ea;
  --muted: #9db3a4;
  --border: #2c4234;
  --accent: #7fb98e;
  --green: #2f9e5f;
  --green-dark: #1d6b40;
  --blue: #2b5ea7;
  --blue-dark: #16294d;
  --blue-cell: #1d3a6e;
  --grey: #5a6b60;
  --red: #d45a5a;
  --maroon: #8e2f3c;
  --gold: #d9a441;
  --yellow: #e8d44d;
}
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page-bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px; line-height: 1.4;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; padding: 0; }
input, select, textarea { font: inherit; color: var(--text); background: #0e1813; border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* ---------- login / setup ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 28px 24px; width: 100%; max-width: 380px; }
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.auth-card p { color: var(--muted); margin: 0 0 18px; }
.person-pick { display: flex; gap: 10px; margin-bottom: 14px; }
.person-pick button { flex: 1; padding: 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 16px; }
.person-pick button.sel { border-color: var(--accent); background: #22392b; }
.auth-card label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.auth-card input { width: 100%; padding: 10px; }
.stay { display: flex; align-items: center; gap: 8px; margin: 12px 0; color: var(--muted); font-size: 14px; }
.stay input { width: auto; accent-color: var(--green); }
.big-btn { width: 100%; padding: 12px; background: var(--green-dark); border-radius: 8px; font-size: 16px; margin-top: 6px; }
.big-btn:disabled { opacity: .5; }
.err { color: #ff9a9a; min-height: 18px; font-size: 13px; margin-top: 8px; }

/* ---------- header & top controls ---------- */
.topbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; background: var(--panel); border-bottom: 1px solid var(--border); }
.topbar .who { font-weight: 600; }
.topbar .switch { color: var(--accent); font-size: 13px; text-decoration: underline; }
.topbar .spacer { flex: 1; }
.topbar select { background: var(--panel); }
.icon-btn { font-size: 20px; padding: 4px 6px; border-radius: 6px; }
.icon-btn:hover { background: #22392b; }
.check-line1 { padding: 10px 12px 0; }
.check-line1 button { width: 100%; padding: 10px; background: var(--green-dark); border-radius: 8px; font-size: 15px; }
.check-line1 button:disabled { opacity: .6; }
.sticky-line2 {
  position: sticky; top: 0; z-index: 20; display: flex; gap: 8px; align-items: center;
  padding: 8px 12px; background: var(--page-bg); border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.sticky-line2 select { font-size: 14px; padding: 5px 6px; background: var(--panel); }
.sticky-line2 select .x-red { color: var(--red); }
#secretMode.hiding { color: var(--green); }
#secretMode.partner { color: #c98a8a; }
#secretMode.all { color: #ff8fa0; }
main { max-width: 860px; margin: 0 auto; padding: 0 12px 40px; }

/* ---------- person sections & budget bubble ---------- */
.person { margin-top: 18px; }
.person > h2 { margin: 0 0 8px; font-size: 19px; display: flex; align-items: center; gap: 8px; }
.budget-bubble { border: 1px solid var(--border); border-radius: 10px; background: var(--panel); padding: 18px 12px 6px; margin-bottom: 10px; }
.budget-bar { height: 12px; border-radius: 6px; background: #0e1813; overflow: hidden; position: relative; }
.budget-bar .spent { position: absolute; left: 0; top: 0; bottom: 0; background: var(--green); border-radius: 6px; }
.budget-bar .over { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(90deg, var(--maroon) 0 4px, transparent 4px 8px); border-radius: 6px; }
.budget-line { display: flex; justify-content: space-between; margin-top: 11px; font-size: 14px; }
.budget-line b { font-weight: 600; }
.budget-line .left-amt { color: var(--muted); }

/* ---------- gift table ---------- */
.gift-table { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--panel); }
.titlebar { display: flex; align-items: center; background: var(--titlebar); padding: 8px 6px; font-size: 12px; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.titlebar .add { font-size: 20px; color: var(--text); padding: 2px 8px; border-radius: 6px; line-height: 1; }
.titlebar .add.open { background: var(--yellow); color: #222; }
.titlebar .col-gift { flex: 1; padding-left: 10px; }
.titlebar .col-bought { width: 132px; text-align: center; }
.titlebar .col-price { width: 92px; text-align: right; padding-right: 8px; }

.gift { border-top: 1px solid var(--border); background: var(--row); }
.gift.status-bought { background: #1d3325; }
.gift.status-considering { background: var(--blue-dark); }
.gift.status-passed, .gift.status-family { background: #232a26; }
.gift.status-family.fam-purchased { background: #1d3325; }
.gift.status-family.fam-asked { background: #3a3413; }
.gift.expanded { background: var(--row-expanded); }
.gift.status-bought.expanded { background: #24402e; }
.gift.status-considering.expanded { background: #1d3358; }

.gift-row { display: flex; align-items: flex-start; padding: 8px 6px; gap: 2px; cursor: pointer; }
.gift-row.dragging-src { opacity: .35; }
.handle-col { width: 23px; flex: none; display: flex; flex-direction: column; align-items: center; padding-top: 2px; }
.handle { cursor: grab; touch-action: none; color: var(--muted); font-size: 16px; padding: 2px 4px; }
.handle:active { cursor: grabbing; }
.pencil { color: var(--muted); font-size: 15px; padding: 2px 4px; margin-top: 2px; }
.pencil.notes-open { color: var(--yellow); }
.pencil.has-notes::after { content: "📝"; font-size: 11px; position: absolute; margin-left: -2px; margin-top: -6px; }
.occ-col { width: 40px; flex: none; text-align: center; padding-top: 1px; }
.occ { font-size: 20px; line-height: 1.15; background: none; }
.occ.grey { filter: grayscale(1); opacity: .55; }
.occ .stack { display: flex; flex-direction: column; align-items: center; gap: 7px; font-size: 20px; line-height: 1; padding-top: 5px; }
.gift-title { flex: 1; min-width: 0; padding: 0 6px 0 4px; }
.gift-title .t { font-weight: 500; overflow-wrap: anywhere; }
.gift-title .sub { font-size: 12px; color: var(--muted); }
.gift-title .secret-tag { color: var(--gold); font-size: 12px; }
.status-box { width: 132px; flex: none; display: flex; justify-content: center; gap: 2px; }
.status-box button { width: 30px; height: 30px; font-size: 16px; border-radius: 6px; border: 1px solid transparent; background: rgba(255,255,255,.05); }
.status-box button:hover { background: rgba(255,255,255,.12); }
.status-box button.sel-bought { background: var(--green); color: #fff; }
.status-box button.sel-passed { background: var(--red); color: #fff; }
.status-box button.sel-considering { background: var(--blue-cell); color: #fff; }
.status-box button.sel-family { background: var(--grey); color: #fff; }
.status-box button.sel-family.purchased { background: var(--green); color: #fff; box-shadow: 0 0 0 2px #7fd6a4, 0 0 10px #7fd6a4; }
.status-box button.sel-family.asked { background: #a08c2e; color: #fff; }
.price-col { width: 92px; flex: none; text-align: right; padding-right: 8px; font-size: 14px; }
.price-col .was { display: block; font-size: 12px; color: var(--muted); }
.price-col .deal { color: #7fd6a4; }
.price-col .free { color: var(--muted); }

/* expanded detail */
.detail { padding: 4px 12px 14px 36px; border-top: 1px dashed var(--border); font-size: 14px; }
.detail h3 { margin: 8px 0 4px; font-size: 16px; }
.detail .meta { color: var(--muted); font-size: 13px; margin: 2px 0; }
.detail .meta a { word-break: break-all; }
.detail .rowline { margin: 8px 0; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.occ-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.occ-btns button { border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-size: 13px; background: rgba(255,255,255,.04); }
.occ-btns button.sel { border-color: var(--accent); background: #22392b; }
.occ-btns button:disabled { opacity: .45; }
.family-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: rgba(255,255,255,.04); border-radius: 8px; padding: 8px; }
.family-row label { color: var(--muted); }
.family-row input { flex: 1; min-width: 90px; }
.delivery-pill { display: inline-flex; border: 1px solid var(--border); border-radius: 20px; padding: 4px 12px; font-size: 12px; letter-spacing: .04em; cursor: pointer; background: rgba(255,255,255,.05); }
.delivery-pill.on { background: var(--green-dark); }
.edit-line { color: var(--muted); font-size: 12px; margin: 10px 0 4px; }
.edit-line button { color: var(--accent); text-decoration: underline; font-size: 12px; }
.edit-form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.edit-form .full { grid-column: 1 / -1; }
.edit-form label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.edit-form input, .edit-form textarea, .edit-form select { width: 100%; }
.edit-form .actions { grid-column: 1 / -1; display: flex; gap: 8px; }
.edit-form .actions button { padding: 8px 14px; border-radius: 6px; background: var(--green-dark); }
.edit-form .actions button.ghost { background: rgba(255,255,255,.08); }

/* notes thread */
.notes { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; }
.notes h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.note { background: rgba(255,255,255,.04); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; }
.note .who { font-weight: 600; font-size: 13px; }
.note .when { color: var(--muted); font-size: 12px; margin-left: 6px; }
.note .body { margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
.note .q-badge { background: var(--gold); color: #221a05; font-size: 11px; font-weight: 700; border-radius: 4px; padding: 1px 6px; margin-left: 6px; }
.note .note-actions { margin-top: 4px; font-size: 12px; }
.note .note-actions button { color: var(--accent); margin-right: 10px; text-decoration: underline; }
.note-add { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.note-add textarea { min-height: 56px; resize: vertical; }
.note-add .row { display: flex; gap: 10px; align-items: center; }
.note-add .row label { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.note-add button { padding: 7px 14px; background: var(--green-dark); border-radius: 6px; }

/* add-gift form */
.add-form { border-top: 1px solid var(--border); background: var(--row-expanded); padding: 12px; }
.add-form h4 { margin: 0 0 8px; }

/* modals */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 20px; width: 100%; max-width: 380px; }
.modal h3 { margin: 0 0 8px; }
.modal p { color: var(--muted); margin: 0 0 14px; }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; }
.modal .row button { padding: 9px 16px; border-radius: 6px; background: var(--green-dark); }
.modal .row button.ghost { background: rgba(255,255,255,.08); }
.modal input { width: 100%; padding: 10px; text-align: center; font-size: 20px; letter-spacing: .3em; }

/* footer */
.legend { margin-top: 22px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--border); padding-top: 12px; }
.totals { margin-top: 14px; font-size: 14px; }
.hide-people { margin-top: 14px; font-size: 13px; color: var(--muted); }
.hide-people label { display: inline-flex; gap: 5px; align-items: center; margin-right: 12px; }
.settings-panel { position: fixed; right: 12px; bottom: 12px; z-index: 40; }
.settings-panel .key { font-size: 22px; background: var(--panel); border: 1px solid var(--border); border-radius: 50%; width: 44px; height: 44px; opacity: .75; }
.settings-panel .key:hover { opacity: 1; }
.settings-pop { position: fixed; right: 12px; bottom: 64px; z-index: 40; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px; width: min(340px, calc(100vw - 24px)); }
.settings-pop h3 { margin: 0 0 8px; font-size: 15px; }
.settings-pop label { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 3px; }
.settings-pop input { width: 100%; }
.settings-pop .row { display: flex; gap: 8px; margin-top: 10px; }
.settings-pop .row button { padding: 7px 12px; border-radius: 6px; background: var(--green-dark); }
.settings-pop .stamp { margin-top: 12px; font-size: 11px; color: var(--muted); }
.drag-clone { position: fixed; z-index: 100; pointer-events: none; opacity: .95; box-shadow: 0 10px 24px rgba(0,0,0,.5); border-radius: 8px; transform: scale(1.02); }

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .titlebar .col-bought { width: 96px; }
  .titlebar .col-price { width: 64px; }
  .titlebar .col-gift { padding-left: 15px; }
  .gift-row { padding-left: 6px; }
  .status-box { width: 96px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
  .status-box button { width: 100%; height: 28px; }
  .price-col { width: 64px; font-size: 13px; }
  .handle-col { padding-left: 5px; }
  .occ-col { width: 34px; }
  .occ { font-size: 18px; }
  .occ .stack { font-size: 18px; }
  .detail { padding-left: 12px; }
  .edit-form { grid-template-columns: 1fr; }
  .topbar { gap: 6px; }
}
