:root {
  --bg: #fbf6ef;
  --card: #ffffff;
  --ink: #1f2430;
  --muted: #6b7180;
  --line: #e8e1d6;
  --brand: #ff6b4a;
  --brand-2: #ff9a3d;
  --match: #15b36c;
  --nej: #f0445a;
  --chip: #f2ebe1;
  --chip-on: #1f2430;
  --chip-on-ink: #ffffff;
  --shadow: 0 8px 30px rgba(31, 36, 48, .16);
  --tabs-h: 60px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171c; --card: #20232b; --ink: #f1efe9; --muted: #a3a8b4; --line: #333743;
    --chip: #2b2f39; --chip-on: #f1efe9; --chip-on-ink: #15171c; --shadow: 0 8px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
[hidden] { display: none !important; }

#app { display: flex; flex-direction: column; height: 100dvh; max-width: 900px; margin: 0 auto; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px; flex: none;
}
.logo { font-weight: 900; letter-spacing: .08em; font-size: 22px; display: flex; align-items: center; gap: 6px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo-mark { -webkit-text-fill-color: var(--brand); }
.who { font-size: 14px; color: var(--muted); text-align: right; }
main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 16px 24px; flex: 1; }

/* bottom tabs */
.tabs { display: flex; flex: none; border-top: 1px solid var(--line); background: var(--card);
  padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; min-height: var(--tabs-h); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 12px; color: var(--muted); text-decoration: none; position: relative; }
.tabs a .ti { font-size: 20px; line-height: 1; filter: grayscale(1); opacity: .7; }
.tabs a.on { color: var(--ink); font-weight: 700; }
.tabs a.on .ti { filter: none; opacity: 1; }
.tabs .badge { position: absolute; top: 6px; left: calc(50% + 8px); background: var(--brand); color: #fff; border-radius: 10px;
  font-size: 11px; padding: 0 6px; font-weight: 700; }

/* login */
.login { margin: auto; width: 100%; max-width: 380px; padding: 24px 20px; }
.login h1 { font-size: 26px; margin: 0 0 6px; }
.login p { color: var(--muted); margin: 0 0 20px; }
label.fld { display: block; margin-bottom: 14px; font-weight: 600; font-size: 14px; }
label.fld input, label.fld select { display: block; width: 100%; margin-top: 6px; padding: 13px 14px; font-size: 17px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--card); }
label.fld input:focus { outline: 2px solid var(--brand); border-color: transparent; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 18px;
  border-radius: 14px; border: 0; background: var(--chip); font-weight: 700; text-decoration: none; color: var(--ink); }
.btn.primary { background: linear-gradient(90deg, var(--brand), var(--brand-2)); color: #fff; }
.btn.block { width: 100%; }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.danger { color: var(--nej); }
.err { color: var(--nej); font-weight: 600; min-height: 1.4em; margin: 6px 0; }

/* swipe */
.swipe { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0 12px; }
.stack { position: relative; flex: 1; min-height: 0; }
.card { position: absolute; inset: 0; border-radius: 22px; overflow: hidden; background: #333; box-shadow: var(--shadow);
  touch-action: none; user-select: none; -webkit-user-select: none; will-change: transform; }
.card.behind { transform: scale(.95) translateY(10px); filter: brightness(.9); }
.card.anim { transition: transform .3s ease; }
.card .photo { position: absolute; inset: 0; background: #444 center/cover no-repeat; }
.card .photo img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.card .dots { position: absolute; top: 8px; left: 10px; right: 10px; display: flex; gap: 4px; z-index: 2; }
.card .dots i { flex: 1; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .45); }
.card .dots i.on { background: #fff; }
.card .shade { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0, 0, 0, .88) 0%, rgba(0, 0, 0, .55) 38%,
  rgba(0, 0, 0, 0) 62%); pointer-events: none; }
