:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f2f6;
  --text: #14171f;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef0fd;
  --primary-text: #ffffff;
  --overdue: #dc2626;
  --overdue-soft: #fee2e2;
  --today: #d97706;
  --today-soft: #fef3c7;
  --upcoming: #ca8a04;
  --upcoming-soft: #fef9c3;
  --done: #059669;
  --done-soft: #d1fae5;
  --danger: #dc2626;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 17, 21, 0.04), 0 1px 3px rgba(15, 17, 21, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 17, 21, 0.10);
  --shadow-lg: 0 20px 50px rgba(15, 17, 21, 0.18);
  --sidebar-w: 232px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101218;
    --surface: #171a21;
    --surface-2: #1c2029;
    --text: #eceef2;
    --muted: #8b90a0;
    --border: #262a35;
    --primary: #6366f1;
    --primary-hover: #7376f5;
    --primary-soft: #23264a;
    --primary-text: #ffffff;
    --overdue: #f87171;
    --overdue-soft: #3b1d1d;
    --today: #fbbf24;
    --today-soft: #3a2f12;
    --upcoming: #facc15;
    --upcoming-soft: #36320f;
    --done: #34d399;
    --done-soft: #123a2c;
    --danger: #f87171;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 12px 28px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  --bg: #101218;
  --surface: #171a21;
  --surface-2: #1c2029;
  --text: #eceef2;
  --muted: #8b90a0;
  --border: #262a35;
  --primary: #6366f1;
  --primary-hover: #7376f5;
  --primary-soft: #23264a;
  --primary-text: #ffffff;
  --overdue: #f87171;
  --overdue-soft: #3b1d1d;
  --today: #fbbf24;
  --today-soft: #3a2f12;
  --upcoming: #facc15;
  --upcoming-soft: #36320f;
  --done: #34d399;
  --done-soft: #123a2c;
  --danger: #f87171;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 12px 28px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-feature-settings: "cv11", "ss01";
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }

/* ---------- Motion ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes shimmer { from { background-position: -400px 0; } to { background-position: 400px 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Shell / layout ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { display: none; }

.mobile-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 12px 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.mobile-topbar .brand-name { font-weight: 700; font-size: 1rem; letter-spacing: -0.01em; }

.main-area { flex: 1; min-width: 0; padding-bottom: 76px; }

main { max-width: 880px; margin: 0 auto; padding: 20px 16px 32px; }

nav.tabs {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 10;
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs .nav-item {
  flex: 1 0 auto;
  min-width: 58px;
  max-width: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  padding: 9px 4px 8px;
  font-size: 0.64rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}
nav.tabs .nav-item .nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
nav.tabs .nav-item.active { color: var(--primary); }

@media (min-width: 900px) {
  .sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-w);
    flex-shrink: 0;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    background: var(--surface-2);
    border-right: 1px solid var(--border);
    padding: 20px 12px 16px;
  }
  .main-area { margin-left: var(--sidebar-w); padding-bottom: 40px; }
  .mobile-topbar { display: none; }
  nav.tabs { display: none; }
  main { padding: 32px 40px 40px; max-width: 1040px; }
}

.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 22px; color: var(--text); }
.sidebar-brand .brand-icon { color: var(--primary); display: inline-flex; }
.sidebar-brand .brand-name { font-weight: 700; font-size: 1.02rem; letter-spacing: -0.01em; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}
.sidebar-nav .nav-item:hover { background: var(--border); color: var(--text); }
.sidebar-nav .nav-item.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

.sidebar-footer { border-top: 1px solid var(--border); padding-top: 12px; }
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
}
.theme-toggle:hover { background: var(--border); color: var(--text); }
.theme-toggle .theme-label { flex: 1; text-align: left; }
.theme-toggle .theme-value { font-size: 0.72rem; color: var(--muted); }

/* ---------- Generic components ---------- */
.panel { display: none; }
.panel.active { display: block; animation: fadeUp 0.22s ease both; }

.page-title { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.015em; margin: 0 0 18px; }

section.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  margin-bottom: 16px;
}
section.card h2 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.005em;
}
section.card h2 .count { color: var(--muted); font-weight: 500; font-size: 0.82rem; }
section.card h2 .icon { color: var(--muted); }
section.card h2.accent-overdue .icon { color: var(--overdue); }
section.card h2.accent-today .icon { color: var(--today); }
section.card h2.accent-week .icon { color: var(--upcoming); }
section.card h2.accent-done .icon { color: var(--done); }

