:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f1f3f6);
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #7d8590);
  --link: var(--tg-theme-link-color, #2481cc);
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: #e5484d;
  --ok: #30a46c;
  --warn: #f5a524;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg2); color: var(--text); font: 16px/1.4 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; }
main { padding: 12px 12px 90px; max-width: 640px; margin: 0 auto; }

h2 { font-size: 20px; margin: 4px 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--hint); margin: 18px 4px 8px; font-weight: 600; }
h3.today { color: var(--btn); }

.card { background: var(--bg); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--hint); font-size: 14px; }
.small { font-size: 13px; }
.pre { white-space: pre-wrap; word-break: break-word; }
.empty { text-align: center; color: var(--hint); padding: 36px 12px; }

.lesson .time { width: 52px; font-variant-numeric: tabular-nums; font-weight: 600; flex: none; }
.lesson .time span { display: block; font-weight: 400; color: var(--hint); font-size: 12px; }
.lesson .subj { font-weight: 600; }

.btn { background: var(--btn); color: var(--btn-text); border: 0; border-radius: 10px; padding: 9px 14px; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--link); padding: 6px 8px; font-weight: 500; }
.btn.sec { background: var(--bg2); color: var(--text); }
.btn.danger { background: transparent; color: var(--danger); padding: 6px 8px; font-weight: 500; }
.btn.block { width: 100%; padding: 12px; }
.btn.sm { padding: 6px 10px; font-size: 14px; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--bg2); color: var(--hint); white-space: nowrap; }
.badge.red { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.badge.green { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.badge.amber { background: color-mix(in srgb, var(--warn) 22%, transparent); color: #b7791f; }

.check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--hint); flex: none; display: grid; place-items: center; cursor: pointer; background: transparent; padding: 0; color: transparent; font-size: 14px; }
.check.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.done .grow { opacity: .5; text-decoration: line-through; }

.seg { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; margin-bottom: 10px; }
.seg button { flex: 1; border: 0; background: transparent; color: var(--hint); padding: 7px 4px; border-radius: 8px; font: inherit; font-size: 14px; cursor: pointer; }
.seg button.on { background: var(--btn); color: var(--btn-text); font-weight: 600; }

nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--bg); border-top: 1px solid color-mix(in srgb, var(--hint) 25%, transparent); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 10; }
nav button { flex: 1; border: 0; background: transparent; color: var(--hint); font: inherit; font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; cursor: pointer; }
nav button .ic { font-size: 21px; line-height: 1; }
nav button.on { color: var(--btn); font-weight: 600; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 90vh; overflow: auto; }
.sheet h2 { margin-top: 0; }
label.f { display: block; margin-bottom: 10px; font-size: 13px; color: var(--hint); }
label.f input, label.f select, label.f textarea { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--hint) 35%, transparent); background: var(--bg2); color: var(--text); font: inherit; font-size: 16px; }
label.f textarea { min-height: 90px; resize: vertical; }
label.c { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 15px; }
label.c input { width: 20px; height: 20px; }
.actions { display: flex; gap: 8px; margin-top: 6px; }
.actions .btn { flex: 1; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
td, th { padding: 6px 4px; text-align: center; }
td:first-child, th:first-child { text-align: left; }
th { color: var(--hint); font-weight: 500; font-size: 12px; }
tr + tr td { border-top: 1px solid color-mix(in srgb, var(--hint) 18%, transparent); }

#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: #222; color: #fff; padding: 9px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; max-width: 90%; text-align: center; }
#toast.show { opacity: 1; }
