:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --link: var(--tg-theme-link-color, #2481cc);
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #d7263d);
  --sep: var(--tg-theme-section-separator-color, rgba(128,128,128,.25));
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg2); color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif; }
[hidden] { display: none !important; }
main { padding: 12px 16px calc(96px + env(safe-area-inset-bottom)); }

.top { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.brand { font-size: 22px; font-weight: 700; }
.hint { color: var(--hint); font-size: 13px; }
.range { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--sep); background: var(--card); color: var(--text); border-radius: 999px;
  padding: 6px 12px; font-size: 14px; }
.chip.small { padding: 5px 10px; font-size: 13px; }
.chip.active { background: var(--btn); color: var(--btn-text); border-color: var(--btn); }

.day { margin: 14px 0 6px; font-size: 13px; font-weight: 600; color: var(--hint); text-transform: uppercase; letter-spacing: .02em; }
.day.today { color: var(--link); }
.card { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.ev { display: flex; gap: 12px; padding: 11px 14px; width: 100%; text-align: left; border: 0;
  background: transparent; color: inherit; font: inherit; border-top: 1px solid var(--sep); }
.ev:first-child { border-top: 0; }
.ev-time { min-width: 62px; font-variant-numeric: tabular-nums; color: var(--link); font-weight: 600; }
.ev-time.allday { color: var(--hint); font-weight: 500; font-size: 13px; padding-top: 2px; }
.ev-body { flex: 1; min-width: 0; }
.ev-title { font-weight: 500; overflow-wrap: anywhere; }
.ev-sub { color: var(--hint); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.ev.past { opacity: .55; }
.empty { color: var(--hint); text-align: center; padding: 40px 12px; }
.error { color: var(--danger); font-size: 14px; margin: 8px 0; }

.fab { position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); width: 56px; height: 56px;
  border-radius: 50%; border: 0; background: var(--btn); color: var(--btn-text); font-size: 30px; line-height: 56px;
  box-shadow: 0 6px 18px rgba(0,0,0,.25); }

.sheet { position: fixed; inset: 0; background: var(--bg); overflow-y: auto; padding: 12px 16px calc(24px + env(safe-area-inset-bottom)); z-index: 10; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 700; font-size: 18px; }
.link { border: 0; background: none; color: var(--link); font-size: 15px; padding: 6px 0; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
.field > span { font-size: 13px; color: var(--hint); }
.field input, .field select, .field textarea { font: inherit; color: var(--text); background: var(--bg2);
  border: 1px solid transparent; border-radius: 10px; padding: 10px 12px; width: 100%; min-height: 44px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--link); }
.row { display: flex; gap: 10px; align-items: flex-end; }
.grow { flex: 1; }
.quick { display: flex; gap: 6px; padding-bottom: 12px; }
.switch { display: flex; gap: 10px; align-items: center; margin: 6px 0 4px; font-size: 15px; }
.switch input { width: 20px; height: 20px; }
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.btn { font: inherit; font-weight: 600; border: 0; border-radius: 12px; padding: 13px; min-height: 48px; }
.btn.primary { background: var(--btn); color: var(--btn-text); }
.btn.danger { background: transparent; color: var(--danger); }
.btn:disabled { opacity: .5; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(88px + env(safe-area-inset-bottom)); background: var(--text);
  color: var(--bg); padding: 10px 14px; border-radius: 12px; font-size: 14px; text-align: center; z-index: 20; }
.gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.gate-box { max-width: 360px; text-align: center; color: var(--hint); }
.gate-title { font-size: 24px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