/* Dashboard header + stats */
.dash-header { margin-bottom: 18px; }
.dash-date { font-size: 0.74rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 4px; }
.dash-header .page-title { margin-bottom: 4px; }
.dash-summary { color: var(--muted); font-size: 0.9rem; margin: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
@media (min-width: 700px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-tile:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.stat-tile .stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-tile .stat-label { font-size: 0.74rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-tile .stat-icon { width: 28px; height: 28px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; }
.stat-tile .stat-value { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.stat-tile.overdue .stat-icon { background: var(--overdue-soft); color: var(--overdue); }
.stat-tile.today .stat-icon { background: var(--today-soft); color: var(--today); }
.stat-tile.week .stat-icon { background: var(--upcoming-soft); color: var(--upcoming); }
.stat-tile.done .stat-icon { background: var(--done-soft); color: var(--done); }

.task-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 8px;
  margin: 0 -8px;
  border-radius: var(--radius-sm);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s ease;
}
.task-row:hover { background: var(--surface-2); }
.task-row:last-child { border-bottom: none; }
.task-row .info { flex: 1; min-width: 0; }
.task-row .title { font-weight: 600; }
.task-row .meta { font-size: 0.78rem; color: var(--muted); margin-top: 1px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fff;
  white-space: nowrap;
}
.badge.NOT_STARTED { background: #94989f; }
.badge.IN_PROGRESS { background: var(--today); color: #3b2900; }
.badge.BLOCKED { background: var(--overdue); }
.badge.DONE { background: var(--done); }

.status-pill { border: none; cursor: pointer; font: inherit; transition: filter 0.12s ease; }
.status-pill:hover { filter: brightness(0.94); }

.status-menu {
  position: fixed;
  z-index: 40;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 6px;
  min-width: 170px;
  animation: popIn 0.12s ease both;
}
.status-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
}
.status-option:hover { background: var(--surface-2); }
.status-option.current { font-weight: 700; }
.status-dot { width: 10px; height: 10px; border-radius: 999px; flex-shrink: 0; }
.status-dot.NOT_STARTED { background: #94989f; }
.status-dot.IN_PROGRESS { background: var(--today); }
.status-dot.BLOCKED { background: var(--overdue); }
.status-dot.DONE { background: var(--done); }

/* Relative deadline labels */
.rel { font-size: 0.75rem; font-weight: 600; }
.rel-overdue { color: var(--overdue); }
.rel-today { color: var(--today); }
.rel-soon { color: var(--upcoming); }
.rel-later, .rel-none { color: var(--muted); font-weight: 500; }

.indicator { color: var(--muted); display: inline-flex; align-items: center; gap: 3px; font-size: 0.78rem; }

/* Empty + loading states */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 22px 12px;
  color: var(--muted);
  font-size: 0.86rem;
}
.empty-state .empty-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.empty-state.positive .empty-icon { background: var(--done-soft); color: var(--done); }
.empty-state .empty-title { font-weight: 600; color: var(--text); }
.empty-state .btn { margin-top: 4px; }
.empty-inline { color: var(--muted); font-size: 0.85rem; padding: 8px 0; display: flex; align-items: center; gap: 8px; }

.skeleton {
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.3s linear infinite;
}
.skeleton-line { height: 12px; margin: 10px 0; }
.skeleton-title { height: 16px; width: 40%; margin-bottom: 14px; }
.skeleton-tile { height: 84px; border-radius: var(--radius); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }

select, input[type=text], input[type=date], textarea, input[type=search] {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.87rem;
  font-family: inherit;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea { width: 100%; resize: vertical; }
button { font-family: inherit; }

button.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--primary);
  color: var(--primary-text);
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.08s ease;
}
button.btn:hover { background: var(--primary-hover); }
button.btn:active { transform: translateY(1px); }
button.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
button.btn.secondary:hover { background: var(--border); }
button.btn.danger { background: var(--danger); color: #fff; }
button.btn.danger:hover { filter: brightness(0.92); }
button.btn.ghost { background: none; color: var(--primary); padding: 6px 8px; }
button.btn.ghost:hover { background: var(--primary-soft); }

button.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 999px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
button.icon-btn:hover { background: var(--surface-2); color: var(--text); }

button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.fab {
  position: fixed;
  right: 20px; bottom: 82px;
  border-radius: 999px;
  width: 54px; height: 54px;
  box-shadow: var(--shadow-md);
  z-index: 9;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.12s ease;
}
.fab:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
@media (min-width: 900px) { .fab { bottom: 28px; right: 32px; } }

.subject-pill-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.subject-pill-row:last-child { border-bottom: none; }
.subject-pill-row .subject-name { font-weight: 600; display: flex; align-items: center; gap: 10px; }
.subject-pill-row .subject-swatch { width: 10px; height: 10px; border-radius: 3px; }
.subject-pill-row .row-actions { display: flex; gap: 6px; }

.form-row { margin-bottom: 12px; display: flex; flex-direction: column; gap: 5px; }
.form-row label { font-size: 0.76rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Task modal: bottom sheet on mobile, side panel on desktop */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, 0.5);
  z-index: 20;
  align-items: flex-end;
  justify-content: center;
}
.modal-backdrop.active { display: flex; }
.modal {
  background: var(--surface);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 18px 18px 0 0;
  box-shadow: var(--shadow-lg);
  padding: 20px;
  animation: slideUp 0.22s ease both;
}
@media (min-width: 900px) {
  .modal-backdrop { justify-content: flex-end; align-items: stretch; background: rgba(10, 12, 16, 0.35); }
  .modal {
    width: 520px;
    max-width: 520px;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border-left: 1px solid var(--border);
    padding: 24px 28px 40px;
    animation: slideInRight 0.22s ease both;
  }
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-header h2 { margin: 0; font-size: 1.08rem; font-weight: 700; }

.subtask-item, .attachment-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.87rem;
}
.subtask-item label { display: flex; align-items: center; gap: 8px; flex: 1; cursor: pointer; }
.attachment-item a { color: var(--primary); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }

.inline-form { display: flex; gap: 8px; margin-top: 10px; }
.inline-form input { flex: 1; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.subject-count-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.subject-count-tile {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  text-align: center;
  border-top: 3px solid var(--tile-color, var(--primary));
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.subject-count-tile:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.subject-count-tile .n { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.subject-count-tile .label { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }

.tamara-answer {
  white-space: pre-wrap;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  margin-top: 10px;
  font-size: 0.88rem;
  line-height: 1.5;
  animation: fadeUp 0.2s ease both;
}
.source-tag { font-size: 0.72rem; color: var(--muted); margin-top: 6px; display: block; }

table.log-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
table.log-table th {
  text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--border);
  color: var(--muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03em;
}
table.log-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }

/* Toast with optional action */
.toast {
  position: fixed;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 14px 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 50;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 14px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast-action {
  background: none;
  border: none;
  color: var(--primary);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}
.toast-action:hover { background: rgba(255,255,255,0.1); }
@media (min-width: 900px) { .toast { bottom: 28px; } }

/* Dialog (replaces prompt/confirm) */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, 0.5);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.dialog {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: 22px;
  animation: popIn 0.15s ease both;
}
.dialog h3 { margin: 0 0 8px; font-size: 1.02rem; font-weight: 700; }
.dialog p { margin: 0 0 14px; color: var(--muted); font-size: 0.88rem; line-height: 1.5; }
.dialog input { width: 100%; margin-bottom: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Board (monday.com-style) ---------- */
.board-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  overflow: hidden;
}
.board-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  cursor: pointer;
  border-left: 4px solid var(--group-color, var(--primary));
  transition: background 0.12s ease;
}
.board-group-header:hover { background: var(--surface-2); }
.board-group-header .collapse-arrow { display: inline-flex; color: var(--muted); transition: transform 0.15s ease; }
.board-group.collapsed .collapse-arrow { transform: rotate(-90deg); }
.board-group-header .group-name { font-weight: 700; font-size: 0.92rem; flex: 1; }
.board-group-header .group-count { font-size: 0.75rem; color: var(--muted); font-weight: 500; }

.group-progress { width: 72px; height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; flex-shrink: 0; }
.group-progress > div { height: 100%; background: var(--group-color, var(--primary)); transition: width 0.4s ease; }

.board-group-body { display: block; }
.board-group.collapsed .board-group-body { display: none; }

.board-table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
.board-table th {
  text-align: left;
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--muted);
  background: var(--surface-2);
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
}
.board-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.board-table tr.task-line td { transition: background 0.12s ease; }
.board-table tr.task-line:hover td { background: var(--surface-2); }
.board-table tr.task-line.dragging { opacity: 0.4; }
.board-table tr.task-line.drag-over-top td { box-shadow: inset 0 2px 0 var(--primary); }
.board-table tr.task-line.drag-over-bottom td { box-shadow: inset 0 -2px 0 var(--primary); }
.board-table tr.task-line.done .task-title-btn { text-decoration: line-through; color: var(--muted); }

.drag-handle { cursor: grab; color: var(--muted); display: flex; padding-right: 2px; opacity: 0.5; }
.board-table tr.task-line:hover .drag-handle { opacity: 1; }

.task-title-btn {
  background: none; border: none; font: inherit; font-weight: 500;
  color: var(--text); text-align: left; cursor: pointer; padding: 0;
  display: inline-flex; align-items: center; gap: 8px;
}
.task-title-btn:hover { color: var(--primary); }

.deadline-cell { cursor: pointer; color: var(--text); white-space: nowrap; }
.deadline-cell .rel { display: block; }
.deadline-cell input[type=date] { border: none; background: transparent; padding: 0; font: inherit; color: inherit; }

.subitems-count { color: var(--muted); font-size: 0.82rem; display: inline-flex; align-items: center; gap: 5px; }
.attachment-count { color: var(--muted); font-size: 0.82rem; display: inline-flex; align-items: center; gap: 4px; margin-left: 10px; }

.add-task-row td { padding: 8px 12px; }
.add-task-inline {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; color: var(--muted);
  font: inherit; font-weight: 500; cursor: pointer; padding: 4px 0;
}
.add-task-inline:hover { color: var(--primary); }
.add-task-inline input { border: none; background: transparent; font: inherit; color: var(--text); width: 100%; }

.board-cards { display: none; padding: 4px 10px 10px; }
.add-group-row { text-align: center; margin: 10px 0 24px; }

@media (max-width: 680px) {
  .board-table { display: none; }
  .board-cards { display: block; }
}

/* ---------- Sidebar top row + notification bell ---------- */
.sidebar-top { display: flex; align-items: flex-start; justify-content: space-between; padding-right: 4px; }
.topbar-actions { display: flex; gap: 2px; }
.bell { position: relative; }
.bell .bell-badge {
  position: absolute; top: 3px; right: 3px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px;
  background: var(--overdue); color: #fff;
  font-size: 0.62rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--surface-2);
}
.notif-panel {
  position: fixed;
  z-index: 40;
  width: 340px;
  max-width: calc(100vw - 24px);
  max-height: 70vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  animation: popIn 0.12s ease both;
}
.notif-head { padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 0.9rem; display: flex; justify-content: space-between; align-items: center; }
.notif-section { padding: 8px 6px; }
.notif-section-title { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 6px 8px 4px; }
.notif-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px; border-radius: 8px; cursor: pointer;
  font-size: 0.84rem;
}
.notif-item:hover { background: var(--surface-2); }
.notif-item .notif-icon { width: 26px; height: 26px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-item .notif-icon.overdue { background: var(--overdue-soft); color: var(--overdue); }
.notif-item .notif-icon.ok { background: var(--done-soft); color: var(--done); }
.notif-item .notif-icon.fail { background: var(--overdue-soft); color: var(--overdue); }
.notif-item .notif-body { flex: 1; min-width: 0; }
.notif-item .notif-title { font-weight: 600; }
.notif-item .notif-meta { color: var(--muted); font-size: 0.76rem; margin-top: 1px; }
.notif-empty { padding: 18px; text-align: center; color: var(--muted); font-size: 0.84rem; }

/* ---------- Segmented control ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.toolbar .filters { margin: 0; }
.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
}
.segmented button {
  display: inline-flex; align-items: center; gap: 6px;
  border: none; background: none;
  padding: 6px 11px;
  border-radius: 7px;
  color: var(--muted);
  font: inherit; font-size: 0.82rem; font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Priority / tags / recurrence ---------- */
.prio {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.01em;
}
.prio.HIGH { background: var(--overdue-soft); color: var(--overdue); }
.prio.MEDIUM { background: var(--surface-2); color: var(--muted); }
.prio.LOW { background: var(--primary-soft); color: var(--primary); }
.tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 6px;
  background: var(--surface-2); color: var(--muted);
  font-size: 0.7rem; font-weight: 600;
  border: 1px solid var(--border);
}
.details-cell { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
@media (max-width: 900px) { .kanban { grid-template-columns: repeat(4, 260px); } }
.kanban-col {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 200px;
  display: flex; flex-direction: column; gap: 8px;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.kanban-col.drag-over { border-color: var(--primary); background: var(--primary-soft); }
.kanban-col-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 6px; font-size: 0.8rem; font-weight: 700; }
.kanban-col-head .count { color: var(--muted); font-weight: 600; margin-left: auto; }
.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
  cursor: grab;
  border-left: 3px solid var(--card-color, var(--primary));
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.kanban-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.kanban-card.dragging { opacity: 0.4; }
.kanban-card .kc-subject { font-size: 0.7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.kanban-card .kc-title { font-weight: 600; margin: 3px 0 6px; font-size: 0.88rem; }
.kanban-card .kc-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.76rem; color: var(--muted); }
.kanban-empty { color: var(--muted); font-size: 0.8rem; text-align: center; padding: 20px 8px; border: 1px dashed var(--border); border-radius: 8px; }

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.cal-title { font-weight: 700; font-size: 1rem; text-transform: capitalize; }
.cal-nav { display: flex; gap: 4px; align-items: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); text-align: center; padding: 4px 0 6px; }
.cal-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 96px;
  padding: 6px;
  display: flex; flex-direction: column; gap: 4px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.cal-cell:hover { border-color: var(--primary); }
.cal-cell.other { opacity: 0.45; }
.cal-cell.drag-over { background: var(--primary-soft); border-color: var(--primary); }
.cal-daynum { font-size: 0.76rem; font-weight: 600; color: var(--muted); display: inline-flex; width: 22px; height: 22px; align-items: center; justify-content: center; border-radius: 999px; }
.cal-cell.today .cal-daynum { background: var(--primary); color: #fff; }
.cal-cell.weekend { background: var(--surface-2); }
.cal-chip {
  font-size: 0.72rem; font-weight: 600;
  padding: 3px 6px; border-radius: 6px;
  background: var(--surface-2);
  border-left: 3px solid var(--chip, var(--primary));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: grab;
}
.cal-chip.done { text-decoration: line-through; color: var(--muted); }
.cal-chip.dragging { opacity: 0.4; }
.cal-chip.overdue-chip { border-left-color: var(--overdue); }
.cal-more { font-size: 0.7rem; color: var(--muted); padding-left: 4px; }
@media (max-width: 680px) {
  .cal-cell { min-height: 64px; padding: 4px; }
  .cal-chip { font-size: 0.62rem; padding: 2px 4px; }
}

/* ---------- Charts ---------- */
.chart-grid { display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 16px; }
@media (min-width: 800px) { .chart-grid { grid-template-columns: 1fr 1fr; } }
.chart-grid section.card { margin-bottom: 0; }
.chart-sub { color: var(--muted); font-size: 0.78rem; margin: -6px 0 12px; }
.bar-chart { width: 100%; height: auto; display: block; overflow: visible; }
.bar-chart .bar { fill: var(--primary); transition: opacity 0.12s ease; }
.bar-chart .bar:hover { opacity: 0.8; }
.bar-chart .bar.empty { fill: var(--border); }
.bar-chart .axis { stroke: var(--border); stroke-width: 1; }
.bar-chart .lbl { fill: var(--muted); font-size: 10px; font-family: inherit; }
.bar-chart .val { fill: var(--text); font-size: 10px; font-weight: 600; font-family: inherit; }
.hbar-row { display: grid; grid-template-columns: 90px 1fr 40px; align-items: center; gap: 10px; padding: 6px 0; font-size: 0.84rem; }
.hbar-row .hbar-label { display: flex; align-items: center; gap: 8px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; position: relative; }
.hbar-fill { height: 100%; border-radius: 999px; background: var(--hbar-color, var(--primary)); transition: width 0.5s ease; }
.hbar-fill.overdue-part { position: absolute; left: 0; top: 0; background: var(--overdue); border-radius: 999px 0 0 999px; }
.hbar-val { text-align: right; color: var(--muted); font-size: 0.8rem; font-weight: 600; }
.chart-legend { display: flex; gap: 14px; font-size: 0.74rem; color: var(--muted); margin-top: 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Settings ---------- */
.settings-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .settings-grid { grid-template-columns: 1fr 1fr; } .settings-grid .span-2 { grid-column: 1 / -1; } }
.settings-grid section.card { margin-bottom: 0; }
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: none; }
.setting-row .setting-label { font-weight: 600; font-size: 0.88rem; }
.setting-row .setting-help { color: var(--muted); font-size: 0.76rem; margin-top: 2px; }
.setting-row .setting-control { flex-shrink: 0; }
.setting-row .setting-control input[type=text], .setting-row .setting-control select { min-width: 180px; }
.readonly-value { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; color: var(--muted); background: var(--surface-2); padding: 4px 8px; border-radius: 6px; }
.switch { position: relative; width: 40px; height: 22px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: background 0.15s ease; cursor: pointer; }
.switch .slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; background: #fff; border-radius: 999px; transition: transform 0.15s ease; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.changelog-version { display: flex; align-items: baseline; gap: 10px; margin: 14px 0 6px; }
.changelog-version:first-child { margin-top: 0; }
.changelog-version .v { font-weight: 700; }
.changelog-version .d { color: var(--muted); font-size: 0.76rem; }
.changelog ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 0.84rem; line-height: 1.6; }
.version-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 0.74rem; font-weight: 700; }

