/* Edunest components — uses tokens.css */

/* Icons (Lucide, 1.75 stroke) */
svg.lucide, i[data-lucide] { width: 20px; height: 20px; stroke-width: 1.75; flex: none; }
i[data-lucide] { display: inline-block; }

/* Press feedback */
.pressable { transition: transform var(--t-press), background var(--t-press); }
.pressable:active { transform: scale(.97); }

/* Layout */
.app { min-height: 100vh; }
.content { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 0 16px 112px; }
.bento { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); }
.bento > * { grid-column: span 12; min-width: 0; }
.stack { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 12px; }

/* Section title */
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: var(--tap); }
.section-title h2 { font-size: var(--fs-section); font-weight: 700; letter-spacing: -0.01em; }
.section-title a { display: inline-flex; align-items: center; min-height: var(--tap); font-size: var(--fs-body); font-weight: 600; color: var(--brand); text-decoration: none; }

/* Card */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-card); padding: 16px; }
.card-flush { padding: 4px 16px; }

/* Hero card (one per screen, the only gradient) */
.hero {
  position: relative; overflow: hidden; padding: 20px; border-radius: var(--r-hero); color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0) 35%, rgba(255, 255, 255, .14) 55%, rgba(255, 255, 255, 0) 75%);
}
.hero > * { position: relative; }
.hero-label { font-size: var(--fs-sub); font-weight: 500; opacity: .85; }
.hero-number { margin-top: 4px; font-size: var(--fs-hero); font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.hero-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; font-size: var(--fs-sub); opacity: .95; }
.pill { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 10px; border-radius: 13px; background: rgba(255, 255, 255, .2); font-size: var(--fs-meta); font-weight: 600; white-space: nowrap; }
.pill svg.lucide, .pill i[data-lucide] { width: 14px; height: 14px; }
a.pill { position: relative; color: inherit; text-decoration: none; }
a.pill::after { content: ""; position: absolute; inset: -9px 0; } /* 44px tap area */
.hero-actions { flex-direction: column; align-items: flex-start; }
@media (max-width: 379px) {
  .hero-actions a.pill { align-self: stretch; justify-content: center; height: 44px; border-radius: 22px; }
}

/* Quick actions */
.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.qa { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--text); font-size: var(--fs-meta); font-weight: 500; text-decoration: none; text-align: center; }
:where(button).qa { background: none; border: 0; padding: 0; font-family: inherit; cursor: pointer; }
.qa-icon {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: var(--r-action);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-card); color: var(--brand);
  transition: transform var(--t-press);
}
.qa:active .qa-icon { transform: scale(.97); }
.qa-icon svg.lucide, .qa-icon i[data-lucide] { width: 22px; height: 22px; }

/* Icon tile */
.tile { display: grid; place-items: center; width: 48px; height: 48px; flex: none; border-radius: var(--r-tile); background: var(--fill); color: var(--secondary); font-size: var(--fs-large); font-weight: 700; }
.tile svg.lucide, .tile i[data-lucide] { width: 22px; height: 22px; }
.tile-sm { width: 44px; height: 44px; }
.tile-math { background: var(--math-bg); color: var(--math); }
.tile-english { background: var(--english-bg); color: var(--english); }
.tile-programming { background: var(--programming-bg); color: var(--programming); }
.tile-payment { background: var(--payment-bg); color: var(--payment); }
.tile-brand { background: var(--brand-soft); color: var(--brand); }

