  
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

    :root {
      /* Light theme (EngBoard-style: white surfaces, blue actions, slate neutrals) */
      --bg: #f6f8fc;
      --bg-card: #ffffff;
      --border: #e2e8f0;
      --border-normal: #e2e8f0;
      --accent: #2563eb;
      --accent-2: #4f46e5;
      --emerald: #059669;
      --amber: #d97706;
      --rose: #e11d48;
      --sky: #0284c7;
      --text: #0f172a;
      --text-muted: #64748b;
      --text-dim: #94a3b8;
      --inset: #f1f5f9;        /* light slate "well" — replaces dark-theme inset panels */
      --radius: 16px;
    }

    html, body {
      height: 100%;
      font-family: 'Inter', -apple-system, sans-serif;
      background: var(--bg);
      color: var(--text);
      -webkit-font-smoothing: antialiased;
      overflow-x: hidden;
    }

    /* Background */
    .bg-mesh {
      position: fixed; inset: 0; z-index: 0; pointer-events: none;
      background:
        radial-gradient(ellipse 60% 50% at 20% 30%, rgba(99,102,241,0.08) 0%, transparent 50%),
        radial-gradient(ellipse 50% 40% at 80% 60%, rgba(16,185,129,0.06) 0%, transparent 50%);
    }

    /* Layout */
    .app {
      position: relative; z-index: 1;
      max-width: 1200px; margin: 0 auto;
      padding: 32px 24px;
    }

    /* Header */
    .dash-header {
      display: flex; align-items: center; justify-content: space-between;
      margin-bottom: 36px;
    }

    .dash-header h1 {
      font-size: 1.8rem; font-weight: 800;
      letter-spacing: -0.5px;
      display: flex; align-items: center; gap: 12px;
    }

    .dash-actions {
      display: flex; gap: 10px;
    }

    .btn-sm {
      padding: 10px 18px; border-radius: 12px;
      border: 1px solid var(--border);
      background: var(--bg-card); color: var(--text-muted);
      font-size: 0.85rem; font-weight: 600; cursor: pointer;
      font-family: inherit; transition: all 0.2s;
      text-decoration: none;
    }

    .btn-sm:hover {
      background: rgba(255,255,255,0.06);
      color: var(--text); border-color: var(--accent);
    }

    /* Stats grid */
    .stats-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
      gap: 16px; margin-bottom: 36px;
    }

    .stat-card {
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 24px;
      transition: transform 0.2s, border-color 0.2s;
    }

    .stat-card:hover {
      transform: translateY(-2px);
      border-color: rgba(255,255,255,0.15);
    }

    .stat-card .label {
      font-size: 0.75rem; font-weight: 700;
      text-transform: uppercase; letter-spacing: 0.5px;
      color: var(--text-dim); margin-bottom: 10px;
    }

    .stat-card .value {
      font-size: 2.2rem; font-weight: 800;
      line-height: 1; margin-bottom: 6px;
    }

    .stat-card .sub {
      font-size: 0.8rem; color: var(--text-dim);
    }

    .stat-card.accent .value { color: var(--accent); }
    .stat-card.emerald .value { color: var(--emerald); }
    .stat-card.amber .value { color: var(--amber); }
    .stat-card.rose .value { color: var(--rose); }

    /* Sections */
    .section {
      margin-bottom: 36px;
    }

    .section-title {
      font-size: 1.15rem; font-weight: 700; margin-bottom: 16px;
      display: flex; align-items: center; gap: 8px;
      color: var(--text);
    }

    /* Student table */
    .table-wrap {
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      overflow: hidden;
    }

    .student-table {
      width: 100%; border-collapse: collapse;
    }

    .student-table th {
      padding: 14px 20px;
      font-size: 0.72rem; font-weight: 700;
      text-transform: uppercase; letter-spacing: 0.5px;
      color: var(--text-dim);
      text-align: left;
      background: rgba(255,255,255,0.02);
      border-bottom: 1px solid var(--border);
    }

    .student-table td {
      padding: 14px 20px;
      font-size: 0.9rem;
      border-bottom: 1px solid rgba(255,255,255,0.04);
      vertical-align: middle;
    }

    .student-table tr:hover td {
      background: rgba(99,102,241,0.04);
    }

    .student-table tr:last-child td {
      border-bottom: none;
    }

    .student-name {
      font-weight: 600; color: var(--text);
    }

    .student-email {
      font-size: 0.78rem; color: var(--text-dim); margin-top: 2px;
    }

    .badge {
      display: inline-flex; padding: 3px 10px;
      border-radius: 8px; font-size: 0.72rem; font-weight: 700;
      text-transform: uppercase; letter-spacing: 0.3px;
    }

    .badge-active {
      background: rgba(16,185,129,0.12); color: #34d399;
    }

    .badge-idle {
      background: rgba(245,158,11,0.12); color: #fbbf24;
    }

    .badge-offline {
      background: rgba(255,255,255,0.05); color: var(--text-dim);
    }

    .progress-bar-mini {
      height: 6px; width: 100px;
      background: rgba(255,255,255,0.06);
      border-radius: 3px; overflow: hidden;
    }

    .progress-bar-mini .fill {
      height: 100%; border-radius: 3px;
      transition: width 0.5s ease;
    }

    /* Recent activity */
    .activity-list {
      display: flex; flex-direction: column;
    }

    .activity-item {
      display: flex; align-items: center; gap: 14px;
      padding: 14px 20px;
      border-bottom: 1px solid rgba(255,255,255,0.04);
      transition: background 0.15s;
    }

    .activity-item:hover {
      background: rgba(99,102,241,0.04);
    }

    .activity-item:last-child { border-bottom: none; }

    .activity-icon {
      width: 36px; height: 36px; border-radius: 10px;
      display: flex; align-items: center; justify-content: center;
      font-size: 16px; flex-shrink: 0;
    }

    .activity-icon.progress { background: rgba(99,102,241,0.12); }
    .activity-icon.vocab { background: rgba(16,185,129,0.12); }
    .activity-icon.session { background: rgba(56,189,248,0.12); }

    .activity-text {
      flex: 1;
    }

    .activity-text strong { color: var(--text); }

    .activity-text .desc {
      font-size: 0.85rem; color: var(--text-muted);
    }

    .activity-time {
      font-size: 0.75rem; color: var(--text-dim);
      white-space: nowrap;
    }

    /* Loading */
    .loading-state {
      text-align: center; padding: 60px 20px;
      color: var(--text-dim);
    }

    .loading-state .spinner {
      width: 32px; height: 32px; margin: 0 auto 16px;
      border: 3px solid rgba(99,102,241,0.2);
      border-top-color: var(--accent); border-radius: 50%;
      animation: spin 0.7s linear infinite;
    }

    @keyframes spin { to { transform: rotate(360deg); } }

    .empty-state {
      text-align: center; padding: 40px 20px; color: var(--text-dim);
      font-size: 0.9rem;
    }

    /* Error */
    .error-banner {
      display: none; padding: 16px 20px;
      background: rgba(239,68,68,0.1);
      border: 1px solid rgba(239,68,68,0.2);
      border-radius: 14px; color: #fca5a5;
      font-size: 0.9rem; margin-bottom: 24px;
    }

    .error-banner.visible { display: flex; align-items: center; gap: 10px; }

    /* Mobile (small screen overrides for top sections) */
    @media (max-width: 768px) {
      .app { padding: 16px 12px; }
      .dash-header h1 { font-size: 1.3rem; }
      .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
      .stat-card { padding: 16px; }
      .stat-card .value { font-size: 1.6rem; }
      .student-table th, .student-table td { padding: 10px 12px; font-size: 0.82rem; }
      .dash-header { flex-direction: column; gap: 12px; align-items: flex-start; }
    }

    /* Modal Styles */
    .modal-overlay {
      position: fixed; top: 0; left: 0; right: 0; bottom: 0;
      background: rgba(0,0,0,0.8); backdrop-filter: blur(4px);
      display: none; align-items: center; justify-content: center;
      z-index: 1000; padding: 20px;
    }
    .modal-overlay.active { display: flex; }
    .modal-content {
      background: var(--bg); border: 1px solid var(--border);
      border-radius: var(--radius); padding: 24px;
      width: 100%; max-width: 400px;
      box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    }

    /* ─── Calendar Grid (mobile-first) ─────────────────
       Mobile (default): 3 days visible, horizontal scroll for the rest of the week.
       Desktop (≥768px): all 7 days fit. */
    /* ─── Calendar Grid: CSS Grid Row-Span architecture ─────────────
       1 column for time labels + 7 day columns.
       Rows: 1 header row + 96 fifteen-minute slots (24h × 4).
       Hour labels span 4 rows. Click-cells span 4 rows.
       Lessons span (durationMins / 15) rows — perfect alignment, no overflow. */
    #weeklyCalendarGrid {
      display: grid;
      grid-template-columns: 48px repeat(7, minmax(96px, 1fr));
      grid-auto-rows: 15px;
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 12px;
      overflow-x: auto;
      overflow-y: hidden;
      -webkit-overflow-scrolling: touch;
      position: relative;
      width: 100%;
      max-width: 100%;
      scrollbar-width: thin;
    }

    @media (min-width: 768px) {
      #weeklyCalendarGrid {
        grid-template-columns: 60px repeat(7, minmax(110px, 1fr));
        overflow-x: visible;
      }
    }

    #calendarBody { display: contents; }

    .cal-time-header, .cal-hour-label {
      background: var(--bg-card);
      padding: 8px 4px;
      font-size: 0.65rem;
      font-weight: 600;
      color: var(--text-muted);
      text-align: center;
      position: sticky;
      left: 0;
      z-index: 11;
      border-right: 1px solid var(--border);
      display: flex;
      align-items: flex-start;
      justify-content: center;
    }
    .cal-time-header {
      align-items: center;
      grid-row: 1;
      grid-column: 1;
    }
    .cal-hour-label {
      grid-column: 1;
      grid-row: span 4;
      border-top: 1px solid var(--border);
      padding-top: 2px;
      font-size: 0.62rem;
    }

    @media (min-width: 768px) {
      .cal-time-header, .cal-hour-label {
        font-size: 0.68rem;
        padding: 10px 4px 0;
      }
      .cal-hour-label { padding-top: 2px; }
    }

    .cal-day-header {
      background: var(--bg-card);
      padding: 10px 4px;
      text-align: center;
      font-weight: 700;
      font-size: 0.72rem;
      color: var(--text-muted);
      letter-spacing: 0.3px;
      grid-row: 1;
      position: sticky;
      top: 0;
      z-index: 10;
      border-bottom: 1px solid var(--border);
      border-left: 1px solid var(--border);
    }
    @media (min-width: 768px) {
      .cal-day-header { font-size: 0.8rem; padding: 12px 4px; }
    }

    /* Click-area cell: spans 1 hour (4 slots), clickable for create-lesson */
    .cal-cell {
      grid-row: span 4;
      background: transparent;
      position: relative;
      transition: background 0.15s;
      border-top: 1px solid var(--border);
      border-left: 1px solid var(--border);
    }
    .cal-cell:hover { background: rgba(255,255,255,0.03); }
    /* Сегодняшняя колонка — лёгкий accent-оттенок поверх всех ячеек,
       чтобы пользователь сразу видел «где сегодня». */
    .cal-cell.is-today { background: rgba(99,102,241,0.05); }
    .cal-cell.is-today:hover { background: rgba(99,102,241,0.09); }

    /* ─── Lesson Cards (cal-event) — Pill-Chip style ───────────────
       Compact pill-shaped chips that always fit inside their cell.
       Color dot replaces the heavy left border.
       Popover/sheet handles full details on hover/tap.
    */
    .cal-event {
      position: relative;
      margin: 1px 3px;
      border-radius: 8px;
      padding: 4px 7px 3px 20px;
      font-size: 0.72rem;
      color: var(--text);
      cursor: pointer;
      z-index: 5;
      background: rgba(99, 102, 241, 0.13);
      border: 1px solid rgba(99, 102, 241, 0.30);
      box-shadow:
        0 1px 3px rgba(0,0,0,0.25),
        inset 0 1px 0 rgba(255,255,255,0.05);
      display: flex;
      flex-direction: column;
      justify-content: center;
      gap: 1px;
      line-height: 1.2;
      overflow: hidden;
      align-self: stretch;
      min-width: 0;
      transform-origin: center top;
      transition:
        transform 160ms cubic-bezier(.2,.7,.2,1),
        box-shadow 160ms ease,
        background-color 130ms ease,
        border-color 130ms ease,
        filter 130ms ease;
      will-change: transform, box-shadow;
    }

    /* Color dot in top-left corner */
    .cal-event::before {
      content: '';
      position: absolute;
      left: 7px;
      top: 50%;
      transform: translateY(-50%);
      width: 6px; height: 6px;
      border-radius: 50%;
      background: var(--accent);
      flex-shrink: 0;
    }
    .cal-event.paid::before    { background: var(--emerald); }
    .cal-event.unpaid::before  { background: var(--rose); }
    .cal-event.pending::before { background: var(--amber); }
    .cal-event.busy::before    { background: var(--text-dim); }

    /* Clip text, never overflow */
    .cal-event .cal-event-title,
    .cal-event .cal-event-sub {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    /* Default state: hide actions, mark hover-only on devices with real pointers */
    .cal-event-actions {
      display: flex;
      gap: 4px;
      margin-top: 0;
      max-height: 0;
      opacity: 0;
      overflow: hidden;
      flex-wrap: wrap;
      pointer-events: none;
      transition:
        max-height 200ms cubic-bezier(.2,.7,.2,1),
        opacity 140ms ease,
        margin-top 200ms ease;
    }

    /* Status colors — pill tint + border, dot via ::before */
    .cal-event.scheduled { background: rgba(99,102,241,0.11);  border-color: rgba(99,102,241,0.30); }
    .cal-event.paid      { background: rgba(16,185,129,0.11);  border-color: rgba(16,185,129,0.32); }
    .cal-event.unpaid    { background: rgba(244,63,94,0.11);   border-color: rgba(244,63,94,0.30); }
    .cal-event.pending   { background: rgba(245,158,11,0.11);  border-color: rgba(245,158,11,0.45); border-style: dashed; animation: calEventPulse 2.4s ease-in-out infinite; }
    @keyframes calEventPulse {
      0%, 100% { box-shadow: 0 0 0 0 rgba(245,158,11,0.30); }
      50%      { box-shadow: 0 0 0 4px rgba(245,158,11,0.10); }
    }
    .cal-event.busy      { background: rgba(255,255,255,0.03); border-color: var(--border); border-style: dashed; color: var(--text-dim); cursor: not-allowed; }
    .cal-event.completed { opacity: 0.78; }
    .cal-event.completed::after {
      content: '';
      position: absolute; inset: 0;
      border-radius: inherit;
      background: repeating-linear-gradient(45deg, transparent 0 6px, rgba(255,255,255,0.03) 6px 8px);
      pointer-events: none;
    }

    /* ── Expanded state — touch only (.is-expanded). Desktop uses popover, see below. ── */
    .cal-event.is-expanded:not(.busy) {
      z-index: 50;
      box-shadow:
        0 0 0 1px rgba(255,255,255,0.08),
        0 16px 32px -6px rgba(0,0,0,0.6),
        0 6px 14px rgba(0,0,0,0.4);
    }
    .cal-event.is-expanded:not(.busy) .cal-event-actions {
      max-height: 60px;
      opacity: 1;
      margin-top: 6px;
      pointer-events: auto;
    }

    /* ── Desktop: pill-chip idle + popover on hover ──
       Idle card stays as a compact chip. Popover handles full info. */
    @media (hover: hover) and (pointer: fine) and (min-width: 768px) {
      .cal-event {
        padding: 3px 6px 3px 18px;
      }
      .cal-event::before {
        left: 6px;
        width: 5px; height: 5px;
      }
      .cal-event .cal-event-title {
        font-size: 0.68rem;
        font-weight: 700;
        padding-right: 20px;
        letter-spacing: -0.1px;
      }
      .cal-event .cal-event-sub {
        font-size: 0.62rem;
      }
      .cal-event .cal-event-time {
        font-size: 0.64rem;
        font-weight: 700;
        opacity: 0.9;
      }
      .cal-event .cal-event-corner {
        width: 18px; height: 18px;
        top: 3px; right: 3px;
      }
      .cal-event .cal-event-corner i {
        width: 10px; height: 10px;
      }
      /* Hide inline action row on desktop — actions live in popover */
      .cal-event .cal-event-actions {
        display: none !important;
      }
      /* Hover: subtle glow lift */
      .cal-event:hover:not(.busy) {
        z-index: 6;
        box-shadow:
          0 3px 10px rgba(0,0,0,0.32),
          0 0 0 1px rgba(255,255,255,0.08);
        filter: brightness(1.08);
      }
    }

    /* Tablet (768px+, touch): comfortable padding with room for dot */
    @media (min-width: 768px) and (hover: none) {
      .cal-event { padding: 5px 9px 5px 20px; }
    }

    /* ── Lesson popover (desktop hover) ──
       Floating card positioned by JS next to the hovered lesson. */
    .cal-popover {
      position: fixed;
      z-index: 900;
      width: 320px;
      max-width: calc(100vw - 24px);
      padding: 14px 16px 12px;
      border-radius: 14px;
      background: rgba(20, 22, 35, 0.96);
      backdrop-filter: blur(14px);
      -webkit-backdrop-filter: blur(14px);
      border: 1px solid rgba(255,255,255,0.10);
      box-shadow:
        0 0 0 1px rgba(0,0,0,0.4),
        0 24px 60px -12px rgba(0,0,0,0.7),
        0 8px 24px rgba(0,0,0,0.4);
      color: var(--text);
      /* По умолчанию popover скрыт и НЕ участвует в hit-testing — иначе
         невидимый элемент (opacity:0) продолжает ловить клики и блокирует
         ячейки календаря под собой. */
      pointer-events: none;
      opacity: 0;
      transform: translateY(4px) scale(0.98);
      transition: opacity 140ms ease, transform 160ms cubic-bezier(.2,.7,.2,1);
    }
    .cal-popover.is-visible {
      opacity: 1;
      transform: translateY(0) scale(1);
      pointer-events: auto;
    }

    /* Top accent stripe matching lesson status */
    .cal-popover::after {
      content: '';
      position: absolute;
      top: 0; left: 0; right: 0;
      height: 3px;
      border-radius: 14px 14px 0 0;
      background: var(--accent);
      opacity: 0.7;
    }
    .cal-popover[data-status="is-paid"]::after      { background: var(--emerald); }
    .cal-popover[data-status="is-unpaid"]::after    { background: var(--rose); }
    .cal-popover[data-status="is-pending"]::after   { background: var(--amber); }
    .cal-popover[data-status="is-scheduled"]::after { background: var(--accent); }

    .cal-popover::before {
      content: '';
      position: absolute;
      width: 12px; height: 12px;
      background: inherit;
      border-left: 1px solid rgba(255,255,255,0.10);
      border-top: 1px solid rgba(255,255,255,0.10);
      transform: rotate(-45deg);
    }
    .cal-popover[data-side="right"]::before { left: -7px; top: 24px; }
    .cal-popover[data-side="left"]::before  { right: -7px; top: 24px; transform: rotate(135deg); }
    .cal-popover[data-side="top"]::before   { bottom: -7px; left: 24px; transform: rotate(-135deg); }
    .cal-popover[data-side="bottom"]::before{ top: -7px; left: 24px; transform: rotate(45deg); }

    .cal-popover__head {
      display: flex;
      align-items: flex-start;
      gap: 10px;
      margin-bottom: 8px;
    }
    .cal-popover__status {
      width: 32px; height: 32px;
      border-radius: 9px;
      display: grid; place-items: center;
      flex-shrink: 0;
    }
    .cal-popover__status i { width: 16px; height: 16px; }
    .cal-popover__status.is-paid      { background: rgba(16,185,129,0.18); color: var(--emerald); }
    .cal-popover__status.is-unpaid    { background: rgba(244,63,94,0.18);  color: var(--rose); }
    .cal-popover__status.is-pending   { background: rgba(245,158,11,0.18); color: var(--amber); }
    .cal-popover__status.is-scheduled { background: rgba(99,102,241,0.15); color: var(--accent); }

    .cal-popover__title {
      font-size: 1rem;
      font-weight: 700;
      color: var(--text);
      line-height: 1.25;
      margin-bottom: 2px;
      word-break: break-word;
    }
    .cal-popover__time {
      font-size: 0.82rem;
      font-weight: 600;
      color: var(--text-muted);
      font-variant-numeric: tabular-nums;
    }
    .cal-popover__meta {
      display: flex; flex-wrap: wrap; gap: 6px;
      margin: 8px 0 10px;
    }
    .cal-popover__meta-item {
      display: inline-flex; align-items: center; gap: 5px;
      padding: 4px 9px;
      border-radius: 999px;
      background: rgba(255,255,255,0.05);
      border: 1px solid rgba(255,255,255,0.08);
      font-size: 0.72rem;
      font-weight: 600;
      color: var(--text-muted);
    }
    .cal-popover__meta-item i { width: 11px; height: 11px; }
    .cal-popover__meta-item.is-paid    { background: rgba(16,185,129,0.12); color: var(--emerald); border-color: rgba(16,185,129,0.3); }
    .cal-popover__meta-item.is-unpaid  { background: rgba(244,63,94,0.10);  color: var(--rose); border-color: rgba(244,63,94,0.3); }

    .cal-popover__hw {
      font-size: 0.78rem;
      color: var(--text-muted);
      margin: 6px 0 10px;
      padding: 8px 10px;
      background: rgba(0,0,0,0.25);
      border-radius: 8px;
      border-left: 2px solid var(--accent);
      max-height: 80px;
      overflow-y: auto;
      line-height: 1.45;
    }
    .cal-popover__hw strong { color: var(--text); display: block; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }

    .cal-popover__actions {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
    }
    .cal-popover__btn {
      flex: 1 1 calc(50% - 3px);
      min-width: 0;
      max-width: 100%;
      padding: 8px 10px;
      border-radius: 8px;
      border: 1px solid var(--border);
      background: rgba(255,255,255,0.05);
      color: var(--text);
      font-size: 0.74rem;
      font-weight: 600;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
      font-family: inherit;
    }
    .cal-popover__btn > span {
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    /* Icon-only delete button stays compact */
    .cal-popover__btn[data-action="delete"] {
      flex: 0 0 40px;
      padding: 8px;
    }
    .cal-popover__btn i {
      width: 14px;
      height: 14px;
      flex-shrink: 0;
    }
    .cal-popover__btn:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.18); transform: translateY(-1px); }
    .cal-popover__btn:active { transform: translateY(0); }
    .cal-popover__btn.is-primary { background: rgba(99,102,241,0.18); color: #a5b4fc; border-color: rgba(99,102,241,0.4); }
    .cal-popover__btn.is-primary:hover { background: rgba(99,102,241,0.28); border-color: rgba(99,102,241,0.55); }
    .cal-popover__btn.is-success { background: rgba(16,185,129,0.18); color: var(--emerald); border-color: rgba(16,185,129,0.4); }
    .cal-popover__btn.is-success:hover { background: rgba(16,185,129,0.28); border-color: rgba(16,185,129,0.55); }
    .cal-popover__btn.is-danger { background: rgba(244,63,94,0.12); color: var(--rose); border-color: rgba(244,63,94,0.3); }
    .cal-popover__btn.is-danger:hover { background: rgba(244,63,94,0.22); border-color: rgba(244,63,94,0.5); }
    .cal-popover__btn.is-warn  { background: rgba(245,158,11,0.14); color: var(--amber); border-color: rgba(245,158,11,0.35); }
    .cal-popover__btn.is-warn:hover  { background: rgba(245,158,11,0.24); border-color: rgba(245,158,11,0.5); }

    @media (prefers-reduced-motion: reduce) {
      .cal-popover { transition: none; transform: none; }
    }

    /* Touch: disable hover-only expansion (it triggers on tap-and-hold otherwise) */
    @media (hover: none) {
      .cal-event:hover:not(.busy) {
        transform: none;
        z-index: 5;
        box-shadow:
          0 1px 2px rgba(0,0,0,0.20),
          0 2px 6px rgba(0,0,0,0.18);
      }
      .cal-event:hover:not(.busy) .cal-event-actions {
        max-height: 0;
        opacity: 0;
        margin-top: 0;
        pointer-events: none;
      }
    }

    .cal-event-body {
      display: flex; flex-direction: column;
      gap: 2px;
      min-width: 0;
      flex: 1;
    }

    .cal-event-title {
      font-weight: 700;
      font-size: 0.76rem;
      color: var(--text);
      display: flex;
      align-items: center;
      gap: 3px;
      padding-right: 20px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .cal-event-sub {
      font-size: 0.66rem;
      color: var(--text-muted);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .cal-event-time {
      font-size: 0.66rem;
      font-weight: 600;
      color: var(--accent);
      letter-spacing: 0.2px;
      font-variant-numeric: tabular-nums;
      opacity: 0.85;
    }
    .cal-event.paid .cal-event-time    { color: var(--emerald); }
    .cal-event.unpaid .cal-event-time  { color: var(--rose); }
    .cal-event.pending .cal-event-time { color: var(--amber); }

    /* Short cards: hide secondary rows to prevent visual clutter */
    .cal-event.is-short .cal-event-sub,
    .cal-event.is-short .cal-event-time { display: none; }
    .cal-event.is-tiny .cal-event-sub,
    .cal-event.is-tiny .cal-event-time,
    .cal-event.is-tiny .cal-event-title { font-size: 0.6rem; }

    .cal-event-warn {
      width: 12px; height: 12px;
      color: var(--amber);
      flex-shrink: 0;
    }

    /* Corner status badge (top-right) */
    .cal-event-corner {
      position: absolute;
      top: 5px; right: 5px;
      width: 22px; height: 22px;
      border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      cursor: pointer;
      z-index: 2;
      transition: transform 0.15s, box-shadow 0.15s;
    }
    .cal-event-corner:hover {
      transform: scale(1.12);
      box-shadow: 0 0 0 3px rgba(255,255,255,0.06);
    }
    .cal-event-corner i { width: 12px; height: 12px; stroke-width: 2.6; }
    .cal-event-corner.is-paid   { background: rgba(16,185,129,0.28); color: var(--emerald); }
    .cal-event-corner.is-unpaid { background: rgba(244,63,94,0.26);  color: var(--rose); }

    .cal-event-btn {
      width: 28px; height: 28px;
      min-width: 28px;
      border-radius: 7px;
      border: 1px solid rgba(255,255,255,0.10);
      background: rgba(0,0,0,0.30);
      color: var(--text-muted);
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
      position: relative;
      flex-shrink: 0;
      backdrop-filter: blur(2px);
    }
    .cal-event-btn i { width: 14px; height: 14px; stroke-width: 2.2; }
    .cal-event-btn:hover {
      background: rgba(255,255,255,0.10);
      color: var(--text);
      border-color: rgba(255,255,255,0.22);
      transform: translateY(-1px);
    }
    .cal-event-btn:active { transform: translateY(0); }
    .cal-event-btn.is-active {
      background: rgba(16,185,129,0.20);
      color: var(--emerald);
      border-color: rgba(16,185,129,0.45);
    }
    .cal-event-btn-danger:hover {
      background: rgba(244,63,94,0.20);
      color: var(--rose);
      border-color: rgba(244,63,94,0.45);
    }

    /* Subtle reveal animation for buttons inside expanded card */
    .cal-event.is-expanded .cal-event-btn,
    .cal-event:hover:not(.busy) .cal-event-btn {
      animation: cal-btn-pop 220ms cubic-bezier(.2,.7,.2,1) backwards;
    }
    .cal-event.is-expanded .cal-event-btn:nth-child(1),
    .cal-event:hover:not(.busy) .cal-event-btn:nth-child(1) { animation-delay: 30ms; }
    .cal-event.is-expanded .cal-event-btn:nth-child(2),
    .cal-event:hover:not(.busy) .cal-event-btn:nth-child(2) { animation-delay: 70ms; }
    .cal-event.is-expanded .cal-event-btn:nth-child(3),
    .cal-event:hover:not(.busy) .cal-event-btn:nth-child(3) { animation-delay: 110ms; }
    .cal-event.is-expanded .cal-event-btn:nth-child(4),
    .cal-event:hover:not(.busy) .cal-event-btn:nth-child(4) { animation-delay: 150ms; }
    @keyframes cal-btn-pop {
      from { opacity: 0; transform: translateY(4px) scale(0.85); }
      to   { opacity: 1; transform: translateY(0)   scale(1); }
    }

    /* Reduced motion: kill animations, keep functional state changes */
    @media (prefers-reduced-motion: reduce) {
      .cal-event,
      .cal-event-actions,
      .cal-event-btn,
      .cal-event-corner { transition: none; }
      .cal-event.is-expanded:not(.busy),
      .cal-event:hover:not(.busy) { transform: none; }
      .cal-event.is-expanded .cal-event-btn,
      .cal-event:hover:not(.busy) .cal-event-btn { animation: none; }
    }

    /* Tooltips on action buttons & corner (data-tooltip).
       Disabled on touch devices (no hover). */
    [data-tooltip] { position: relative; }
    @media (hover: hover) and (pointer: fine) {
      [data-tooltip]::after {
        content: attr(data-tooltip);
        position: absolute;
        bottom: calc(100% + 6px);
        left: 50%;
        transform: translateX(-50%);
        background: #18181b;
        color: var(--text);
        font-size: 0.68rem;
        font-weight: 600;
        padding: 4px 8px;
        border-radius: 6px;
        white-space: nowrap;
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.15s;
        z-index: 50;
        border: 1px solid var(--border);
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
      }
      [data-tooltip]:hover::after { opacity: 1; }
    }

    /* ─── Hover Pointer (teacher click-to-create indicator) ─── */
    .hover-pointer {
      position: absolute;
      left: 48px; right: 0;
      height: 2px;
      background: var(--accent);
      opacity: 0;
      pointer-events: none;
      z-index: 14;
      transition: top 0.1s linear;
      grid-column: 1 / -1;
      grid-row: 1 / -1;
    }
    @media (min-width: 768px) {
      .hover-pointer { left: 60px; }
    }

    .hover-pointer-time {
      position: absolute;
      left: -50px;
      top: -10px;
      background: var(--accent);
      color: white;
      font-size: 0.68rem;
      font-weight: 700;
      padding: 2px 6px;
      border-radius: 10px;
    }

    /* ─── "Now" indicator (eng-board style: red dot + line) ─── */
    .cal-now-indicator {
      position: absolute;
      left: 0;
      right: 0;
      height: 0;
      pointer-events: none;
      z-index: 12;
      display: flex;
      align-items: center;
      grid-column: 1 / -1;
      grid-row: 1 / -1;
    }
    .cal-now-dot {
      position: absolute;
      left: 36px;
      width: 12px;
      height: 12px;
      border-radius: 50%;
      background: #ef4444;
      box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18), 0 0 8px rgba(239, 68, 68, 0.5);
      transform: translateY(-50%);
      z-index: 2;
    }
    @media (min-width: 768px) {
      .cal-now-dot { left: 48px; }
    }
    .cal-now-line {
      position: absolute;
      left: 48px;
      right: 0;
      top: 50%;
      transform: translateY(-50%);
      height: 2px;
      background: #ef4444;
      box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
    }
    @media (min-width: 768px) {
      .cal-now-line { left: 60px; }
    }
    .cal-now-time {
      position: absolute;
      left: 2px;
      top: 50%;
      transform: translateY(-50%);
      background: #ef4444;
      color: #fff;
      font-size: 0.62rem;
      font-weight: 700;
      padding: 1px 4px;
      border-radius: 4px;
      letter-spacing: 0.3px;
      z-index: 3;
    }
    @media (min-width: 768px) {
      .cal-now-time { font-size: 0.66rem; padding: 2px 5px; }
    }

    /* ─── Calendar Navigation Buttons ─── */
    .nav-btn {
      background: transparent;
      color: var(--text);
      border: none;
      padding: 8px 14px;
      font-size: 0.85rem;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.15s;
      min-width: 40px;
    }
    .nav-btn:hover { background: rgba(255,255,255,0.1); }
    .nav-btn:not(:last-child) { border-right: 1px solid var(--border); }

    /* ── Reschedule banner (top of calendar, teacher view) ── */
    .reschedule-banner {
      background: linear-gradient(135deg, rgba(245,158,11,0.10), rgba(245,158,11,0.04));
      border: 1px solid rgba(245,158,11,0.3);
      border-radius: 12px;
      padding: 12px 14px;
      display: flex;
      flex-direction: column;
      gap: 8px;
    }
    .reschedule-banner-header {
      font-size: 0.78rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.6px;
      color: var(--amber);
      display: inline-flex;
      align-items: center;
      gap: 6px;
    }
    .reschedule-banner-item {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 10px 12px;
      background: rgba(0,0,0,0.25);
      border-radius: 8px;
      font-size: 0.85rem;
      flex-wrap: wrap;
    }
    .reschedule-banner-info {
      display: flex;
      align-items: center;
      gap: 8px;
      flex: 1;
      min-width: 0;
    }
    .reschedule-banner-info strong { color: var(--text); font-weight: 700; }
    .reschedule-banner-actions {
      display: flex;
      gap: 6px;
      flex-shrink: 0;
    }
    .btn-mini {
      padding: 6px 10px;
      border-radius: 7px;
      border: 1px solid var(--border);
      background: rgba(255,255,255,0.04);
      color: var(--text);
      font-size: 0.78rem;
      font-weight: 600;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 4px;
      font-family: inherit;
      transition: background 0.15s, border-color 0.15s, transform 0.1s;
    }
    .btn-mini i { width: 12px; height: 12px; }
    .btn-mini:hover { transform: translateY(-1px); }
    .btn-mini-success {
      background: rgba(16,185,129,0.18);
      color: var(--emerald);
      border-color: rgba(16,185,129,0.4);
    }
    .btn-mini-success:hover { background: rgba(16,185,129,0.28); }
    .btn-mini-danger {
      background: rgba(244,63,94,0.15);
      color: var(--rose);
      border-color: rgba(244,63,94,0.4);
    }
    .btn-mini-danger:hover { background: rgba(244,63,94,0.25); }

    /* Pending corner badge */
    .cal-event-corner.is-pending {
      background: rgba(245,158,11,0.22);
      color: var(--amber);
      animation: rs-corner-pulse 2.4s ease-in-out infinite;
    }
    @keyframes rs-corner-pulse {
      0%, 100% { box-shadow: 0 0 0 0 rgba(245,158,11,0.5); }
      50%      { box-shadow: 0 0 0 5px rgba(245,158,11,0); }
    }

    /* ── Reschedule visual states ──
       .reschedule-original — original lesson with a pending move-request (dashed border)
       .reschedule-proposed — proposed new time slot (striped fill, awaiting approval) */
    .cal-event.reschedule-original {
      border-style: dashed !important;
      opacity: 0.85;
    }
    .cal-event.reschedule-original::after {
      content: '';
      position: absolute;
      inset: 0;
      border-radius: inherit;
      background:
        repeating-linear-gradient(
          135deg,
          transparent 0 8px,
          rgba(245,158,11,0.06) 8px 12px
        );
      pointer-events: none;
    }
    .cal-event.reschedule-proposed {
      border-color: rgba(245,158,11,0.55) !important;
      background:
        repeating-linear-gradient(
          45deg,
          rgba(245,158,11,0.10) 0 8px,
          rgba(245,158,11,0.22) 8px 16px
        ) !important;
    }
    .cal-event.reschedule-proposed .cal-event-time {
      color: var(--amber) !important;
    }

    /* Tiny "request" badge (hourglass) overlaid on cards involved in a reschedule */
    .cal-event__rsbadge {
      position: absolute;
      top: -6px; left: -6px;
      width: 22px; height: 22px;
      border-radius: 50%;
      background: var(--amber);
      color: #1a1100;
      display: grid; place-items: center;
      font-size: 11px;
      font-weight: 800;
      box-shadow: 0 4px 10px rgba(245,158,11,0.4);
      z-index: 3;
      animation: rs-pulse 2.4s ease-in-out infinite;
    }
    .cal-event__rsbadge i { width: 12px; height: 12px; stroke-width: 2.6; }
    @keyframes rs-pulse {
      0%, 100% { box-shadow: 0 0 0 0 rgba(245,158,11,0.55), 0 4px 10px rgba(245,158,11,0.4); }
      50%      { box-shadow: 0 0 0 6px rgba(245,158,11,0), 0 4px 10px rgba(245,158,11,0.4); }
    }

    /* ─── Bottom sheet (mobile only) ─────────────── */
    .cal-sheet-backdrop {
      position: fixed; inset: 0;
      background: rgba(0,0,0,0.55);
      backdrop-filter: blur(2px);
      z-index: 999;
      opacity: 0;
      pointer-events: none;
      transition: opacity 200ms ease;
    }
    .cal-sheet-backdrop.is-open { opacity: 1; pointer-events: auto; }

    .cal-sheet {
      position: fixed;
      left: 0; right: 0; bottom: 0;
      z-index: 1000;
      background: rgba(20,22,35,0.98);
      backdrop-filter: blur(20px);
      -webkit-backdrop-filter: blur(20px);
      border-top-left-radius: 20px;
      border-top-right-radius: 20px;
      border-top: 1px solid rgba(255,255,255,0.08);
      box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
      max-height: 85vh;
      display: flex;
      flex-direction: column;
      transform: translateY(100%);
      transition: transform 280ms cubic-bezier(.2,.7,.2,1);
      padding-bottom: env(safe-area-inset-bottom, 0);
    }
    .cal-sheet.is-open { transform: translateY(0); }
    .cal-sheet__handle {
      width: 40px; height: 4px;
      background: rgba(255,255,255,0.2);
      border-radius: 2px;
      margin: 8px auto 0;
      flex-shrink: 0;
    }
    .cal-sheet__head {
      display: flex; align-items: flex-start; gap: 12px;
      padding: 14px 18px 10px;
      flex-shrink: 0;
    }
    .cal-sheet__close {
      width: 32px; height: 32px;
      border-radius: 8px;
      border: 1px solid var(--border);
      background: rgba(255,255,255,0.04);
      color: var(--text-muted);
      display: grid; place-items: center;
      cursor: pointer;
      flex-shrink: 0;
    }
    .cal-sheet__close i { width: 16px; height: 16px; }
    .cal-sheet__title { flex: 1; min-width: 0; }
    .cal-sheet__title h2 {
      font-size: 1.1rem; font-weight: 700; color: var(--text);
      margin: 0 0 2px; line-height: 1.25;
      word-break: break-word;
    }
    .cal-sheet__title .time {
      font-size: 0.85rem; font-weight: 600;
      color: var(--text-muted);
      font-variant-numeric: tabular-nums;
    }
    .cal-sheet__body {
      flex: 1;
      overflow-y: auto;
      padding: 0 18px 14px;
      -webkit-overflow-scrolling: touch;
    }
    .cal-sheet__section {
      margin-bottom: 14px;
    }
    .cal-sheet__section-label {
      font-size: 0.7rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.6px;
      color: var(--text-dim);
      margin-bottom: 8px;
    }
    .cal-sheet__chips {
      display: flex; flex-wrap: wrap; gap: 6px;
    }
    .cal-sheet__hw {
      padding: 12px 14px;
      background: rgba(0,0,0,0.3);
      border-radius: 10px;
      border-left: 3px solid var(--accent);
      font-size: 0.9rem;
      color: var(--text);
      line-height: 1.5;
      white-space: pre-wrap;
      word-break: break-word;
    }
    .cal-sheet__hw-empty {
      padding: 16px;
      background: rgba(255,255,255,0.03);
      border-radius: 10px;
      border: 1px dashed var(--border);
      font-size: 0.85rem;
      color: var(--text-dim);
      text-align: center;
    }
    .cal-sheet__files {
      display: flex; flex-direction: column; gap: 6px;
      margin-top: 8px;
    }
    .cal-sheet__file-link {
      display: flex; align-items: center; gap: 8px;
      padding: 8px 12px;
      background: rgba(99,102,241,0.08);
      border: 1px solid rgba(99,102,241,0.2);
      border-radius: 8px;
      color: #a5b4fc;
      text-decoration: none;
      font-size: 0.85rem;
      font-weight: 600;
      transition: background 0.15s;
    }
    .cal-sheet__file-link:hover { background: rgba(99,102,241,0.15); }
    .cal-sheet__file-link i { width: 14px; height: 14px; flex-shrink: 0; }

    .cal-sheet__upload {
      margin-top: 10px;
      padding: 14px;
      border: 2px dashed rgba(99,102,241,0.35);
      border-radius: 10px;
      text-align: center;
      cursor: pointer;
      transition: background 0.15s, border-color 0.15s;
    }
    .cal-sheet__upload:hover { background: rgba(99,102,241,0.05); border-color: rgba(99,102,241,0.55); }
    .cal-sheet__upload-icon {
      width: 36px; height: 36px;
      margin: 0 auto 8px;
      display: grid; place-items: center;
      background: rgba(99,102,241,0.15);
      border-radius: 50%;
      color: #a5b4fc;
    }
    .cal-sheet__upload-icon i { width: 18px; height: 18px; }
    .cal-sheet__upload-text {
      font-size: 0.85rem;
      color: var(--text);
      font-weight: 600;
    }
    .cal-sheet__upload-hint {
      font-size: 0.75rem;
      color: var(--text-dim);
      margin-top: 2px;
    }
    .cal-sheet__selected {
      display: flex; flex-direction: column; gap: 6px;
      margin-top: 10px;
    }
    .cal-sheet__selected-item {
      display: flex; align-items: center; gap: 8px;
      padding: 8px 12px;
      background: rgba(255,255,255,0.04);
      border-radius: 8px;
      font-size: 0.82rem;
    }
    .cal-sheet__selected-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .cal-sheet__selected-item button {
      width: 24px; height: 24px;
      border: none;
      background: rgba(244,63,94,0.15);
      color: var(--rose);
      border-radius: 6px;
      cursor: pointer;
      flex-shrink: 0;
    }
    .cal-sheet__actions {
      padding: 12px 18px;
      display: flex; flex-direction: column; gap: 8px;
      flex-shrink: 0;
      border-top: 1px solid rgba(255,255,255,0.06);
      background: rgba(0,0,0,0.2);
    }
    .cal-sheet__action-row { display: flex; gap: 8px; }
    .cal-sheet__btn {
      flex: 1;
      padding: 12px;
      border-radius: 10px;
      border: 1px solid var(--border);
      background: rgba(255,255,255,0.05);
      color: var(--text);
      font-size: 0.9rem;
      font-weight: 700;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      font-family: inherit;
      transition: background 0.15s, border-color 0.15s, transform 0.1s;
    }
    .cal-sheet__btn:active { transform: scale(0.98); }
    .cal-sheet__btn i { width: 16px; height: 16px; }
    .cal-sheet__btn.is-primary  { background: linear-gradient(135deg, #6366f1, #8b5cf6); border: none; box-shadow: 0 4px 14px rgba(99,102,241,0.35); }
    .cal-sheet__btn.is-success  { background: rgba(16,185,129,0.2); color: var(--emerald); border-color: rgba(16,185,129,0.4); }
    .cal-sheet__btn.is-warn     { background: rgba(245,158,11,0.18); color: var(--amber); border-color: rgba(245,158,11,0.4); }
    .cal-sheet__btn.is-danger   { background: rgba(244,63,94,0.15); color: var(--rose); border-color: rgba(244,63,94,0.4); }

    /* ─── Mobile-specific calendar adjustments ─── */
    @media (max-width: 767px) {
      #weeklyCalendarGrid {
        margin: 0 -12px;
        width: calc(100% + 24px);
        max-width: calc(100% + 24px);
        border-radius: 0;
        border-left: none;
        border-right: none;
      }
      .cal-event {
        font-size: 0.68rem;
        padding: 4px 7px 3px 18px;
        margin: 1px 2px;
      }
      .cal-event::before { left: 6px; width: 5px; height: 5px; }
      .cal-event-title { font-size: 0.72rem; padding-right: 22px; }
      .cal-event-sub { font-size: 0.62rem; }
      .cal-event-time { font-size: 0.66rem; }

      /* On mobile, tap-expand grows in place (no scale — looks better in scrollable grid) */
      .cal-event.is-expanded:not(.busy) {
        transform: none;
        z-index: 50;
        box-shadow:
          0 0 0 1px rgba(255,255,255,0.06),
          0 16px 32px -6px rgba(0,0,0,0.6),
          0 6px 14px rgba(0,0,0,0.4);
      }

      /* Mobile: actions are in bottom-sheet, not inline */
      .cal-event .cal-event-actions { display: none !important; }
      .cal-event-corner {
        width: 26px; height: 26px;
        top: 4px; right: 4px;
      }
      .cal-event-corner i { width: 13px; height: 13px; }

      .cal-now-dot { left: 30px; width: 10px; height: 10px; }
      .cal-now-line { left: 36px; }
      .cal-now-time { font-size: 0.6rem; }
      #calendarSection {
        padding: 16px 12px !important;
      }
    }

    /* ─── Lesson detail modal: participants + grading ─── */
    .lesson-participant {
      margin-bottom: 8px;
      padding: 8px 10px;
      background: transparent;
      border: 1px solid var(--border);
      border-radius: 8px;
      transition: background 0.15s, border-color 0.15s;
    }
    .lesson-participant.is-member {
      background: rgba(99,102,241,0.08);
      border-color: rgba(99,102,241,0.25);
    }
    .lesson-participant__row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      flex-wrap: wrap;
    }
    .lesson-participant__name {
      display: flex;
      align-items: center;
      gap: 8px;
      cursor: pointer;
      flex: 1 1 auto;
      min-width: 0;
    }
    .lesson-participant__name input[type="checkbox"] { accent-color: var(--accent); }
    .lesson-participant__name span {
      font-size: 0.88rem;
      color: var(--text);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .lesson-participant:not(.is-member) .lesson-participant__name span { color: var(--text-dim); }
    .lesson-participant__actions {
      display: flex;
      align-items: center;
      gap: 12px;
      flex-shrink: 0;
    }
    .lesson-participant__pay {
      display: flex; align-items: center; gap: 4px;
      cursor: pointer;
      font-size: 0.75rem;
      color: var(--text-dim);
    }
    .lesson-participant__pay input { accent-color: var(--emerald); }
    .lesson-participant__pay span.is-paid { color: var(--emerald); }
    .lesson-participant__price {
      display: flex; align-items: center; gap: 4px;
    }
    .lesson-participant__price input {
      width: 60px;
      padding: 3px 6px;
      border-radius: 6px;
      border: 1px solid var(--border);
      background: rgba(0,0,0,0.25);
      color: var(--text);
      font-size: 0.78rem;
      font-family: inherit;
    }
    .lesson-participant__price span { font-size: 0.7rem; color: var(--text-dim); }

    .lesson-participant__grade {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-top: 8px;
      padding-top: 8px;
      border-top: 1px dashed rgba(255,255,255,0.06);
      position: relative;
    }
    .grade-saved-indicator {
      position: absolute;
      right: 0;
      top: -2px;
      color: var(--emerald);
      font-weight: 800;
      font-size: 0.78rem;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.2s;
    }
    .lesson-participant__grade.is-saved .grade-saved-indicator {
      animation: gradeSavedPulse 1.4s ease-out;
    }
    @keyframes gradeSavedPulse {
      0%   { opacity: 0; transform: translateY(0); }
      20%  { opacity: 1; transform: translateY(-2px); }
      80%  { opacity: 1; transform: translateY(-2px); }
      100% { opacity: 0; transform: translateY(-6px); }
    }
    .grade-stars {
      display: inline-flex;
      gap: 2px;
      flex-shrink: 0;
    }
    .grade-star {
      background: transparent;
      border: none;
      cursor: pointer;
      font-size: 1.1rem;
      line-height: 1;
      padding: 2px 3px;
      color: rgba(255,255,255,0.18);
      transition: color 0.12s, transform 0.12s;
      font-family: inherit;
    }
    .grade-star:hover { transform: scale(1.18); }
    .grade-star.active { color: #fbbf24; text-shadow: 0 0 8px rgba(251,191,36,0.4); }
    .grade-feedback {
      flex: 1 1 auto;
      min-width: 0;
      padding: 5px 8px;
      border-radius: 6px;
      border: 1px solid var(--border);
      background: rgba(0,0,0,0.25);
      color: var(--text);
      font-size: 0.78rem;
      font-family: inherit;
    }
    .grade-feedback:focus {
      outline: none;
      border-color: rgba(99,102,241,0.5);
      background: rgba(0,0,0,0.4);
    }

    /* ─── Calendar chip: grade badge ─── */
    .cal-event__grade {
      position: absolute;
      bottom: 3px;
      right: 4px;
      display: inline-flex;
      align-items: center;
      gap: 1px;
      padding: 1px 5px;
      border-radius: 6px;
      background: rgba(251,191,36,0.18);
      color: #fbbf24;
      font-size: 0.62rem;
      font-weight: 800;
      font-variant-numeric: tabular-nums;
      pointer-events: none;
      box-shadow: 0 0 0 1px rgba(251,191,36,0.25);
    }
    .cal-event__grade::before {
      content: '★';
      font-size: 0.6rem;
      margin-right: 1px;
    }

    /* ─── Popover: grade block ─── */
    .cal-popover__grade {
      margin-top: 10px;
      padding: 10px 12px;
      border-radius: 10px;
      background: rgba(251,191,36,0.08);
      border: 1px solid rgba(251,191,36,0.22);
    }
    .cal-popover__grade-head {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-bottom: 4px;
    }
    .cal-popover__grade-stars {
      color: #fbbf24;
      font-size: 0.95rem;
      letter-spacing: 1px;
    }
    .cal-popover__grade-stars .empty { color: rgba(255,255,255,0.15); }
    .cal-popover__grade-name {
      font-size: 0.8rem;
      color: var(--text-muted);
      font-weight: 600;
    }
    .cal-popover__grade-feedback {
      font-size: 0.82rem;
      color: var(--text);
      line-height: 1.35;
      font-style: italic;
    }
    .cal-popover__grade + .cal-popover__grade {
      margin-top: 6px;
    }

    /* ─── Student dashboard: my grades card ─── */
    .my-grades-card {
      grid-column: 1 / -1;
      background:
        radial-gradient(ellipse 60% 60% at 100% 0%, rgba(251,191,36,0.06) 0%, transparent 60%),
        var(--bg-card);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 24px;
    }
    .my-grades-card__head {
      display: flex;
      align-items: baseline;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 14px;
    }
    .my-grades-card__title {
      font-size: 1rem;
      font-weight: 800;
      letter-spacing: -0.2px;
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .my-grades-card__avg {
      font-size: 1.6rem;
      font-weight: 800;
      color: #fbbf24;
      font-variant-numeric: tabular-nums;
      line-height: 1;
      text-shadow: 0 0 20px rgba(251,191,36,0.25);
    }
    .my-grades-card__avg small {
      font-size: 0.7rem;
      color: var(--text-dim);
      font-weight: 600;
      margin-left: 6px;
      letter-spacing: 0.2px;
    }

    /* Sparkline trend */
    .my-grades-spark {
      display: flex;
      align-items: stretch;
      gap: 14px;
      padding: 14px 16px;
      background: rgba(0,0,0,0.22);
      border: 1px solid rgba(251,191,36,0.12);
      border-radius: 12px;
      margin-bottom: 16px;
    }
    .grades-sparkline {
      flex: 1;
      width: 100%;
      height: 48px;
      display: block;
    }
    .my-grades-spark__meta {
      display: flex;
      flex-direction: column;
      align-items: flex-end;
      justify-content: center;
      gap: 2px;
      font-size: 0.78rem;
      font-weight: 700;
      flex-shrink: 0;
      min-width: 90px;
    }
    .my-grades-spark__arrow {
      font-size: 1.4rem;
      line-height: 1;
      font-weight: 800;
    }

    .my-grades-list {
      display: flex;
      flex-direction: column;
      gap: 8px;
      max-height: 380px;
      overflow-y: auto;
      padding-right: 4px;
    }
    .my-grades-list::-webkit-scrollbar { width: 6px; }
    .my-grades-list::-webkit-scrollbar-thumb {
      background: rgba(255,255,255,0.08);
      border-radius: 4px;
    }

    .my-grades-row {
      display: grid;
      grid-template-columns: 60px 100px 1fr;
      gap: 14px;
      align-items: flex-start;
      padding: 12px 14px;
      background: rgba(255,255,255,0.025);
      border: 1px solid var(--border);
      border-radius: 10px;
      font-size: 0.85rem;
      transition: background 0.15s, border-color 0.15s;
    }
    .my-grades-row:hover {
      background: rgba(255,255,255,0.045);
      border-color: rgba(251,191,36,0.22);
    }
    .my-grades-row__date {
      color: var(--text-muted);
      font-variant-numeric: tabular-nums;
      line-height: 1.2;
    }
    .my-grades-row__date-day {
      font-size: 0.85rem;
      font-weight: 700;
      color: var(--text);
    }
    .my-grades-row__date-time {
      font-size: 0.7rem;
      color: var(--text-dim);
      margin-top: 1px;
    }
    .my-grades-row__stars {
      color: #fbbf24;
      letter-spacing: 1.5px;
      font-size: 0.95rem;
      line-height: 1.2;
    }
    .my-grades-row__stars .empty { color: rgba(255,255,255,0.12); }
    .my-grades-row__body {
      min-width: 0;
    }
    .my-grades-row__title {
      font-size: 0.85rem;
      font-weight: 600;
      color: var(--text);
      margin-bottom: 3px;
      line-height: 1.3;
    }
    .my-grades-row__tutor {
      color: var(--text-dim);
      font-weight: 500;
      font-size: 0.78rem;
    }
    .my-grades-row__source {
      display: inline-block;
      margin-right: 4px;
      opacity: 0.65;
      cursor: help;
    }
    .my-grades-row__feedback {
      color: var(--text-muted);
      line-height: 1.4;
      font-size: 0.82rem;
      font-style: italic;
    }
    .my-grades-empty {
      padding: 32px 24px;
      text-align: center;
      color: var(--text-dim);
      font-size: 0.85rem;
      background: rgba(0,0,0,0.15);
      border-radius: 10px;
    }
    @media (max-width: 600px) {
      .my-grades-card { padding: 18px 16px; }
      .my-grades-spark { padding: 10px 12px; gap: 10px; }
      .my-grades-spark__meta { min-width: 70px; font-size: 0.7rem; }
      .my-grades-row {
        grid-template-columns: 50px 1fr;
        gap: 10px;
      }
      .my-grades-row__stars {
        grid-column: 1 / -1;
        font-size: 0.88rem;
        letter-spacing: 1px;
      }
    }

    /* ─── Debtor list (clickable buttons in finance card) ─── */
    .debtor-item {
      display: grid;
      grid-template-columns: 1fr auto auto auto auto;
      align-items: center;
      gap: 12px;
      padding: 10px 14px;
      width: 100%;
      background: rgba(244,63,94,0.06);
      border: 1px solid rgba(244,63,94,0.18);
      border-radius: 10px;
      cursor: pointer;
      font-family: inherit;
      color: var(--text);
      text-align: left;
      transition: background 0.15s, border-color 0.15s, transform 0.1s;
      margin-bottom: 6px;
    }
    .debtor-item:hover {
      background: rgba(244,63,94,0.10);
      border-color: rgba(244,63,94,0.32);
    }
    .debtor-item:active { transform: scale(0.99); }
    .debtor-item__name { font-size: 0.88rem; font-weight: 600; }
    .debtor-item__meta {
      font-size: 0.72rem;
      color: var(--text-muted);
      font-weight: 500;
      white-space: nowrap;
    }
    .debtor-item__sum {
      color: var(--rose);
      font-weight: 800;
      font-size: 0.95rem;
      font-variant-numeric: tabular-nums;
    }
    .debtor-item__cta {
      font-size: 0.72rem;
      color: var(--accent);
      font-weight: 700;
      white-space: nowrap;
    }
    .debtor-item__age {
      display: inline-block;
      margin-left: 6px;
      padding: 1px 7px;
      border-radius: 999px;
      font-size: 0.62rem;
      font-weight: 800;
      letter-spacing: 0.02em;
      background: rgba(148,163,184,0.15);
      color: var(--text-muted);
      vertical-align: middle;
    }
    .debtor-item__age.is-warn {
      background: rgba(245,158,11,0.16);
      color: #fbbf24;
    }
    .debtor-item__age.is-late {
      background: rgba(244,63,94,0.18);
      color: var(--rose);
    }
    .debtor-item__remind {
      width: 30px; height: 30px;
      border: 1px solid var(--border);
      background: rgba(99,102,241,0.10);
      border-radius: 8px;
      cursor: pointer;
      font-size: 0.85rem;
      line-height: 1;
      transition: background 0.15s, border-color 0.15s;
    }
    .debtor-item__remind:hover {
      background: rgba(99,102,241,0.25);
      border-color: rgba(99,102,241,0.6);
    }
    .debtor-item__remind:disabled { opacity: 0.5; cursor: wait; }
    @media (max-width: 600px) {
      .debtor-item { grid-template-columns: 1fr auto auto; gap: 6px 12px; }
      .debtor-item__meta { grid-column: 1; font-size: 0.7rem; }
      .debtor-item__cta { display: none; }
    }

    /* ─── Finance: месячный тренд доходов ─── */
    .fin-chart {
      margin-top: 20px;
      padding: 14px 16px 10px;
      background: rgba(255,255,255,0.02);
      border: 1px solid var(--border);
      border-radius: 12px;
    }
    .fin-chart__head {
      display: flex;
      justify-content: space-between;
      align-items: baseline;
      gap: 12px;
      margin-bottom: 10px;
    }
    .fin-chart__title {
      font-size: 0.82rem;
      font-weight: 700;
      color: var(--text-dim);
    }
    .fin-chart__delta {
      font-size: 0.72rem;
      font-weight: 700;
      white-space: nowrap;
    }
    .fin-chart__delta.is-up { color: var(--emerald); }
    .fin-chart__delta.is-down { color: var(--rose); }
    .fin-chart__bars {
      display: grid;
      grid-auto-flow: column;
      grid-auto-columns: 1fr;
      gap: 8px;
      align-items: end;
      height: 130px;
    }
    .fin-chart__col {
      display: flex;
      flex-direction: column;
      align-items: stretch;
      height: 100%;
      min-width: 0;
    }
    .fin-chart__value {
      font-size: 0.6rem;
      font-weight: 700;
      color: var(--text-muted);
      text-align: center;
      white-space: nowrap;
      overflow: hidden;
      font-variant-numeric: tabular-nums;
    }
    .fin-chart__stack {
      flex: 1;
      display: flex;
      flex-direction: column;
      justify-content: flex-end;
      gap: 1px;
      margin-top: 2px;
    }
    .fin-chart__seg {
      border-radius: 4px 4px 0 0;
      min-height: 0;
      transition: height 0.4s ease;
    }
    .fin-chart__seg.is-paid {
      background: linear-gradient(180deg, rgba(16,185,129,0.85), rgba(16,185,129,0.45));
      border-radius: 0 0 4px 4px;
    }
    .fin-chart__seg.is-unpaid {
      background: linear-gradient(180deg, rgba(244,63,94,0.75), rgba(244,63,94,0.4));
    }
    .fin-chart__col.is-current .fin-chart__seg.is-paid { box-shadow: 0 0 10px rgba(16,185,129,0.35); }
    .fin-chart__label {
      margin-top: 6px;
      text-align: center;
      font-size: 0.68rem;
      font-weight: 600;
      color: var(--text-muted);
      text-transform: capitalize;
    }
    .fin-chart__col.is-current .fin-chart__label { color: var(--accent); font-weight: 800; }
    .fin-chart__legend {
      display: flex;
      gap: 14px;
      margin-top: 8px;
      font-size: 0.68rem;
      color: var(--text-muted);
    }
    .fin-chart__legend span { display: inline-flex; align-items: center; gap: 5px; }
    .fin-dot {
      width: 8px; height: 8px;
      border-radius: 50%;
      display: inline-block;
    }
    .fin-dot.is-paid { background: var(--emerald); }
    .fin-dot.is-unpaid { background: var(--rose); }

    /* ─── Finance: unit-экономика (топ учеников) ─── */
    .fin-econ {
      margin-top: 20px;
      padding: 14px 16px;
      background: rgba(255,255,255,0.02);
      border: 1px solid var(--border);
      border-radius: 12px;
    }
    .fin-econ__title {
      font-size: 0.82rem;
      font-weight: 700;
      color: var(--text-dim);
      margin-bottom: 10px;
    }
    .fin-econ__row {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 2px 12px;
      padding: 7px 0;
      border-top: 1px solid rgba(255,255,255,0.04);
    }
    .fin-econ__row:first-of-type { border-top: none; }
    .fin-econ__info { min-width: 0; }
    .fin-econ__name { font-size: 0.85rem; font-weight: 600; }
    .fin-econ__meta {
      display: block;
      font-size: 0.7rem;
      color: var(--text-muted);
      margin-top: 1px;
      font-variant-numeric: tabular-nums;
    }
    .fin-econ__amount {
      font-size: 0.9rem;
      font-weight: 800;
      color: var(--emerald);
      font-variant-numeric: tabular-nums;
      align-self: center;
    }
    .fin-econ__bar {
      grid-column: 1 / -1;
      height: 4px;
      border-radius: 999px;
      background: rgba(255,255,255,0.05);
      overflow: hidden;
    }
    .fin-econ__bar i {
      display: block;
      height: 100%;
      border-radius: 999px;
      background: linear-gradient(90deg, var(--accent), var(--emerald));
      transition: width 0.4s ease;
    }

    /* ─── Письмо об оплате ─── */
    .letter-toggle {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      margin: 12px 0 10px;
      font-size: 0.82rem;
      color: var(--text-dim);
      font-weight: 600;
      cursor: pointer;
      user-select: none;
    }
    .letter-toggle input { accent-color: var(--accent); width: 15px; height: 15px; }
    .letter-textarea {
      width: 100%;
      min-height: 220px;
      resize: vertical;
      padding: 12px 14px;
      background: rgba(255,255,255,0.03);
      border: 1px solid var(--border);
      border-radius: 10px;
      color: var(--text);
      font-family: inherit;
      font-size: 0.85rem;
      line-height: 1.55;
    }
    .letter-textarea:focus {
      outline: none;
      border-color: rgba(99,102,241,0.5);
    }
    .letter-qr {
      display: flex;
      align-items: center;
      gap: 12px;
      margin-top: 12px;
      padding: 10px 12px;
      background: rgba(255,255,255,0.02);
      border: 1px dashed var(--border);
      border-radius: 10px;
      font-size: 0.72rem;
      color: var(--text-muted);
    }
    .letter-qr img {
      width: 56px; height: 56px;
      object-fit: contain;
      border-radius: 8px;
      background: #fff;
      flex: none;
    }

    /* ─── Форма реквизитов ─── */
    .req-form {
      display: flex;
      flex-direction: column;
      gap: 12px;
      overflow-y: auto;
      padding: 4px 2px;
    }
    .req-field { display: flex; flex-direction: column; gap: 5px; }
    .req-field span {
      font-size: 0.72rem;
      font-weight: 700;
      color: var(--text-muted);
      letter-spacing: 0.03em;
    }
    .req-field input {
      padding: 10px 12px;
      background: rgba(255,255,255,0.03);
      border: 1px solid var(--border);
      border-radius: 9px;
      color: var(--text);
      font-family: inherit;
      font-size: 0.88rem;
      font-variant-numeric: tabular-nums;
    }
    .req-field input:focus { outline: none; border-color: rgba(99,102,241,0.5); }
    .req-qr {
      margin-top: 4px;
      padding: 12px;
      background: rgba(255,255,255,0.02);
      border: 1px dashed var(--border);
      border-radius: 10px;
    }
    .req-qr__head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 10px;
      flex-wrap: wrap;
    }
    .req-qr__head > span {
      font-size: 0.72rem;
      font-weight: 700;
      color: var(--text-muted);
      letter-spacing: 0.03em;
    }
    .req-qr__actions { display: flex; gap: 8px; }
    .req-qr__upload { cursor: pointer; display: inline-flex; align-items: center; }
    #reqQrPreview {
      margin-top: 10px;
      max-width: 160px;
      max-height: 160px;
      object-fit: contain;
      border-radius: 10px;
      background: #fff;
      padding: 6px;
    }

    /* ─── Налоги ─── */
    .tax-head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 12px;
      cursor: pointer;
      user-select: none;
    }
    .tax-head__rate {
      display: flex;
      align-items: center;
      gap: 7px;
      cursor: default;
      font-size: 0.78rem;
      color: var(--text-muted);
      font-weight: 600;
    }
    .tax-head__rate input {
      width: 64px;
      padding: 6px 8px;
      background: rgba(255,255,255,0.03);
      border: 1px solid var(--border);
      border-radius: 8px;
      color: var(--text);
      font-family: inherit;
      font-size: 0.85rem;
      text-align: right;
      font-variant-numeric: tabular-nums;
    }
    .tax-head__rate input:focus { outline: none; border-color: rgba(99,102,241,0.5); }
    .tax-hint {
      margin-top: 14px;
      padding: 10px 12px;
      background: rgba(99,102,241,0.06);
      border: 1px solid rgba(99,102,241,0.18);
      border-radius: 10px;
      font-size: 0.75rem;
      line-height: 1.5;
      color: var(--text-muted);
    }
    .tax-month {
      border: 1px solid var(--border);
      border-radius: 10px;
      margin-bottom: 8px;
      background: rgba(255,255,255,0.02);
      overflow: hidden;
    }
    .tax-month__head {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 10px 14px;
      cursor: pointer;
      list-style: none;
      flex-wrap: wrap;
    }
    .tax-month__head::-webkit-details-marker { display: none; }
    .tax-month__head::before { content: '▸'; color: var(--text-muted); font-size: 0.8rem; }
    .tax-month[open] .tax-month__head::before { content: '▾'; }
    .tax-month__name {
      font-size: 0.88rem;
      font-weight: 700;
      text-transform: capitalize;
    }
    .tax-month__meta {
      font-size: 0.74rem;
      color: var(--text-muted);
      font-variant-numeric: tabular-nums;
      flex: 1;
    }
    .tax-month__badge {
      font-size: 0.66rem;
      font-weight: 800;
      padding: 2px 8px;
      border-radius: 999px;
      white-space: nowrap;
    }
    .tax-month__badge.is-due { background: rgba(244,63,94,0.15); color: var(--rose); }
    .tax-month__badge.is-ok { background: rgba(16,185,129,0.15); color: var(--emerald); }
    .tax-month__rows {
      border-top: 1px solid var(--border);
      padding: 6px 10px;
      display: flex;
      flex-direction: column;
      gap: 2px;
    }
    .tax-row {
      display: grid;
      grid-template-columns: auto 58px 1fr auto auto auto;
      align-items: center;
      gap: 10px;
      padding: 6px 8px;
      border-radius: 8px;
      cursor: pointer;
      font-size: 0.8rem;
      transition: background 0.12s;
    }
    .tax-row:hover { background: rgba(255,255,255,0.04); }
    .tax-row input { accent-color: var(--emerald); width: 15px; height: 15px; }
    .tax-row__date { color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
    .tax-row__student { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .tax-row__price { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
    .tax-row__tax { font-size: 0.7rem; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
    .tax-row__mark { font-size: 0.68rem; color: var(--emerald); white-space: nowrap; min-width: 86px; text-align: right; }
    .tax-row.is-paid { opacity: 0.72; }
    .tax-row.is-paid .tax-row__student { text-decoration: line-through; text-decoration-color: rgba(148,163,184,0.5); }
    @media (max-width: 600px) {
      .tax-row { grid-template-columns: auto 52px 1fr auto; }
      .tax-row__tax, .tax-row__mark { display: none; }
      .tax-month__payall { margin-left: auto; }
    }

    /* ─── Student row actions ─── */
    .student-actions {
      display: flex;
      gap: 6px;
      align-items: center;
      justify-content: flex-end;
      flex-wrap: wrap;
    }
    .btn-debt {
      background: rgba(244,63,94,0.15) !important;
      color: var(--rose) !important;
      border: 1px solid rgba(244,63,94,0.35) !important;
      padding: 4px 10px !important;
      font-size: 0.75rem !important;
      font-weight: 700 !important;
      font-variant-numeric: tabular-nums;
    }
    .btn-debt:hover {
      background: rgba(244,63,94,0.25) !important;
      border-color: rgba(244,63,94,0.55) !important;
    }
    .badge-paid {
      display: inline-flex;
      align-items: center;
      padding: 3px 8px;
      border-radius: 6px;
      font-size: 0.7rem;
      font-weight: 700;
      color: var(--emerald);
      background: rgba(16,185,129,0.12);
      border: 1px solid rgba(16,185,129,0.28);
    }

    /* ─── Debt Modal ─── */
    .debt-modal {
      background: linear-gradient(180deg, rgba(244,63,94,0.04) 0%, var(--bg) 80%);
    }
    .debt-modal__head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 16px;
    }
    .debt-modal__title {
      font-size: 1.2rem;
      font-weight: 800;
      margin: 0;
      letter-spacing: -0.3px;
    }
    .debt-modal__subtitle {
      font-size: 0.82rem;
      color: var(--text-muted);
      margin-top: 4px;
    }
    .debt-modal__close {
      background: transparent;
      border: none;
      color: var(--text-muted);
      font-size: 1.1rem;
      cursor: pointer;
      padding: 4px 8px;
      border-radius: 6px;
      transition: background 0.15s, color 0.15s;
    }
    .debt-modal__close:hover {
      background: rgba(255,255,255,0.05);
      color: var(--text);
    }
    .debt-modal__summary {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 8px;
      margin-bottom: 16px;
    }
    .debt-modal__summary-item {
      background: rgba(255,255,255,0.03);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 10px 12px;
    }
    .debt-modal__summary-label {
      font-size: 0.7rem;
      color: var(--text-dim);
      text-transform: uppercase;
      letter-spacing: 0.3px;
      font-weight: 700;
      margin-bottom: 4px;
    }
    .debt-modal__summary-value {
      font-size: 1.1rem;
      font-weight: 800;
      color: var(--rose);
      font-variant-numeric: tabular-nums;
    }
    .debt-modal__toolbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      padding: 10px 0;
      border-top: 1px solid var(--border);
      border-bottom: 1px solid var(--border);
      margin-bottom: 12px;
    }
    .debt-modal__checkbox-all {
      display: flex;
      align-items: center;
      gap: 8px;
      cursor: pointer;
      font-size: 0.82rem;
      color: var(--text-muted);
      font-weight: 600;
    }
    .debt-modal__checkbox-all input { accent-color: var(--accent); }
    .debt-modal__list {
      flex: 1;
      overflow-y: auto;
      display: flex;
      flex-direction: column;
      gap: 6px;
      max-height: 45vh;
      padding-right: 2px;
    }
    .debt-modal__empty {
      padding: 32px 16px;
      text-align: center;
      color: var(--text-dim);
      font-size: 0.9rem;
    }
    .debt-modal__section {
      margin-top: 8px;
      padding: 4px 2px;
      font-size: 0.72rem;
      font-weight: 700;
      letter-spacing: 0.02em;
      color: var(--rose);
    }
    .debt-modal__section:first-child { margin-top: 0; }
    .debt-modal__section.is-upcoming { color: var(--text-muted); }
    .debt-row {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 8px;
      align-items: center;
      padding: 10px 12px;
      background: rgba(255,255,255,0.025);
      border: 1px solid var(--border);
      border-radius: 10px;
      transition: background 0.15s, border-color 0.15s;
    }
    .debt-row:hover {
      background: rgba(255,255,255,0.05);
      border-color: rgba(99,102,241,0.32);
    }
    .debt-row__select {
      display: grid;
      grid-template-columns: auto 1fr auto;
      gap: 12px;
      align-items: center;
      min-width: 0;
      cursor: pointer;
    }
    .debt-row__del {
      flex: none;
      width: 34px; height: 34px;
      border: 1px solid var(--border);
      background: rgba(239,68,68,0.08);
      border-radius: 8px;
      cursor: pointer;
      font-size: 0.95rem;
      line-height: 1;
      transition: background 0.15s, border-color 0.15s;
    }
    .debt-row__del:hover {
      background: rgba(239,68,68,0.22);
      border-color: rgba(239,68,68,0.6);
    }
    .debt-row__group { font-size: 0.85em; opacity: 0.85; }
    .debt-row__check { accent-color: var(--accent); width: 16px; height: 16px; }
    .debt-row__main { min-width: 0; }
    .debt-row__title {
      font-size: 0.88rem;
      font-weight: 600;
      color: var(--text);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .debt-row__meta {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-top: 2px;
      font-size: 0.72rem;
      color: var(--text-muted);
      font-variant-numeric: tabular-nums;
    }
    .debt-row__status {
      padding: 1px 6px;
      border-radius: 5px;
      font-size: 0.65rem;
      font-weight: 700;
      background: rgba(99,102,241,0.15);
      color: #a5b4fc;
      border: none;
      cursor: pointer;
      font-family: inherit;
      line-height: inherit;
      transition: filter 0.12s, box-shadow 0.12s;
    }
    .debt-row__status:hover {
      filter: brightness(1.3);
      box-shadow: 0 0 0 1px rgba(99,102,241,0.45);
    }
    .debt-row__status.is-done:hover { box-shadow: 0 0 0 1px rgba(16,185,129,0.45); }
    .debt-row__status:disabled { opacity: 0.5; cursor: wait; }
    .debt-row__status.is-done {
      background: rgba(16,185,129,0.15);
      color: var(--emerald);
    }
    .debt-row__price {
      font-size: 0.95rem;
      font-weight: 800;
      color: var(--rose);
      font-variant-numeric: tabular-nums;
      white-space: nowrap;
    }
    .debt-modal__footer {
      display: flex;
      justify-content: flex-end;
      gap: 10px;
      margin-top: 14px;
      padding-top: 14px;
      border-top: 1px solid var(--border);
    }
    .btn-debt-primary {
      background: var(--emerald) !important;
      color: white !important;
      border: none !important;
      font-weight: 700 !important;
    }
    .btn-debt-primary:hover { background: #0ea271 !important; }
    .btn-debt-primary:disabled { opacity: 0.6; cursor: not-allowed; }

    @media (max-width: 600px) {
      .debt-modal__summary { grid-template-columns: 1fr 1fr; }
      .debt-modal__summary-item:nth-child(3) { grid-column: 1 / -1; }
      .debt-row__select { grid-template-columns: auto 1fr; }
      .debt-row__price { grid-column: 2; justify-self: end; margin-top: 4px; }
    }

    /* ─── Student "My Debt" card ─── */
    .my-debt-card {
      background:
        radial-gradient(ellipse 60% 60% at 100% 0%, rgba(244,63,94,0.06) 0%, transparent 60%),
        var(--bg-card);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 24px;
    }
    .my-debt-card__head {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 8px;
    }
    .my-debt-card__title {
      font-size: 1rem;
      font-weight: 800;
      letter-spacing: -0.2px;
    }
    .my-debt-card__subtitle {
      font-size: 0.78rem;
      color: var(--text-muted);
      margin-top: 4px;
    }
    .my-debt-card__total {
      font-size: 1.6rem;
      font-weight: 800;
      color: var(--rose);
      font-variant-numeric: tabular-nums;
      line-height: 1;
      text-shadow: 0 0 20px rgba(244,63,94,0.2);
    }
    .my-debt-card__hint {
      font-size: 0.78rem;
      color: var(--text-muted);
      background: rgba(245,158,11,0.06);
      border: 1px solid rgba(245,158,11,0.18);
      border-radius: 8px;
      padding: 10px 12px;
      margin-bottom: 12px;
    }
    .my-debt-empty {
      padding: 18px 4px 0;
      font-size: 0.85rem;
      color: var(--text-muted);
    }
    .my-debt-list {
      display: flex;
      flex-direction: column;
      gap: 6px;
      max-height: 340px;
      overflow-y: auto;
      padding-right: 4px;
    }
    .my-debt-list::-webkit-scrollbar { width: 6px; }
    .my-debt-list::-webkit-scrollbar-thumb {
      background: rgba(255,255,255,0.08);
      border-radius: 4px;
    }
    .my-debt-row {
      display: grid;
      grid-template-columns: 60px 1fr auto;
      gap: 14px;
      align-items: center;
      padding: 10px 14px;
      background: rgba(244,63,94,0.04);
      border: 1px solid rgba(244,63,94,0.18);
      border-radius: 10px;
      transition: background 0.15s, border-color 0.15s;
    }
    .my-debt-row:hover {
      background: rgba(244,63,94,0.08);
      border-color: rgba(244,63,94,0.32);
    }
    .my-debt-row__date {
      color: var(--text-muted);
      font-variant-numeric: tabular-nums;
      line-height: 1.2;
    }
    .my-debt-row__date-day {
      font-size: 0.88rem;
      font-weight: 700;
      color: var(--text);
    }
    .my-debt-row__date-time {
      font-size: 0.7rem;
      color: var(--text-dim);
      margin-top: 1px;
    }
    .my-debt-row__body { min-width: 0; }
    .my-debt-row__title {
      font-size: 0.88rem;
      font-weight: 600;
      color: var(--text);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .my-debt-row__meta {
      display: flex;
      gap: 6px;
      margin-top: 3px;
    }
    .my-debt-row__status {
      padding: 1px 7px;
      border-radius: 5px;
      font-size: 0.66rem;
      font-weight: 700;
      background: rgba(99,102,241,0.15);
      color: #a5b4fc;
    }
    .my-debt-row__status.is-done {
      background: rgba(16,185,129,0.15);
      color: var(--emerald);
    }
    .my-debt-row__status.is-upcoming {
      background: rgba(99,102,241,0.15);
      color: var(--accent);
    }
    .my-debt-row.is-upcoming {
      border-color: rgba(99,102,241,0.2);
      background: rgba(99,102,241,0.04);
    }
    .my-debt-row.is-upcoming .my-debt-row__price {
      color: var(--accent);
    }
    .my-debt-row__price {
      font-size: 1.1rem;
      font-weight: 800;
      color: var(--rose);
      font-variant-numeric: tabular-nums;
      white-space: nowrap;
    }

    .my-debt-upcoming {
      margin-top: 20px;
      border-top: 1px solid rgba(99,102,241,0.25);
      padding-top: 16px;
    }
    .my-debt-upcoming__head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 8px;
    }
    .my-debt-upcoming__title {
      font-size: 0.95rem;
      font-weight: 700;
      color: var(--text);
    }
    .my-debt-upcoming__total {
      font-size: 1.2rem;
      font-weight: 800;
      color: var(--accent);
      font-variant-numeric: tabular-nums;
    }
    .my-debt-upcoming__hint {
      font-size: 0.82rem;
      color: var(--text-muted);
      background: rgba(99,102,241,0.08);
      border: 1px solid rgba(99,102,241,0.2);
      border-radius: 8px;
      padding: 8px 12px;
      margin-bottom: 12px;
    }

    @media (max-width: 600px) {
      .my-debt-card { padding: 18px 16px; }
      .my-debt-row { grid-template-columns: 50px 1fr; gap: 10px; }
      .my-debt-row__price {
        grid-column: 1 / -1;
        justify-self: end;
        margin-top: 2px;
        font-size: 1rem;
      }
    }

    /* ── Homework History Timeline ─────────────────── */
    .hw-history-container {
      max-height: 600px;
      overflow-y: auto;
      padding-right: 4px;
    }
    .hw-timeline {
      display: flex;
      flex-direction: column;
      gap: 0;
      position: relative;
      padding-left: 28px;
    }
    .hw-timeline::before {
      content: '';
      position: absolute;
      left: 9px;
      top: 12px;
      bottom: 12px;
      width: 2px;
      background: var(--border);
    }
    .hw-timeline-item {
      position: relative;
      padding-bottom: 16px;
    }
    .hw-timeline-item:last-child {
      padding-bottom: 0;
    }
    .hw-timeline-dot {
      position: absolute;
      left: -23px;
      top: 18px;
      width: 12px;
      height: 12px;
      border-radius: 50%;
      border: 2px solid var(--border);
      background: var(--bg-card);
      z-index: 1;
    }
    .hw-timeline-dot.pending_review {
      background: var(--amber);
      border-color: var(--amber);
    }
    .hw-timeline-dot.approved {
      background: var(--emerald);
      border-color: var(--emerald);
    }
    .hw-timeline-dot.rejected {
      background: var(--rose);
      border-color: var(--rose);
    }
    .hw-timeline-dot.not_submitted {
      background: var(--bg-card);
      border-color: var(--text-dim);
    }

    /* ── HW cards ─────────────────────────────────── */
    .hw-card {
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 14px 16px;
      display: flex;
      flex-direction: column;
      gap: 6px;
    }
    .hw-card--unsent {
      border-color: rgba(156,163,175,0.25);
      opacity: 0.92;
    }
    .hw-card__head {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      gap: 8px;
    }
    .hw-card__title {
      font-size: 0.85rem;
      font-weight: 700;
    }
    .hw-card__date {
      font-size: 0.75rem;
      color: var(--text-dim);
      margin-top: 2px;
    }
    .hw-card__task {
      font-size: 0.82rem;
      color: var(--text-muted);
      white-space: pre-wrap;
      background: rgba(0,0,0,0.15);
      padding: 8px 10px;
      border-radius: 8px;
      margin: 2px 0;
      max-height: 80px;
      overflow-y: auto;
    }
    .hw-card__text {
      font-size: 0.82rem;
      color: var(--text-muted);
      white-space: pre-wrap;
      background: rgba(0,0,0,0.1);
      padding: 8px;
      border-radius: 6px;
      max-height: 80px;
      overflow-y: auto;
      margin: 2px 0;
    }
    .hw-card__feedback {
      margin-top: 4px;
      padding: 10px;
      background: rgba(99,102,241,0.05);
      border-radius: 8px;
      border: 1px solid rgba(99,102,241,0.12);
    }
    .hw-card__feedback-label {
      font-size: 0.72rem;
      color: var(--text-dim);
      margin-bottom: 4px;
    }
    .hw-card__feedback-text {
      font-size: 0.82rem;
      color: var(--text-muted);
      white-space: pre-wrap;
    }
    .hw-card__chat-row {
      border-top: 1px solid var(--border);
      padding-top: 8px;
      margin-top: 4px;
    }
    .hw-chat-box {
      max-height: 150px;
      overflow-y: auto;
      margin-bottom: 8px;
      border: 1px solid var(--border);
      border-radius: 6px;
      padding: 8px;
      background: rgba(0,0,0,0.1);
    }
    .hw-chat-input {
      flex: 1;
      padding: 6px;
      border-radius: 6px;
      border: 1px solid var(--border);
      background: rgba(255,255,255,0.05);
      color: white;
      font-size: 0.75rem;
    }

    /* ── HW badges ────────────────────────────────── */
    .hw-badge {
      font-size: 0.7rem;
      padding: 2px 8px;
      border-radius: 10px;
      border: 1px solid transparent;
      white-space: nowrap;
      flex-shrink: 0;
    }
    .hw-badge--gray {
      background: rgba(156,163,175,0.15);
      color: #9ca3af;
      border-color: rgba(156,163,175,0.3);
    }
    .hw-badge--warn {
      background: rgba(245,158,11,0.15);
      color: var(--amber);
      border-color: rgba(245,158,11,0.4);
      align-self: flex-start;
      margin-top: -2px;
    }

    /* ── HW buttons ───────────────────────────────── */
    .hw-btn-submit {
      background: var(--accent);
      color: white;
      border: none;
      border-radius: 8px;
      padding: 6px 14px;
      font-size: 0.8rem;
      font-weight: 600;
      cursor: pointer;
      align-self: flex-start;
      margin-top: 4px;
    }
    .hw-btn-submit:hover { opacity: 0.85; }
    .hw-btn-revisions {
      background: rgba(245,158,11,0.15);
      color: var(--amber);
      border: 1px solid rgba(245,158,11,0.3);
      padding: 3px 8px;
      border-radius: 4px;
      font-size: 0.65rem;
      cursor: pointer;
    }
    .hw-btn-chat {
      background: none;
      border: none;
      color: var(--accent);
      font-size: 0.8rem;
      cursor: pointer;
    }
    .hw-btn-send {
      background: var(--accent);
      color: white;
      border: none;
      padding: 0 10px;
      border-radius: 6px;
      cursor: pointer;
      height: 30px;
    }
    .hw-revisions-box {
      background: rgba(0,0,0,0.3);
      padding: 10px;
      border-radius: 8px;
      border-left: 3px solid var(--amber);
      margin-bottom: 4px;
    }
    .hw-file-link {
      font-size: 0.7rem;
      color: var(--accent);
      background: rgba(255,255,255,0.05);
      padding: 2px 6px;
      border-radius: 4px;
      border: 1px solid var(--border);
      text-decoration: none;
    }
    .hw-file-link--teacher {
      color: var(--emerald);
      background: rgba(16,185,129,0.05);
      border-color: rgba(16,185,129,0.2);
    }

    /* ─── HW Drop Zone — анимации прикрепления файлов ─────── */
    .hw-drop-zone {
      border-radius: 10px;
      border: 1.5px dashed rgba(99,102,241,0.35);
      background: rgba(99,102,241,0.03);
      transition: border-color .25s ease, background .25s ease,
                  box-shadow .25s ease, transform .15s ease;
      cursor: pointer;
      position: relative;
      overflow: hidden;
    }
    .hw-drop-zone:hover {
      border-color: rgba(99,102,241,0.6);
      background: rgba(99,102,241,0.06);
      box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
    }
    .hw-drop-zone.dragover {
      border-color: var(--accent);
      border-style: solid;
      background: rgba(99,102,241,0.14);
      box-shadow: 0 0 0 4px rgba(99,102,241,0.18),
                  inset 0 0 30px rgba(99,102,241,0.12);
      transform: scale(1.015);
      animation: hwPulse 1.4s ease-in-out infinite;
    }
    @keyframes hwPulse {
      0%, 100% { box-shadow: 0 0 0 4px rgba(99,102,241,0.18), inset 0 0 30px rgba(99,102,241,0.12); }
      50%      { box-shadow: 0 0 0 8px rgba(99,102,241,0.28), inset 0 0 40px rgba(99,102,241,0.22); }
    }
    /* "Снег" — диагональные полосы при dragover */
    .hw-drop-zone.dragover::before {
      content: '';
      position: absolute;
      inset: 0;
      background: repeating-linear-gradient(
        45deg,
        rgba(99,102,241,0.06) 0,
        rgba(99,102,241,0.06) 10px,
        transparent 10px,
        transparent 20px
      );
      animation: hwStripes 1.5s linear infinite;
      pointer-events: none;
    }
    @keyframes hwStripes {
      from { background-position: 0 0; }
      to   { background-position: 28px 0; }
    }

    /* Кнопка-скрепка с эффектом нажатия */
    .chat-attachment-btn {
      background: rgba(99,102,241,0.12);
      border: 1px solid rgba(99,102,241,0.25);
      color: var(--accent);
      width: 30px; height: 30px;
      border-radius: 8px;
      cursor: pointer;
      font-size: 1rem;
      transition: transform .15s ease, background .2s ease, box-shadow .2s ease;
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }
    .chat-attachment-btn:hover {
      background: rgba(99,102,241,0.22);
      box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
    }
    .chat-attachment-btn:active {
      transform: scale(0.9) rotate(-12deg);
    }

    /* ── Чипы прикреплённых файлов ── */
    .hw-file-chip {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      background: rgba(99,102,241,0.12);
      border: 1px solid rgba(99,102,241,0.3);
      color: var(--accent);
      padding: 5px 10px;
      border-radius: 999px;
      font-size: 0.78rem;
      font-weight: 500;
      margin: 2px 4px 2px 0;
      animation: hwChipIn .35s cubic-bezier(.34,1.56,.64,1) both;
      max-width: 220px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    @keyframes hwChipIn {
      0%   { transform: scale(0.3) translateY(8px); opacity: 0; }
      60%  { transform: scale(1.1)  translateY(0);  opacity: 1; }
      100% { transform: scale(1)    translateY(0);  opacity: 1; }
    }
    .hw-file-chip .remove {
      cursor: pointer;
      width: 16px; height: 16px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border-radius: 50%;
      background: rgba(244,63,94,0.0);
      color: var(--text-dim);
      font-size: 0.95rem;
      line-height: 1;
      transition: background .2s ease, color .2s ease, transform .15s ease;
    }
    .hw-file-chip .remove:hover {
      background: rgba(244,63,94,0.85);
      color: white;
      transform: scale(1.15);
    }

    /* Кнопка "+" добавления ещё файлов */
    .hw-add-btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 28px; height: 28px;
      border-radius: 50%;
      background: rgba(99,102,241,0.12);
      border: 1px dashed rgba(99,102,241,0.4);
      color: var(--accent);
      cursor: pointer;
      font-size: 1.05rem;
      font-weight: 700;
      transition: transform .15s ease, background .2s ease;
      vertical-align: middle;
    }
    .hw-add-btn:hover {
      background: rgba(99,102,241,0.22);
      transform: rotate(90deg) scale(1.1);
    }

    /* Удаляемые файлы (уже сохранённые) — slot animation */
    .removable-file {
      position: relative;
      display: inline-flex;
      align-items: center;
      margin: 2px 4px 2px 0;
      animation: hwChipIn .3s ease both;
    }
    .removable-file.is-removing {
      animation: hwChipOut .3s ease forwards;
    }
    @keyframes hwChipOut {
      to { transform: scale(0.3) translateY(-8px); opacity: 0; }
    }
    .removable-file .remove-btn {
      position: absolute;
      top: -6px; right: -6px;
      width: 18px; height: 18px;
      background: var(--rose);
      color: white;
      border-radius: 50%;
      font-size: 0.75rem;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      box-shadow: 0 2px 6px rgba(0,0,0,0.4);
      transition: transform .15s ease;
    }
    .removable-file .remove-btn:hover {
      transform: scale(1.2);
    }
    .removable-file.marked-delete {
      opacity: 0.45;
      filter: grayscale(0.7);
      animation: hwShakeOut .4s ease;
    }
    .removable-file.marked-delete a {
      text-decoration: line-through !important;
    }
    @keyframes hwShakeOut {
      0%, 100% { transform: translateX(0); }
      25%      { transform: translateX(-4px) rotate(-2deg); }
      75%      { transform: translateX(4px)  rotate(2deg); }
    }

    /* Текстарея с homework — мягкий focus */
    #detailHomework, #hwSubmitText {
      transition: border-color .25s ease, box-shadow .25s ease, background .25s ease;
    }
    #detailHomework:focus, #hwSubmitText:focus {
      outline: none;
      border-color: var(--accent) !important;
      background: rgba(99,102,241,0.04) !important;
      box-shadow: 0 0 0 3px rgba(99,102,241,0.18);
    }

    /* ─── HW Gallery (превью прикреплённых файлов) ────────── */
    .hw-gallery-wrap {
      margin: 6px 0;
    }
    .hw-gallery-label {
      font-size: 0.72rem;
      color: var(--text-dim);
      margin-bottom: 4px;
      letter-spacing: 0.02em;
    }
    .hw-gallery-label--row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }
    .hw-gallery-dl-all {
      flex: none;
      cursor: pointer;
      font-size: 0.72rem;
      font-weight: 700;
      color: #c7d2fe;
      background: rgba(99, 102, 241, 0.12);
      border: 1px solid rgba(99, 102, 241, 0.35);
      border-radius: 6px;
      padding: 3px 9px;
      transition: background 0.15s ease, color 0.15s ease;
    }
    .hw-gallery-dl-all:hover {
      background: rgba(99, 102, 241, 0.22);
      color: #fff;
    }
    .hw-gallery {
      display: flex;
      gap: 8px;
      overflow-x: auto;
      padding: 2px 2px 6px;
      scrollbar-width: thin;
      scrollbar-color: rgba(255,255,255,0.15) transparent;
    }
    .hw-gallery::-webkit-scrollbar { height: 6px; }
    .hw-gallery::-webkit-scrollbar-thumb {
      background: rgba(255,255,255,0.15);
      border-radius: 3px;
    }
    .hw-gallery-item {
      flex: 0 0 auto;
      position: relative;
      width: 96px;
      height: 96px;
      border-radius: 10px;
      border: 1px solid var(--border);
      background: rgba(255,255,255,0.04);
      cursor: pointer;
      overflow: hidden;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 0;
      transition: transform .18s ease, border-color .2s ease, box-shadow .2s ease;
    }
    .hw-gallery-item:hover {
      transform: translateY(-2px) scale(1.03);
      border-color: var(--accent);
      box-shadow: 0 6px 18px rgba(0,0,0,0.35),
                  0 0 0 3px rgba(99,102,241,0.18);
    }
    .hw-gallery-item__img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block;
    }
    .hw-gallery-item__icon {
      font-size: 2rem;
      line-height: 1;
      margin-bottom: 4px;
    }
    .hw-gallery-item__name {
      position: absolute;
      bottom: 0;
      left: 0; right: 0;
      padding: 3px 6px;
      font-size: 0.65rem;
      color: white;
      background: linear-gradient(to top, rgba(0,0,0,0.75), rgba(0,0,0,0));
      text-align: center;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      pointer-events: none;
    }
    .hw-gallery-item__zoom {
      position: absolute;
      top: 4px; right: 4px;
      width: 22px; height: 22px;
      border-radius: 50%;
      background: rgba(0,0,0,0.55);
      color: white;
      font-size: 0.7rem;
      display: flex;
      align-items: center;
      justify-content: center;
      opacity: 0;
      transition: opacity .15s ease;
      pointer-events: none;
    }
    .hw-gallery-item:hover .hw-gallery-item__zoom { opacity: 1; }

    /* ─── HW Lightbox (полноэкранный просмотр) ────────────── */
    .hw-lightbox {
      position: fixed;
      inset: 0;
      z-index: 2000;
      background: rgba(0,0,0,0.92);
      backdrop-filter: blur(6px);
      display: none;
      flex-direction: column;
      animation: hwLbFade .2s ease;
    }
    .hw-lightbox.is-open { display: flex; }
    @keyframes hwLbFade {
      from { opacity: 0; }
      to   { opacity: 1; }
    }
    .hw-lightbox__bar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 12px 18px;
      background: rgba(0,0,0,0.4);
      border-bottom: 1px solid rgba(255,255,255,0.08);
    }
    .hw-lightbox__name {
      color: white;
      font-size: 0.95rem;
      font-weight: 500;
      max-width: 60vw;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .hw-lightbox__actions {
      display: flex;
      gap: 8px;
      flex-shrink: 0;
    }
    .hw-lightbox__btn {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 6px 14px;
      background: rgba(255,255,255,0.08);
      color: white;
      border: 1px solid rgba(255,255,255,0.15);
      border-radius: 8px;
      cursor: pointer;
      font-size: 0.82rem;
      text-decoration: none;
      transition: background .15s ease, transform .15s ease;
    }
    .hw-lightbox__btn:hover {
      background: rgba(255,255,255,0.16);
      transform: translateY(-1px);
    }
    .hw-lightbox__btn--close {
      background: rgba(244,63,94,0.2);
      border-color: rgba(244,63,94,0.4);
      font-weight: 700;
    }
    .hw-lightbox__btn--close:hover {
      background: rgba(244,63,94,0.4);
    }
    .hw-lightbox__stage {
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 20px;
      overflow: auto;
    }
    .hw-lightbox__img {
      max-width: 100%;
      max-height: 100%;
      object-fit: contain;
      border-radius: 6px;
      box-shadow: 0 12px 40px rgba(0,0,0,0.6);
      animation: hwLbZoomIn .25s cubic-bezier(.22,1.4,.36,1);
    }
    @keyframes hwLbZoomIn {
      from { transform: scale(0.85); opacity: 0; }
      to   { transform: scale(1);    opacity: 1; }
    }
    .hw-lightbox__frame {
      width: min(100%, 1100px);
      height: 100%;
      border: none;
      border-radius: 6px;
      background: white;
      box-shadow: 0 12px 40px rgba(0,0,0,0.6);
    }
    .hw-lightbox__video {
      max-width: 100%;
      max-height: 100%;
      border-radius: 6px;
      box-shadow: 0 12px 40px rgba(0,0,0,0.6);
    }
    .hw-lightbox__audio {
      width: min(100%, 500px);
    }
    .hw-lightbox__placeholder {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 12px;
      color: rgba(255,255,255,0.65);
    }
    .hw-lightbox__placeholder-icon {
      font-size: 5rem;
      opacity: 0.7;
    }
    .hw-lightbox__placeholder-text {
      text-align: center;
      font-size: 0.95rem;
    }

    @media (max-width: 600px) {
      .hw-lightbox__bar { padding: 8px 12px; }
      .hw-lightbox__btn { padding: 6px 10px; font-size: 0.75rem; }
      .hw-lightbox__name { max-width: 40vw; font-size: 0.85rem; }
      .hw-gallery-item { width: 80px; height: 80px; }
    }


    /* ─── AI Settings: model selector modal (OpenRouter catalog) ─── */
    .model-modal-overlay {
      display: none;
      position: fixed;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      background: rgba(10, 10, 15, 0.82);
      backdrop-filter: blur(10px);
      -webkit-backdrop-filter: blur(10px);
      z-index: 2000;
      align-items: center;
      justify-content: center;
      opacity: 0;
      transition: opacity 0.2s ease;
    }
    .model-modal-overlay.open {
      display: flex;
      opacity: 1;
    }
    .model-modal-dialog {
      background: #16161f;
      border: 1px solid var(--border);
      border-radius: 16px;
      width: 90%;
      max-width: 750px;
      height: 85vh;
      display: flex;
      flex-direction: column;
      box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65), 0 0 40px rgba(99, 102, 241, 0.15);
      transform: scale(0.95);
      transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
      overflow: hidden;
    }
    .model-modal-overlay.open .model-modal-dialog {
      transform: scale(1);
    }
    .model-modal-header {
      padding: 16px 20px;
      border-bottom: 1px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: space-between;
    }
    .model-modal-title {
      font-size: 1.05rem;
      font-weight: 700;
      color: #fff;
      margin: 0;
    }
    .model-modal-close {
      background: transparent;
      border: none;
      color: var(--text-muted);
      font-size: 1.4rem;
      cursor: pointer;
      padding: 4px;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: color 0.15s;
    }
    .model-modal-close:hover {
      color: #ff4a4a;
    }
    .model-modal-body {
      padding: 16px 20px;
      display: flex;
      flex-direction: column;
      gap: 14px;
      flex: 1;
      overflow: hidden;
    }
    .model-search-wrapper {
      position: relative;
      display: flex;
      align-items: center;
    }
    .model-search-input {
      width: 100%;
      padding: 10px 36px 10px 14px;
      border-radius: 8px;
      border: 1px solid var(--border);
      background: rgba(0, 0, 0, 0.3);
      color: #fff;
      font-size: 0.88rem;
      outline: none;
      transition: border-color 0.2s, box-shadow 0.2s;
    }
    .model-search-input:focus {
      border-color: var(--accent);
      box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
    }
    .model-search-clear {
      position: absolute;
      right: 12px;
      background: transparent;
      border: none;
      color: var(--text-muted);
      cursor: pointer;
      font-size: 0.85rem;
      display: none;
    }
    .model-search-clear.visible {
      display: block;
    }
    .model-search-clear:hover {
      color: #fff;
    }
    .model-tabs {
      display: flex;
      gap: 6px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.05);
      padding-bottom: 2px;
    }
    .model-tab-btn {
      background: transparent;
      border: none;
      color: var(--text-muted);
      padding: 6px 12px;
      font-size: 0.82rem;
      font-weight: 600;
      cursor: pointer;
      border-bottom: 2px solid transparent;
      transition: color 0.15s, border-color 0.15s;
    }
    .model-tab-btn:hover {
      color: #fff;
    }
    .model-tab-btn.active {
      color: var(--accent);
      border-bottom-color: var(--accent);
    }
    .model-list {
      flex: 1;
      overflow-y: auto;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: rgba(0, 0, 0, 0.2);
      padding: 4px;
    }
    .model-list-item {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 8px 12px;
      border-radius: 6px;
      cursor: pointer;
      border-bottom: 1px solid rgba(255, 255, 255, 0.02);
      transition: background 0.15s;
    }
    .model-list-item:last-child {
      border-bottom: none;
    }
    .model-list-item:hover {
      background: rgba(255, 255, 255, 0.03);
    }
    .model-list-item.selected {
      background: rgba(99, 102, 241, 0.12);
      border-left: 3px solid var(--accent);
    }
    .model-item-info {
      display: flex;
      flex-direction: column;
      gap: 2px;
      min-width: 0;
      flex: 1;
      padding-right: 10px;
    }
    .model-item-name-row {
      display: flex;
      align-items: center;
      gap: 8px;
    }
    .model-item-name {
      font-size: 0.82rem;
      font-weight: 600;
      color: #fff;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .model-item-id {
      font-size: 0.7rem;
      color: var(--text-muted);
      font-family: ui-monospace, 'SF Mono', Menlo, monospace;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .model-item-badges {
      display: flex;
      gap: 6px;
      align-items: center;
    }
    .model-checkmark {
      color: var(--accent);
      font-weight: bold;
      font-size: 1.05rem;
      padding-right: 4px;
    }
    .model-list-empty, .model-list-loading {
      padding: 24px;
      text-align: center;
      color: var(--text-muted);
      font-size: 0.8rem;
    }
    .model-custom-wrapper {
      padding: 12px 16px;
      background: rgba(255, 255, 255, 0.02);
      border-top: 1px solid var(--border);
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .model-custom-label {
      font-size: 0.78rem;
      font-weight: 700;
      color: var(--text-muted);
      white-space: nowrap;
    }
    .model-custom-input {
      flex: 1;
      padding: 8px 10px;
      border-radius: 6px;
      border: 1px solid var(--border);
      background: rgba(0, 0, 0, 0.3);
      color: #fff;
      font-size: 0.8rem;
      font-family: ui-monospace, 'SF Mono', Menlo, monospace;
      outline: none;
    }
    .model-custom-input:focus {
      border-color: var(--accent);
    }
    .model-custom-btn {
      background: var(--accent);
      color: white;
      border: none;
      border-radius: 6px;
      padding: 8px 14px;
      font-size: 0.78rem;
      font-weight: 700;
      cursor: pointer;
      transition: background 0.15s;
      white-space: nowrap;
    }
    .model-custom-btn:hover {
      background: #4f46e5;
    }
    .ai-badge {
      font-size: 0.62rem;
      font-weight: 800;
      padding: 1px 6px;
      border-radius: 6px;
      background: rgba(255, 255, 255, 0.08);
      color: var(--text-muted);
      flex-shrink: 0;
    }
    .ai-badge.free {
      background: rgba(16, 185, 129, 0.2);
      color: #34d399;
    }
    .ai-badge.audio {
      background: rgba(139, 92, 246, 0.2);
      color: #a78bfa;
    }

    /* ─── Trainer Assignment Modal (mobile-first) ─────────────────────
       Single column on phones; two columns side-by-side from 760px up.
       Trainer cards use an auto-fill grid so they wrap instead of
       overflowing horizontally (the old fixed 2-col grid was clipping). */
    #trainerAssignmentModal .modal-content {
      max-width: 880px;
      width: min(880px, 96vw);
      max-height: 88vh;
      padding: 0;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      background: #151d30;
    }
    .tam-head {
      display: flex; align-items: flex-start; justify-content: space-between;
      gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border-normal);
      flex-shrink: 0;
    }
    .tam-title {
      font-size: 1.15rem; font-weight: 800; margin: 0; line-height: 1.2;
      display: flex; align-items: center; gap: 8px;
    }
    .tam-sub { font-size: 0.82rem; color: var(--text-dim); margin-top: 3px; }
    .tam-close {
      background: rgba(255,255,255,0.05); border: none; color: var(--text-muted);
      width: 34px; height: 34px; border-radius: 9px; font-size: 1.05rem;
      cursor: pointer; flex-shrink: 0; transition: background .15s, color .15s;
    }
    .tam-close:hover { background: rgba(255,255,255,0.12); color: #fff; }

    .tam-body {
      display: grid; grid-template-columns: 1fr; min-height: 0; flex: 1; overflow: hidden;
    }
    .tam-col {
      display: flex; flex-direction: column; min-height: 0; min-width: 0;
      overflow-y: auto; padding: 16px 20px;
    }
    .tam-col--picker { gap: 14px; }
    .tam-col--active { border-top: 1px solid var(--border-normal); }

    .tam-section-title { font-size: 0.95rem; font-weight: 700; margin: 0; color: var(--accent); }
    .tam-active-title { font-size: 0.95rem; font-weight: 700; margin: 0 0 12px; color: var(--text-muted); }
    .tam-step-label {
      font-size: 0.7rem; text-transform: uppercase; letter-spacing: .04em;
      color: var(--text-dim); font-weight: 800; margin-bottom: 8px;
    }

    .tam-cards {
      display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px;
    }
    .tam-card {
      display: flex; align-items: center; gap: 9px; text-align: left;
      background: var(--bg-card); border: 1px solid var(--border-normal);
      border-radius: 11px; padding: 10px 11px; color: #fff; cursor: pointer;
      min-width: 0; transition: border-color .15s, background .15s, transform .1s;
    }
    .tam-card:hover { border-color: rgba(99,102,241,0.5); transform: translateY(-1px); }
    .tam-card.selected { border-color: var(--accent); background: rgba(99,102,241,0.18); }
    .tam-card__icon { font-size: 1.3rem; line-height: 1; flex-shrink: 0; }
    .tam-card__body { display: flex; flex-direction: column; min-width: 0; }
    .tam-card__title {
      font-size: 0.82rem; font-weight: 600; line-height: 1.2;
      overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    .tam-card__tag { font-size: 0.6rem; color: var(--accent); margin-top: 2px; font-weight: 800; }

    .tam-chips { display: flex; flex-wrap: wrap; gap: 6px; }
    .tam-chip {
      background: transparent; border: 1px solid var(--border-normal); border-radius: 8px;
      padding: 7px 11px; color: #fff; font-size: 0.78rem; cursor: pointer; transition: all .15s;
    }
    .tam-chip:hover:not(:disabled) { border-color: rgba(99,102,241,0.6); }
    .tam-chip.selected { border-color: var(--accent); background: rgba(99,102,241,0.22); }
    .tam-chip:disabled { cursor: default; border-color: var(--accent); background: rgba(99,102,241,0.18); }

    .tam-help { font-size: 0.7rem; color: var(--text-muted); line-height: 1.35; margin-top: 6px; }
    .tam-field { display: flex; flex-direction: column; }
    .tam-input {
      background: #0f172a; border: 1px solid var(--border-normal); border-radius: 9px;
      padding: 10px; color: #fff; outline: none; font-size: 0.85rem;
      width: 100%; box-sizing: border-box; transition: border-color .15s;
    }
    .tam-input:focus { border-color: var(--accent); }

    .tam-btn {
      border: none; border-radius: 10px; padding: 11px; font-weight: 700; font-size: 0.85rem;
      cursor: pointer; transition: all .15s; width: 100%;
    }
    .tam-btn--add { background: rgba(99,102,241,0.14); color: var(--accent); border: 1px solid var(--accent); }
    .tam-btn--add:hover { background: rgba(99,102,241,0.24); }
    .tam-btn--commit { background: var(--accent); color: #fff; }
    .tam-btn--commit:hover { filter: brightness(1.08); }
    .tam-btn:disabled { opacity: .6; cursor: default; }

    .tam-staging {
      display: flex; flex-direction: column; gap: 9px; margin-top: 2px;
      border-top: 1px dashed var(--border-normal); padding-top: 14px;
    }
    .tam-staging-list { display: flex; flex-direction: column; gap: 8px; }
    .tam-staging-row {
      display: flex; align-items: center; justify-content: space-between; gap: 8px;
      background: var(--bg-card); border: 1px solid var(--border-normal);
      border-radius: 9px; padding: 8px 10px;
    }
    .tam-staging-row__main { min-width: 0; }
    .tam-staging-row__title { font-size: 0.82rem; font-weight: 600; display: flex; align-items: center; gap: 6px; min-width: 0; }
    .tam-staging-row__title .tam-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .tam-staging-row__meta { font-size: 0.7rem; color: var(--text-dim); margin-top: 2px; }
    .tam-x { background: transparent; border: none; color: var(--rose); font-size: 0.95rem; cursor: pointer; padding: 2px 5px; flex-shrink: 0; }

    .tam-list { display: flex; flex-direction: column; gap: 10px; }
    .tam-empty { color: var(--text-dim); font-size: 0.85rem; text-align: center; padding: 22px 10px; }

    @media (min-width: 760px) {
      .tam-body { grid-template-columns: 1fr 1fr; }
      .tam-col--picker { border-right: 1px solid var(--border-normal); }
      .tam-col--active { border-top: none; }
    }

    /* ─── Lesson link button (student) — ablaze while a lesson is live ─── */
    .lesson-link-card {
      display: flex; align-items: center; gap: 14px;
      width: 100%; box-sizing: border-box;
      padding: 16px 20px; border-radius: 16px;
      text-decoration: none; text-align: left;
      background: linear-gradient(135deg, rgba(99,102,241,0.18), rgba(139,92,246,0.12));
      border: 1px solid rgba(139,92,246,0.35);
      color: #fff;
      transition: transform .15s ease, box-shadow .25s ease;
    }
    .lesson-link-card:hover { transform: translateY(-1px); }
    .lesson-link-card .lesson-link-ico { font-size: 1.7rem; line-height: 1; }
    .lesson-link-card .lesson-link-txt { display: flex; flex-direction: column; flex: 1; min-width: 0; }
    .lesson-link-card .lesson-link-txt strong { font-size: 1rem; font-weight: 700; }
    .lesson-link-card .lesson-link-txt small { font-size: 0.76rem; opacity: 0.75; }
    .lesson-link-card .lesson-link-arrow { font-size: 1.2rem; opacity: 0.8; }

    .lesson-link-card.live {
      background: linear-gradient(135deg, #f97316, #ef4444 60%, #dc2626);
      border-color: #fb923c;
      animation: lessonFire 1.4s ease-in-out infinite;
    }
    .lesson-link-card.live .lesson-link-txt small { opacity: 0.92; }
    @keyframes lessonFire {
      0%, 100% { box-shadow: 0 0 0 0 rgba(249,115,22,0.55), 0 0 18px 2px rgba(239,68,68,0.45); }
      50%      { box-shadow: 0 0 0 6px rgba(249,115,22,0.0), 0 0 34px 8px rgba(251,146,60,0.75); }
    }
    @media (prefers-reduced-motion: reduce) {
      .lesson-link-card.live { animation: none; box-shadow: 0 0 26px 4px rgba(251,146,60,0.7); }
    }

    /* Light theme: keep the calm state readable; the fire state pops anywhere. */
    @media (prefers-color-scheme: light) {
      .lesson-link-card {
        background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(139,92,246,0.08));
        border-color: rgba(99,102,241,0.4);
        color: #1e1b3a;
      }
      .lesson-link-card .lesson-link-arrow { opacity: 0.6; }
    }
    body.light-theme .lesson-link-card,
    [data-theme="light"] .lesson-link-card {
      background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(139,92,246,0.08));
      border-color: rgba(99,102,241,0.4);
      color: #1e1b3a;
    }

    /* =====================================================================
       LIGHT THEME OVERRIDES — EngBoard look (white surfaces + blue accents)
       The base rules above were authored for a dark UI. These overrides
       re-skin the structural chrome for a light theme.
       Deliberately left dark: the fullscreen media viewer (.hw-lightbox*),
       which reads better as an immersive dark stage.
       ===================================================================== */

    /* Airy page backdrop with soft blue/indigo light */
    .bg-mesh {
      background:
        radial-gradient(ellipse 60% 50% at 20% 30%, rgba(37,99,235,0.07) 0%, transparent 55%),
        radial-gradient(ellipse 50% 40% at 80% 60%, rgba(79,70,229,0.06) 0%, transparent 55%);
    }

    /* Cards need a soft shadow on light (they can't lean on contrast anymore) */
    .section,
    .stat-card,
    .table-wrap,
    .hw-card,
    .my-grades-card,
    .my-debt-card {
      box-shadow: 0 1px 2px rgba(15,23,42,0.04), 0 4px 12px rgba(15,23,42,0.05);
    }
    .stat-card:hover { border-color: #cbd5e1; }

    /* Modal scrims: lighter, engboard-style slate veil */
    .modal-overlay { background: rgba(15,23,42,0.45); }
    .modal-content { box-shadow: 0 20px 50px rgba(15,23,42,0.22); }

    /* Form controls — flip inline dark styling (color:white + dark fills).
       Broad, since modals live outside .app. Checkbox/radio/range keep accent-color. */
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    select,
    textarea {
      background: #ffffff !important;
      color: var(--text) !important;
      border-color: var(--border) !important;
      color-scheme: light !important;
    }
    input::placeholder,
    textarea::placeholder { color: var(--text-dim) !important; }

    /* Ghost buttons + calendar nav read on light */
    .btn-sm:hover { background: #eef2f7; color: var(--text); }
    .nav-btn { color: var(--text); }
    .nav-btn:hover { background: #eef2f7; }
    .cal-cell:hover { background: rgba(37,99,235,0.05); }
    .cal-cell.is-today { background: rgba(37,99,235,0.05); }
    .cal-cell.is-today:hover { background: rgba(37,99,235,0.09); }

    /* Floating popover + bottom sheet → light glass */
    .cal-popover,
    .cal-sheet {
      background: rgba(255,255,255,0.97) !important;
      border-color: var(--border) !important;
      box-shadow: 0 12px 34px rgba(15,23,42,0.14), 0 2px 8px rgba(15,23,42,0.08) !important;
      color: var(--text);
    }
    .cal-popover::before,
    .cal-sheet__handle { border-color: var(--border) !important; }
    .cal-sheet__handle { background: #cbd5e1; }

    /* Dark inset panels inside cards → light slate panels */
    .cal-popover__hw,
    .cal-sheet__hw,
    .reschedule-banner-item,
    .hw-card__task,
    .hw-card__text,
    .hw-chat-box,
    .hw-revisions-box,
    .my-grades-spark,
    .my-grades-empty,
    .my-grades-row,
    .debt-modal__summary-item,
    .debt-row {
      background: #f1f5f9 !important;
      color: var(--text-muted);
    }

    /* Empty grade stars: light slate instead of translucent white */
    .grade-star { color: #cbd5e1; }

    /* Tooltip stays a dark chip (good contrast floating over light) */
    [data-tooltip]::after {
      background: #1e293b !important;
      color: #fff !important;
      border-color: #1e293b !important;
    }

    /* AI model selector modal → light */
    .model-modal-overlay { background: rgba(15,23,42,0.45) !important; }
    .model-modal-dialog {
      background: #ffffff !important;
      box-shadow: 0 20px 50px rgba(15,23,42,0.25) !important;
    }
    .model-modal-title,
    .model-item-name { color: var(--text) !important; }
    .model-modal-close:hover,
    .model-search-clear:hover,
    .model-tab-btn:hover { color: var(--text) !important; }
    .model-list,
    .model-custom-wrapper { background: #f8fafc !important; }
    .model-list-item:hover { background: #f1f5f9 !important; }
    .ai-badge { background: #f1f5f9; }

    /* Trainer assignment modal → light */
    #trainerAssignmentModal .modal-content { background: #ffffff !important; }
    .tam-card,
    .tam-chip { color: var(--text) !important; background: #ffffff; }
    .tam-staging-row { background: #f8fafc; }
    .tam-close { background: #f1f5f9; }
    .tam-close:hover { background: #e2e8f0; color: var(--text); }

    /* Light-indigo text that used to sit on dark now needs a darker blue on light */
    .debt-row__status,
    .my-debt-row__status,
    .cal-popover__btn.is-primary,
    .cal-sheet__file-link,
    .hw-gallery-dl-all { color: var(--accent) !important; }
    .cal-sheet__file-link { background: rgba(37,99,235,0.08); border-color: rgba(37,99,235,0.2); }

    /* ---------------------------------------------------------------------
       Inline "inset" surfaces authored for the dark theme.
       Hundreds of JS-generated + HTML elements inline a dark well
       (background: rgba(0,0,0,0.1–0.4)) or a faint white raised panel
       (background: rgba(255,255,255,0.0x)). On a light theme both read as
       unreadable/invisible. This layer re-skins them to a light slate inset.

       • Scoped to the `background` property → rgba-based box-shadows/borders
         are untouched.
       • Form fields keep their own white rule above (input/select/textarea
         has higher specificity, so it still wins → white fields).
       • The fullscreen media viewer (.hw-lightbox*) is class-styled, not
         inline, so it stays an immersive dark stage.
       --------------------------------------------------------------------- */
    [style*="background: rgba(0,0,0"],
    [style*="background:rgba(0,0,0"],
    [style*="background: rgba(0, 0, 0"],
    [style*="background: rgba(255,255,255,0.0"],
    [style*="background:rgba(255,255,255,0.0"],
    [style*="background: rgba(255, 255, 255, 0.0"] {
      background: var(--inset) !important;
    }

    /* Emoji "attach file" chips: were faint-white on dark; give them a
       visible light chip so they don't vanish on white. */
    .chat-attachment-btn {
      background: var(--inset) !important;
      border-color: var(--border) !important;
      color: var(--text-muted) !important;
    }
    .chat-attachment-btn:hover { background: #e2e8f0 !important; }

    /* "Join lesson" card: the calm state used white text (dark-theme era) which
       is unreadable on the pale-indigo gradient over a light page. Give it dark
       text; the live/fire state re-asserts white (it pops on any surface). */
    .lesson-link-card { color: #1e1b3a; }
    .lesson-link-card.live { color: #fff; }
