:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #f0efea;
  --text: #1d1d1b;
  --muted: #6b6a64;
  --border: #e2e0d8;
  --accent: #c8102e;
  --accent-text: #ffffff;
  --ok: #1f7a4d;
  --warn: #b25e00;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 2px 8px rgba(0, 0, 0, .04);

  --p-duchys: #2563eb;
  --p-protiva66: #d97706;
  --p-al: #059669;
  --p-elly: #c026d3;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --surface: #1f1f1d;
    --surface-2: #2a2a27;
    --text: #f1f0ea;
    --muted: #a3a29b;
    --border: #34332f;
    --accent: #ef4058;
    --ok: #4ade80;
    --warn: #fbbf24;
    --shadow: none;

    --p-duchys: #60a5fa;
    --p-protiva66: #fbbf24;
    --p-al: #34d399;
    --p-elly: #e879f9;
  }
}

.pc-duchys { --pc: var(--p-duchys); }
.pc-protiva66 { --pc: var(--p-protiva66); }
.pc-al { --pc: var(--p-al); }
.pc-elly { --pc: var(--p-elly); }
.person { color: var(--pc); font-weight: 700; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
h1 { font-size: 1.15rem; margin: 0; }
h2 { font-size: 1rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.error { color: var(--accent); min-height: 1.4em; margin: .5rem 0 0; }

button { font: inherit; color: inherit; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 1rem;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); font-weight: 600;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: .5rem; }

/* --- přihlášení --- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; display: grid; gap: .75rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 1.5rem; box-shadow: var(--shadow); text-align: center;
}
.login-card p { margin: 0; }
.login-icon { font-size: 2.5rem; }
.login-card input {
  min-height: 48px; padding: 0 .9rem; font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
}

/* --- horní lišta --- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner, .tabs, .content, .bottombar-inner { max-width: 720px; margin: 0 auto; }
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px 8px;
}
.topbar-inner p { margin: 2px 0 0; }
.me-button {
  display: inline-flex; align-items: center; gap: .4rem;
  min-height: 40px; padding: 0 .8rem; border-radius: 999px;
  border: 2px solid var(--pc, var(--border)); background: var(--surface); font-weight: 700;
  white-space: nowrap;
}
.tabs { display: flex; padding: 0 16px; gap: 4px; }
.tab {
  flex: 1; min-height: 44px; background: none; border: 0;
  border-bottom: 3px solid transparent; font-weight: 600; color: var(--muted);
}
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

.content { padding: 12px 16px 96px; }

/* --- filtry --- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-filter {
  min-height: 36px; padding: 0 .9rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); font-size: .9rem;
}
.chip-filter[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.hint { margin: .6rem 0 .8rem; }

/* --- položky --- */
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: start;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; box-shadow: var(--shadow);
  border-left: 4px solid var(--border);
}
.item.is-open { border-left-color: var(--accent); }
.item.is-done { border-left-color: var(--ok); }
.item.is-mine { background: color-mix(in srgb, var(--pc) 9%, var(--surface)); border-color: color-mix(in srgb, var(--pc) 45%, var(--border)); border-left-color: var(--pc); }
.item.toggle { cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; }
.item.toggle:focus-visible { outline: 3px solid var(--pc); outline-offset: 2px; }

.check {
  width: 26px; height: 26px; margin-top: 1px; border-radius: 8px;
  border: 2px solid var(--border); display: grid; place-items: center;
  background: var(--surface); color: #fff; font-size: 16px; font-weight: 900;
}
.is-mine .check { background: var(--pc); border-color: var(--pc); }
.line-no {
  width: 26px; text-align: center; font-size: .75rem; color: var(--muted);
  font-variant-numeric: tabular-nums; margin-top: 4px;
}

.item-name { font-weight: 600; overflow-wrap: anywhere; }
.item-meta { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.item-price { font-weight: 700; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.item-share { font-size: .8rem; color: var(--muted); text-align: right; white-space: nowrap; }
.item-body { min-width: 0; }

.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .78rem; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--pc) 16%, transparent);
  color: color-mix(in srgb, var(--pc) 80%, var(--text));
  border: 1px solid color-mix(in srgb, var(--pc) 40%, transparent);
}
.badge-warn { --pc: var(--warn); }
.badge-left { --pc: var(--accent); }
.badge-split { --pc: var(--muted); }

.stepper {
  grid-column: 2 / 4; display: flex; align-items: center; gap: 8px; margin-top: 6px;
}
.stepper button {
  width: 44px; height: 40px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); font-size: 1.25rem; font-weight: 700; line-height: 1;
}
.stepper button:disabled { opacity: .35; cursor: default; }
.stepper output { min-width: 4.5ch; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.stepper .all { width: auto; padding: 0 .7rem; font-size: .85rem; }

.empty { text-align: center; padding: 2rem 0; }

/* --- souhrn --- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.field { display: grid; gap: 6px; font-weight: 600; }
.field select {
  min-height: 44px; padding: 0 .6rem; font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
}
.progress { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
#progress-bar { height: 100%; width: 0; background: var(--ok); transition: width .3s; }
#progress-text { margin: .5rem 0 0; }

.sum-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.sum-table td { padding: 8px 0; border-bottom: 1px solid var(--border); }
.sum-table tr:last-child td { border-bottom: 0; }
.sum-table td:last-child { text-align: right; font-weight: 700; white-space: nowrap; }
.sum-table .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--pc); margin-right: 8px; }
.sum-table .total td { font-weight: 700; border-top: 2px solid var(--border); }
.sum-table .open td { color: var(--accent); }
.sum-table .count { color: var(--muted); font-size: .85rem; padding-left: 8px; }

.settle { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.settle li {
  display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
  padding: 10px 12px; border-radius: 10px; background: var(--surface-2);
  font-variant-numeric: tabular-nums;
}
.settle strong { white-space: nowrap; }

/* --- spodní lišta --- */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottombar-inner { display: flex; justify-content: space-between; padding: 10px 16px; }
.bottombar-inner > div { display: grid; }
.bottombar-inner .right { text-align: right; }
.bottombar strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
#my-total { color: var(--pc, var(--text)); }
#open-total { color: var(--accent); }

/* --- výběr osoby --- */
.who {
  border: 0; border-radius: 16px; padding: 1.25rem; width: min(92vw, 380px);
  background: var(--surface); color: var(--text);
}
.who::backdrop { background: rgba(0, 0, 0, .45); }
.who p { margin: 0 0 1rem; }
.who-buttons { display: grid; gap: 8px; }
.who-buttons button {
  min-height: 52px; border-radius: 12px; font-weight: 700; font-size: 1.05rem;
  border: 2px solid var(--pc); background: color-mix(in srgb, var(--pc) 10%, var(--surface));
}
