/* Colours come from the Telegram theme, so the app matches light and dark. */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --accent: var(--tg-theme-button-color, #2f80ed);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --line: color-mix(in srgb, var(--hint) 22%, transparent);
  --danger: #e5484d;
  --ok: #30a46c;
  --hour: 56px;
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { padding-bottom: env(safe-area-inset-bottom); overscroll-behavior: none; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 4px; }
.nav { font-size: 26px; width: 40px; height: 40px; border-radius: 12px; color: var(--accent); }
.nav:active { background: var(--bg2); }
.range { text-align: center; font-weight: 600; }
.today { font-size: 12px; font-weight: 500; color: var(--accent); padding: 2px 8px; }

.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; padding: 6px 10px; }
.day { display: flex; flex-direction: column; align-items: center; padding: 6px 0 5px; border-radius: 12px; }
.day .wd { font-size: 11px; color: var(--hint); text-transform: uppercase; }
.day .dn { font-size: 17px; font-weight: 600; }
.day .dots { height: 6px; display: flex; gap: 2px; margin-top: 3px; }
.day .dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); opacity: .6; }
.day.today .dn { color: var(--accent); }
.day.sel { background: var(--accent); }
.day.sel .wd, .day.sel .dn { color: var(--accent-text); }
.day.sel .dots i { background: var(--accent-text); }

.views { display: flex; gap: 6px; margin: 4px 12px 8px; background: var(--bg2); padding: 3px; border-radius: 10px; }
.tab { flex: 1; padding: 6px; border-radius: 8px; font-size: 13px; color: var(--hint); }
.tab.active { background: var(--bg); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / .08); }

.timeline-wrap { height: calc(100vh - 186px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.timeline { position: relative; margin: 0 12px 0 48px; }
.hour { position: absolute; left: -48px; right: 0; height: var(--hour); border-top: 1px solid var(--line); }
.hour span { position: absolute; top: -8px; left: 0; width: 40px; text-align: right; font-size: 11px; color: var(--hint); background: var(--bg); padding-right: 6px; }
.now { position: absolute; left: -6px; right: 0; height: 2px; background: var(--danger); z-index: 3; pointer-events: none; }
.now::before { content: ''; position: absolute; left: -4px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }

.block {
  position: absolute; border-radius: 10px; padding: 4px 8px; overflow: hidden; z-index: 2;
  background: color-mix(in srgb, var(--accent) 16%, var(--bg)); border-left: 3px solid var(--accent);
  touch-action: pan-y; transition: box-shadow .15s, transform .15s;
}
.block.fixed { background: var(--accent); color: var(--accent-text); border-left-color: color-mix(in srgb, var(--accent) 60%, #000); }
.block.done { opacity: .45; }
.block.skipped { opacity: .45; text-decoration: line-through; }
.block .t { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.block .h { font-size: 11px; opacity: .8; }
.block.drag { z-index: 5; box-shadow: 0 8px 24px rgb(0 0 0 / .25); transform: scale(1.02); transition: none; }
.drag-label { position: absolute; left: -46px; width: 42px; text-align: right; font-size: 11px; font-weight: 700; color: var(--accent); z-index: 6; }

.week { padding: 0 12px 90px; }
.wday { margin: 10px 0 4px; font-size: 13px; font-weight: 600; color: var(--hint); }
.wday.today { color: var(--accent); }
.witem { display: flex; gap: 10px; padding: 9px 10px; border-radius: 10px; background: var(--bg2); margin-bottom: 4px; }
.witem .wt { font-variant-numeric: tabular-nums; color: var(--hint); font-size: 13px; min-width: 88px; }
.witem.fixed .wn { font-weight: 600; }
.witem.done, .witem.skipped { opacity: .5; }
.empty { color: var(--hint); font-size: 13px; padding: 4px 2px; }

.fab {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); width: 54px; height: 54px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font-size: 28px; box-shadow: 0 6px 18px rgb(0 0 0 / .2); z-index: 10;
}

.scrim { position: fixed; inset: 0; background: rgb(0 0 0 / .35); z-index: 20; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: var(--bg); border-radius: 16px 16px 0 0;
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 86vh; overflow-y: auto;
  box-shadow: 0 -8px 30px rgb(0 0 0 / .18); user-select: text; -webkit-user-select: text;
}
.sheet h2 { margin: 0 0 2px; font-size: 19px; }
.sheet .sub { color: var(--hint); font-size: 13px; margin-bottom: 12px; }
.sheet .notes { background: var(--bg2); border-radius: 10px; padding: 8px 10px; margin-bottom: 12px; white-space: pre-wrap; }
.row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.btn { flex: 1; min-width: 70px; padding: 10px 8px; border-radius: 10px; background: var(--bg2); font-weight: 500; text-align: center; }
.btn:active { opacity: .7; }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.ok { background: color-mix(in srgb, var(--ok) 18%, var(--bg)); color: var(--ok); }
.btn.danger { background: color-mix(in srgb, var(--danger) 14%, var(--bg)); color: var(--danger); }
.chip { padding: 7px 10px; border-radius: 9px; background: var(--bg2); font-size: 13px; }
.chip.on { background: var(--accent); color: var(--accent-text); }
.label { font-size: 12px; color: var(--hint); margin: 10px 0 5px; }
input[type=text], input[type=time], textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg2); border: 0; border-radius: 10px; padding: 10px; outline: none;
}
textarea { min-height: 64px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 8px 0 12px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 30;
  background: color-mix(in srgb, var(--text) 88%, transparent); color: var(--bg); padding: 9px 14px; border-radius: 10px; font-size: 13px;
  max-width: 90vw; text-align: center;
}
