:root {
  --bg: #0c0f1d;
  --surface: #141a2f;
  --surface-2: #1b2240;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f4efe3;
  --muted: #9aa1bb;
  --gold: #f2c14e;
  --gold-2: #ffdf8e;
  --gold-soft: rgba(242, 193, 78, 0.12);
  --ok: #5fd39a;
  --error: #ff7a7a;
  --radius: 18px;
  --display: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.wrap { width: min(960px, 100% - 32px); margin-inline: auto; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- Hero ---------- */

.hero {
  position: relative;
  overflow: hidden;
  padding: 56px 0 40px;
  background:
    radial-gradient(60% 120% at 85% 0%, rgba(242, 193, 78, 0.18), transparent 60%),
    radial-gradient(50% 90% at 0% 100%, rgba(110, 90, 255, 0.16), transparent 60%);
  border-bottom: 1px solid var(--line);
}

.sparkles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 30%, var(--gold-2), transparent),
    radial-gradient(1px 1px at 28% 70%, #fff, transparent),
    radial-gradient(2px 2px at 64% 22%, var(--gold), transparent),
    radial-gradient(1px 1px at 78% 62%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 90% 34%, var(--gold-2), transparent),
    radial-gradient(1px 1px at 46% 48%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 55% 85%, var(--gold-2), transparent);
  opacity: 0.8;
  animation: twinkle 4s ease-in-out infinite alternate;
}

@keyframes twinkle { from { opacity: 0.35; } to { opacity: 0.9; } }

@media (prefers-reduced-motion: reduce) {
  .sparkles { animation: none; }
  * { transition: none !important; }
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font: 600 clamp(2.6rem, 8vw, 4.2rem) / 1.02 var(--display);
  letter-spacing: -0.02em;
}
h1 em { font-style: italic; font-weight: 500; color: var(--gold); }

.lede { margin: 14px 0 0; max-width: 36ch; color: var(--muted); font-size: 1.05rem; }

/* ---------- Tabs ---------- */

.tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(12, 15, 29, 0.86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.tabs-inner { display: flex; gap: 4px; padding: 8px 0; overflow-x: auto; }
.tabs button {
  flex: 0 0 auto;
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
  transition: background 0.15s, color 0.15s;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { background: var(--gold); color: #1a1405; }

main { padding: 24px 0 120px; }

/* ---------- Cards & common ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin: 0 0 16px;
}
.card.flush { padding: 0; overflow: hidden; }

h2 { margin: 0 0 4px; font: 600 1.5rem/1.2 var(--display); }
.section-title { margin-top: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: transparent;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.05); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #1a1405; }
.btn.primary:hover:not(:disabled) { background: var(--gold-2); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.small { min-height: 38px; font-size: 0.9rem; }

.link {
  border: 0;
  background: none;
  padding: 4px 0;
  color: var(--gold);
  font-size: 0.9rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.note {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--gold-soft);
  color: var(--gold-2);
  font-size: 0.9rem;
}

.warn {
  margin: 0 0 16px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 122, 122, 0.35);
  background: rgba(255, 122, 122, 0.08);
  font-size: 0.92rem;
}
.warn strong { color: var(--error); }

/* ---------- Ki vagy? ---------- */

.who { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chip {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s;
}
.chip:hover { border-color: var(--gold); background: var(--gold-soft); }

.hello { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.hello p { margin: 0; font-size: 1.1rem; }

/* ---------- Pia kártyák ---------- */

.drinks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
  gap: 12px;
  margin-top: 16px;
}
@media (max-width: 460px) { .drinks { grid-template-columns: 1fr 1fr; gap: 10px; } }

.drink {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-height: 150px;
  padding: 14px;
  text-align: left;
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.drink:hover { border-color: var(--line-strong); }
.drink:active { transform: scale(0.98); }
.drink.on {
  border-color: var(--gold);
  background: linear-gradient(160deg, rgba(242, 193, 78, 0.16), rgba(242, 193, 78, 0.04) 70%), var(--surface);
  box-shadow: 0 0 0 4px rgba(242, 193, 78, 0.08);
}

.drink-top { display: flex; width: 100%; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.emoji { font-size: 1.9rem; line-height: 1; }
.tick {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  display: grid;
  place-items: center;
  transition: background 0.15s, border-color 0.15s;
}
.drink.on .tick { background: var(--gold); border-color: var(--gold); }
.drink.on .tick::after {
  content: "";
  width: 11px;
  height: 6px;
  margin-top: -3px;
  border: 2.5px solid #1a1405;
  border-top: 0;
  border-right: 0;
  transform: rotate(-45deg);
}

.drink-name { font-weight: 700; font-size: 1.08rem; }
.tag {
  display: inline-block;
  margin-left: 2px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  vertical-align: 2px;
}
.drink-price { font-size: 0.88rem; color: var(--muted); }
.drink-price b { color: var(--text); font-weight: 600; }
.drink.on .drink-price b { color: var(--gold-2); }
.drink-who { margin-top: auto; padding-top: 6px; font-size: 0.8rem; color: var(--muted); line-height: 1.35; }
.drink-who b { color: var(--text); font-weight: 600; }

/* ---------- Saját számla ---------- */

.bill { margin-top: 24px; border-color: rgba(242, 193, 78, 0.35); }
.bill-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.bill-head span { color: var(--muted); font-weight: 600; }
.bill-head strong { font: 600 2rem/1 var(--display); color: var(--gold); font-variant-numeric: tabular-nums; }
.lines { margin: 14px 0 0; padding-top: 10px; border-top: 1px dashed var(--line-strong); }
.lines div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 0.94rem; }
.lines dt { color: var(--muted); }
.lines dd { margin: 0; font-variant-numeric: tabular-nums; }

/* ---------- Összesítő ---------- */

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.stat span { display: block; color: var(--muted); font-size: 0.8rem; font-weight: 500; }
.stat strong { font: 600 1.35rem/1.25 var(--display); font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:first-child { grid-column: 1 / -1; }
}

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.grid { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.grid th, .grid td { padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid thead th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; font-size: 0.8rem; color: var(--muted); }
.grid .name { text-align: left; position: sticky; left: 0; z-index: 1; background: var(--surface); font-weight: 500; }
.grid thead .name { z-index: 2; background: var(--surface-2); }
.grid .c { text-align: center; padding-inline: 6px; }
.grid .c small { display: block; font-size: 0.7rem; color: var(--muted); font-weight: 500; }
.grid thead .c small { margin-top: 2px; }
.emoji-sm { font-size: 1.1rem; }
.grid .num { text-align: right; }
.grid .total { font-weight: 700; color: var(--gold); }
.grid tbody tr:hover td, .grid tbody tr:hover th { background: var(--surface-2); }
.grid tr.me th.name { color: var(--gold); }
.grid tr.me td, .grid tr.me th { background: rgba(242, 193, 78, 0.06); }
.grid tfoot th, .grid tfoot td { border-bottom: 0; border-top: 1px solid var(--line-strong); font-weight: 600; background: var(--surface-2); }
.grid tfoot .name { background: var(--surface-2); }
.dot { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; color: var(--muted); }
.dot.on { background: var(--gold); color: #1a1405; font-weight: 800; font-size: 0.8rem; }

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

/* ---------- Beállítások ---------- */

fieldset.card { min-width: 0; }
legend { padding: 0 6px; margin-left: -6px; font: 600 1.15rem var(--display); }

.field { display: grid; gap: 6px; margin-top: 14px; }
.field > span { font-weight: 600; font-size: 0.92rem; }
.field small { color: var(--muted); font-size: 0.82rem; }

input[type="text"], input:not([type]), input[type="number"], input[type="password"] {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  transition: border-color 0.15s;
}
input:focus { border-color: var(--gold); outline: none; }
input[type="number"] { font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.money { position: relative; display: block; }
.money input { padding-right: 36px; text-align: right; }
.money span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 0.85rem; pointer-events: none; }
.field .money { max-width: 260px; }

.rows { display: grid; gap: 8px; margin: 14px 0; }
.row { display: grid; gap: 8px; align-items: center; }
.row.head { font-size: 0.75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.drink-row { grid-template-columns: 52px minmax(0, 1fr) minmax(0, 150px) 56px 40px; }
.person-row { grid-template-columns: minmax(0, 1fr) minmax(0, 150px) 40px; }
.row.head > span:nth-child(4) { text-align: center; }
.emoji-in { text-align: center; padding: 0 4px !important; }

.check { display: grid; place-items: center; height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--gold); cursor: pointer; }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
}
.icon-btn:hover { color: var(--error); border-color: rgba(255, 122, 122, 0.35); }

@media (max-width: 520px) {
  .drink-row { grid-template-columns: 44px minmax(0, 1fr) 40px 36px; }
  .drink-row .money { grid-column: 2 / 3; grid-row: 2; }
  .drink-row.head { display: none; }
  .drink-row { padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .drink-row .check { grid-column: 3; grid-row: 1; }
  .drink-row .icon-btn { grid-column: 4; grid-row: 1; }
  .person-row { grid-template-columns: minmax(0, 1fr) 120px 36px; }
}

.savebar {
  position: sticky;
  bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 12px 12px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: rgba(20, 26, 47, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}
.savebar.dirty { border-color: var(--gold); }
.savebar.dirty > span { color: var(--gold-2); }
.savebar > div { display: flex; gap: 8px; }

/* ---------- Toast ---------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 12px;
  background: #fff;
  color: #111;
  font-weight: 600;
  font-size: 0.92rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--error); color: #2a0707; }
#toast.ok { background: var(--ok); color: #05210f; }

/* ---------- Szobakód ---------- */

.gate { max-width: 420px; margin: 8px auto 0; display: grid; gap: 12px; }
.gate h2 { margin: 0; }
.gate p { margin: 0; }
.gate input {
  min-height: 52px;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}
.gate input::placeholder { letter-spacing: 0.04em; font-weight: 400; text-transform: none; color: var(--muted); opacity: 0.6; }
.gate-error { min-height: 1.4em; color: var(--error); font-size: 0.9rem; font-weight: 500; }
.gate-error:empty { min-height: 0; }

/* ---------- Mentési állapot ---------- */

.title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.sync {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}
.sync::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.sync.ok::before { background: var(--ok); }
.sync.busy { color: var(--gold-2); }
.sync.busy::before { animation: pulse 0.9s ease-in-out infinite alternate; }
.sync.error { color: var(--error); font-weight: 700; }
@keyframes pulse { from { opacity: 0.3; } to { opacity: 1; } }
@media (max-width: 400px) { .tabs button { padding: 8px 12px; font-size: 0.9rem; } }

/* ---------- Napló ---------- */

.history { margin-top: 24px; }
.log { list-style: none; margin: 14px 0 0; padding: 0; max-height: 320px; overflow-y: auto; }
.log li {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 12px;
  padding: 8px 0 8px 12px;
  border-left: 2px solid var(--line-strong);
  font-size: 0.9rem;
}
.log li.add { border-left-color: var(--gold); }
.log li.remove { border-left-color: rgba(255, 122, 122, 0.6); }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.82rem; }
.log b { font-weight: 600; }
@media (max-width: 460px) { .log li { grid-template-columns: 1fr; gap: 0; } }

/* ---------- Törölt elemek ---------- */

.archived { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.archived li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 8px 8px 14px;
  border-radius: 12px;
  border: 1px dashed var(--line-strong);
}
