/* Colours come from Telegram's theme (themeParams → --tg-theme-*). The fallbacks are only for a
   plain browser while developing: Telegram's own light and dark defaults. */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #efeff4);
  --section: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --sub: var(--tg-theme-subtitle-text-color, var(--hint));
  --link: var(--tg-theme-link-color, #2481cc);
  --accent: var(--tg-theme-accent-text-color, var(--link));
  --button: var(--tg-theme-button-color, #2481cc);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --header: var(--tg-theme-section-header-text-color, var(--hint));
  --separator: var(--tg-theme-section-separator-color, rgba(60, 60, 67, 0.2));
  --danger: var(--tg-theme-destructive-text-color, #e53935);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not(.tg) {
    --bg: var(--tg-theme-secondary-bg-color, #000000);
    --section: var(--tg-theme-section-bg-color, #1c1c1e);
    --text: var(--tg-theme-text-color, #ffffff);
    --separator: var(--tg-theme-section-separator-color, rgba(84, 84, 88, 0.6));
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding: 0 0 calc(80px + env(safe-area-inset-bottom));
  -webkit-text-size-adjust: 100%;
}
main { max-width: 640px; margin: 0 auto; padding: 0 16px; }
button, input, select, textarea { font: inherit; color: inherit; }

.title { padding: 16px 4px 4px; }
.title h1 { font-size: 22px; margin: 0; font-weight: 600; }
.title p { margin: 4px 0 0; color: var(--hint); font-size: 14px; }

section { margin: 20px 0; }
section h2 { font-size: 13px; font-weight: 400; text-transform: uppercase; color: var(--header); margin: 0 16px 6px; letter-spacing: 0.02em; }
.footer { font-size: 13px; color: var(--hint); margin: 6px 16px 0; }
.list { background: var(--section); border-radius: 10px; overflow: hidden; }

.row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 10px 16px;
  background: none; border: 0; text-align: left; position: relative;
}
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--separator); }
.tappable { cursor: pointer; }
.tappable:active { background: var(--separator); }
.row-text { flex: 1; min-width: 0; }
.row-title { overflow-wrap: anywhere; }
.row-title.done { color: var(--hint); text-decoration: line-through; }
.row-sub { font-size: 14px; color: var(--sub); margin-top: 2px; overflow-wrap: anywhere; white-space: pre-line; }
.row-value { color: var(--hint); font-size: 15px; text-align: right; max-width: 45%; overflow-wrap: anywhere; }
.chevron { width: 8px; height: 8px; border-right: 2px solid var(--hint); border-top: 2px solid var(--hint); transform: rotate(45deg); opacity: 0.6; flex: none; }
.row.action { color: var(--link); }
.row.danger { color: var(--danger); }
.row.warn .row-sub { color: var(--danger); }

.empty { color: var(--hint); text-align: center; padding: 16px; margin: 0; }

/* Plain-browser stand-ins for Telegram's back and main buttons. */
#back-button { position: sticky; top: 0; z-index: 2; background: var(--bg); border: 0; color: var(--link); padding: 12px 16px; width: 100%; text-align: left; }
#main-button {
  position: fixed; left: 16px; right: 16px; bottom: calc(12px + env(safe-area-inset-bottom)); max-width: 608px; margin: 0 auto;
  background: var(--button); color: var(--button-text); border: 0; border-radius: 10px; padding: 14px; font-weight: 600;
}
#main-button:disabled { opacity: 0.6; }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); max-width: 608px; margin: 0 auto; z-index: 3;
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-size: 15px;
}
#toast[hidden], [hidden] { display: none; }
#toast span { flex: 1; }
#toast button { background: none; border: 0; color: var(--button); font-weight: 600; padding: 0; filter: brightness(1.3); }

.input { width: 100%; border: 0; background: none; padding: 0; outline: none; min-height: 24px; }
textarea.input { resize: vertical; line-height: 1.4; }
select.input { appearance: none; -webkit-appearance: none; text-align: right; color: var(--hint); }
.field { cursor: text; }
.field .field-label { flex: none; min-width: 96px; }
.field .input { text-align: right; color: var(--hint); }
.field input[type="date"], .field input[type="time"] { text-align: right; }
.row.checked .row-value { color: var(--link); font-weight: 600; }

.row.muted .row-title, .row.muted .row-sub { color: var(--hint); }
.row.action .row-title { color: var(--link); }
.row.danger .row-title { color: var(--danger); }
.hint { color: var(--hint); font-size: 13px; margin: 12px 16px 0; }

.segmented { display: flex; margin: 12px 0 0; padding: 2px; border-radius: 9px; background: var(--section); gap: 2px; }
.segmented button { flex: 1; border: 0; background: none; padding: 7px 4px; border-radius: 7px; font-size: 14px; color: var(--text); }
.segmented button.on { background: var(--button); color: var(--button-text); font-weight: 600; }

.pager { display: flex; align-items: center; justify-content: space-between; margin: 12px 0 0; }
.pager span { font-weight: 600; }
.pager button { border: 0; background: none; color: var(--link); font-size: 26px; line-height: 1; padding: 4px 14px; }

.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; padding: 8px; margin-top: 12px; }
.month .dow { text-align: center; font-size: 12px; color: var(--hint); padding: 2px 0 6px; }
.month button { border: 0; background: none; aspect-ratio: 1; border-radius: 50%; position: relative; font-size: 15px; padding: 0; }
.month button.today { color: var(--link); font-weight: 600; }
.month button.has::after { content: ""; position: absolute; left: 50%; bottom: 12%; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--link); }
.month button.picked { background: var(--button); color: var(--button-text); }
.month button.picked::after { background: var(--button-text); }

.media { display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px; }
.media-item { flex: none; width: 140px; height: 140px; border-radius: 8px; overflow: hidden; background: var(--bg); display: flex; align-items: center; justify-content: center; }
.media-item img, .media-item video { width: 100%; height: 100%; object-fit: cover; }
.media-note { font-size: 13px; color: var(--hint); text-align: center; padding: 8px; }
