*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  :root {
    --bg: #f7f6f2; --surface: #ffffff; --surface2: #f0ede6;
    --border: #e0dcd3; --text: #1a1917; --muted: #6b6762;
    --accent: #e85d26; --accent-light: #fef0eb; --accent-dark: #b8401a;
    --green: #2d7d46; --green-bg: #edf7f1;
    --blue: #1a5fa8; --blue-bg: #eaf1fb;
    --yellow: #a06b00; --yellow-bg: #fef8ec;
    --red: #c0392b; --red-bg: #fdecea;
    --radius: 10px; --radius-lg: 16px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
    --font: 'DM Sans', sans-serif; --mono: 'DM Mono', monospace;
    --sidebar-w: 240px;
  }
  body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; display: flex; font-size: 14px; line-height: 1.6; }

  /* Sidebar */
  #sidebar { width: var(--sidebar-w); min-height: 100vh; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; padding-top: env(safe-area-inset-top); padding-left: env(safe-area-inset-left); transition: transform 0.22s ease; }
  .sidebar-logo { padding: 20px 20px 16px; border-bottom: 1px solid var(--border); }
  .logo-mark { display: flex; align-items: center; gap: 10px; text-decoration: none; }
  .logo-icon { width: 32px; height: 32px; background: var(--accent); border-radius: 8px; display: flex; align-items: center; justify-content: center; }
  .logo-icon svg { width: 18px; height: 18px; fill: white; }
  .logo-text { font-size: 16px; font-weight: 600; color: var(--text); letter-spacing: -0.3px; }
  .sidebar-section { padding: 12px 14px 4px; font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
  .sidebar-nav { padding: 6px 10px; flex: 1; overflow-y: auto; }
  .nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); cursor: pointer; color: var(--muted); font-size: 13.5px; font-weight: 400; transition: all 0.15s; border: none; background: none; width: 100%; text-align: left; }
  .nav-item:hover { background: var(--surface2); color: var(--text); }
  .nav-item.active { background: var(--accent-light); color: var(--accent); font-weight: 500; }
  .nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
  .sidebar-footer { padding: 14px; border-top: 1px solid var(--border); }
  .user-chip { display: flex; align-items: center; gap: 10px; }
  .user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: white; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex-shrink: 0; }
  .user-name { font-size: 13px; font-weight: 500; }
  .user-inst { font-size: 11px; color: var(--muted); }

  /* Main */
  #main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; min-width: 0; }
  #topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 28px; padding-top: env(safe-area-inset-top); height: calc(58px + env(safe-area-inset-top)); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
  .topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .topbar-title { font-size: 16px; font-weight: 600; letter-spacing: -0.3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
  .back-btn { display: none; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: none; color: var(--muted); font-size: 13px; font-weight: 500; cursor: pointer; font-family: var(--font); transition: all 0.15s; }
  .back-btn:hover { background: var(--surface2); color: var(--text); }
  .back-btn svg { width: 14px; height: 14px; }
  .back-btn.visible { display: flex; }

  /* Mobile menu toggle + drawer backdrop */
  .menu-btn { display: none; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border); background: none; color: var(--text); cursor: pointer; flex-shrink: 0; }
  .menu-btn svg { width: 18px; height: 18px; }
  .menu-btn:hover { background: var(--surface2); }
  #sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 99; opacity: 0; transition: opacity 0.2s; }
  #sidebar-backdrop.open { display: block; opacity: 1; }

  /* Offline banner */
  #offline-banner { display: none; align-items: center; justify-content: center; gap: 8px; background: var(--yellow-bg); color: var(--yellow); font-size: 12.5px; font-weight: 500; padding: 7px 12px; text-align: center; }
  #offline-banner.show { display: flex; }
  #offline-banner svg { width: 14px; height: 14px; flex-shrink: 0; }

  /* Update-available toast */
  #update-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(80px); background: var(--text); color: #fff; padding: 12px 14px 12px 18px; border-radius: 10px; box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 14px; font-size: 13px; z-index: 900; transition: transform 0.25s ease; }
  #update-toast.show { transform: translateX(-50%) translateY(0); }
  #update-toast button { background: var(--accent); color: #fff; border: none; border-radius: 7px; padding: 7px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: var(--font); white-space: nowrap; }
  #update-toast .dismiss { background: none; color: rgba(255,255,255,0.6); padding: 4px; }

  /* Buttons */
  .btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; border: 1px solid transparent; transition: all 0.15s; font-family: var(--font); }
  .btn-ghost { background: none; border-color: var(--border); color: var(--muted); }
  .btn-ghost:hover { background: var(--surface2); color: var(--text); }
  .btn-primary { background: var(--accent); color: white; }
  .btn-primary:hover { background: var(--accent-dark); }
  .btn svg { width: 14px; height: 14px; }
  .btn:disabled { opacity: 0.5; cursor: not-allowed; }

  /* Setup */
  #setup-screen { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px; }
  .setup-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 44px 48px; width: 100%; max-width: 500px; box-shadow: var(--shadow-md); }
  .setup-icon { width: 52px; height: 52px; background: var(--accent-light); border-radius: 14px; display: flex; align-items: center; justify-content: center; margin-bottom: 20px; }
  .setup-icon svg { width: 28px; height: 28px; color: var(--accent); }
  .setup-card h2 { font-size: 22px; font-weight: 600; margin-bottom: 8px; letter-spacing: -0.4px; }
  .setup-card p { color: var(--muted); font-size: 13.5px; margin-bottom: 28px; line-height: 1.6; }
  .field-group { margin-bottom: 18px; }
  .field-group label { display: block; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
  .field-group input { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; font-family: var(--font); background: var(--bg); color: var(--text); transition: border-color 0.15s, box-shadow 0.15s; outline: none; }
  .field-group input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,93,38,0.12); }
  .field-group input::placeholder { color: var(--muted); opacity: 0.6; }
  .field-hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; line-height: 1.5; }
  .field-hint a { color: var(--accent); text-decoration: none; }
  .setup-error { background: var(--red-bg); color: var(--red); border: 1px solid #f5c6c4; border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 16px; display: none; }

  /* Content */
  #content { padding: 28px; flex: 1; display: none; }
  .page { display: none; }
  .page.active { display: block; }

  /* Grids */
  .grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
  .grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
  .grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
  .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px 22px; box-shadow: var(--shadow); }
  .stat-card .stat-label { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
  .stat-card .stat-value { font-size: 28px; font-weight: 600; letter-spacing: -0.8px; color: var(--text); line-height: 1; margin-bottom: 2px; }
  .stat-card .stat-sub { font-size: 12px; color: var(--muted); }

  /* Badges */
  .badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 500; white-space: nowrap; }
  .badge-green { background: var(--green-bg); color: var(--green); }
  .badge-blue  { background: var(--blue-bg);  color: var(--blue);  }
  .badge-red   { background: var(--red-bg);   color: var(--red);   }
  .badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
  .badge-gray  { background: var(--surface2); color: var(--muted); }
  .badge-orange { background: var(--accent-light); color: var(--accent); }

  /* Section header */
  .section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; margin-top: 28px; }
  .section-header:first-child { margin-top: 0; }
  .section-header h3 { font-size: 14px; font-weight: 600; color: var(--text); letter-spacing: -0.2px; }

  /* Course cards */
  .course-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); transition: transform 0.15s, box-shadow 0.15s; cursor: pointer; }
  .course-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
  .course-card-header { height: 8px; }
  .course-card-body { padding: 16px 18px 18px; }
  .course-card h4 { font-size: 14px; font-weight: 600; margin-bottom: 4px; letter-spacing: -0.2px; line-height: 1.35; }
  .course-card .course-code { font-size: 11.5px; color: var(--muted); font-family: var(--mono); margin-bottom: 12px; }
  .course-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
  .course-card-footer .meta { font-size: 11.5px; color: var(--muted); }
  .course-card-actions { display: flex; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
  .course-action-btn { flex: 1; padding: 6px; border-radius: 7px; border: 1px solid var(--border); background: none; font-size: 11.5px; font-weight: 500; color: var(--muted); cursor: pointer; font-family: var(--font); transition: all 0.15s; text-align: center; }
  .course-action-btn:hover { background: var(--surface2); color: var(--text); }

  /* Table */
  .table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); }
  table { width: 100%; border-collapse: collapse; font-size: 13px; }
  thead th { background: var(--bg); padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); }
  tbody td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
  tbody tr:last-child td { border-bottom: none; }
  tbody tr:hover { background: var(--bg); }
  .assign-name { font-weight: 500; color: var(--text); margin-bottom: 2px; }
  .due-date { font-family: var(--mono); font-size: 12px; color: var(--muted); }
  .due-soon { color: var(--red); }
  .points { font-family: var(--mono); font-size: 12.5px; }

  /* Empty state */
  .empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
  .empty-state svg { width: 40px; height: 40px; opacity: 0.3; margin-bottom: 12px; }
  .empty-state p { font-size: 13.5px; }

  /* Spinner */
  .spinner-wrap { display: flex; align-items: center; justify-content: center; padding: 60px; }
  @keyframes spin { to { transform: rotate(360deg); } }
  .spinner { width: 26px; height: 26px; border: 2.5px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.75s linear infinite; }

  /* Grade bar */
  .grade-bar-track { height: 5px; background: var(--surface2); border-radius: 999px; overflow: hidden; }
  .grade-bar-fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width 0.4s ease; }
  .grade-bar-label { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }

  /* Tabs */
  .tab-bar { display: flex; gap: 2px; background: var(--surface2); border-radius: 10px; padding: 3px; margin-bottom: 20px; width: fit-content; flex-wrap: wrap; }
  .tab-btn { padding: 6px 16px; border-radius: 8px; border: none; background: none; font-family: var(--font); font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; transition: all 0.15s; }
  .tab-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

  /* Announcements */
  .announcement { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 20px; box-shadow: var(--shadow); margin-bottom: 10px; cursor: pointer; transition: box-shadow 0.15s; }
  .announcement:hover { box-shadow: var(--shadow-md); }
  .announcement h4 { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
  .announcement .anno-meta { font-size: 11.5px; color: var(--muted); margin-bottom: 8px; }
  .announcement p { font-size: 13px; color: var(--muted); line-height: 1.6; }

  /* Toast */
  #toast { position: fixed; bottom: 24px; right: 24px; background: var(--text); color: white; padding: 11px 18px; border-radius: 10px; font-size: 13px; font-weight: 500; box-shadow: var(--shadow-md); opacity: 0; transform: translateY(8px); transition: opacity 0.25s, transform 0.25s; pointer-events: none; z-index: 999; max-width: 320px; }
  #toast.show { opacity: 1; transform: translateY(0); }

  /* Settings */
  .settings-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 20px; }
  .settings-section-title { padding: 14px 20px; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); background: var(--bg); }
  .settings-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); gap: 16px; }
  .settings-row:last-child { border-bottom: none; }
  .settings-row-label { font-size: 13.5px; font-weight: 500; }
  .settings-row-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
  .settings-row input[type="text"], .settings-row input[type="password"] { flex: 1; max-width: 340px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-family: var(--mono); background: var(--bg); color: var(--text); outline: none; }
  .settings-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,93,38,0.12); }

  /* Toggle switch */
  .toggle { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
  .toggle input { opacity: 0; width: 0; height: 0; }
  .toggle-slider { position: absolute; inset: 0; background: var(--border); border-radius: 22px; cursor: pointer; transition: 0.2s; }
  .toggle-slider:before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: white; border-radius: 50%; transition: 0.2s; }
  .toggle input:checked + .toggle-slider { background: var(--accent); }
  .toggle input:checked + .toggle-slider:before { transform: translateX(18px); }

  /* Modal */
  .modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
  .modal-backdrop.open { opacity: 1; pointer-events: all; }
  .modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: 0 20px 60px rgba(0,0,0,0.25); width: 100%; max-width: 680px; max-height: 90vh; display: flex; flex-direction: column; transform: translateY(12px); transition: transform 0.2s; overflow: hidden; }
  .modal-backdrop.open .modal { transform: translateY(0); }
  .modal-header { padding: 20px 24px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 14px; flex-shrink: 0; }
  .modal-header-info { flex: 1; min-width: 0; }
  .modal-course-badge { font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 6px; display: inline-flex; align-items: center; gap: 5px; }
  .modal-title { font-size: 18px; font-weight: 600; letter-spacing: -0.4px; line-height: 1.3; margin-bottom: 8px; }
  .modal-meta { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); }
  .modal-meta span { display: flex; align-items: center; gap: 4px; }
  .modal-close { background: none; border: none; cursor: pointer; padding: 4px; color: var(--muted); border-radius: 6px; flex-shrink: 0; }
  .modal-close:hover { background: var(--surface2); color: var(--text); }
  .modal-close svg { width: 20px; height: 20px; }
  .modal-body { overflow-y: auto; flex: 1; }
  .modal-tab-bar { display: flex; border-bottom: 1px solid var(--border); padding: 0 24px; flex-shrink: 0; }
  .modal-tab { padding: 10px 14px; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; border: none; background: none; font-family: var(--font); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all 0.15s; }
  .modal-tab:hover { color: var(--text); }
  .modal-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
  .modal-panel { display: none; padding: 22px 24px; }
  .modal-panel.active { display: block; }
  .modal-desc { font-size: 13.5px; line-height: 1.75; color: var(--text); }
  .modal-desc img { max-width: 100%; border-radius: 6px; }
  .modal-desc a { color: var(--accent); }
  .modal-desc ul, .modal-desc ol { padding-left: 22px; margin: 8px 0; }
  .modal-desc table { border-collapse: collapse; width: 100%; font-size: 13px; }
  .modal-desc table td, .modal-desc table th { border: 1px solid var(--border); padding: 6px 10px; }

  /* Upload panel */
  .upload-zone { border: 2px dashed var(--border); border-radius: var(--radius-lg); padding: 36px 24px; text-align: center; cursor: pointer; transition: all 0.15s; background: var(--bg); }
  .upload-zone:hover, .upload-zone.drag-over { border-color: var(--accent); background: var(--accent-light); }
  .upload-zone svg { width: 32px; height: 32px; color: var(--muted); margin-bottom: 10px; }
  .upload-zone p { font-size: 13.5px; color: var(--muted); margin-bottom: 4px; }
  .upload-zone small { font-size: 11.5px; color: var(--muted); opacity: 0.7; }
  #upload-file-input { display: none; }
  .file-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
  .file-item { display: flex; align-items: center; gap: 10px; background: var(--surface2); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
  .file-item-name { flex: 1; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .file-item-size { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
  .file-item-remove { background: none; border: none; cursor: pointer; color: var(--muted); padding: 2px; border-radius: 4px; display: flex; }
  .file-item-remove:hover { color: var(--red); }
  .file-item-remove svg { width: 14px; height: 14px; }
  .upload-progress { margin-top: 14px; }
  .upload-progress-bar { height: 4px; background: var(--surface2); border-radius: 999px; overflow: hidden; margin-top: 6px; }
  .upload-progress-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.3s ease; }
  .upload-status { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
  .upload-success { background: var(--green-bg); color: var(--green); border: 1px solid #b7e4c7; border-radius: 8px; padding: 10px 14px; font-size: 13px; display: flex; align-items: center; gap: 8px; margin-top: 12px; }
  .upload-error { background: var(--red-bg); color: var(--red); border: 1px solid #f5c6c4; border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-top: 12px; }
  .modal-footer { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-shrink: 0; background: var(--bg); }
  .rubric-row { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
  .rubric-row:last-child { border-bottom: none; }
  .rubric-desc { flex: 1; font-weight: 500; }
  .rubric-pts { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }

  /* Sort arrows */
  .sort-arrow { font-size: 10px; color: var(--accent); margin-left: 2px; }
  thead th { cursor: default; }

  /* Modules */
  .module-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: 14px; overflow: hidden; box-shadow: var(--shadow); }
  .module-header { padding: 13px 18px; background: var(--bg); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
  .module-header h4 { font-size: 13.5px; font-weight: 600; flex: 1; }
  .module-header .module-count { font-size: 11.5px; color: var(--muted); }
  .module-chevron { transition: transform 0.2s; color: var(--muted); }
  .module-chevron.open { transform: rotate(90deg); }
  .module-items { }
  .module-item { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--border); font-size: 13px; transition: background 0.12s; }
  .module-item:last-child { border-bottom: none; }
  .module-item:hover { background: var(--bg); }
  .module-item-icon { width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .module-item-icon svg { width: 14px; height: 14px; }
  .module-item-name { flex: 1; font-weight: 500; }
  .module-item-name a { color: var(--text); text-decoration: none; }
  .module-item-name a:hover { color: var(--accent); }
  .module-item-type { font-size: 11px; color: var(--muted); }
  .module-item-pts { font-size: 11.5px; font-family: var(--mono); color: var(--muted); white-space: nowrap; }
  .module-item-status { font-size: 11px; color: var(--green); white-space: nowrap; }
  body.dim-completed .module-item.completed-item { opacity: 0.5; }

  /* Course pill tabs */
  .course-pill { padding: 5px 12px; border-radius: 20px; font-size: 12px; font-weight: 500; border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; transition: all 0.15s; white-space: nowrap; }
  .course-pill.active { color: white; border-color: transparent; }

  /* Announcement modal */
  .anno-modal-body { padding: 22px 24px; }
  .anno-modal-body .modal-desc { font-size: 13.5px; line-height: 1.75; }
  .anno-modal-body .modal-desc img { max-width: 100%; border-radius: 6px; }

  /* No-submit notice */
  .no-submit-notice { background: var(--surface2); border-radius: 10px; padding: 28px 20px; text-align: center; color: var(--muted); font-size: 13.5px; }
  .no-submit-notice svg { width: 32px; height: 32px; opacity: 0.4; margin-bottom: 10px; display: block; margin-inline: auto; }

  /* ── Course Detail Page ───────────────────────────────────────────────── */
  .course-detail-header { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px 28px; margin-bottom: 24px; box-shadow: var(--shadow); }
  .course-detail-accent { width: 100%; height: 6px; border-radius: 999px; margin-bottom: 18px; }
  .course-detail-title { font-size: 22px; font-weight: 600; letter-spacing: -0.5px; margin-bottom: 4px; }
  .course-detail-code { font-family: var(--mono); font-size: 12.5px; color: var(--muted); margin-bottom: 16px; }
  .course-detail-stats { display: flex; gap: 24px; flex-wrap: wrap; }
  .course-detail-stat { display: flex; flex-direction: column; gap: 2px; }
  .course-detail-stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
  .course-detail-stat-value { font-size: 18px; font-weight: 600; letter-spacing: -0.3px; }

  /* Course detail tabs */
  .detail-tab-bar { display: flex; gap: 2px; background: var(--surface2); border-radius: 10px; padding: 3px; margin-bottom: 22px; width: fit-content; }
  .detail-tab { padding: 7px 18px; border-radius: 8px; border: none; background: none; font-family: var(--font); font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; transition: all 0.15s; }
  .detail-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
  .detail-panel { display: none; }
  .detail-panel.active { display: block; }

  /* Progress ring */
  .progress-ring-wrap { position: relative; width: 64px; height: 64px; flex-shrink: 0; }
  .progress-ring { transform: rotate(-90deg); }
  .progress-ring-bg { fill: none; stroke: var(--surface2); stroke-width: 5; }
  .progress-ring-fill { fill: none; stroke-width: 5; stroke-linecap: round; transition: stroke-dashoffset 0.5s ease; }
  .progress-ring-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; }

  /* Submissions list in course detail */
  .submission-item { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); font-size: 13px; cursor: pointer; transition: background 0.12s; }
  .submission-item:hover { background: var(--bg); }
  .submission-item:last-child { border-bottom: none; }
  .submission-item-name { flex: 1; font-weight: 500; }
  .submission-item-due { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

  /* Quick stats bar */
  .quick-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--border); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 24px; border: 1px solid var(--border); }
  .quick-stat { background: var(--surface); padding: 16px 20px; text-align: center; }
  .quick-stat-num { font-size: 22px; font-weight: 600; letter-spacing: -0.5px; }
  .quick-stat-lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; margin-top: 2px; }

  /* People / roster */
  .person-row { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--border); font-size: 13px; }
  .person-row:last-child { border-bottom: none; }
  .person-avatar { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: white; flex-shrink: 0; }
  .person-name { flex: 1; font-weight: 500; }
  .person-role { font-size: 11.5px; color: var(--muted); }

  /* Calendar */
  .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
  .cal-day-header { text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; padding: 6px 2px; }
  .cal-day { aspect-ratio: 1; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 6px 4px; font-size: 12px; font-weight: 500; color: var(--muted); cursor: pointer; transition: background 0.12s; position: relative; border: 1px solid transparent; }
  .cal-day.has-events { color: var(--text); background: var(--surface); border-color: var(--border); }
  .cal-day.has-events:hover { background: var(--surface2); }
  .cal-day.today { background: var(--accent); color: white; border-color: transparent; }
  .cal-day.today .cal-dot { background: white; }
  .cal-day.other-month { opacity: 0.35; }
  .cal-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); margin-top: 2px; }
  .cal-month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
  .cal-month-nav h4 { font-size: 15px; font-weight: 600; }
  .cal-nav-btn { background: none; border: 1px solid var(--border); border-radius: 7px; padding: 5px 10px; cursor: pointer; color: var(--muted); font-family: var(--font); transition: all 0.15s; font-size: 13px; }
  .cal-nav-btn:hover { background: var(--surface2); color: var(--text); }
  .cal-event-list { margin-top: 16px; }
  .cal-event { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; font-size: 13px; cursor: pointer; transition: box-shadow 0.15s; }
  .cal-event:hover { box-shadow: var(--shadow-md); }
  .cal-event-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
  .cal-event-title { font-weight: 500; flex: 1; }
  .cal-event-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
  .cal-event-date { font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; }

  /* Search */
  .search-bar { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 9px 14px; margin-bottom: 20px; box-shadow: var(--shadow); }
  .search-bar svg { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }
  .search-bar input { flex: 1; border: none; background: none; font-family: var(--font); font-size: 14px; color: var(--text); outline: none; }
  .search-bar input::placeholder { color: var(--muted); opacity: 0.7; }
  .search-result { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; cursor: pointer; transition: box-shadow 0.15s; font-size: 13px; }
  .search-result:hover { box-shadow: var(--shadow-md); }
  .search-result-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .search-result-icon svg { width: 15px; height: 15px; }
  .search-result-title { font-weight: 500; flex: 1; }
  .search-result-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
  .search-result-badge { flex-shrink: 0; }

  /* Planner / To-do */
  .todo-item { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); font-size: 13px; }
  .todo-item:last-child { border-bottom: none; }
  .todo-check { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; flex-shrink: 0; cursor: pointer; transition: all 0.15s; }
  .todo-check.done { background: var(--green); border-color: var(--green); }
  .todo-check.done::after { content: '✓'; font-size: 10px; color: white; font-weight: 700; }
  .todo-check:hover { border-color: var(--accent); }
  .todo-name { flex: 1; font-weight: 500; }
  .todo-name.done { text-decoration: line-through; color: var(--muted); }
  .todo-due { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

  /* Files browser */
  .file-browser-item { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--border); font-size: 13px; cursor: pointer; transition: background 0.12s; }
  .file-browser-item:hover { background: var(--bg); }
  .file-browser-item:last-child { border-bottom: none; }
  .file-browser-icon { width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .file-browser-icon svg { width: 14px; height: 14px; }
  .file-browser-name { flex: 1; font-weight: 500; }
  .file-browser-meta { font-size: 11.5px; color: var(--muted); font-family: var(--mono); }

  /* Notification badge */
  .notif-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); display: inline-block; margin-left: 4px; vertical-align: middle; }
  .nav-badge { margin-left: auto; background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 1; padding: 3px 6px 2px; border-radius: 20px; flex-shrink: 0; }

  /* Discussions */
  .discussion-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 20px; box-shadow: var(--shadow); margin-bottom: 10px; cursor: pointer; transition: box-shadow 0.15s; }
  .discussion-item:hover { box-shadow: var(--shadow-md); }
  .discussion-item h4 { font-size: 14px; font-weight: 600; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
  .discussion-item .disc-meta { font-size: 11.5px; color: var(--muted); margin-bottom: 8px; }
  .discussion-item p { font-size: 13px; color: var(--muted); line-height: 1.6; }
  .discussion-entry { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
  .discussion-entry:last-child { border-bottom: none; }
  .discussion-entry-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; flex-shrink: 0; }
  .discussion-entry-body { flex: 1; min-width: 0; }
  .discussion-entry-name { font-size: 12.5px; font-weight: 600; }
  .discussion-entry-date { font-size: 11px; color: var(--muted); margin-left: 6px; font-weight: 400; }
  .discussion-entry-msg { font-size: 13px; margin-top: 4px; line-height: 1.55; }
  .reply-box { display: flex; gap: 10px; margin-top: 14px; align-items: flex-start; }
  .reply-box textarea { flex: 1; min-height: 64px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-family: var(--font); font-size: 13px; resize: vertical; outline: none; background: var(--bg); color: var(--text); }
  .reply-box textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,93,38,0.12); }

  /* Inbox / conversations */
  .inbox-layout { display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start; height: calc(100vh - 160px); min-height: 420px; }
  .conv-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow-y: auto; height: 100%; }
  .conv-item { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.12s; }
  .conv-item:hover { background: var(--bg); }
  .conv-item.active { background: var(--accent-light); }
  .conv-item:last-child { border-bottom: none; }
  .conv-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; flex-shrink: 0; }
  .conv-item-body { flex: 1; min-width: 0; }
  .conv-item-title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
  .conv-item-sub { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
  .conv-item-date { font-size: 10.5px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
  .conv-thread { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); height: 100%; display: flex; flex-direction: column; overflow: hidden; }
  .conv-thread-header { padding: 14px 20px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 14px; }
  .conv-thread-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
  .conv-thread-footer { padding: 14px 20px; border-top: 1px solid var(--border); }
  @media (max-width: 900px) { .inbox-layout { grid-template-columns: 1fr; height: auto; } .conv-list { max-height: 260px; } }

  /* Quizzes */
  .quiz-item { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.12s; }
  .quiz-item:hover { background: var(--bg); }
  .quiz-item:last-child { border-bottom: none; }
  .quiz-item-icon { width: 34px; height: 34px; border-radius: 8px; background: var(--blue-bg); color: var(--blue); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .quiz-item-icon svg { width: 16px; height: 16px; }
  .quiz-item-name { flex: 1; font-weight: 500; min-width: 0; }
  .quiz-item-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
  .quiz-question { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; margin-bottom: 14px; }
  .quiz-question-text { font-size: 13.5px; font-weight: 500; margin-bottom: 12px; }
  .quiz-answer-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; }
  .quiz-answer-row:hover { background: var(--surface2); }
  .quiz-answer-row input[type="text"], .quiz-answer-row textarea { width: 100%; }

  /* Wiki page / syllabus rich content */
  .page-content-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px 26px; box-shadow: var(--shadow); line-height: 1.7; font-size: 13.5px; }
  .page-content-wrap img { max-width: 100%; height: auto; border-radius: 6px; }
  .page-content-wrap a { color: var(--accent); }
  .page-content-wrap table { width: 100%; margin: 10px 0; }
  .page-list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.12s; }
  .page-list-item:hover { background: var(--bg); }
  .page-list-item:last-child { border-bottom: none; }
  .page-list-item-name { font-weight: 500; }
  .page-list-item-meta { font-size: 11.5px; color: var(--muted); }

  /* Collapsible sidebar courses list */
  .sidebar-courses { padding: 0 10px; }
  .sidebar-course-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 12.5px; transition: all 0.15s; }
  .sidebar-course-item:hover { background: var(--surface2); color: var(--text); }
  .sidebar-course-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

  /* Grade detail */
  .grade-assignment-row { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--border); font-size: 13px; cursor: pointer; transition: background 0.12s; }
  .grade-assignment-row:hover { background: var(--bg); }
  .grade-assignment-row:last-child { border-bottom: none; }
  .grade-assignment-name { flex: 1; font-weight: 500; }
  .grade-assignment-score { font-family: var(--mono); font-size: 12.5px; font-weight: 600; }
  .grade-group-header { padding: 8px 18px; background: var(--bg); border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); display: flex; justify-content: space-between; }

  /* Submission detail */
  .submission-detail-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 14px; }
  .submission-detail-header { padding: 12px 18px; background: var(--bg); border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); display: flex; align-items: center; justify-content: space-between; }
  .submission-detail-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); font-size: 13px; }
  .submission-detail-row:last-child { border-bottom: none; }
  .submission-detail-label { width: 120px; flex-shrink: 0; font-weight: 500; color: var(--muted); }
  .submission-detail-value { flex: 1; line-height: 1.5; }
  .submission-type-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
  .submission-file-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; font-size: 13px; cursor: pointer; transition: box-shadow 0.15s; }
  .submission-file-item:hover { box-shadow: var(--shadow-md); }
  .submission-file-icon { width: 30px; height: 30px; border-radius: 7px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .submission-file-icon svg { width: 14px; height: 14px; }

  /* Responsive tweaks */
  @media (max-width: 768px) {
    :root { --sidebar-w: 0px; }
    #sidebar { transform: translateX(-100%); box-shadow: var(--shadow-md); width: min(80vw, 300px); }
    #sidebar.open { transform: translateX(0); }
    .menu-btn { display: inline-flex; }
    #content { padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
    #topbar { padding: 0 16px; padding-top: env(safe-area-inset-top); }
    .quick-stats { grid-template-columns: repeat(2, 1fr); }
    .setup-card { padding: 32px 24px; }
    .modal-meta { gap: 10px; }
    .submission-detail-row { flex-direction: column; gap: 4px; }
    .submission-detail-label { width: auto; }
  }
  @media (max-width: 420px) {
    .quick-stats { grid-template-columns: 1fr 1fr; }
    .topbar-title { font-size: 15px; }
  }
