/* G34 P5 Mini App. Colours come from Telegram's theme (the --tg-theme-* variables telegram-web-app.js sets),
   so the page looks like the chat it opens from. The one loud thing is the drag: the card tints toward the
   action it will take, and the action word grows as the finger moves. */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #eff1f4);
  --ink: var(--tg-theme-text-color, #15171a);
  --hint: var(--tg-theme-hint-color, #7d8590);
  --link: var(--tg-theme-link-color, #2a7bd4);
  --btn: var(--tg-theme-button-color, #2a7bd4);
  --btn-ink: var(--tg-theme-button-text-color, #ffffff);
  --bubble: var(--tg-theme-section-bg-color, #ffffff);
  --send: #23955a;
  --later: #c4861a;
  --reject: #c6423a;
  --r-card: 18px;
  --r-btn: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg2); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
#app { min-height: 100%; display: flex; flex-direction: column; padding: 10px 14px calc(14px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; }
button:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 3px; background: var(--bg); border-radius: 11px; }
.tabs button { border: 0; background: transparent; padding: 8px 0; border-radius: 9px; font-weight: 600; color: var(--hint); }
.tabs button[aria-selected="true"] { background: var(--bg2); color: var(--ink); }
.count { font-variant-numeric: tabular-nums; color: var(--hint); font-weight: 500; }

.banner { margin-top: 10px; padding: 8px 12px; border-radius: 10px; background: color-mix(in srgb, var(--later) 18%, var(--bg)); font-size: 14px; }
.note { color: var(--hint); text-align: center; margin: 48px 16px; }
main { flex: 1; display: flex; flex-direction: column; }

/* home */
.home { padding: 18px 4px 0; }
.home .total { font-size: 44px; line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.home .total-label { color: var(--hint); margin: 6px 0 18px; }
.home .lines { font: inherit; white-space: pre-wrap; font-size: 15px; line-height: 1.5; background: var(--bg); border-radius: 14px; padding: 12px 14px; margin: 0; }
.primary { display: block; width: 100%; margin-top: 16px; border: 0; border-radius: var(--r-btn); padding: 13px; font-weight: 600;
  background: var(--btn); color: var(--btn-ink); }

/* feed */
.stack { position: relative; flex: 1; margin-top: 12px; min-height: 380px; }
.card { position: absolute; inset: 0 0 auto 0; max-height: 100%; overflow: hidden; background: var(--bg); border-radius: var(--r-card);
  padding: 16px 16px 18px; touch-action: none; user-select: none; -webkit-user-select: none; will-change: transform;
  box-shadow: 0 1px 0 color-mix(in srgb, var(--ink) 8%, transparent); }
.card.behind { transform: translateY(10px) scale(0.96); opacity: 0.55; pointer-events: none; }
.card.back { transition: transform 0.22s ease-out; }
.card.gone { transition: transform 0.25s ease-in, opacity 0.25s ease-in; opacity: 0; }
.card .kind { font-size: 13px; color: var(--hint); }
.card .header { font-size: 13px; font-weight: 600; margin-top: 2px; }
.card h2 { font-size: 21px; line-height: 1.2; margin: 4px 0 2px; }
.card .why { color: var(--hint); font-size: 14px; margin: 0 0 12px; }
.card .quote-label { font-size: 12px; color: var(--hint); margin: 0 0 4px; }
.card .quote { margin: 0 0 14px; padding-left: 10px; border-left: 3px solid color-mix(in srgb, var(--hint) 45%, transparent);
  white-space: pre-wrap; font-size: 15px; max-height: 9.5em; overflow: hidden; }
.card .out { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.card .bubble { max-width: 92%; padding: 8px 12px; border-radius: 16px 16px 4px 16px; white-space: pre-wrap; font-size: 15px;
  background: color-mix(in srgb, var(--btn) 16%, var(--bg)); }
.card .to { font-size: 12px; color: var(--hint); margin-top: 6px; text-align: right; }
.card .to.person { color: var(--send); font-weight: 600; }
.card .nodraft { color: var(--hint); font-style: italic; }
.card .verb { position: absolute; top: 14px; padding: 4px 10px; border-radius: 8px; font-weight: 700; font-size: 17px;
  color: #fff; opacity: 0; transform-origin: center; pointer-events: none; }
.card .verb.send { right: 14px; background: var(--send); }
.card .verb.reject { left: 14px; background: var(--reject); }
.card .verb.later { left: 50%; margin-left: -48px; width: 96px; text-align: center; background: var(--later); }
.card .tint { position: absolute; inset: 0; pointer-events: none; opacity: 0; border-radius: inherit; }

.actions { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px; margin-top: 12px; }
.actions button { border: 0; border-radius: var(--r-btn); padding: 13px 4px; font-weight: 600; background: var(--bg); }
.actions .a-reject { color: var(--reject); }
.actions .a-later { color: var(--later); }
.actions .a-send { background: var(--send); color: #fff; }
.actions button:disabled { opacity: 0.4; }
.left { text-align: center; color: var(--hint); font-size: 13px; margin-top: 8px; }

/* toast and sheet */
.toast { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 10px;
  padding: 11px 12px 11px 14px; border-radius: 14px; background: var(--ink); color: var(--bg); font-size: 14px; z-index: 5; }
.toast span { flex: 1; }
.toast button { border: 0; background: transparent; color: var(--bg); font-weight: 700; padding: 6px 8px; text-decoration: underline; }
.sheet { position: fixed; inset: 0; background: color-mix(in srgb, #000 40%, transparent); display: flex; align-items: flex-end; z-index: 6; }
.sheet .panel { width: 100%; background: var(--bg); border-radius: 18px 18px 0 0; padding: 16px 14px calc(16px + env(safe-area-inset-bottom)); }
.sheet h3 { margin: 0 0 10px; font-size: 17px; }
.sheet .reasons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet .reasons button, .sheet .row button { border: 0; border-radius: var(--r-btn); padding: 12px 6px; background: var(--bg2); font-weight: 600; }
.sheet textarea { width: 100%; margin-top: 10px; min-height: 64px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--hint) 40%, transparent);
  background: var(--bg2); color: var(--ink); font: inherit; padding: 8px 10px; resize: vertical; }
.sheet .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.sheet .row .go { background: var(--reject); color: #fff; }

@media (prefers-reduced-motion: reduce) { .card.back, .card.gone { transition: none; } }
