:root {
  --bg: var(--tg-theme-secondary-bg-color, #f1f1f4);
  --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, #8a8a8f);
  --accent: var(--tg-theme-button-color, #2f7cf6);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #e5484d);
  --line: color-mix(in srgb, var(--hint) 22%, transparent);
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.top { padding: 18px 16px 6px; }
.hello { font-size: 22px; font-weight: 700; }
.sub { color: var(--hint); font-size: 13px; margin-top: 2px; }
main { padding: 6px 12px; }
.loading { color: var(--hint); text-align: center; padding: 40px 0; }

.card { background: var(--card); border-radius: var(--radius); padding: 14px 14px; margin: 10px 0; }
.card h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--hint); text-transform: uppercase; letter-spacing: .04em; }
.empty { color: var(--hint); font-size: 14px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.stats.one { grid-template-columns: 1fr; }
.stat { background: var(--card); border-radius: var(--radius); padding: 12px 14px; min-width: 0; }
.stat .label { color: var(--hint); font-size: 12px; }
.stat .value { font-size: 20px; font-weight: 700; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .note { color: var(--hint); font-size: 12px; margin-top: 2px; }

.meter { height: 6px; border-radius: 3px; background: var(--line); margin-top: 8px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.meter.warn > i { background: var(--danger); }

.row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: 0; padding-top: 2px; }
.row .main { flex: 1; min-width: 0; }
.row .title { overflow-wrap: anywhere; }
.row .meta { color: var(--hint); font-size: 12px; margin-top: 1px; }
.row .amount { font-weight: 600; white-space: nowrap; }
.act { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-size: 16px; }
.act.del { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.check { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--hint); }
.check:active, .check.done { background: var(--accent); border-color: var(--accent); }

a { color: var(--hint); font-size: 12px; margin-top: 1px; }
.row .amount { font-weight: 600; white-space: nowrap; }
.act { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-size: 16px; }
.act.del { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.check { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--hint); }
.check:active, .check.done { background: var(--accent); border-color: var(--accent); }

.pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; margin-left: 6px;
  background: var(--line); color: var(--hint); vertical-align: 1px; }
.pill.on { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
a { color: var(--accent); text-decoration: none; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-size: 11px; color: var(--hint); padding: 4px 0; min-width: 0; }
.tabs button span { font-size: 20px; line-height: 1.1; filter: grayscale(1); opacity: .7; }
.tabs button.on { color: var(--accent); }
.tabs button.on span { filter: none; opacity: 1; }

/* Morning routine */
.week { display: flex; justify-content: space-between; margin-top: 10px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--hint); }
.day i { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center;
  font-style: normal; font-size: 13px; }
.day.on i { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.day.now { color: var(--text); font-weight: 600; }
button.row { width: 100%; text-align: left; }
.empty.small { font-size: 12px; margin-top: 10px; }
body.lock { overflow: hidden; }

.player { position: fixed; inset: 0; z-index: 10; background: #000; color: #fff; display: flex; flex-direction: column;
  gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom)); }
.player[hidden] { display: none; }
.p-top { display: flex; align-items: center; gap: 10px; }
.p-info { flex: 1; min-width: 0; }
.p-count { font-size: 12px; color: #9aa; }
.p-title { font-size: 17px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-segs { display: flex; gap: 4px; }
.p-segs[hidden] { display: none; }
.p-segs i { flex: 1; height: 4px; border-radius: 2px; background: rgba(255,255,255,.2); }
.p-segs i.past { background: rgba(255,255,255,.55); }
.p-segs i.cur { background: var(--accent); }
.p-stage { flex: 1; min-height: 0; position: relative; display: grid; place-items: center; }
.p-stage video { width: 100%; height: 100%; object-fit: contain; border-radius: 12px; background: #000; }
.p-stage video[hidden] { display: none; }
.p-stage img { width: 100%; height: 100%; object-fit: contain; border-radius: 12px; }
.p-stage img[hidden], .p-btn[hidden] { display: none; }
.p-status { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; text-align: center; padding: 20px; color: #ccd; }
.p-status[hidden] { display: none; }
.p-status b { color: #fff; font-size: 17px; }
.p-big { font-size: 64px; font-weight: 800; line-height: 1; color: var(--accent); }
.p-bottom { display: flex; gap: 8px; align-items: center; }
.p-bottom[hidden] { display: none; }
.p-btn { background: rgba(255,255,255,.12); color: #fff; border-radius: 12px; padding: 12px 16px; font-weight: 600; }
.p-btn:disabled { opacity: .35; }
.p-btn.go { background: var(--accent); color: var(--accent-text); flex: 1; }
.p-status .p-btn.go { flex: none; margin-top: 6px; padding: 12px 24px; }
.p-auto { display: flex; align-items: center; gap: 4px; font-size: 12px; color: #9aa; white-space: nowrap; }

.error { text-align: center; padding: 40px 20px; color: var(--hint); }
.error b { display: block; color: var(--text); font-size: 17px; margin-bottom: 6px; }

/* Morning routine: кнопка старта и доска колонок */
.start { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0 4px;
  background: var(--accent); color: var(--accent-text); border-radius: var(--radius); padding: 14px 16px; font-weight: 700; font-size: 16px; }
.start small { font-weight: 500; font-size: 13px; opacity: .85; }
.board { display: flex; gap: 8px; align-items: flex-start; overflow-x: auto; margin: 10px -12px 0; padding: 0 12px 8px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.board::-webkit-scrollbar { display: none; }
.col { flex: 1 0 108px; min-width: 108px; max-width: 280px; background: var(--card); border-radius: var(--radius); padding: 8px;
  display: flex; flex-direction: column; gap: 6px; }
.col-head, .item { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; cursor: grab; }
.col-head { padding: 2px 2px 0 4px; }
.col-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 14px;
  line-height: 1.25; overflow-wrap: anywhere; }
.col-meta { display: flex; align-items: center; justify-content: space-between; gap: 4px; min-height: 28px; margin-top: 2px; }
.col-meta small { font-size: 11px; color: var(--hint); }
.col-play { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 12px;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.col-list { display: flex; flex-direction: column; gap: 6px; min-height: 36px; }
.item { background: var(--bg); border-radius: 10px; overflow: hidden; }
.thumb { position: relative; aspect-ratio: 4 / 3; overflow: hidden;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 38%, transparent), color-mix(in srgb, var(--accent) 8%, transparent)); }
.thumb.photo { background: linear-gradient(135deg, color-mix(in srgb, #f5a524 45%, transparent), color-mix(in srgb, #f5a524 10%, transparent)); }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.thumb img[hidden] { display: none; }
.thumb .kind { position: absolute; left: 5px; top: 5px; font-size: 11px; line-height: 1; padding: 3px 4px; border-radius: 6px;
  background: rgba(0, 0, 0, .35); }
.thumb .dur { position: absolute; right: 5px; bottom: 5px; font-size: 10.5px; font-weight: 600; color: #fff; padding: 2px 5px;
  border-radius: 6px; background: rgba(0, 0, 0, .5); }
.item-title { font-size: 12.5px; line-height: 1.3; padding: 5px 7px 6px; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.col-add { border: 1.5px dashed var(--line); border-radius: 10px; padding: 6px 0; color: var(--accent); font-size: 18px; line-height: 1; }
.col-new { flex: 0 0 72px; min-width: 72px; background: transparent; border: 1.5px dashed var(--line); padding: 0; align-self: stretch;
  min-height: 120px; justify-content: center; }
.col-new:has(input) { flex-basis: 160px; min-width: 160px; padding: 8px; justify-content: flex-start; }
.col-new-btn { height: 100%; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--accent); font-size: 22px; }
.col-new-btn small { font-size: 11px; }
.col-input { width: 100%; font: inherit; font-size: 14px; color: var(--text); background: var(--card); border: 1.5px solid var(--accent);
  border-radius: 10px; padding: 8px 10px; outline: none; }
.placeholder { opacity: .25; }
.ghost { position: fixed; z-index: 50; pointer-events: none; margin: 0; box-shadow: 0 14px 34px rgba(0, 0, 0, .28);
  opacity: .96; overflow: hidden; }
.ghost-item { border-radius: 10px; }
body.dragging, body.dragging * { cursor: grabbing !important; -webkit-user-select: none; user-select: none; }
.hint { text-align: center; margin: 6px 4px 0; }
