:root {
  color-scheme: light;
  --bg: var(--tg-theme-bg-color, #f3f1eb);
  --text: var(--tg-theme-text-color, #1e1a14);
  --hint: var(--tg-theme-hint-color, #6f675c);
  --card: var(--tg-theme-section-bg-color, #fffdf8);
  --button: var(--tg-theme-button-color, #0c6b4d);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --secondary: var(--tg-theme-secondary-bg-color, #e7e2d8);
  --line: rgba(120, 110, 95, 0.28);
  --danger: #a33b32;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-scheme="light"]) {
    color-scheme: dark;
    --bg: var(--tg-theme-bg-color, #161410);
    --text: var(--tg-theme-text-color, #f3efe6);
    --hint: var(--tg-theme-hint-color, #b7ad9e);
    --card: var(--tg-theme-section-bg-color, #221f1a);
    --button: var(--tg-theme-button-color, #8dcea8);
    --button-text: var(--tg-theme-button-text-color, #14241b);
    --secondary: var(--tg-theme-secondary-bg-color, #2c2822);
    --danger: #ffb4ab;
  }
}

html[data-scheme="dark"] {
  color-scheme: dark;
  --bg: var(--tg-theme-bg-color, #161410);
  --text: var(--tg-theme-text-color, #f3efe6);
  --hint: var(--tg-theme-hint-color, #b7ad9e);
  --card: var(--tg-theme-section-bg-color, #221f1a);
  --button: var(--tg-theme-button-color, #8dcea8);
  --button-text: var(--tg-theme-button-text-color, #14241b);
  --secondary: var(--tg-theme-secondary-bg-color, #2c2822);
  --danger: #ffb4ab;
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
}

body {
  max-width: 32rem;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(168px + env(safe-area-inset-bottom));
}

.gate {
  min-height: 70vh;
  display: grid;
  align-content: center;
  gap: 8px;
}

.gate-kicker, .eyebrow, .label {
  margin: 0;
  color: var(--hint);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2 { font-weight: 600; }

h1 { margin: 0; font-family: var(--serif); font-size: 2.4rem; }

h2 {
  margin: 28px 0 8px;
  font-size: 0.95rem;
}

.hero {
  background: var(--card);
  border-radius: 18px;
  padding: 18px 18px 16px;
  box-shadow: 0 1px 0 var(--line);
}

.hero-sum {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-size: 3.4rem;
  line-height: 0.95;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.currency {
  font-family: var(--font);
  font-size: 1rem;
  letter-spacing: 0.08em;
  color: var(--hint);
}

.sub {
  margin: 10px 0 0;
  color: var(--hint);
}

.choices {
  display: grid;
  gap: 8px;
}

.choices button {
  width: 100%;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
}

.people {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--card);
  border-radius: 16px;
}

.people li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.people li:first-child { border-top: 0; }

.people .me { font-weight: 600; }

.people span:last-child { color: var(--hint); }

.entry {
  margin: 0;
  padding: 12px 2px;
  border-top: 1px solid var(--line);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

#feed .entry:first-child { border-top: 0; }

.empty {
  margin: 0;
  color: var(--hint);
  line-height: 1.45;
}

.composer {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(32rem, 100%);
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.row {
  display: flex;
  gap: 8px;
}

input, button {
  font: inherit;
  border-radius: 12px;
}

input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  padding: 12px 12px;
  font-size: 16px;
}

button {
  border: 0;
  background: var(--button);
  color: var(--button-text);
  padding: 12px 14px;
  min-height: 44px;
  cursor: pointer;
}

button.ghost {
  width: 100%;
  margin-top: 8px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

button:disabled { opacity: 0.55; }

.status {
  min-height: 1.2em;
  margin: 0 0 8px;
  color: var(--danger);
  font-size: 0.92rem;
}

.status.ok { color: var(--hint); }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
