: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, #2f6bff);
    --accent-text: var(--tg-theme-button-text-color, #ffffff);
    --danger: var(--tg-theme-destructive-text-color, #e5484d);
    --ok: #2fb36b;
    --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg2); color: var(--text);
    font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }

header#top { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 16px 16px 8px; }
.hello .name { font-size: 22px; font-weight: 700; }
.top-actions { display: flex; gap: 6px; }
.top-actions select { width: auto; padding: 8px; }
main#screen, .stack { display: flex; flex-direction: column; gap: 10px; }
main#screen { padding: 8px 16px 16px; }

.card { background: var(--bg); border-radius: var(--radius); padding: 14px 16px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.card.lesson.cancelled { opacity: .5; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.title { font-weight: 600; font-size: 16px; }
.time { font-weight: 700; font-size: 17px; }
.big { font-size: 28px; font-weight: 800; }
.big.warn { color: var(--danger); }
.muted { color: var(--hint); font-size: 13px; }
.error { color: var(--danger); }
.center { text-align: center; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--hint); margin: 10px 4px 0; }
.parent-label { font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }

.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bg2); color: var(--hint); white-space: nowrap; }
.badge.planned { color: var(--accent); }
.badge.held { color: var(--ok); }
.badge.cancelled, .badge.moved { color: var(--danger); }

.actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btn { appearance: none; border: 0; border-radius: 12px; padding: 12px 16px; font: inherit; font-weight: 600;
    background: var(--accent); color: var(--accent-text); width: 100%; cursor: pointer; }
.btn.small { width: auto; padding: 8px 12px; font-size: 14px; }
.btn.ghost { background: var(--bg2); color: var(--accent); }
.btn.danger { background: var(--bg2); color: var(--danger); }
.btn:disabled { opacity: .5; }
button.icon { border: 0; background: none; font-size: 16px; color: var(--hint); cursor: pointer; margin-left: 6px; }

nav#tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--bg);
    border-top: 1px solid rgba(0,0,0,.06); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
nav#tabs button { flex: 1; border: 0; background: none; color: var(--hint); font: inherit; font-size: 11px;
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; cursor: pointer; }
nav#tabs button .ico { font-size: 22px; line-height: 1; }
nav#tabs button.on { color: var(--accent); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.chip { flex: 0 0 auto; border: 0; border-radius: 12px; padding: 8px 12px; background: var(--bg); color: var(--text);
    font: inherit; text-align: center; cursor: pointer; }
.sheet .chip { background: var(--bg2); }
.chip.on { background: var(--accent); color: var(--accent-text); }
.chip.on .muted { color: inherit; opacity: .8; }
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.slots p { grid-column: 1 / -1; }
.slot { border: 0; border-radius: 12px; padding: 10px 6px; background: var(--bg2); color: var(--text); font: inherit;
    display: flex; flex-direction: column; align-items: center; cursor: pointer; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field > span { font-size: 13px; color: var(--hint); }
input, select { width: 100%; border: 0; border-radius: 12px; padding: 12px; background: var(--bg2); color: var(--text); font: inherit; }
.sheet .card input, .sheet .card select { background: var(--bg); }
.check { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.check input { width: auto; }

.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; z-index: 10; }
.sheet.hidden, .toast.hidden { display: none; }
.sheet-body { background: var(--bg); width: 100%; max-height: 90vh; overflow-y: auto; border-radius: 20px 20px 0 0;
    padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; font-size: 19px; }
.sheet .card { background: var(--bg2); box-shadow: none; margin-top: 10px; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(90px + env(safe-area-inset-bottom)); background: rgba(20,20,20,.9);
    color: #fff; padding: 12px 16px; border-radius: 12px; text-align: center; z-index: 20; }

.list-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; gap: 8px;
    border-bottom: 1px solid var(--bg2); cursor: pointer; }
.list-item:last-child { border-bottom: 0; }
.link-box { word-break: break-all; font-size: 13px; background: var(--bg); padding: 10px; border-radius: 10px; margin: 8px 0; }
.hours { display: grid; grid-template-columns: 44px repeat(7, 1fr); gap: 4px; font-size: 12px; }
.hours .h { text-align: center; color: var(--hint); align-self: center; }
.hours button { border: 0; border-radius: 6px; height: 28px; background: var(--bg2); cursor: pointer; }
.hours button.on { background: var(--accent); }
table.stats { width: 100%; border-collapse: collapse; font-size: 13px; }
table.stats td, table.stats th { padding: 6px 4px; text-align: right; }
table.stats td:first-child, table.stats th:first-child { text-align: left; }
.bar { height: 6px; background: var(--accent); border-radius: 3px; margin-top: 3px; }
.slot.on { background: var(--accent); color: var(--accent-text); }