:root {
  --bg: #F7F5F0;
  --card: #FFFFFF;
  --ink: #1D2033;
  --ink-2: #5B5F73;
  --ink-3: #9A9DAD;
  --line: #E7E3DA;
  --accent: #5A3FE0;
  --accent-2: #EDE9FF;
  --mint: #19A974;
  --mint-2: #E2F6EE;
  --warm: #FF7A3D;
  --warm-2: #FFEDE3;
  --danger: #E5484D;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(29,32,51,.05), 0 6px 20px rgba(29,32,51,.06);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.4; }
body { min-height: 100dvh; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Шапка ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); background: rgba(247,245,240,.92);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 19px; letter-spacing: -.02em; text-decoration: none; color: var(--ink); }
.logo-mark { width: 32px; height: 32px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; }
.logo-mark svg { width: 18px; height: 18px; }
.logo b { color: var(--accent); font-weight: 800; }
.topbar .spacer { flex: 1; }

.wrap { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(96px + var(--safe-b)); }
h1 { font-size: 26px; letter-spacing: -.02em; margin: 6px 0 14px; }
h2 { font-size: 18px; margin: 22px 0 10px; letter-spacing: -.01em; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }

/* ---------- Карточки и кнопки ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px;
  border-radius: 14px; border: 0; background: var(--accent); color: #fff; font-weight: 650; cursor: pointer; text-decoration: none;
  transition: transform .08s ease, opacity .15s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--accent-2); color: var(--accent); }
.btn.light { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.mint { background: var(--mint); }
.btn.danger { background: #FDECEC; color: var(--danger); }
.btn.sm { min-height: 38px; padding: 0 12px; border-radius: 11px; font-size: 14px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.icon-btn:active { background: var(--accent-2); }

label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; font-weight: 600; }
input[type=text], input[type=password], input[type=datetime-local], input[type=number], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 13px; border: 1.5px solid var(--line); background: #fff; outline: none; font-size: 16px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

.error { color: var(--danger); font-size: 14px; min-height: 20px; margin: 6px 0; }
.empty { text-align: center; padding: 28px 16px; color: var(--ink-2); }
.empty .big { font-size: 40px; margin-bottom: 6px; }

/* ---------- Нижние вкладки ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; background: rgba(255,255,255,.96);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabbar button { flex: 1; border: 0; background: none; padding: 9px 0 8px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600; color: var(--ink-3); cursor: pointer; }
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button.on { color: var(--accent); }
.tab { display: none; }
.tab.on { display: block; }

/* ---------- Урок в списке ---------- */
.day-label { font-size: 13px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; margin: 18px 4px 8px; }
.lesson { display: flex; align-items: center; gap: 12px; }
.lesson .time { min-width: 58px; text-align: center; padding: 8px 4px; border-radius: 12px; background: var(--accent-2); color: var(--accent); font-weight: 750; font-size: 15px; line-height: 1.1; }
.lesson .time small { display: block; font-weight: 600; font-size: 11px; opacity: .8; }
.lesson .info { flex: 1; min-width: 0; }
.lesson .who { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lesson .topic { font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lesson.past { opacity: .55; }
.lesson.live .time { background: var(--mint); color: #fff; }

.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--accent-2); color: var(--accent); }
.badge.mint { background: var(--mint-2); color: var(--mint); }
.badge.warm { background: var(--warm-2); color: var(--warm); }
.badge.gray { background: #F0EEE8; color: var(--ink-2); }

/* Ближайший урок (большая карточка) */
.next-card { background: linear-gradient(135deg, #5A3FE0 0%, #7B5CF5 100%); color: #fff; border-radius: 22px; padding: 20px; margin-bottom: 14px; box-shadow: 0 10px 30px rgba(90,63,224,.28); position: relative; overflow: hidden; }
.next-card .lbl { font-size: 13px; opacity: .85; font-weight: 600; }
.next-card .when { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 4px 0 2px; }
.next-card .count { font-size: 15px; opacity: .9; margin-bottom: 16px; }
.next-card .btn { background: #fff; color: var(--accent); }
.next-card .btn.go { background: var(--mint); color: #fff; animation: pulse 1.6s infinite; }
.next-card .staff-deco { position: absolute; right: -10px; top: 14px; width: 150px; opacity: .18; pointer-events: none; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(25,169,116,.55); } 50% { box-shadow: 0 0 0 10px rgba(25,169,116,0); } }

/* ---------- Таблица учеников ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--ink-3); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 0 8px 8px; }
.table td { padding: 12px 8px; border-top: 1px solid var(--line); vertical-align: middle; font-size: 15px; }
.table td.num { text-align: center; font-weight: 700; }
.table .name { font-weight: 650; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 750; color: #fff; font-size: 14px; flex: none; }
.row-name { display: flex; align-items: center; gap: 10px; }

/* ---------- Нижний лист (модальное окно) ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(20,22,35,.38); z-index: 50; display: none; align-items: flex-end; justify-content: center; }
.sheet-bg.on { display: flex; }
.sheet { width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto; background: #fff; border-radius: 24px 24px 0 0; padding: 10px 18px calc(18px + var(--safe-b)); animation: up .22s ease; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { margin: 0 0 14px; font-size: 20px; }
.sheet .row { display: flex; gap: 10px; }
.sheet .row > * { flex: 1; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.copybox { display: flex; gap: 8px; align-items: center; background: var(--bg); border-radius: 13px; padding: 10px 12px; font-size: 14px; word-break: break-all; margin: 10px 0; }

.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 13px; font-size: 14px; font-weight: 600; z-index: 100; opacity: 0; transition: .2s; pointer-events: none; max-width: 90vw; text-align: center; }
.toast.on { opacity: 1; transform: translateX(-50%); }

.hint { display: flex; gap: 12px; align-items: flex-start; background: var(--warm-2); border-radius: 16px; padding: 14px; margin-bottom: 12px; font-size: 14px; }
.hint .ic { font-size: 22px; line-height: 1; }

/* ---------- Вход / приглашение ---------- */
.center-page { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px 20px; max-width: 420px; margin: 0 auto; }
.hero-logo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 26px; text-align: center; }
.hero-logo .logo-mark { width: 64px; height: 64px; border-radius: 20px; box-shadow: 0 10px 30px rgba(90,63,224,.3); }
.hero-logo .logo-mark svg { width: 34px; height: 34px; }
.hero-logo .title { font-size: 30px; font-weight: 850; letter-spacing: -.03em; }
.hero-logo .title b { color: var(--accent); }
