:root {
  --bg: #f6f5f3;
  --surface: #ffffff;
  --surface-2: #f1efec;
  --text: #1d1b1a;
  --muted: #6f6a66;
  --line: #e4e0db;
  --red: #7a1424;
  --red-600: #8f1a2c;
  --red-50: #f7ecee;
  --green: #2f6b4f;
  --green-50: #e9f2ed;
  --amber: #8a5a12;
  --amber-50: #f8f0e2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 10, 10, .04), 0 4px 16px rgba(20, 10, 10, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
.muted { color: var(--muted); }
a { color: var(--red); }

/* Buttons */
.btn {
  font: inherit; font-weight: 600; font-size: .92rem;
  border: 1px solid transparent; border-radius: 10px;
  padding: .6rem 1rem; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--red-600); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-outline { background: var(--surface); border-color: var(--red); color: var(--red); }
.btn-outline:hover:not(:disabled) { background: var(--red-50); }
.btn-sm { padding: .4rem .75rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; font-size: .82rem; cursor: pointer; }

/* Fields */
.field { display: flex; flex-direction: column; gap: .35rem; font-size: .85rem; font-weight: 500; }
.field em { font-style: normal; color: var(--muted); font-weight: 400; }
input, select, textarea {
  font: inherit; font-size: .95rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: .6rem .75rem; width: 100%;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .tab:focus-visible, .chip-btn:focus-visible {
  outline: 2px solid var(--red); outline-offset: 1px; border-color: var(--red);
}
.error { color: var(--red); font-size: .88rem; margin: 0; }
.error.banner { background: var(--red-50); border: 1px solid #e8cfd3; padding: .75rem 1rem; border-radius: 10px; margin-top: 1rem; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 500px at 50% -10%, var(--red-50), transparent 70%), var(--bg); }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 2rem 1.75rem; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 1rem;
}
.login-card h1 { font-size: 1.6rem; }
.login-card h1 span, .brand span { color: var(--red); }
.login-card p.muted { margin: -.5rem 0 .25rem; font-size: .92rem; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; background: var(--red);
  position: relative; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; background: #fff; opacity: .9; }
.brand-mark::before { left: 18px; top: 0; bottom: 0; width: 4px; }
.brand-mark::after { top: 14px; left: 0; right: 0; height: 4px; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-inner { max-width: 960px; margin: 0 auto; padding: .8rem 16px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { font-weight: 700; display: flex; align-items: center; gap: .55rem; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); }
.user { display: flex; align-items: center; gap: .75rem; font-size: .9rem; }

.container { max-width: 960px; margin: 0 auto; padding: 1.5rem 16px 4rem; }

/* Metrics */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-bottom: 1.5rem; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.metric .label { font-size: .78rem; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.metric .value { font-size: 1.5rem; font-weight: 700; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.metric .sub { font-size: .8rem; color: var(--muted); margin-top: .15rem; }
.metric.accent { background: var(--red); border-color: var(--red); color: #fff; }
.metric.accent .label, .metric.accent .sub { color: rgba(255,255,255,.78); }
.bar { height: 6px; background: rgba(255,255,255,.25); border-radius: 99px; margin-top: .6rem; overflow: hidden; }
.bar > span { display: block; height: 100%; background: #fff; border-radius: 99px; }

/* Tabs */
.tabs { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 1.25rem; }
.tab { font: inherit; font-weight: 600; font-size: .9rem; border: 0; background: transparent; color: var(--muted);
  padding: .5rem 1rem; border-radius: 9px; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.card h2 { font-size: 1.05rem; margin-bottom: .2rem; }
.card .hint { font-size: .85rem; color: var(--muted); margin: 0 0 1rem; }

.form-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: .75rem; }
.col-6 { grid-column: span 6; } .col-4 { grid-column: span 4; } .col-3 { grid-column: span 3; } .col-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.price-input { position: relative; }
.price-input::before { content: "$"; position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .95rem; }
.price-input input { padding-left: 1.6rem; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin: .5rem 0 .75rem; }
.section-head h2 { font-size: 1.05rem; }
.section-head .muted { font-size: .85rem; }

/* Items */
.items { display: flex; flex-direction: column; gap: .6rem; }
.item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem;
  display: flex; gap: 1rem; align-items: flex-start; justify-content: space-between; }
.item-main { min-width: 0; flex: 1; }
.item-title { font-size: 1rem; font-weight: 600; overflow-wrap: anywhere; }
.item-meta { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-top: .4rem; }
.price { font-weight: 700; font-variant-numeric: tabular-nums; margin-right: .2rem; }
.chip, .tag { font-size: .75rem; font-weight: 600; padding: .18rem .55rem; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.tag-high { background: var(--red-50); color: var(--red); }
.tag-low { background: var(--green-50); color: var(--green); }
.tag-optional { background: var(--amber-50); color: var(--amber); }
.item-note { margin: .55rem 0 0; font-size: .88rem; color: var(--muted); background: var(--surface-2); padding: .45rem .65rem; border-radius: 8px; overflow-wrap: anywhere; white-space: pre-wrap; }
.item-link { display: inline-block; margin-top: .5rem; font-size: .85rem; font-weight: 600; text-decoration: none; }
.item-link:hover { text-decoration: underline; }
.item-actions { display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; flex-shrink: 0; }
.item.is-bought { background: #fbfaf9; }
.item.is-bought .item-title { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(0,0,0,.25); }
.bought-badge { font-size: .8rem; font-weight: 600; color: var(--green); background: var(--green-50); padding: .3rem .65rem; border-radius: 99px; white-space: nowrap; }
.bought-badge.mine { color: #fff; background: var(--green); }

.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; border: 1px dashed var(--line); border-radius: var(--radius); font-size: .92rem; }

/* People */
.people { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.25rem; }
.chip-btn { font: inherit; font-size: .88rem; font-weight: 600; background: var(--surface); border: 1px solid var(--line);
  border-radius: 99px; padding: .45rem .9rem; cursor: pointer; display: inline-flex; gap: .45rem; align-items: center; color: var(--text); }
.chip-btn .count { font-size: .75rem; color: var(--muted); font-weight: 500; }
.chip-btn[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: #fff; }
.chip-btn[aria-pressed="true"] .count { color: rgba(255,255,255,.8); }
.my-spend { font-size: .88rem; color: var(--muted); margin: -.5rem 0 1rem; }
.my-spend strong { color: var(--text); }

/* Surprise gifts */
.surprise-section { margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.surprise-section .section-head { align-items: center; }
.surprise-section .hint { font-size: .85rem; color: var(--muted); margin: -.4rem 0 .9rem; }
.item.is-surprise { border-color: #e8cfd3; background: linear-gradient(0deg, var(--surface), var(--surface)) padding-box, var(--red-50); border-left: 3px solid var(--red); }
.surprise-badge { font-size: .8rem; font-weight: 600; color: var(--red); background: var(--red-50); padding: .3rem .65rem; border-radius: 99px; white-space: nowrap; }
.surprise-badge.mine { color: #fff; background: var(--red); }
.chip-btn .gift { font-size: .75rem; font-weight: 600; }
.action-row { display: flex; gap: .6rem; align-items: center; }

/* Photos */
.item-body { display: flex; gap: .9rem; flex: 1; min-width: 0; align-items: flex-start; }
.item-thumb { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; flex-shrink: 0;
  background: var(--surface-2); border: 1px solid var(--line); cursor: zoom-in; }
.photo-row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.photo-preview { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); }
.photo-pick { display: inline-flex; align-items: center; cursor: pointer; }
.photo-msg { font-size: .82rem; font-weight: 400; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.photo-pick:focus-within { outline: 2px solid var(--red); outline-offset: 1px; }
.lightbox { padding: .75rem; cursor: zoom-out; text-align: center; }
.lightbox img { display: block; max-width: 100%; max-height: 75vh; margin: 0 auto; border-radius: 12px; }
.lightbox p { margin: .6rem 0 .1rem; font-weight: 600; font-size: .92rem; }

/* Dialog */
.dialog { border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.dialog::backdrop { background: rgba(25, 10, 12, .45); }
.dialog .card { margin: 0; border: 0; box-shadow: none; }

@media (max-width: 760px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric .value { font-size: 1.25rem; }
  .form-grid > * { grid-column: span 6; }
  .form-grid > .col-3, .form-grid > .col-2 { grid-column: span 3; }
  .item { flex-direction: column; }
  .item-actions { flex-direction: row; align-items: center; flex-wrap: wrap; }
  .tabs { display: flex; }
  .tab { flex: 1; }
  #hello { display: none; }
}
