:root {
  --bg: #f7f3ee; --card: #fff; --ink: #2b2522; --muted: #7a6f68; --line: #e7ddd3;
  --red: #b3262e; --red-dark: #8e1c23; --green: #2f6b45; --gold: #b8892b;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(60,30,10,.06);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1b1716; --card: #26201e; --ink: #f1e9e2; --muted: #a99d95; --line: #3a312d;
          --red: #d6464e; --red-dark: #b3262e; --green: #5aa676; --gold: #d8ab4a; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--red); }
h1, h2, h3 { line-height: 1.2; margin: .2em 0 .5em; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 18px; }
main.wrap { padding-top: 24px; padding-bottom: 40px; min-height: 70vh; }

.topbar { background: var(--red); color: #fff; box-shadow: 0 2px 0 var(--red-dark); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 700; font-size: 1.2rem; text-decoration: none; }
.topbar nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topbar nav a, .topbar .linkbtn { color: #fff; text-decoration: none; opacity: .92; }
.topbar nav a:hover, .topbar .linkbtn:hover { opacity: 1; text-decoration: underline; }
.langs a { font-size: .8rem; margin-left: 4px; padding: 1px 5px; border-radius: 4px; }
.langs a.active { background: rgba(255,255,255,.2); }

.footer { color: var(--muted); font-size: .85rem; padding: 20px 18px 30px; text-align: center; }

.box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin: 0 0 18px; box-shadow: var(--shadow); }
.box.highlight { border-color: var(--gold); }
.box.danger { border-color: rgba(179,38,46,.35); }
.narrow { max-width: 460px; margin-left: auto; margin-right: auto; }
.center { text-align: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } }

.hero { text-align: center; padding: 30px 0 20px; }
.hero h1 { font-size: 2.3rem; }
.hero p { color: var(--muted); max-width: 560px; margin: .5em auto 1em; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 26px; }
.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; color: inherit; text-decoration: none; box-shadow: var(--shadow); transition: transform .1s, border-color .1s; }
.card:hover { transform: translateY(-2px); border-color: var(--red); }
.card p { margin: .3em 0; }

.muted { color: var(--muted); } .small { font-size: .87rem; } .right { text-align: right; }
.tag { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 99px; background: var(--line); color: var(--ink); vertical-align: middle; white-space: nowrap; }
.tag-green { background: rgba(47,107,69,.15); color: var(--green); }
.tag-gold { background: rgba(184,137,43,.18); color: var(--gold); }

label { display: block; margin: 0 0 12px; font-weight: 500; font-size: .95rem; }
input, textarea, select { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px; }
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(179,38,46,.35); border-color: var(--red); }
label.check, label.radio { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
label.check input, label.radio input { width: auto; margin-top: 5px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 12px; padding: 8px 14px 2px; }
legend { font-weight: 500; padding: 0 6px; }

.btn { display: inline-block; background: var(--red); color: #fff; border: 0; border-radius: 9px; padding: 9px 16px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--red-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn-ghost:hover { background: rgba(179,38,46,.08); }
.btn-gold { background: var(--gold); } .btn-gold:hover { filter: brightness(.92); background: var(--gold); }
.btn-danger { background: #8e1c23; }
.btn-big { font-size: 1.15rem; padding: 13px 26px; }
.btn-small { padding: 4px 10px; font-size: .88rem; }
.linkbtn { background: none; border: 0; padding: 0 4px; font: inherit; color: var(--red); cursor: pointer; }
.danger-text { color: var(--red); }
form.inline { display: inline; }

.flash { padding: 11px 15px; border-radius: 10px; margin-bottom: 14px; border: 1px solid var(--line); background: var(--card); }
.flash-success { border-color: var(--green); background: rgba(47,107,69,.1); }
.flash-error { border-color: var(--red); background: rgba(179,38,46,.1); }
.flash-info { border-color: var(--gold); background: rgba(184,137,43,.1); }

.group-head .meta { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); align-items: center; }
.group-head .desc { margin: 4px 0 18px; }
.hello { margin-top: 0; }

.draw { text-align: center; border: 2px solid var(--red); }
.draw .reveal { font-size: 1.15rem; }
.draw .reveal strong { font-size: 2.2rem; color: var(--red); display: inline-block; margin-top: 6px; }
.wishlist-view { text-align: left; background: var(--bg); padding: 12px 16px; border-radius: 10px; white-space: normal; word-break: break-word; }

.chat { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.msg { align-self: flex-start; max-width: 85%; background: var(--bg); border: 1px solid var(--line); padding: 7px 11px; border-radius: 12px 12px 12px 3px; word-break: break-word; }
.msg.mine { align-self: flex-end; background: rgba(179,38,46,.1); border-radius: 12px 12px 3px 12px; }
.msg span { display: block; font-size: .7rem; color: var(--muted); }
.chat-form { display: flex; gap: 8px; } .chat-form input { margin: 0; }

.copyrow { display: flex; gap: 8px; } .copyrow input { margin: 0; font-family: ui-monospace, monospace; font-size: .85rem; }
.people { columns: 2; padding-left: 20px; } @media (max-width: 600px) { .people { columns: 1; } }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .82rem; color: var(--muted); font-weight: 600; }
td.actions { white-space: nowrap; }
.tablewrap { overflow-x: auto; }
.pairs { padding-left: 20px; }
.pairform { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pairform select { width: auto; margin: 0; } .pairform label { margin: 0; }

.tabs { display: flex; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--red); border-color: var(--red); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-align: center; }
.stat b { display: block; font-size: 1.8rem; color: var(--red); } .stat span { color: var(--muted); font-size: .85rem; }
@media (max-width: 600px) { .stats { grid-template-columns: 1fr 1fr; } }
.searchrow { display: flex; gap: 8px; margin-bottom: 14px; } .searchrow input { margin: 0; }
details summary { cursor: pointer; font-weight: 500; }
.remind-row { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
