:root {
  --bg: #faf6ef;
  --card: #ffffff;
  --text: #2b2118;
  --muted: #7d6c5b;
  --line: #ece2d3;
  --accent: #c2620a;
  --accent-ink: #ffffff;
  --accent-soft: #fdf0dc;
  --hero: linear-gradient(160deg, #f6b445 0%, #e08a16 55%, #c2620a 100%);
  --hero-ink: #2a1703;
  --pos: #15803d;
  --neg: #c22c2c;
  --chip: #f3ece1;
  --shadow: 0 1px 2px rgba(60, 35, 10, .06), 0 4px 16px rgba(60, 35, 10, .05);
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17120d;
    --card: #221b14;
    --text: #f3e9dc;
    --muted: #a8988a;
    --line: #3a2f24;
    --accent: #f59e0b;
    --accent-ink: #1d1206;
    --accent-soft: #3a2a12;
    --hero: linear-gradient(160deg, #f8bb4f 0%, #e8921c 60%, #c96a0e 100%);
    --hero-ink: #241302;
    --pos: #4ade80;
    --neg: #f87171;
    --chip: #2e251c;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  overscroll-behavior-y: none;
}
body.busy { cursor: progress; }
main { max-width: 520px; margin: 0 auto; }
button { font: inherit; color: inherit; touch-action: manipulation; }
a { color: var(--accent); }

h1 { font-size: 22px; margin: 0 0 4px; line-height: 1.25; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 12px; font-weight: 700; }
.hint { color: var(--muted); font-size: 14px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.error { color: var(--neg); }
.loading { text-align: center; color: var(--muted); padding: 60px 0; }
.loading.small { padding: 24px 0; }
.loading::before { content: "🍺"; display: block; font-size: 32px; margin-bottom: 8px; animation: tilt 1s ease-in-out infinite alternate; }
@keyframes tilt { from { transform: rotate(-12deg); } to { transform: rotate(12deg); } }

/* ---------- horní lišta ---------- */
.bar { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 6px 0; }
.brand { font-weight: 800; font-size: 20px; color: var(--accent); }
.title {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; text-align: left;
  background: none; border: 0; padding: 6px 0; cursor: pointer; font-size: 22px; font-weight: 800;
}
.title span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title .pen { font-size: 15px; color: var(--muted); font-weight: 400; }
.bar-actions { display: flex; gap: 4px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--card); color: var(--text);
  display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow);
}
.rename { flex: 1; display: flex; gap: 8px; }

/* ---------- tlačítka, inputy ---------- */
input {
  font: inherit; font-size: 16px; color: inherit; background: var(--bg);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; min-width: 0; width: 100%;
}
input:focus { outline: none; border-color: var(--accent); }
.btn {
  font-weight: 650; border: 1.5px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 12px; padding: 12px 16px; cursor: pointer; white-space: nowrap; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px;
  transition: transform .08s;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.small { min-height: 40px; padding: 8px 14px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.big { width: 100%; min-height: 56px; font-size: 17px; margin: 4px 0 14px; border-radius: 14px; }
.btn.wide { width: 100%; margin-top: 10px; }
.link { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 6px 0; font-size: 15px; }
.row { display: flex; gap: 8px; }
.row > .btn { flex: 1; }
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.row-between h2 { margin-bottom: 10px; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card.center p { margin-top: 0; }

.add { display: flex; gap: 8px; margin-top: 12px; }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid transparent; background: var(--chip); color: var(--text);
  border-radius: 999px; padding: 9px 15px; min-height: 42px; cursor: pointer; font-weight: 550;
  transition: transform .08s, background .15s;
}
.chip:active { transform: scale(.95); }
.chip.on { background: var(--accent); color: var(--accent-ink); }
.chip.ghost { background: none; border-color: var(--line); color: var(--muted); border-style: dashed; }
.chip.static { cursor: default; }

/* ---------- podnik ---------- */
.venue {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer;
  background: var(--card); border: 0; border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; box-shadow: var(--shadow);
  min-height: 50px;
}
.venue-name { flex: 1; min-width: 0; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.venue-name .muted { font-weight: 400; }
.chev { color: var(--muted); font-size: 22px; line-height: 1; }

/* ---------- hlavní karta ---------- */
.hero {
  background: var(--hero); color: var(--hero-ink); border-radius: 24px; padding: 20px 18px 16px; margin-bottom: 14px;
  box-shadow: 0 10px 30px rgba(194, 98, 10, .25); text-align: center;
}
.hero.empty { padding: 26px 18px; font-weight: 600; }
.hero.empty p { margin: 0; }
.hero-label { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; opacity: .75; }
.hero-name { font-size: 40px; font-weight: 850; line-height: 1.1; margin: 4px 0 2px; overflow-wrap: anywhere; letter-spacing: -.01em; }
.hero-sub { font-weight: 600; opacity: .8; margin-bottom: 16px; }
.hero-btn {
  width: 100%; flex-direction: column; gap: 2px; min-height: 72px; border: 0; border-radius: 18px;
  background: #2a1703; color: #fff3df; font-size: 20px; font-weight: 800; box-shadow: 0 4px 14px rgba(42, 23, 3, .35);
}
.hero-btn small { font-size: 13px; font-weight: 500; opacity: .75; }
.hero-other { margin-top: 14px; }
.hero-other > span { display: block; font-size: 14px; font-weight: 600; opacity: .8; margin-bottom: 8px; }
.hero-other .chips { justify-content: center; }
.hero .chip { background: rgba(255, 255, 255, .45); color: var(--hero-ink); }
.hero .chip.ghost { background: none; border-color: rgba(42, 23, 3, .35); color: var(--hero-ink); }

/* ---------- onboarding ---------- */
.onboarding { position: relative; padding-left: 58px; }
.onboarding .step {
  position: absolute; left: 16px; top: 16px; width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800;
}
.onboarding .hint { margin: 0 0 12px; }
.onboarding .row { margin-top: 4px; }
.whoami { border: 2px dashed var(--accent); }

/* ---------- bilance ---------- */
.balances { list-style: none; margin: 0 0 8px; padding: 0; }
.balances li { display: grid; grid-template-columns: minmax(0, 1fr) 90px 44px; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.balances li:first-child { border-top: 0; }
.balances li.absent { opacity: .45; }
.balances li.me .b-name { font-weight: 800; }
.b-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.b-bar { height: 8px; border-radius: 4px; background: var(--chip); overflow: hidden; }
.b-bar span { display: block; height: 100%; border-radius: 4px; }
.b-bar .neg { background: var(--neg); }
.b-bar .pos { background: var(--pos); }
.b-val { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--muted); }
.b-val.neg { color: var(--neg); }
.b-val.pos { color: var(--pos); }
.tag { font-style: normal; font-size: 11px; font-weight: 700; text-transform: uppercase; background: var(--accent-soft); color: var(--accent); padding: 2px 6px; border-radius: 6px; vertical-align: 2px; }

/* ---------- historie, lidi ---------- */
.history, .people, .venues, .group-list, .counts { list-style: none; margin: 0; padding: 0; }
.history li, .people li { display: flex; align-items: center; gap: 6px; padding: 10px 0; border-top: 1px solid var(--line); }
.history li:first-child, .people li:first-child { border-top: 0; }
.h-main, .p-main { flex: 1; min-width: 0; }
.h-main .hint { font-size: 13px; }
.people li form { flex: 1; margin: 0; }
.del {
  border: 0; background: none; color: var(--muted); cursor: pointer; min-width: 40px; height: 40px; border-radius: 10px; flex: none;
}
.del.armed { background: var(--neg); color: #fff; font-size: 13px; font-weight: 700; padding: 0 10px; }

.group-list a { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); color: var(--text); text-decoration: none; font-weight: 650; }
.group-list li:first-child a { border-top: 0; }

.foot { text-align: center; color: var(--muted); font-size: 14px; padding: 10px 0; }
.foot a, .foot .link { color: var(--muted); font-size: 14px; }

/* ---------- spodní panel ---------- */
dialog#sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 520px; max-height: 88dvh;
  background: var(--card); color: var(--text); border-radius: 22px 22px 0 0;
}
dialog#sheet[open] { animation: up .22s cubic-bezier(.2, .8, .3, 1); }
dialog#sheet::backdrop { background: rgba(20, 12, 4, .45); }
@keyframes up { from { transform: translateY(40%); opacity: .4; } to { transform: none; opacity: 1; } }
#sheet-body { padding: 8px 18px calc(18px + env(safe-area-inset-bottom)); max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 12px; }
.sheet-title { font-size: 20px; text-transform: none; letter-spacing: 0; color: var(--text); text-align: center; margin: 0 0 10px; }
.label { font-weight: 700; margin: 16px 0 8px; }

.qr { width: min(240px, 70vw); margin: 10px auto; background: #fff; border-radius: 16px; padding: 10px; }
.qr svg { display: block; width: 100%; height: auto; }
.url { text-align: center; font-size: 14px; color: var(--muted); margin-bottom: 14px; word-break: break-all; }

.venues li button {
  width: 100%; display: flex; justify-content: space-between; gap: 10px; align-items: center; text-align: left;
  background: none; border: 0; border-top: 1px solid var(--line); padding: 14px 4px; cursor: pointer; font-weight: 600; min-height: 52px;
}
.venues li:first-child button { border-top: 0; }
.venues li button.on { color: var(--accent); }
.venues + .link { display: block; margin: 4px auto 0; }

.counts li { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; gap: 10px; }
.counts li.on > span:first-child { font-weight: 700; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--chip);
  font-size: 22px; line-height: 1; cursor: pointer;
}
.stepper button:disabled { opacity: .35; }
.stepper output { min-width: 26px; text-align: center; font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.counts li.on output { color: var(--accent); }
#sheet .btn.big { margin-top: 18px; margin-bottom: 0; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translate(-50%, 30px);
  display: flex; align-items: center; gap: 14px; width: max-content; max-width: calc(100% - 32px);
  background: #2a1d10; color: #fbefdc; padding: 10px 10px 10px 18px; border-radius: 14px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; font-size: 15px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); z-index: 10;
}
#toast:not(:has(button)) { padding-right: 18px; }
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { border: 0; background: #f59e0b; color: #241302; font-weight: 800; border-radius: 10px; padding: 9px 14px; cursor: pointer; }

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