/* ---------- Auth ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-md); padding: 28px; animation: fadeUp 0.25s ease both; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; color: var(--text); }
.auth-brand .brand-icon { color: var(--primary); display: inline-flex; }
.auth-brand .brand-name { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; }
.auth-card h1 { font-size: 1.3rem; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.015em; }
.auth-card .sub { color: var(--muted); font-size: 0.88rem; margin: 0 0 18px; }
.auth-card .form-row input { width: 100%; }
.auth-card .btn { width: 100%; justify-content: center; margin-top: 4px; }
.auth-links { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; font-size: 0.84rem; }
.auth-links button { background: none; border: none; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }
.auth-error { background: var(--overdue-soft); color: var(--overdue); padding: 9px 12px; border-radius: 8px; font-size: 0.84rem; margin-bottom: 12px; }
.auth-ok { background: var(--done-soft); color: var(--done); padding: 9px 12px; border-radius: 8px; font-size: 0.84rem; margin-bottom: 12px; }

.verify-banner { background: var(--today-soft); color: var(--text); border-bottom: 1px solid var(--border); padding: 10px 18px; font-size: 0.84rem; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.verify-banner .btn { padding: 5px 10px; font-size: 0.78rem; }

.user-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px 6px; }
.user-avatar { width: 30px; height: 30px; border-radius: 999px; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8rem; flex-shrink: 0; }
.user-row .user-name { flex: 1; min-width: 0; font-size: 0.84rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row .user-mail { font-size: 0.72rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Suggestions ---------- */
.suggest-card { border-left: 3px solid var(--primary); }
.suggest-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.suggest-item:last-child { border-bottom: none; }
.suggest-item .s-icon { width: 30px; height: 30px; border-radius: 9px; background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.suggest-item .s-body { flex: 1; min-width: 0; }
.suggest-item .s-label { font-weight: 600; font-size: 0.88rem; }
.suggest-item .s-reason { color: var(--muted); font-size: 0.78rem; margin-top: 2px; }
.suggest-item .s-actions { display: flex; gap: 4px; flex-shrink: 0; }
.suggest-item .s-actions .btn { padding: 5px 10px; font-size: 0.78rem; }

/* ---------- Periods ---------- */
.period-card { border-left: 3px solid var(--group-color, var(--primary)); }
.period-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.period-head .p-name { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.period-head .p-dates { color: var(--muted); font-size: 0.78rem; }
.period-head .p-actions { display: flex; gap: 4px; }
.subject-pill-row.archived .subject-name { color: var(--muted); text-decoration: line-through; }
.subject-meta { display: flex; align-items: center; gap: 6px; }
.subject-meta select { padding: 5px 8px; font-size: 0.8rem; }

/* ---------- Rooster (week timetable) ---------- */
.week-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.week-toolbar .week-title { font-weight: 700; font-size: 1rem; }
.week-scroll { overflow-x: auto; }
.week-grid { display: grid; grid-template-columns: 52px repeat(7, minmax(120px, 1fr)); min-width: 900px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.wg-corner, .wg-day { border-bottom: 1px solid var(--border); background: var(--surface-2); padding: 8px 8px 6px; }
.wg-day { border-left: 1px solid var(--border); }
.wg-day .d-name { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.wg-day .d-num { font-size: 1.05rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 999px; margin-top: 2px; }
.wg-day.today .d-num { background: var(--primary); color: #fff; }
.wg-day .d-tasks { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.wg-day .d-task { font-size: 0.7rem; font-weight: 600; padding: 2px 6px; border-radius: 5px; background: var(--surface); border-left: 3px solid var(--chip, var(--primary)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.wg-day .d-task.overdue-chip { border-left-color: var(--overdue); }
.wg-day .d-allday { font-size: 0.7rem; padding: 2px 6px; border-radius: 5px; background: var(--primary-soft); color: var(--primary); font-weight: 600; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wg-times { position: relative; border-right: 1px solid var(--border); }
.wg-time { position: absolute; right: 6px; transform: translateY(-50%); font-size: 0.68rem; color: var(--muted); }
.wg-col { position: relative; border-left: 1px solid var(--border); background-image: linear-gradient(to bottom, var(--border) 1px, transparent 1px); }
.wg-col.today { background-color: color-mix(in srgb, var(--primary) 4%, transparent); }
.wg-col.weekend { background-color: var(--surface-2); }
.lesson {
  position: absolute; left: 4px; right: 4px;
  background: var(--primary-soft); color: var(--text);
  border-left: 3px solid var(--lesson-color, var(--primary));
  border-radius: 7px; padding: 5px 7px;
  font-size: 0.72rem; line-height: 1.3; overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: default;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.lesson:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); z-index: 2; }
.lesson .l-course { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lesson .l-meta { color: var(--muted); font-size: 0.68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--overdue); z-index: 3; }
.now-line::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 999px; background: var(--overdue); }
.feed-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 0.84rem; color: var(--muted); }
.course-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.86rem; }
.course-row:last-child { border-bottom: none; }
.course-row input[type=text] { flex: 1; min-width: 140px; }
.course-row .c-count { color: var(--muted); font-size: 0.76rem; white-space: nowrap; }

/* ---------- Contact / feedback ---------- */
.fb-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.fb-item:last-child { border-bottom: none; }
.fb-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fb-head .fb-subject { font-weight: 600; flex: 1; min-width: 0; }
.fb-meta { color: var(--muted); font-size: 0.76rem; margin-top: 3px; }
.fb-message { margin-top: 8px; font-size: 0.86rem; white-space: pre-wrap; line-height: 1.5; }
.fb-note { margin-top: 8px; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; font-size: 0.84rem; white-space: pre-wrap; }
.fb-note b { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; display: block; margin-bottom: 2px; }
.kind-pill { padding: 2px 8px; border-radius: 6px; font-size: 0.72rem; font-weight: 700; }
.kind-pill.bug { background: var(--overdue-soft); color: var(--overdue); }
.kind-pill.idea { background: var(--upcoming-soft); color: var(--upcoming); }
.kind-pill.question { background: var(--primary-soft); color: var(--primary); }
.status-pill-fb { padding: 2px 8px; border-radius: 6px; font-size: 0.72rem; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.status-pill-fb.in_progress { background: var(--today-soft); color: var(--today); }
.status-pill-fb.resolved { background: var(--done-soft); color: var(--done); }
.fb-admin-row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.fb-admin-row select { padding: 5px 8px; font-size: 0.8rem; }
.fb-admin-row input { flex: 1; min-width: 180px; }

/* ---------- Paywall ---------- */
.paywall { max-width: 640px; }
.pw-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.pw-title { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
.pw-sub { color: var(--muted); font-size: 0.86rem; margin-top: 2px; }
.pw-price { margin-left: auto; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; display: flex; flex-direction: column; align-items: flex-end; line-height: 1; }
.pw-price span { font-size: 0.7rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 4px; }
.pw-features { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 8px; font-size: 0.88rem; }
.pw-features li { display: flex; align-items: center; gap: 8px; }
.pw-features li .icon { color: var(--done); }
.pw-methods { display: grid; gap: 8px; }
.pw-method { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); color: var(--text); text-decoration: none; transition: border-color 0.12s ease; }
.pw-method:not(.static):hover { border-color: var(--primary); }
.pw-m-title { font-weight: 700; display: inline-flex; align-items: center; gap: 8px; }
.pw-m-sub { color: var(--muted); font-size: 0.82rem; }
.pw-pending { display: flex; gap: 10px; align-items: flex-start; background: var(--today-soft); border-radius: 10px; padding: 12px 14px; font-size: 0.86rem; margin: 6px 0 12px; }
.trial-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 0.72rem; font-weight: 700; cursor: pointer; }
.trial-pill.locked { background: var(--overdue-soft); color: var(--overdue); }

/* ---------- Admin ---------- */
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.admin-table th { text-align: left; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.admin-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr.banned td { opacity: 0.6; }
.admin-table .adm-name { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.admin-table .adm-mail { color: var(--muted); font-size: 0.74rem; }
.admin-table .adm-muted { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.admin-table .adm-actions { display: flex; gap: 4px; align-items: center; justify-content: flex-end; }

/* ---------- Tamara agent workspace ---------- */
main.full { max-width: none; padding: 0; }
:root { --topbar-h: 57px; --tabs-h: 62px; }
.agent-layout { display: flex; height: calc(100vh - var(--topbar-h) - var(--tabs-h)); height: calc(100dvh - var(--topbar-h) - var(--tabs-h)); overflow: hidden; }
@media (min-width: 900px) { .agent-layout { height: 100vh; } }

.agent-chat { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--surface); }
.agent-chat-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; }
.agent-chat-head .chat-title { font-size: 0.85rem; color: var(--text); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.agent-chat-head .head-actions { display: flex; gap: 2px; }
.agent-chat-body { flex: 1; overflow-y: auto; padding: 12px 20px; }
.agent-welcome { max-width: 720px; margin: 36px auto 0; animation: fadeUp 0.25s ease both; }
.agent-welcome h3 { font-size: 1rem; font-weight: 500; margin: 0 0 14px; }
.agent-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.agent-chips button {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 7px 12px; font: inherit; font-size: 0.84rem;
  display: inline-flex; gap: 8px; align-items: center; cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.agent-chips button:hover { border-color: var(--primary); background: var(--primary-soft); }
.agent-chips button .icon { color: var(--muted); }
.agent-messages { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; padding-bottom: 12px; }

.composer-wrap { padding: 8px 20px 18px; }
.composer {
  max-width: 720px; margin: 0 auto;
  border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface); box-shadow: var(--shadow-sm);
  padding: 12px 12px 8px 14px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.composer:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.composer textarea { width: 100%; border: none; background: transparent; resize: none; font: inherit; font-size: 0.9rem; color: var(--text); min-height: 44px; max-height: 160px; padding: 2px 4px; }
.composer textarea:focus { outline: none; box-shadow: none; }
.composer-bar { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.composer-bar .left, .composer-bar .right { display: flex; align-items: center; gap: 2px; }
.composer-model { font-size: 0.78rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; }
.send-round { width: 32px; height: 32px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: background 0.12s ease, color 0.12s ease; }
.send-round.ready { background: var(--primary); color: #fff; border-color: var(--primary); }

.agent-panel { width: 400px; flex-shrink: 0; border-left: 1px solid var(--border); background: var(--bg); display: flex; flex-direction: column; overflow: hidden; }
.agent-panel.collapsed { display: none; }
.agent-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 12px 16px; font-size: 0.85rem; font-weight: 500; gap: 8px; }
.agent-panel-head .lbl { display: inline-flex; align-items: center; gap: 8px; }
.agent-profile { margin: 0 16px; background: var(--surface-2); border-radius: 14px; padding: 12px; display: flex; gap: 14px; }
.agent-avatar { width: 84px; height: 84px; border-radius: 12px; flex-shrink: 0; background: linear-gradient(135deg, #6366f1 0%, #a855f7 60%, #ec4899 100%); display: flex; align-items: center; justify-content: center; color: #fff; box-shadow: var(--shadow-sm); }
.agent-profile .name-row { display: flex; align-items: center; gap: 8px; font-size: 0.84rem; }
.live-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--done); box-shadow: 0 0 0 3px var(--done-soft); }
.live-dot.off { background: var(--muted); box-shadow: 0 0 0 3px var(--border); }
.agent-profile .role { font-size: 1.05rem; font-weight: 600; margin: 4px 0 14px; }
.agent-profile .tools-row { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--muted); }
.tool-chip { width: 24px; height: 24px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center; color: var(--primary); }
.agent-tabs { display: flex; gap: 2px; margin: 14px 16px 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
.agent-tabs button { background: none; border: none; padding: 8px 11px; font: inherit; font-size: 0.86rem; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.agent-tabs button.active { color: var(--text); border-bottom-color: var(--text); font-weight: 500; }
.agent-tab-body { flex: 1; overflow-y: auto; padding: 14px 16px 24px; }
.panel-note { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: 0.84rem; margin-bottom: 8px; }
.activity-item { display: flex; justify-content: space-between; gap: 12px; padding: 12px 8px; border-bottom: 1px solid var(--border); font-size: 0.84rem; }
.activity-item .sub { color: var(--muted); font-size: 0.76rem; margin-top: 6px; display: flex; gap: 6px; align-items: center; }
.activity-item .right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.activity-item .when { color: var(--muted); font-size: 0.74rem; }
.pill-ok { background: var(--done-soft); color: var(--done); padding: 3px 8px; border-radius: 6px; font-size: 0.74rem; font-weight: 600; }
.pill-fail { background: var(--overdue-soft); color: var(--overdue); padding: 3px 8px; border-radius: 6px; font-size: 0.74rem; font-weight: 600; }
.pill-neutral { background: var(--primary-soft); color: var(--primary); padding: 3px 8px; border-radius: 6px; font-size: 0.74rem; font-weight: 600; }
.panel-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 0.86rem; }
.panel-row:last-child { border-bottom: none; }
.panel-row .help { color: var(--muted); font-size: 0.76rem; margin-top: 2px; }
.panel-row .lead { display: flex; align-items: center; gap: 10px; }
.panel-row .lead .tool-chip { width: 30px; height: 30px; }
.brain-stat { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 14px; }
.brain-stat div { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px; text-align: center; }
.brain-stat .n { font-size: 1.2rem; font-weight: 700; }
.brain-stat .l { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.rules { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 0.82rem; line-height: 1.6; }
.history-menu { position: fixed; z-index: 40; width: 300px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-md); padding: 6px; animation: popIn 0.12s ease both; }
.history-menu .hm-title { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 6px 10px 4px; font-weight: 700; }
.history-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 0.84rem; }
.history-item:hover { background: var(--surface-2); }
.history-item.current { background: var(--primary-soft); }
.history-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item .d { color: var(--muted); font-size: 0.72rem; flex-shrink: 0; }
@media (max-width: 899px) {
  .agent-panel { position: fixed; top: var(--topbar-h); bottom: var(--tabs-h); right: 0; width: 100%; z-index: 15; transform: translateX(100%); transition: transform 0.2s ease; display: flex; }
  .agent-panel.collapsed { display: flex; }
  .agent-panel.open { transform: none; }
  .agent-chat-body { padding: 10px 12px; }
  .composer-wrap { padding: 6px 10px 12px; }
}

/* ---------- Tamara chat ---------- */
.chat-card { padding: 0; overflow: hidden; }
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.chat-head h2 { margin: 0; }
.chat-head .chat-status { font-size: 0.74rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.chat-head .chat-status .dot { width: 7px; height: 7px; border-radius: 999px; background: var(--done); }
.chat-messages { padding: 16px; display: flex; flex-direction: column; gap: 12px; max-height: 60vh; overflow-y: auto; min-height: 220px; }
.chat-msg { display: flex; gap: 10px; align-items: flex-start; animation: fadeUp 0.18s ease both; }
.chat-msg.user { flex-direction: row-reverse; }
.chat-avatar { width: 30px; height: 30px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--primary-soft); color: var(--primary); }
.chat-msg.user .chat-avatar { background: var(--surface-2); color: var(--muted); }
.chat-bubble { max-width: 78%; padding: 10px 13px; border-radius: 14px; font-size: 0.88rem; line-height: 1.5; white-space: pre-wrap; background: var(--surface-2); color: var(--text); }
.chat-msg.user .chat-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.assistant .chat-bubble { border-bottom-left-radius: 4px; }
.chat-bubble .source-tag { margin-top: 6px; }
.chat-typing { display: inline-flex; gap: 4px; padding: 6px 2px; }
.chat-typing span { width: 6px; height: 6px; border-radius: 999px; background: var(--muted); animation: typing 1s infinite ease-in-out; }
.chat-typing span:nth-child(2) { animation-delay: 0.15s; } .chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.chat-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.action-card { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; font-size: 0.84rem; box-shadow: var(--shadow-sm); }
.action-card .action-icon { width: 26px; height: 26px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--primary-soft); color: var(--primary); }
.action-card.delete_task .action-icon { background: var(--overdue-soft); color: var(--overdue); }
.action-card.done_state .action-icon { background: var(--done-soft); color: var(--done); }
.action-card .action-label { flex: 1; min-width: 0; }
.action-card .action-buttons { display: flex; gap: 4px; flex-shrink: 0; }
.action-card .action-buttons .btn { padding: 5px 10px; font-size: 0.78rem; }
.action-card.done_state, .action-card.cancelled { opacity: 0.7; }
.action-card .action-state { font-size: 0.74rem; color: var(--muted); font-weight: 600; }
.chat-suggestions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 12px; }
.chat-suggestions button { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 0.78rem; cursor: pointer; }
.chat-suggestions button:hover { border-color: var(--primary); color: var(--primary); }
.chat-input { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface); }
.chat-input textarea { flex: 1; min-height: 40px; max-height: 120px; resize: none; }
.chat-input .btn { align-self: flex-end; }
.chat-empty { text-align: center; color: var(--muted); font-size: 0.86rem; padding: 26px 16px 10px; }
.chat-empty .empty-icon { margin: 0 auto 10px; }

/* ---------- Import ---------- */
.import-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.import-table th { text-align: left; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--border); }
.import-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.import-table input[type=text] { width: 100%; min-width: 160px; }
.import-table input[type=date] { min-width: 130px; }
.import-table tr.excluded td:not(:first-child) { opacity: 0.45; }
.import-table .guess { color: var(--today); font-size: 0.7rem; font-weight: 600; margin-left: 4px; }
.import-summary { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.import-summary .muted { color: var(--muted); font-size: 0.82rem; }

/* =====================================================================
   Mobile optimizations — applies below 900px / 680px only; desktop unchanged
   ===================================================================== */
@media (max-width: 899px) {
  main { padding: 14px 12px 28px; }
  section.card { padding: 14px; border-radius: 12px; }
  .page-title { font-size: 1.25rem; margin-bottom: 14px; }
  .toolbar { gap: 8px; }
  .toolbar .page-title { margin-bottom: 0; }
  .toolbar .filters, .filters { width: 100%; }
  .filters select, .filters input[type=search], .filters input[type=text] { flex: 1 1 140px; min-width: 0; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; justify-content: center; padding: 7px 6px; }

  /* Task sheet: single-column form, sticky header with the close button */
  .modal { padding: 14px 14px 32px; }
  .modal-header { position: sticky; top: -14px; background: var(--surface); padding: 14px 0 10px; margin: -14px 0 10px; z-index: 2; }
  .form-grid { grid-template-columns: 1fr; }
  .actions-row .btn { flex: 1 1 auto; justify-content: center; }
  .inline-form { flex-wrap: wrap; }
  .inline-form input[type=file] { width: 100%; }

  /* Settings / account / contact rows stack */
  .setting-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .setting-row .setting-control { width: 100%; display: flex; flex-wrap: wrap; gap: 8px; }
  .setting-row .setting-control input[type=text], .setting-row .setting-control select, .setting-row .setting-control input[type=time] { width: 100%; min-width: 0; flex: 1 1 100%; }
  .setting-row .setting-control .segmented { width: 100%; }
  .readonly-value { word-break: break-all; }

  /* Subjects & periods */
  .subject-pill-row { flex-wrap: wrap; gap: 8px; }
  .subject-pill-row .row-actions { width: 100%; flex-wrap: wrap; justify-content: flex-start; }
  .subject-pill-row .row-actions .subject-meta select { max-width: 100%; }
  .period-head .p-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }

  /* Dashboard */
  .dash-summary { font-size: 0.84rem; }
  .stat-tile { padding: 12px; }
  .stat-tile .stat-value { font-size: 1.4rem; }
  .suggest-item { flex-wrap: wrap; }
  .suggest-item .s-actions { width: 100%; justify-content: flex-end; }
  .hbar-row { grid-template-columns: 72px 1fr 34px; }

  /* Board cards / kanban */
  .kanban { scroll-snap-type: x mandatory; gap: 10px; }
  .kanban-col { scroll-snap-align: start; }
  .task-row { padding: 10px 4px; margin: 0 -4px; }
  .task-row .meta { gap: 4px; }

  /* Popovers */
  .notif-panel { left: 12px !important; right: 12px; width: auto; }
  .status-menu { min-width: 190px; }

  /* Admin table scrolls, contact admin row wraps */
  .admin-table { min-width: 760px; }
  .fb-admin-row input { flex: 1 1 100%; }

  /* FAB clears the (scrollable) tab bar */
  .fab { bottom: calc(var(--tabs-h) + 14px + env(safe-area-inset-bottom)); right: 16px; width: 50px; height: 50px; }
  .toast { bottom: calc(var(--tabs-h) + 18px + env(safe-area-inset-bottom)); max-width: calc(100vw - 24px); }

  /* Tamara */
  .agent-chat-head { padding: 10px 12px; }
  .agent-welcome { margin-top: 18px; }
  .agent-welcome h3 { font-size: 0.95rem; }
  .chat-bubble { max-width: 88%; }
  .composer { padding: 10px 10px 6px 12px; border-radius: 14px; }
  .composer-model { display: none; }
  .agent-profile { margin: 0 12px; }
  .agent-avatar { width: 64px; height: 64px; }
  .agent-tabs { margin: 12px 12px 0; }
  .agent-tab-body { padding: 12px; }
  .chat-suggestions, .agent-chips { gap: 6px; }
  .agent-chips button { font-size: 0.8rem; padding: 6px 10px; }
}

@media (max-width: 680px) {
  /* Prevent iOS zoom-on-focus and give thumbs bigger targets */
  input[type=text], input[type=search], input[type=date], input[type=time], input[type=email], input[type=password], select, textarea { font-size: 16px; padding: 10px 12px; }
  button.btn { padding: 10px 14px; }
  .stat-grid { gap: 8px; }
  .subject-count-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-sub { font-size: 0.76rem; }

  /* Month calendar: chips become compact bars, day cells shorter */
  .cal-grid { gap: 3px; }
  .cal-cell { min-height: 58px; padding: 3px; border-radius: 7px; gap: 2px; }
  .cal-daynum { width: 20px; height: 20px; font-size: 0.7rem; }
  .cal-chip { font-size: 0; height: 6px; padding: 0; border-left: none; border-radius: 3px; background: var(--chip, var(--primary)); }
  .cal-chip.done { opacity: 0.35; }
  .cal-chip.overdue-chip { background: var(--overdue); }
  .cal-more { font-size: 0.6rem; }
  .cal-head { flex-wrap: wrap; }

  /* Import review cards */
  .action-card .action-buttons { width: 100%; justify-content: flex-end; }
  .action-card { flex-wrap: wrap; }

  /* Rooster day view (rendered by JS on narrow screens) */
  .day-pills { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
  .day-pills::-webkit-scrollbar { display: none; }
  .day-pill { flex: 0 0 auto; min-width: 46px; text-align: center; padding: 6px 8px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-size: 0.72rem; color: var(--muted); cursor: pointer; }
  .day-pill .dp-num { display: block; font-size: 1rem; font-weight: 700; color: var(--text); }
  .day-pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }
  .day-pill.active .dp-num { color: #fff; }
  .day-pill .dp-dot { display: block; width: 5px; height: 5px; border-radius: 999px; background: var(--primary); margin: 3px auto 0; }
  .day-pill.active .dp-dot { background: #fff; }
  .day-lesson { display: grid; grid-template-columns: 58px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .day-lesson:last-child { border-bottom: none; }
  .day-lesson .dl-time { font-size: 0.78rem; font-weight: 600; color: var(--muted); line-height: 1.35; }
  .day-lesson .dl-body { border-left: 3px solid var(--lesson-color, var(--primary)); padding-left: 10px; }
  .day-lesson .dl-course { font-weight: 700; }
  .day-lesson .dl-meta { color: var(--muted); font-size: 0.78rem; margin-top: 2px; }
  .day-lesson.now .dl-body { background: var(--primary-soft); border-radius: 0 8px 8px 0; padding: 6px 10px; }
}