/* Progress ring */
.ring { position: relative; width: 72px; height: 72px; flex: none; }
.ring svg { display: block; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; }
.ring .track { stroke: var(--line); }
.ring .value { stroke: var(--brand); stroke-linecap: round; }
.ring span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 18px; font-weight: 800; }
.ring-card { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.ring-stats { display: flex; flex-basis: 100%; gap: 8px; margin: 0; padding: 12px 0 0; list-style: none; border-top: 1px solid var(--line); }
.ring-stats li { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.ring-stats b { font-size: var(--fs-large); font-weight: 700; }
.ring-card h3 { font-size: var(--fs-large); font-weight: 600; }

/* List row */
.row { display: flex; align-items: center; gap: 12px; min-height: 68px; padding: 12px 0; }
.row + .row { border-top: 1px solid var(--line); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: var(--fs-large); font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
.row-sub { font-size: var(--fs-sub); color: var(--secondary); overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
.row-value { font-size: var(--fs-large); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-value.pos { color: var(--present); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sub); font-weight: 600; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-present { color: var(--present); }
.status-late { color: var(--late); }
.status-absent { color: var(--absent); }
.status-pending { color: var(--secondary); }
/* Narrow rows: only money amounts move under the title */
.card-flush { container-type: inline-size; }
@container (max-width: 339px) {
  .row-money { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 12px; row-gap: 4px; }
  .row-money > .tile, .row-money > .avatar { grid-row: 1 / span 2; align-self: center; }
  .row-money > :not(.tile):not(.avatar):not(.row-main) { grid-column: 2; justify-self: start; }
}

/* Badge */
.badge { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 12px; background: var(--fill); color: var(--secondary); font-size: var(--fs-meta); font-weight: 600; white-space: nowrap; }
.badge-success { background: var(--english-bg); color: var(--present); }
.badge-warning { background: var(--payment-bg); color: var(--payment); }
.row-main .badge { margin-top: 6px; }

/* Header */
.header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 16px; margin: 0 -16px; transition: background var(--t-press); }
.header.is-stuck { background: var(--blur-bg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border-bottom: 1px solid var(--line); }
.avatar { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-size: var(--fs-large); font-weight: 700; }
.header-text { flex: 1; min-width: 0; }
.header-text h1 { font-size: var(--fs-greeting); font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; }
.icon-btn { position: relative; display: grid; place-items: center; width: 44px; height: 44px; flex: none; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--text); cursor: pointer; }
.icon-btn .badge-dot { position: absolute; top: 11px; right: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--absent); box-shadow: 0 0 0 2px var(--surface); }

/* Button */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--tap); padding: 0 18px;
  border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface); color: var(--text);
  font: inherit; font-size: var(--fs-large); font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: transform var(--t-press), background var(--t-press);
}
.btn:active { transform: scale(.97); }
.btn:hover { background: #FAFAFC; }
.btn-primary { border-color: var(--brand); background: var(--brand); color: #fff; }
.btn-primary:hover { background: #4E4EC9; }
.btn-text { border-color: transparent; background: transparent; color: var(--brand); padding: 0 12px; }
.btn-text:hover { background: var(--brand-soft); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }

/* Input */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: var(--fs-sub); color: var(--secondary); }
.input {
  height: 48px; width: 100%; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--r-control);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px; font-weight: 500;
  transition: border-color var(--t-press), box-shadow var(--t-press);
}
.input::placeholder { color: #9CA3AF; }
.input:focus-visible { border-color: var(--brand); box-shadow: var(--focus); }

/* Segmented */
.segmented { display: inline-flex; gap: 4px; padding: 4px; border-radius: var(--r-control); background: var(--fill); }
.segmented button {
  min-height: 36px; padding: 0 14px; border: 0; border-radius: 10px; background: transparent;
  color: var(--secondary); font: inherit; font-size: var(--fs-body); font-weight: 600; cursor: pointer;
  transition: background var(--t-press), color var(--t-press);
  flex: 1; position: relative; white-space: nowrap;
}
.segmented button::after { content: ""; position: absolute; inset: -4px 0; } /* 44px tap area */
.segmented.att button { padding: 0 10px; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(17, 24, 39, .08); }
.segmented.att button[aria-pressed="true"][data-v="present"] { color: var(--present); }
.segmented.att button[aria-pressed="true"][data-v="late"] { color: var(--late); }
.segmented.att button[aria-pressed="true"][data-v="absent"] { color: var(--absent); }

/* Sidebar (desktop) */
.sidebar { display: none; }
.nav-item {
  display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 0 12px; border-radius: var(--r-control);
  color: var(--secondary); font-size: var(--fs-large); font-weight: 600; text-decoration: none; transition: background var(--t-press);
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--brand-soft); color: var(--brand); }
/* Not built yet: visible, not clickable, "Tez orada" badge */
.is-soon { cursor: default; color: var(--secondary); }
.nav-item.is-soon:hover { background: none; color: var(--secondary); }
.nav-item.is-soon .badge { margin-left: auto; height: 20px; padding: 0 8px; font-size: 11px; }
.icon-btn.is-soon:disabled { opacity: .5; }

/* Tab bar (mobile, floating) */
.tabbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 30;
  display: flex; padding: 6px; border-radius: 24px; background: var(--surface); box-shadow: var(--shadow-float);
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .tabbar { background: var(--blur-bg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px;
  color: var(--secondary); font-size: 11px; font-weight: 600; text-decoration: none; border-radius: 18px;
}
.tab[aria-current="page"] { color: var(--brand); }

/* Bottom sheet */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(17, 24, 39, .3); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; width: 100%; max-width: 520px; max-height: 90vh; margin: 0 auto;
  overflow: auto; padding: 8px 20px calc(20px + env(safe-area-inset-bottom)); border-radius: 24px 24px 0 0;
  background: var(--surface); box-shadow: var(--shadow-float);
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .sheet { background: rgba(255, 255, 255, .92); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
}
.sheet-grabber { width: 40px; height: 5px; margin: 0 auto 12px; border-radius: 3px; background: #D1D5DB; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.sheet-head h3 { font-size: var(--fs-section); font-weight: 700; }
.sheet-enter, .sheet-leave { transition: transform var(--t-sheet); }
.sheet-from { transform: translateY(100%); }
.fade-enter, .fade-leave { transition: opacity var(--t-sheet); }
.fade-from { opacity: 0; }

[x-cloak] { display: none !important; }

/* Desktop */
@media (min-width: 1024px) {
  .app { display: flex; }
  .sidebar {
    position: sticky; top: 0; height: 100vh; width: var(--sidebar-w); flex: none;
    display: flex; flex-direction: column; gap: 4px; padding: 20px 16px; background: var(--surface); border-right: 1px solid var(--line);
  }
  .sidebar-brand { display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 0 12px; margin-bottom: 12px; font-size: var(--fs-section); font-weight: 700; }
  .sidebar-foot { margin-top: auto; padding-top: 8px; border-top: 1px solid var(--line); }
  .sidebar-foot .row { min-height: 60px; padding: 8px 4px; }
  .main { flex: 1; min-width: 0; }
  .content { padding: 0 32px 48px; }
  .header { margin: 0 -32px; padding: 20px 32px; }
  .tabbar { display: none; }
  .hero-actions { flex-direction: row; align-items: center; }
  .span-8 { grid-column: span 8; }
  .span-6 { grid-column: span 6; }
  .span-4 { grid-column: span 4; }
  .card { padding: 20px; }
  .card-flush { padding: 4px 20px; }
  .quick-actions {
    grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 8px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-card);
  }
  .qa { flex-direction: row; gap: 12px; min-height: 64px; padding: 8px 12px; border-radius: var(--r-control); font-size: var(--fs-large); font-weight: 600; transition: background var(--t-press); }
  .qa:hover { background: var(--bg); }
  .qa-icon { width: 48px; height: 48px; border: 0; box-shadow: none; background: var(--brand-soft); border-radius: var(--r-tile); }
  .sheet { bottom: 24px; border-radius: 24px; }
}

/* Login (/kirish) */
.sidebar-logo { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--brand); color: #fff; }
.card-title { font-size: var(--fs-section); font-weight: 700; margin-bottom: 4px; }
.field-label { font-size: var(--fs-sub); font-weight: 500; color: var(--secondary); }
.form-error { font-size: var(--fs-sub); font-weight: 600; color: var(--absent); }
.auth { width: 100%; max-width: 420px; margin: 0 auto; padding: 32px 16px 48px; display: flex; flex-direction: column; gap: 16px; }
.auth-brand { display: flex; align-items: center; gap: 10px; min-height: var(--tap); font-size: var(--fs-section); font-weight: 700; }
.auth-card { display: flex; flex-direction: column; gap: 16px; }
.auth-title { font-size: var(--fs-greeting); font-weight: 700; letter-spacing: -0.02em; }
.code-boxes { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.code-boxes .input { height: 56px; padding: 0; text-align: center; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.code-boxes .input[aria-invalid="true"] { border-color: var(--absent); }
.auth-or { display: flex; align-items: center; gap: 12px; color: var(--secondary); font-size: var(--fs-sub); }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-widget { min-height: var(--tap); }
.auth-dev { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

/* Navigation: AI tab (brand-filled circle), profile row link, empty state */
.tab-ai { gap: 2px; }
.tab-ai-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: #fff; box-shadow: var(--shadow-card); }
.tab-ai-icon svg.lucide, .tab-ai-icon i[data-lucide] { width: 20px; height: 20px; }
.tab-ai[aria-current="page"] .tab-ai-icon { background: var(--brand-2); }
.nav-profile { color: inherit; text-decoration: none; border-radius: var(--r-control); }
.nav-profile:hover { background: var(--bg); }
.nav-profile[aria-current="page"] { background: var(--brand-soft); }
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px 20px; text-align: center; }
.empty .meta { max-width: 36ch; }
.row-btn { width: 100%; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.row-btn:hover { background: var(--bg); }
.tab-ai-icon { margin: -20px 0 4px; } /* raised circle; label sits fully below it, aligned with other labels */
.badge { gap: 6px; }
.badge svg.lucide, .badge i[data-lucide] { width: 14px; height: 14px; }
.tile-danger { background: var(--fill); color: var(--absent); }
.row-danger .row-title { color: var(--absent); }

/* Groups / teachers (P5) */
.row-link { color: inherit; text-decoration: none; }
.row-link:hover { background: var(--bg); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.toolbar .meta { flex: 1 1 200px; }
.seg-link { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 10px; color: var(--secondary); font-size: var(--fs-body); font-weight: 600; text-decoration: none; position: relative; }
.seg-link::after { content: ""; position: absolute; inset: -4px 0; }
.seg-link[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(17, 24, 39, .08); }
.segmented.block { display: flex; width: 100%; }
.segmented.block button { padding: 0 6px; }
.segmented.days button { padding: 0 2px; }
.form-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
select.input { padding-right: 10px; }
.input-suffix { position: relative; }
.input-suffix .input { padding-right: 56px; }
.input-suffix span { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--secondary); font-size: var(--fs-body); font-weight: 500; pointer-events: none; }
.btn-danger { color: var(--absent); }
.btn-danger:hover { background: var(--fill); }

/* Students / parents (P6) */
.btn-danger-fill { border-color: var(--absent); background: var(--absent); color: #fff; }
.btn-danger-fill:hover { background: var(--absent); opacity: .92; }
.textarea { height: auto; min-height: 88px; padding: 12px 14px; resize: vertical; line-height: 1.45; }
.invite-code { width: 100%; height: 64px; border: 1px dashed var(--line); border-radius: var(--r-control); background: var(--bg); color: var(--text); font: inherit; font-size: 28px; font-weight: 800; letter-spacing: .2em; cursor: pointer; }
.row-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn.ghost { border-color: transparent; background: transparent; color: var(--brand); }
.icon-btn.ghost:hover { background: var(--brand-soft); }
.child-switch { margin-bottom: 4px; }
.badge-success svg.lucide, .badge-warning svg.lucide, .badge-success i[data-lucide], .badge-warning i[data-lucide] { width: 14px; height: 14px; }
.row-stretch { position: relative; }
.row-stretch .stretched { color: inherit; text-decoration: none; }
.row-stretch .stretched::after { content: ""; position: absolute; inset: 0; }
.row-stretch:hover { background: var(--bg); }
.row-stretch .row-actions { position: relative; z-index: 1; }
.icon-btn.ghost.danger { color: var(--absent); }
.icon-btn.ghost.danger:hover { background: var(--fill); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }

/* Attendance (P7) */
.mobile-only { display: block; }
.desktop-only { display: none; }
@media (min-width: 1024px) { .mobile-only { display: none; } .desktop-only { display: flex; } }
.att-list { margin: 0 -4px; }
.att-row { align-items: flex-start; }
.att-row .row-main { padding-top: 8px; }
.att-late { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.att-late .input { height: 36px; width: 84px; padding: 0 8px; font-size: var(--fs-body); }
.att-save { margin-top: 12px; position: sticky; bottom: 0; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; }
.dot-present { background: var(--present); }
.dot-late { background: var(--late); }
.dot-absent { background: var(--absent); }
.dot-none { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
.dot-na { background: transparent; }
.att-table-wrap { padding: 8px 20px 16px; overflow-x: auto; }
.att-table { width: 100%; border-collapse: collapse; font-size: var(--fs-body); }
.att-table th, .att-table td { padding: 10px 8px; text-align: center; border-bottom: 1px solid var(--line); }
.att-table tbody tr:last-child th, .att-table tbody tr:last-child td { border-bottom: 0; }
.att-table th[scope="row"], .att-table thead th:first-child { text-align: left; }
.att-col { position: relative; min-height: var(--tap); padding: 0 6px; border: 0; border-radius: 10px; background: none; color: var(--secondary); font: inherit; font-size: var(--fs-sub); font-weight: 600; cursor: pointer; }
.att-col:hover { background: var(--bg); color: var(--text); }
.att-unmarked { position: absolute; top: 6px; right: 0; width: 6px; height: 6px; border-radius: 50%; background: var(--late); }
.att-name { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; text-decoration: none; }
.avatar-sm { width: 32px; height: 32px; font-size: var(--fs-meta); }
.att-legend { display: flex; flex-wrap: wrap; gap: 16px; padding-top: 12px; }
.att-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.ring-empty .value { stroke: transparent; }
.pill-btn { border: 0; color: inherit; font: inherit; font-size: var(--fs-meta); font-weight: 600; cursor: pointer; position: relative; }
.pill-btn::after { content: ""; position: absolute; inset: -9px 0; }
@media (max-width: 379px) { .hero-actions .pill-btn { align-self: stretch; justify-content: center; height: 44px; border-radius: 22px; } }
.desktop-only > .segmented { align-self: flex-start; max-width: 100%; overflow-x: auto; }

/* P7 fixes / P8 */
.btn-sm { height: 36px; padding: 0 12px; font-size: var(--fs-body); position: relative; }
.btn-sm::after { content: ""; position: absolute; inset: -4px 0; } /* 44px tap area */
.approve-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badge-danger { background: var(--fill); color: var(--absent); }
.att-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
.att-stat { display: flex; flex-direction: column; gap: 4px; }
.att-stat b { font-size: var(--fs-section); font-weight: 700; }
.att-table .att-pct { font-weight: 700; color: var(--text); }
.att-table .att-low { color: var(--absent); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.file-btn { cursor: pointer; }
.file-btn:focus-within { box-shadow: var(--focus); }
.hw-image { display: block; width: 100%; max-height: 420px; object-fit: contain; border-radius: 14px; background: var(--bg); }
.hw-desc { white-space: pre-line; font-size: var(--fs-large); line-height: 1.5; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { min-height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--secondary); font: inherit; font-size: var(--fs-sub); font-weight: 600; cursor: pointer; position: relative; }
.chip::after { content: ""; position: absolute; inset: -6px 0; }
.chip[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.note-student { padding: 12px 0; border-top: 1px solid var(--line); }
.note-student .input { height: 40px; margin-top: 8px; font-size: var(--fs-body); }
.comment-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.hw-save { margin-top: 12px; }
@media (min-width: 1024px) {
  .quick-actions.qa-compact { grid-template-columns: repeat(2, 1fr); align-content: center; }
}
.child-switch { align-self: flex-start; max-width: 100%; overflow-x: auto; }

/* Payments (P9) */
.month-nav { display: inline-flex; align-items: center; gap: 8px; }
.month-nav b { min-width: 120px; text-align: center; font-size: var(--fs-section); }
.icon-btn-off { opacity: .35; cursor: default; }
.filter-seg { align-self: flex-start; max-width: 100%; overflow-x: auto; }
.filter-seg .seg-link { white-space: nowrap; }
.pos { color: var(--present); }
.money-big { font-size: var(--fs-hero); font-weight: 800; letter-spacing: -0.02em; }
.receipt { max-width: 420px; margin: 0 auto; }
.receipt-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px dashed var(--line); font-size: var(--fs-large); }
.receipt-row span:first-child { color: var(--secondary); }
.void { text-decoration: line-through; opacity: .6; }
@media (max-width: 600px) { .att-summary { grid-template-columns: 1fr; } }
@media print { .sidebar, .tabbar, .header, .no-print { display: none !important; } .content { padding: 0; } }
.col > .badge, .card.col > .badge { align-self: flex-start; }

/* Parent cabinet (P10) */
.month-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; align-content: center; }
.month-stats > div { display: flex; flex-direction: column; gap: 4px; }
.month-stats b { font-size: var(--fs-greeting); font-weight: 800; }
.subject-row { align-items: flex-start; }
.progress { display: grid; grid-template-columns: 72px 1fr 44px; align-items: center; gap: 8px; margin-top: 8px; }
.progress b { text-align: right; font-size: var(--fs-body); }
.bar { display: block; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 4px; background: var(--present); }
.bar-hw i { background: var(--brand); }
.hero-link { color: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* Profile (P10a) */
.switch { position: relative; display: inline-block; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; inset: -7px 0; width: 100%; height: 44px; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 16px; background: var(--line); transition: background var(--t-press); }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(17, 24, 39, .2); transition: transform var(--t-press); }
.switch input:checked + span { background: var(--present); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { box-shadow: var(--focus); }
.faq details { border-top: 1px solid var(--line); }
.faq details:first-child { border-top: 0; }
.faq summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; font-size: var(--fs-large); font-weight: 600; cursor: pointer; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--secondary); font-size: 20px; }
.faq details[open] summary::after { content: "–"; }
.faq p { padding-bottom: 14px; color: var(--secondary); font-size: var(--fs-large); line-height: 1.5; }
.fb-text { font-size: var(--fs-large); line-height: 1.5; white-space: pre-line; }
.fb-reply { padding: 10px 12px; border-radius: 12px; background: var(--brand-soft); font-size: var(--fs-body); }
.fb-item { padding: 14px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.fb-item:first-child { border-top: 0; }
.fb-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.day-free { padding: 0 4px 8px; }

/* AI assistant: notice, chat bubbles, composer, teacher report */
.ai-page { gap: 16px; }
.ai-page > .segmented { align-self: flex-start; max-width: 100%; overflow-x: auto; }
.ai-notice { display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px 14px; border-radius: var(--r-control); background: var(--brand-soft); color: var(--brand); font-size: var(--fs-sub); font-weight: 600; }
.ai-notice svg.lucide, .ai-notice i[data-lucide] { width: 18px; height: 18px; flex: none; }
.chat { display: flex; flex-direction: column; gap: 10px; }
.chat:empty { display: none; }
.bubble { display: flex; flex-direction: column; gap: 8px; max-width: 85%; padding: 12px 14px; border-radius: 18px; font-size: var(--fs-large); font-weight: 500; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble-user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 6px; }
.bubble-ai { align-self: flex-start; background: var(--bg); color: var(--text); border-bottom-left-radius: 6px; }
.bubble-wait { color: var(--secondary); }
.bubble img { display: block; max-width: 100%; max-height: 260px; border-radius: 12px; object-fit: contain; }
.bubble-copy { align-self: flex-start; margin: 0 -8px -6px; white-space: nowrap; }
.composer { display: flex; flex-direction: column; gap: 8px; }
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.composer-input { flex: 1; min-height: 44px; max-height: 160px; resize: vertical; }
.composer-btn { flex: none; cursor: pointer; }
.composer-send { flex: none; background: var(--brand); color: #fff; }
.composer-send:disabled { background: var(--fill); color: var(--secondary); }
.composer-preview { position: relative; align-self: flex-start; }
.composer-preview img { display: block; max-height: 120px; border-radius: 12px; }
.composer-preview .icon-btn { position: absolute; top: -10px; right: -10px; width: 32px; height: 32px; }
.ai-q { display: flex; flex-direction: column; gap: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.ai-text { margin: 0; font-size: var(--fs-large); white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-thumb { display: block; max-width: 160px; max-height: 160px; border-radius: 12px; border: 1px solid var(--line); object-fit: cover; }
.ai-answer summary { min-height: 44px; display: flex; align-items: center; color: var(--brand); font-size: var(--fs-body); font-weight: 600; cursor: pointer; }
.ai-answer .ai-text { color: var(--secondary); }

/* Chat (P11a): reuses AI bubbles and composer */
.chat-item { display: flex; flex-direction: column; gap: 4px; }
.chat-item.is-mine { align-items: flex-end; }
.chat-day { align-self: center; text-align: center; padding: 4px 0; }
.chat-item .bubble { cursor: pointer; transition: transform var(--t-press); }
.chat-item .bubble-ai { background: var(--surface); border: 1px solid var(--line); }
.chat-item .bubble { max-width: min(85%, 560px); }
.chat-item .bubble:active { transform: scale(.97); }
.bubble-name { font-size: var(--fs-sub); font-weight: 600; color: var(--brand); }
.bubble-meta { align-self: flex-end; margin-top: -4px; font-size: var(--fs-meta); opacity: .7; }
.bubble-deleted { font-style: italic; opacity: .75; }
.bubble-reported { box-shadow: 0 0 0 2px var(--absent); }
.reacts { display: flex; flex-wrap: wrap; gap: 4px; }
.react { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; padding: 0 10px; }
.react svg.lucide, .react i[data-lucide] { width: 14px; height: 14px; }
.react-row { display: flex; justify-content: space-between; gap: 8px; }
.react-row .icon-btn[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.chat-composer { position: sticky; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 5; padding: 8px 0; background: var(--bg); }
@media (min-width: 1024px) { .chat-composer { bottom: 0; padding-bottom: 16px; } }


/* Smoothness (perf pass): tap feedback, page transitions, skeletons, low-end devices */
a, button, label, summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.qa, .tab, .row-link, .row-btn, .icon-btn, .chip, .seg-link, .nav-item, a.pill, .pill-btn, .composer-send {
  transition: transform var(--t-press), background var(--t-press);
}
.qa:active, .tab:active, .row-link:active, .row-btn:active, .icon-btn:active, .chip:active, .seg-link:active, .nav-item:active,
a.pill:active, .pill-btn:active, .composer-send:active { transform: scale(.97); }
.row-link:active, .row-btn:active { background: var(--bg); }
:disabled:active { transform: none; }

/* Cross-document View Transitions: the page content cross-fades, nav bars stay put */
@view-transition { navigation: auto; }
.tabbar { view-transition-name: tabbar; }
.sidebar { view-transition-name: sidebar; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 180ms; animation-timing-function: cubic-bezier(.32, .72, 0, 1); }

/* Skeletons while a sheet loads its data */
.skeleton { display: block; height: 14px; border-radius: 7px; background: linear-gradient(90deg, var(--line) 25%, #F7F8FB 50%, var(--line) 75%); background-size: 200% 100%; animation: skeleton 1.1s linear infinite; }
.skeleton-row { display: flex; align-items: center; gap: 12px; min-height: 68px; padding: 12px 0; }
.skeleton-row + .skeleton-row { border-top: 1px solid var(--line); }
.skeleton-row .skeleton-tile { flex: none; width: 44px; height: 44px; border-radius: var(--r-tile); }
.skeleton-row .skeleton-lines { flex: 1; display: grid; gap: 8px; }
@keyframes skeleton { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Blur only where cheap: no-blur (set in <head> for low-end devices / data saver) and reduced transparency */
.no-blur .tabbar, .no-blur .header.is-stuck { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--surface); }
.no-blur .sheet { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--surface); }
@media (prefers-reduced-transparency: reduce) {
  .tabbar, .header.is-stuck, .sheet { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; background: var(--surface) !important; }
}
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .skeleton { animation: none; }
  .qa:active, .tab:active, .row-link:active, .row-btn:active, .icon-btn:active, .chip:active, .seg-link:active, .nav-item:active,
  a.pill:active, .pill-btn:active, .btn:active, .chat-item .bubble:active { transform: none; }
}