.card .info { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 16px 14px; color: #fff; }
.card h2 { margin: 0; font-size: 25px; line-height: 1.15; text-shadow: 0 1px 4px rgba(0, 0, 0, .5); }
.card .stars { color: #ffd34d; font-size: 16px; letter-spacing: 1px; white-space: nowrap; }
.card .place { opacity: .9; font-size: 15px; margin-top: 2px; }
.card .price { font-size: 28px; font-weight: 800; margin-top: 8px; }
.card .price small { font-size: 14px; font-weight: 500; opacity: .85; }
.card .when { font-size: 14px; opacity: .9; }
.card .more { position: absolute; right: 14px; bottom: 16px; width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, .92); color: #1f2430; font-weight: 800; font-size: 20px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; padding-right: 52px; }
.pill { font-size: 13px; padding: 3px 9px; border-radius: 999px; background: rgba(255, 255, 255, .2); white-space: nowrap; }
.pill.water { background: #2aa6ff; color: #fff; font-weight: 700; }
.pill.warn { background: #ffcf4d; color: #1f2430; font-weight: 700; }
.pill.uai { background: #b06cff; color: #fff; }
.stamp { position: absolute; top: 40px; z-index: 3; font-size: 40px; font-weight: 900; letter-spacing: .06em; padding: 2px 14px;
  border: 5px solid; border-radius: 12px; opacity: 0; pointer-events: none; }
.stamp.yes { left: 22px; color: var(--match); border-color: var(--match); transform: rotate(-14deg); }
.stamp.no { right: 22px; color: var(--nej); border-color: var(--nej); transform: rotate(14deg); }
.actions { display: flex; align-items: center; justify-content: center; gap: 22px; padding: 12px 0 10px; flex: none; }
.round { width: 64px; height: 64px; border-radius: 50%; border: 0; background: var(--card); box-shadow: var(--shadow);
  font-size: 30px; font-weight: 900; display: flex; align-items: center; justify-content: center; }
.round.no { color: var(--nej); }
.round.yes { color: var(--match); }
.round.undo { width: 50px; height: 50px; font-size: 22px; color: var(--brand-2); }
.round:active { transform: scale(.92); }
.round:disabled { opacity: .4; }
.left-hint { text-align: center; font-size: 13px; color: var(--muted); min-height: 18px; }
.left-hint a { font-weight: 600; }

/* empty deck */
.empty { margin: auto; text-align: center; max-width: 440px; padding: 20px 8px; }
.empty .big { font-size: 54px; }
.empty h2 { margin: 6px 0 8px; font-size: 21px; }
.empty p { color: var(--muted); margin: 0 0 16px; }
.sugg { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.sugg button { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 52px; padding: 10px 16px;
  border-radius: 14px; border: 1.5px solid var(--line); background: var(--card); font-weight: 600; text-align: left; }
.sugg button b { color: var(--match); white-space: nowrap; }

/* lists */
.list-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 6px 0 10px; }
.list-head h1 { font-size: 22px; margin: 0; }
.list-head span { color: var(--muted); font-size: 14px; }
.items { display: grid; gap: 12px; }
@media (min-width: 700px) { .items { grid-template-columns: 1fr 1fr; } }
.item { display: flex; gap: 12px; background: var(--card); border-radius: 16px; padding: 10px; box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
  border: 1px solid var(--line); }
.item img { width: 80px; height: 80px; object-fit: cover; border-radius: 12px; flex: none; background: var(--chip); }
.item .body { flex: 1; min-width: 0; }
.item h3 { margin: 0; font-size: 17px; line-height: 1.2; }
.item .meta { font-size: 13px; color: var(--muted); }
.item .p { font-weight: 800; margin-top: 2px; }
.item .row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.item .row .btn { padding: 0 10px; font-size: 13px; min-height: 36px; }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--chip); margin: 2px 4px 0 0; }
.tag.yes { background: #d6f5e5; color: #0b6b40; }
.tag.no { background: #fde0e4; color: #9b1c2e; }
.tag.warn { background: #fff1c2; color: #6b5200; }
.sheet .stars, .item .stars { color: #e0a800; font-size: 15px; }
.none { color: var(--muted); text-align: center; padding: 40px 10px; }

/* settings */
.set { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 12px; }
.set h3 { margin: 0 0 4px; font-size: 16px; }
.set .hint { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { min-height: 42px; padding: 0 14px; border-radius: 999px; border: 0; background: var(--chip); font-size: 15px; }
.chips button.on { background: var(--chip-on); color: var(--chip-on-ink); font-weight: 700; }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row input { flex: 1; accent-color: var(--brand); height: 32px; }
.range-row output { font-weight: 800; min-width: 104px; text-align: right; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; font-weight: 600; }
.toggle input { width: 52px; height: 30px; appearance: none; -webkit-appearance: none; border-radius: 15px; background: var(--chip);
  position: relative; transition: background .2s; flex: none; margin: 0; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: left .2s; }
.toggle input:checked { background: var(--match); }
.toggle input:checked::after { left: 25px; }
.toggle small { display: block; font-weight: 400; color: var(--muted); }
select.sel { width: 100%; padding: 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); font-size: 16px; }
.livecount { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 8px 0 10px; font-weight: 700; }
.livecount small { display: block; font-weight: 400; color: var(--muted); }

/* sheet (Mere info) */
.sheet-bg, .modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 20; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-width: 900px; margin: 0 auto; max-height: 92dvh; overflow-y: auto;
  background: var(--bg); border-radius: 22px 22px 0 0; z-index: 21; padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet .grab { position: sticky; top: 0; background: var(--bg); padding: 10px 0 8px; display: flex; justify-content: space-between;
  align-items: center; z-index: 2; }
.sheet .grab h2 { margin: 0; font-size: 20px; }
.sheet .x { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--chip); font-size: 20px; flex: none; }
.gallery { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -16px; padding: 0 16px 8px; }
.gallery img { height: 220px; width: 85%; max-width: 420px; object-fit: cover; border-radius: 14px; scroll-snap-align: center; flex: none;
  background: var(--chip); }
table.facts { width: 100%; border-collapse: collapse; font-size: 15px; }
table.facts td { padding: 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.facts td:first-child { color: var(--muted); width: 42%; padding-right: 10px; }
.prices { display: grid; gap: 8px; }
.prow { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.prow.off { opacity: .55; }
.prow .top-line { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; font-size: 16px; }
.prow .sub { color: var(--muted); }
.sheet h4 { margin: 18px 0 8px; font-size: 16px; }
.note { font-size: 13px; color: var(--muted); }

/* modal + toast */
.modal-bg { display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 30; }
.modal { background: var(--bg); border-radius: 18px; padding: 20px; max-width: 380px; width: 100%; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 8px; }
.modal .btns { display: flex; gap: 10px; margin-top: 16px; }
.modal .btns .btn { flex: 1; }
.pw { font: 700 20px ui-monospace, monospace; background: var(--chip); padding: 12px; border-radius: 10px; word-break: break-all;
  user-select: all; -webkit-user-select: all; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + 90px + env(safe-area-inset-bottom));
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 40; font-size: 15px;
  max-width: calc(100% - 32px); display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow); }
.toast button { background: none; border: 0; color: var(--brand-2); font-weight: 800; padding: 4px; }

/* admin */
.subtabs { display: flex; gap: 8px; margin: 4px 0 12px; }
.rank { font-weight: 900; font-size: 20px; color: var(--brand); min-width: 30px; }
.fam { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 12px; }
.fam h3 { margin: 0; }
.fam .nums { display: flex; gap: 16px; margin: 8px 0 10px; font-size: 14px; color: var(--muted); }
.fam .nums b { color: var(--ink); font-size: 18px; }

@media (min-width: 700px) {
  .swipe { max-width: 560px; width: 100%; margin: 0 auto; }
}
@media (orientation: landscape) and (max-height: 500px) {
  /* phone on its side: card left, buttons in a column on the right, no header */
  :root { --tabs-h: 46px; }
  .top { display: none; }
  .swipe { flex-direction: row; gap: 14px; padding: calc(env(safe-area-inset-top) + 8px) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); }
  .left-hint { display: none; }
  .actions { flex-direction: column; justify-content: center; gap: 12px; padding: 0; }
  .round { width: 54px; height: 54px; font-size: 26px; }
  .round.undo { width: 44px; height: 44px; }
  .card .info { padding: 10px 14px; }
  .card h2 { font-size: 20px; }
  .card .price { font-size: 21px; margin-top: 2px; }
  .card .pills .pill:nth-child(n+5) { display: none; }
  .tabs a { flex-direction: row; gap: 6px; font-size: 13px; }
  .tabs a .ti { font-size: 17px; }
  .scroll { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
}
