/* ===== בסיס ===== */
:root {
  --bg: #f5f7fb;
  --bg-soft: #eef2f9;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-solid: #ffffff;
  --border: rgba(15, 23, 42, 0.10);
  --border-strong: rgba(15, 23, 42, 0.20);
  --text: #0f172a;
  --muted: #5f6f86;
  --accent: #4f6ef7;
  --accent-strong: #3b5bdb;
  --mint: #14b8a6;
  --done: #059669;
  --danger: #e11d48;
  --radius: 18px;
  --shadow: 0 18px 44px -24px rgba(15, 23, 42, 0.28);
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Heebo", "Rubik", "Assistant", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

button, a, label { touch-action: manipulation; }

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 520px at 88% -12%, rgba(99, 102, 241, 0.14), transparent 62%),
    radial-gradient(760px 460px at 6% -4%, rgba(20, 184, 166, 0.12), transparent 60%),
    radial-gradient(700px 600px at 50% 110%, rgba(99, 102, 241, 0.06), transparent 65%);
}

h1, h2, h3, p { margin: 0; }

button, input, select, textarea { font: inherit; color: inherit; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95em;
  background: rgba(15, 23, 42, 0.06);
  padding: 1px 5px;
  border-radius: 5px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.muted { color: var(--muted); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ===== כפתורים ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 9px 15px;
  font-size: 14px;
  font-weight: 600;
  background: transparent;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  white-space: nowrap;
  user-select: none;
}
.btn svg { width: 16px; height: 16px; flex: 0 0 auto; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.65; cursor: progress; }

.btn.ghost {
  border-color: var(--border);
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.btn.ghost:hover { background: #f8fafc; border-color: var(--border-strong); }

.btn.primary {
  color: #ffffff;
  background: linear-gradient(135deg, #6d8bff, var(--accent) 60%, #3f5fe8);
  box-shadow: 0 10px 24px -12px rgba(79, 110, 247, 0.85);
}
.btn.primary:hover { filter: brightness(1.05); box-shadow: 0 14px 28px -12px rgba(79, 110, 247, 0.9); }

.btn.small {
  min-height: 32px;
  padding: 5px 11px;
  font-size: 12.5px;
  border-radius: 9px;
}
.btn.small svg { width: 14px; height: 14px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #7b8aa1;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { background: rgba(15, 23, 42, 0.06); color: var(--text); }
.icon-btn.danger:hover { background: rgba(225, 29, 72, 0.09); color: var(--danger); }

/* ===== שדות ===== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field.grow { flex: 1 1 220px; min-width: 0; }
.field label { font-size: 12px; color: var(--muted); padding-inline-start: 2px; }

input[type="text"],
input[type="search"],
input[type="password"],
input[type="email"],
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #ffffff;
  color: var(--text);
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #98a5b8; }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(79, 110, 247, 0.65);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.15);
}

/* ===== אווטאר ===== */
.avatar {
  display: inline-grid;
  place-items: center;
  width: 36px; height: 36px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: linear-gradient(135deg, #2dd4bf, var(--accent));
  color: #ffffff;
  font-weight: 800;
  font-size: 14px;
  text-decoration: none;
  user-select: none;
}
.avatar-sm { width: 30px; height: 30px; border-radius: 9px; font-size: 12px; }
.avatar-lg { width: 76px; height: 76px; border-radius: 22px; font-size: 28px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }

.profile-avatar-wrap { position: relative; flex: 0 0 auto; }
.avatar-edit {
  position: absolute;
  inset-inline-end: -5px;
  bottom: -5px;
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #ffffff;
  color: var(--accent-strong);
  box-shadow: 0 6px 14px -8px rgba(15, 23, 42, 0.4);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.avatar-edit svg { width: 15px; height: 15px; }
.avatar-edit:hover { background: #f8fafc; border-color: rgba(79, 110, 247, 0.4); }

/* ===== מסכי טעינה והתחברות ===== */
.center-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.boot-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
}
.spinner {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 3px solid rgba(79, 110, 247, 0.2);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.login-card {
  width: min(100%, 420px);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 30px 80px -30px rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-lg { margin-bottom: 22px; }
.brand-lg .brand-mark { width: 52px; height: 52px; border-radius: 16px; }
.brand-lg h1 { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.brand-lg .muted { font-size: 12.5px; margin-top: 2px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  border: 1px solid rgba(15, 23, 42, 0.16);
  box-shadow: 0 8px 20px -10px rgba(15, 23, 42, 0.35);
  overflow: hidden;
}
.brand-logo { width: 78%; height: 78%; object-fit: contain; display: block; }

.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-btn { width: 100%; min-height: 44px; margin-top: 4px; }

.form-error {
  margin: 0;
  font-size: 12.5px;
  color: var(--danger);
  background: rgba(225, 29, 72, 0.06);
  border: 1px solid rgba(225, 29, 72, 0.18);
  padding: 8px 11px;
  border-radius: 9px;
}

.login-hint {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.8;
}

/* ===== פריסת האפליקציה ===== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 280px;
  flex: 0 0 280px;
  position: sticky;
  top: 12px;
  height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  margin: 12px;
  padding: 18px 14px 14px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 22px 50px -30px rgba(15, 23, 42, 0.35);
  z-index: 45;
  overflow: hidden;
}

.sidebar-close {
  display: none;
  position: absolute;
  z-index: 2;
  width: 40px; height: 40px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #ffffff;
  color: #64748b;
  cursor: pointer;
}
.sidebar-close svg { width: 17px; height: 17px; }

.side-brand-mini {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 2px 0 16px;
  color: #94a3b8;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.side-brand-mini img { width: 18px; height: 18px; object-fit: contain; }

.side-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2px 8px 22px;
}
.side-avatar-link { display: block; border-radius: 50%; text-decoration: none; }
.side-avatar {
  display: grid;
  place-items: center;
  width: 92px; height: 92px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(135deg, #2dd4bf, var(--accent));
  color: #ffffff;
  font-size: 30px;
  font-weight: 800;
  border: 4px solid #ffffff;
  box-shadow: 0 12px 26px -16px rgba(15, 23, 42, 0.45), 0 0 0 1px rgba(15, 23, 42, 0.06);
}
.side-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.side-name {
  margin-top: 12px;
  max-width: 100%;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.side-field { margin-top: 2px; font-size: 12px; color: var(--muted); }

.side-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 2px 2px 0;
  scrollbar-width: none;
}
.side-nav::-webkit-scrollbar { display: none; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 14px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #64748b;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: right;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}
.nav-link svg { width: 20px; height: 20px; flex: 0 0 auto; color: #94a3b8; }
.nav-link:hover { background: #f3f6fb; color: #334155; }
.nav-link:hover svg { color: #64748b; }
.nav-link.active {
  background: #1e90ff;
  color: #ffffff;
  box-shadow: 0 12px 26px -14px rgba(30, 144, 255, 0.9);
}
.nav-link.active svg { color: #ffffff; }

.side-divider { flex: 0 0 auto; margin: 10px 6px; border-top: 1px solid var(--border); }
.nav-logout { flex: 0 0 auto; }
.nav-logout:hover { background: rgba(225, 29, 72, 0.07); color: var(--danger); }
.nav-logout:hover svg { color: var(--danger); }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.drawer-backdrop { display: none; }

.mobile-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 30;
  align-items: center;
  gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-left)) 8px calc(14px + env(safe-area-inset-right));
  background: rgba(245, 247, 251, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.mobile-title { font-weight: 800; font-size: 15px; }
.mobile-topbar .avatar { margin-inline-start: auto; }
.mobile-topbar .icon-btn { width: 42px; height: 42px; }
.mobile-topbar .avatar-sm { width: 34px; height: 34px; }

.content {
  flex: 1;
  width: min(100% - 48px, 1040px);
  margin-inline: auto;
  padding: 28px 0 10px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head h2 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.page-head p { font-size: 13.5px; margin-top: 3px; }

.date-chip {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--muted);
  background: #ffffff;
  border: 1px solid var(--border);
  padding: 6px 11px;
  border-radius: 99px;
  white-space: nowrap;
}

.page-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.model-chip {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent-strong);
  background: rgba(79, 110, 247, 0.08);
  border: 1px solid rgba(79, 110, 247, 0.16);
  padding: 5px 10px;
  border-radius: 99px;
  white-space: nowrap;
}

/* ===== פאנלים ===== */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.progress-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 28px;
  padding: 22px 26px;
}

.task-progress-panel {
  row-gap: 14px;
  align-content: start;
}

.task-progress-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.task-progress-head h3 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.task-progress-head p {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
}

.task-progress-list {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 13px 26px;
  margin-top: 2px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.task-progress-item { min-width: 0; }
.task-progress-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}
.task-progress-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}
.task-progress-fraction {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  color: #16a34a;
  font-variant-numeric: tabular-nums;
}
.task-progress-bar {
  display: block;
  height: 8px;
  border-radius: 99px;
  background: rgba(34, 197, 94, 0.13);
  overflow: hidden;
}
.task-progress-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4ade80, #22c55e);
  transition: width 0.35s ease;
}
.task-progress-empty {
  grid-column: 1 / -1;
  padding: 16px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
}

.ring {
  --p: 0;
  position: relative;
  display: grid;
  place-items: center;
  width: 128px; height: 128px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: conic-gradient(from -90deg, var(--accent) calc(var(--p) * 1%), rgba(15, 23, 42, 0.08) 0);
  box-shadow: 0 0 40px -14px rgba(79, 110, 247, 0.5);
  transition: background 0.4s ease;
}
.ring::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.06);
}
.ring-label {
  position: relative;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.progress-main { min-width: 0; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.02);
  overflow: hidden;
}

.stat {
  padding: 12px 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.stat + .stat { border-inline-start: 1px solid var(--border); }
.stat-label { display: block; font-size: 12px; color: var(--muted); }
.stat b {
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.stat-done { color: var(--done); }

.progress-hint { margin-top: 12px; font-size: 13.5px; color: var(--muted); }

/* ===== טופס הוספה ===== */
.add-panel { padding: 20px 22px 22px; margin-top: 16px; }

.panel-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}

.add-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.add-panel-head .panel-title { margin-bottom: 0; }
.add-panel-hint { font-size: 11.5px; color: var(--muted); }

.add-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.add-grid .field { min-width: 0; }
.add-title { flex: 2.2 1 260px; }
.add-subject { flex: 1.1 1 170px; }
.add-notes { flex: 1.4 1 210px; }
.add-link { flex: 1.1 1 200px; }
.add-grid .add-btn {
  flex: 0 0 auto;
  min-height: 42px;
  padding-inline: 20px;
}

/* ===== סרגל כלים ===== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 18px 0 16px;
}

@media (min-width: 901px) {
  body.route-topics .toolbar {
    position: sticky;
    top: 0;
    z-index: 24;
    margin: 4px 0 16px;
    padding-block: 12px;
    background: rgba(245, 247, 251, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
  }
}

.search-wrap { position: relative; flex: 1 1 260px; min-width: 0; }
.search-wrap svg {
  position: absolute;
  inset-inline-start: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px; height: 17px;
  color: var(--muted);
  pointer-events: none;
}
.search-wrap input { padding-inline-start: 38px; border-radius: 12px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.16s ease;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.is-active {
  color: #ffffff;
  background: linear-gradient(135deg, #6d8bff, var(--accent));
  border-color: transparent;
  box-shadow: 0 6px 16px -8px rgba(79, 110, 247, 0.8);
}
.chip-count {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.07);
  font-variant-numeric: tabular-nums;
}
.chip.is-active .chip-count { background: rgba(255, 255, 255, 0.25); }

.toolbar-selects { display: flex; gap: 8px; flex: 0 0 auto; }
.select-wrap { display: block; }
.toolbar-selects select {
  min-height: 38px;
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 11px;
  background: #ffffff;
  cursor: pointer;
  max-width: 160px;
}

/* ===== קבוצות ונושאים ===== */
#groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr));
  gap: 16px;
  align-items: start;
}

.group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, #fbfcff);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: rise 0.22s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 18px;
  background: rgba(15, 23, 42, 0.025);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.group-title-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.group-kicker {
  padding-inline-start: 17px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}
.group-title {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  font-size: 15.5px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.group-dot {
  width: 8px; height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--mint), var(--accent));
}

.group.is-collapsed .group-head { border-bottom: 0; }

.group-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 0 0 auto;
}
.group-topic-count {
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(15, 23, 42, 0.04);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}
.group-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border: 1px solid rgba(79, 110, 247, 0.2);
  border-radius: 8px;
  background: rgba(79, 110, 247, 0.06);
  color: var(--accent-strong);
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.group-add-btn svg { width: 12px; height: 12px; }
.group-add-btn:hover { background: rgba(79, 110, 247, 0.11); border-color: rgba(79, 110, 247, 0.34); }

.group-collapse {
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #ffffff;
  color: #7b8aa1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.group-collapse:hover { background: #f8fafc; color: var(--text); border-color: var(--border-strong); }
.group-collapse svg { width: 14px; height: 14px; transition: transform 0.15s ease; }
.group-collapse[aria-expanded="false"] svg { transform: rotate(-90deg); }

.group-add-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 18px;
  background: rgba(79, 110, 247, 0.035);
  border-bottom: 1px solid var(--border);
}
.group-add-form input {
  flex: 1 1 220px;
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 9px;
}

.mini-bar {
  display: block;
  width: 78px; height: 5px;
  border-radius: 99px;
  background: rgba(15, 23, 42, 0.09);
  overflow: hidden;
}
.mini-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint), var(--accent));
  transition: width 0.35s ease;
}

.topic-list { list-style: none; margin: 0; padding: 0; }

.topic {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 14px 18px;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  transition: background 0.15s ease;
  animation: rise 0.18s ease both;
}
.topic:first-child { border-top: 0; }
.topic:hover { background: rgba(79, 110, 247, 0.035); }

.check-wrap { position: relative; display: flex; padding-top: 1px; }
.check-input {
  position: absolute;
  opacity: 0;
  width: 24px; height: 24px;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}
.check-box {
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(15, 23, 42, 0.28);
  background: #ffffff;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}
.check-box svg {
  width: 13px; height: 13px;
  fill: none;
  stroke: #ffffff;
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.16s ease, transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.check-input:hover + .check-box { border-color: var(--done); }
.check-input:checked + .check-box {
  background: var(--done);
  border-color: var(--done);
  box-shadow: 0 0 14px -3px rgba(5, 150, 105, 0.55);
}
.check-input:checked + .check-box svg { opacity: 1; transform: scale(1); }
.check-input:focus-visible + .check-box { box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.2); }

.topic-body { flex: 1 1 auto; min-width: 0; }

.topic-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.topic-collapse {
  display: grid;
  place-items: center;
  width: 20px; height: 20px;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
}
.topic-collapse:hover { background: rgba(15, 23, 42, 0.06); color: #475569; }
.topic-collapse svg { width: 14px; height: 14px; transition: transform 0.15s ease; }
.topic-collapse[aria-expanded="false"] svg { transform: rotate(-90deg); }

.topic-sub-count {
  padding: 1px 6px;
  border-radius: 99px;
  background: rgba(15, 23, 42, 0.05);
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.topic-title {
  display: inline-block;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
  text-align: right;
  cursor: pointer;
  overflow-wrap: anywhere;
  transition: color 0.16s ease;
}
.topic-title:hover { color: var(--accent-strong); }

.topic-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--muted);
}
.done-tag { color: var(--done); }

.topic-notes {
  margin-top: 5px;
  font-size: 13px;
  color: #475569;
  overflow-wrap: anywhere;
}

.topic-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
  font-size: 12.5px;
  color: var(--accent-strong);
  text-decoration: none;
  max-width: 100%;
}
.topic-link svg { width: 13px; height: 13px; flex: 0 0 auto; }
.topic-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: ltr;
}
.topic-link:hover { text-decoration: underline; }

.is-done .topic-title {
  color: #94a3b8;
  text-decoration: line-through;
  text-decoration-color: rgba(148, 163, 184, 0.6);
}
.is-done .topic-notes { color: #7b8798; }

.topic-actions {
  display: flex;
  gap: 2px;
  flex: 0 0 auto;
  opacity: 0;
  transition: opacity 0.16s ease;
}
.topic:hover .topic-actions,
.topic:focus-within .topic-actions { opacity: 1; }

/* ===== תתי־נושאים ===== */
.subtopics { margin-top: 6px; }
.subtopics.has-content {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed rgba(15, 23, 42, 0.10);
}

.subtopics-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 24px;
}

.sub-progress { display: flex; align-items: center; gap: 7px; min-width: 0; }
.sub-progress .mini-bar { width: 64px; height: 4px; flex: 0 0 auto; }
.sub-count {
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sub-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-inline-start: 0;
  padding: 3px 7px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}
.sub-add-btn svg { width: 12px; height: 12px; }
.sub-add-btn:hover { background: rgba(79, 110, 247, 0.08); }

.subtopic-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  padding-inline-start: 10px;
  margin-inline-start: 5px;
  border-inline-start: 2px solid rgba(79, 110, 247, 0.16);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.subtopic-node { list-style: none; }

.subtopic-children {
  list-style: none;
  margin: 2px 0 2px;
  margin-inline-start: 10px;
  padding: 0;
  padding-inline-start: 10px;
  border-inline-start: 1px dashed rgba(79, 110, 247, 0.18);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sub-collapse,
.sub-collapse-spacer { width: 20px; height: 20px; flex: 0 0 auto; }
.sub-collapse {
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
}
.sub-collapse:hover { background: rgba(15, 23, 42, 0.05); color: #475569; }
.sub-collapse svg { width: 14px; height: 14px; transition: transform 0.15s ease; }
.sub-collapse[aria-expanded="false"] svg { transform: rotate(-90deg); }

.subtopic-child-count {
  flex: 0 0 auto;
  padding: 1px 5px;
  border-radius: 99px;
  background: rgba(15, 23, 42, 0.05);
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.subtopic.is-editing { background: transparent; }

.subtopic {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 3px 6px;
  border-radius: 8px;
  transition: background 0.15s ease;
}
.subtopic:hover { background: rgba(79, 110, 247, 0.04); }

.subtopic .check-wrap { padding-top: 0; }
.subtopic .check-input { width: 18px; height: 18px; }
.subtopic .check-box { width: 18px; height: 18px; border-width: 2px; }
.subtopic .check-box svg { width: 10px; height: 10px; stroke-width: 4; }

.subtopic-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13.5px;
  color: #334155;
  text-align: right;
  cursor: pointer;
  overflow-wrap: anywhere;
  padding-block: 1px;
}
.subtopic.is-done .subtopic-title {
  color: #94a3b8;
  text-decoration: line-through;
  text-decoration-color: rgba(148, 163, 184, 0.6);
}

.subtopic-actions {
  display: flex;
  gap: 0;
  flex: 0 0 auto;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.subtopic:hover .subtopic-actions,
.subtopic:focus-within .subtopic-actions { opacity: 1; }
.subtopic .icon-btn { width: 26px; height: 26px; border-radius: 7px; }
.subtopic .icon-btn svg { width: 14px; height: 14px; }

.subtopic-form {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  margin-inline-start: 7px;
  flex-wrap: wrap;
}
.subtopic-form input {
  flex: 1 1 160px;
  min-width: 0;
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 9px;
}

.sub-edit-form {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
}
.sub-edit-form input {
  flex: 1;
  min-height: 30px;
  padding: 4px 8px;
  font-size: 13px;
  border-radius: 8px;
}

/* ===== דשבורד וטיימר ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
  gap: 16px;
  align-items: stretch;
}

.timer-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 20px 22px;
  overflow: hidden;
  background: linear-gradient(160deg, #ffffff, #f7f9ff 65%, #eef2ff);
}
.timer-panel::after {
  content: "";
  position: absolute;
  width: 190px; height: 190px;
  inset-inline-end: -70px;
  top: -90px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(79, 110, 247, 0.14), transparent 68%);
  pointer-events: none;
}
.timer-head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}
.timer-icon {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  flex: 0 0 auto;
  border-radius: 12px;
  color: var(--accent-strong);
  background: rgba(79, 110, 247, 0.1);
  border: 1px solid rgba(79, 110, 247, 0.16);
}
.timer-icon svg { width: 19px; height: 19px; }
.timer-head-text { min-width: 0; }
.timer-head h3 { font-size: 14px; font-weight: 700; }
.timer-head p { margin-top: 1px; font-size: 10.5px; color: var(--muted); }

.timer-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-inline-start: auto;
  padding: 3px 8px;
  border-radius: 99px;
  background: rgba(15, 23, 42, 0.05);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}
.timer-status.is-running { color: #047857; background: rgba(16, 185, 129, 0.1); }
.timer-status.is-running::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--done);
  animation: timer-pulse 1.6s ease-in-out infinite;
}
@keyframes timer-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.timer-display {
  position: relative;
  z-index: 1;
  margin: 14px 0 8px;
  text-align: center;
  direction: ltr;
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.timer-panel.is-running .timer-display { color: var(--accent-strong); }

.timer-foot {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
}
.timer-today { font-size: 11.5px; color: var(--muted); }
.timer-btn { min-height: 40px; padding-inline: 16px; font-size: 13px; }
.timer-btn .timer-stop-icon { display: none; }
.timer-btn.is-running {
  background: linear-gradient(135deg, #fb7185, #e11d48);
  box-shadow: 0 10px 24px -12px rgba(225, 29, 72, 0.8);
}
.timer-btn.is-running .timer-play-icon { display: none; }
.timer-btn.is-running .timer-stop-icon { display: block; }

/* ===== לוח שנה ===== */
body.route-calendar .content { width: min(100% - 48px, 1400px); }

.calendar-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.calendar-stat {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.calendar-stat span { font-size: 11.5px; color: var(--muted); }
.calendar-stat b {
  display: block;
  margin-top: 2px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.weekly-plan-panel {
  padding: 18px 20px;
  margin-bottom: 16px;
}
.weekly-plan-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.weekly-plan-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.weekly-plan-icon {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  flex: 0 0 auto;
  border-radius: 11px;
  color: #16a34a;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.18);
}
.weekly-plan-icon svg { width: 18px; height: 18px; }
.weekly-plan-title h3 { font-size: 15px; font-weight: 700; }
.weekly-plan-title p { margin-top: 1px; font-size: 11.5px; color: var(--muted); }

.weekly-goal-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.weekly-goal-form label { font-size: 11.5px; color: var(--muted); }
.weekly-goal-form input {
  width: 82px;
  min-height: 34px;
  padding: 5px 8px;
  font-size: 13px;
  border-radius: 9px;
}

.weekly-progress-bar {
  height: 10px;
  margin-top: 14px;
  border-radius: 99px;
  background: rgba(34, 197, 94, 0.13);
  overflow: hidden;
}
.weekly-progress-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #4ade80, #22c55e);
  transition: width 0.35s ease;
}

.weekly-plan-hint {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 12px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--muted);
}
.weekly-plan-hint svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  margin-top: 2px;
  color: var(--accent-strong);
}

.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: start;
}

.calendar-panel { padding: 18px 20px; }
.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.calendar-head h3 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-align: center;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  padding: 0 2px 8px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.cal-day {
  position: relative;
  min-height: 82px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  color: inherit;
  overflow: hidden;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.cal-day:hover { border-color: var(--border-strong); background: #fbfcff; }
.cal-day.is-empty {
  min-height: 82px;
  background: transparent;
  border-color: transparent;
  cursor: default;
  pointer-events: none;
}
.cal-day-select {
  width: 100%;
  min-height: 80px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: right;
  cursor: pointer;
}
.cal-day-num {
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  font-variant-numeric: tabular-nums;
}
.cal-day-time {
  margin-top: auto;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-day.is-today {
  border-color: rgba(79, 110, 247, 0.45);
  box-shadow: inset 0 0 0 1px rgba(79, 110, 247, 0.3);
}
.cal-day.is-today .cal-day-num { color: var(--accent-strong); }
.cal-day.is-selected {
  border-color: rgba(79, 110, 247, 0.45);
  background: rgba(79, 110, 247, 0.16);
}
.cal-day.level-1 { background: rgba(79, 110, 247, 0.05); }
.cal-day.level-2 { background: rgba(79, 110, 247, 0.09); }
.cal-day.level-3 { background: rgba(79, 110, 247, 0.14); }
.cal-day.level-4 { background: rgba(79, 110, 247, 0.2); }
.cal-day.level-4 .cal-day-num { color: var(--accent-strong); }
.cal-day.is-planned { border-color: rgba(30, 144, 255, 0.3); }

.cal-day-plan {
  position: absolute;
  top: 6px;
  inset-inline-end: 6px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 18px; height: 18px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  color: #94a3b8;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.cal-day-plan svg {
  width: 10px; height: 10px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.cal-day:hover .cal-day-plan,
.cal-day-plan:focus-visible,
.cal-day-plan.is-planned { opacity: 1; }
.cal-day-plan:hover { border-color: var(--accent); color: var(--accent-strong); }
.cal-day-plan.is-planned {
  border-color: #1e90ff;
  background: #1e90ff;
  color: #ffffff;
}

.calendar-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  margin-top: 12px;
  font-size: 10px;
  color: var(--muted);
}
.legend-cell {
  width: 16px; height: 10px;
  border-radius: 3px;
  background: rgba(79, 110, 247, 0.05);
}
.legend-cell.level-1 { background: rgba(79, 110, 247, 0.05); }
.legend-cell.level-2 { background: rgba(79, 110, 247, 0.09); }
.legend-cell.level-3 { background: rgba(79, 110, 247, 0.14); }
.legend-cell.level-4 { background: rgba(79, 110, 247, 0.2); }

.calendar-day-panel {
  padding: 18px 20px;
  position: sticky;
  top: 16px;
}
.calendar-day-panel h3 { font-size: 15px; font-weight: 700; }
.calendar-day-total { margin-top: 2px; font-size: 12px; color: var(--muted); }
.calendar-day-sessions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}
.session-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.015);
}
.session-time {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.session-duration {
  margin-inline-start: auto;
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(79, 110, 247, 0.08);
  color: var(--accent-strong);
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}
.session-live {
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(16, 185, 129, 0.1);
  color: #047857;
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}
.session-row .icon-btn { width: 26px; height: 26px; border-radius: 7px; }
.session-row .icon-btn svg { width: 14px; height: 14px; }

.calendar-empty {
  padding: 20px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.015);
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
}

/* ===== מצב ריק ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  max-width: 860px;
  margin-inline: auto;
  padding: 44px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.6);
}
.empty-icon {
  display: grid;
  place-items: center;
  width: 58px; height: 58px;
  margin-bottom: 4px;
  border-radius: 18px;
  color: var(--accent);
  background: rgba(79, 110, 247, 0.08);
  border: 1px solid rgba(79, 110, 247, 0.18);
}
.empty-icon svg { width: 28px; height: 28px; }
.empty-state h2 { font-size: 18px; font-weight: 700; }
.empty-state .muted { max-width: 440px; font-size: 13.5px; }
.empty-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; justify-content: center; }

/* ===== מאמן אישי ===== */
body.route-topics .content { width: min(100% - 48px, 1560px); }
body.route-topics .page-head h2 { font-size: 26px; }
body.route-coach .app-footer { display: none; }
body.route-coach .main { height: 100vh; overflow: hidden; }
body.route-coach .content {
  width: 100%;
  max-width: none;
  padding: 0;
  flex: 1;
  min-height: 0;
  display: flex;
}
body.route-coach #view-coach {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.coach-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex: 0 0 auto;
  min-height: 64px;
  padding: 11px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.coach-topbar-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.coach-topbar h2 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.coach-topbar-sub {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.coach-history-btn svg { width: 17px; height: 17px; }

.coach-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}
.coach-layout.history-collapsed { grid-template-columns: minmax(0, 1fr); }
.coach-layout.history-collapsed .coach-side { display: none; }

.coach-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  padding: 14px;
}

.coach-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 6px 12px;
  border-bottom: 1px solid var(--border);
}
.coach-side-head h3 { font-size: 13.5px; font-weight: 700; }
.coach-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-strong);
  background: rgba(79, 110, 247, 0.1);
  padding: 1px 8px;
  border-radius: 99px;
  font-variant-numeric: tabular-nums;
}

.chat-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin-top: 8px;
  padding-inline-end: 2px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
}

.chat-list-empty {
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
  padding: 28px 10px;
  line-height: 1.7;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 10px;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.chat-item:hover { background: rgba(79, 110, 247, 0.05); }
.chat-item.active {
  background: rgba(79, 110, 247, 0.1);
  box-shadow: inset 0 0 0 1px rgba(79, 110, 247, 0.14);
}

.chat-item-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  text-align: right;
  cursor: pointer;
}
.chat-item-title {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-item-meta { font-size: 10.5px; color: var(--muted); }
.chat-item-delete {
  width: 28px;
  height: 28px;
  opacity: 0;
  flex: 0 0 auto;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.chat-item-delete svg { width: 14px; height: 14px; }
.chat-item:hover .chat-item-delete,
.chat-item.active .chat-item-delete,
.chat-item:focus-within .chat-item-delete { opacity: 1; }

.coach-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.coach-welcome {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  padding: 30px 24px;
}

.coach-orb {
  display: grid;
  place-items: center;
  width: 64px; height: 64px;
  margin-bottom: 6px;
  border-radius: 20px;
  color: var(--accent);
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.16), rgba(79, 110, 247, 0.16));
  border: 1px solid rgba(79, 110, 247, 0.18);
  box-shadow: 0 14px 30px -18px rgba(79, 110, 247, 0.6);
}
.coach-orb svg { width: 30px; height: 30px; }
.coach-welcome h3 { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; }
.coach-welcome p { max-width: 500px; font-size: 13.5px; line-height: 1.65; }

.coach-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: center;
  margin-top: 12px;
}
.suggestion {
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent-strong);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.suggestion:hover { background: rgba(79, 110, 247, 0.05); border-color: rgba(79, 110, 247, 0.4); }

.chat-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.02);
}
.chat-head-text { min-width: 0; }
.chat-head h3 {
  font-size: 15px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.chat-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-block: 18px;
  padding-inline: max(18px, calc((100% - 880px) / 2));
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.msg { display: flex; gap: 9px; align-items: flex-start; max-width: 100%; }
.msg-user { justify-content: flex-end; }

.msg-avatar {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  flex: 0 0 auto;
  border-radius: 10px;
  color: #ffffff;
  font-size: 14px;
  background: linear-gradient(135deg, #2dd4bf, var(--accent));
  box-shadow: 0 6px 14px -8px rgba(79, 110, 247, 0.7);
}

.msg-bubble {
  max-width: min(86%, 680px);
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.msg-assistant .msg-bubble {
  background: #ffffff;
  border: 1px solid var(--border);
  border-start-start-radius: 6px;
}
.msg-user .msg-bubble {
  background: linear-gradient(135deg, #eef2ff, #e9efff);
  border: 1px solid rgba(79, 110, 247, 0.18);
  color: #1e293b;
  border-start-end-radius: 6px;
}

.msg-role {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent-strong);
  margin-bottom: 4px;
}
.msg-user .msg-role { color: #64748b; }

.msg-time {
  display: block;
  margin-top: 6px;
  font-size: 10px;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
}

.msg-text { white-space: normal; }

/* Markdown בתוך בועת המאמן */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 8px; }
.md h3, .md h4, .md h5, .md h6 {
  margin: 13px 0 6px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.4;
}
.md h3 { font-size: 15px; }
.md ul, .md ol { margin: 6px 0 9px; padding-inline-start: 20px; }
.md li { margin: 2px 0; }
.md strong { font-weight: 800; }
.md code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  direction: ltr;
  unicode-bidi: isolate;
  background: rgba(15, 23, 42, 0.06);
  padding: 1px 5px;
  border-radius: 5px;
}
.md pre {
  margin: 9px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #0f172a;
  color: #e2e8f0;
  overflow-x: auto;
  direction: ltr;
  text-align: left;
}
.md pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-size: 12px;
  line-height: 1.55;
}
.md blockquote {
  margin: 8px 0;
  padding: 2px 10px;
  border-inline-start: 3px solid rgba(79, 110, 247, 0.3);
  color: #475569;
}

.typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-top: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.015);
  font-size: 12.5px;
  color: var(--muted);
  flex: 0 0 auto;
}
.typing-avatar {
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  border-radius: 8px;
  color: #ffffff;
  font-size: 11px;
  background: linear-gradient(135deg, #2dd4bf, var(--accent));
}
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: typing-blink 1.2s infinite ease-in-out;
}
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-blink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

.chat-composer {
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  padding-block: 12px 10px;
  padding-inline: max(16px, calc((100% - 880px) / 2));
  background: rgba(255, 255, 255, 0.65);
}

.coach-topic-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.coach-topic-row label {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}
.coach-topic-row select {
  width: auto;
  max-width: 340px;
  flex: 1 1 180px;
  min-height: 32px;
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 9px;
  background: #ffffff;
}

.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.composer-box:focus-within {
  border-color: rgba(79, 110, 247, 0.55);
  box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.12);
}
.composer-box textarea {
  flex: 1;
  min-height: 40px;
  max-height: 140px;
  padding: 7px 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  resize: none;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: none;
}
.composer-box textarea:focus { border: 0; box-shadow: none; background: transparent; }

.send-btn {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 11px;
  color: #ffffff;
  background: linear-gradient(135deg, #6d8bff, var(--accent));
  box-shadow: 0 8px 18px -9px rgba(79, 110, 247, 0.9);
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.12s ease, opacity 0.15s ease;
}
.send-btn svg { width: 19px; height: 19px; }
.send-btn:hover { filter: brightness(1.06); }
.send-btn:active { transform: translateY(1px); }
.send-btn:disabled { opacity: 0.55; cursor: progress; }

.composer-hint {
  margin-top: 5px;
  padding-inline-start: 3px;
  font-size: 10.5px;
  color: #94a3b8;
}

/* ===== פרופיל ===== */
.profile-hero {
  position: relative;
  overflow: hidden;
  padding: 0;
  background: #ffffff;
}

.profile-cover {
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 112px;
  overflow: hidden;
  background: linear-gradient(120deg, rgba(45, 212, 191, 0.16), rgba(79, 110, 247, 0.18) 55%, rgba(124, 156, 255, 0.12));
}
.profile-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.65) 1px, transparent 1px);
  background-size: 14px 14px;
  opacity: 0.35;
  mask-image: linear-gradient(to bottom, #000 10%, transparent 96%);
  -webkit-mask-image: linear-gradient(to bottom, #000 10%, transparent 96%);
}
.cover-orb { position: absolute; border-radius: 50%; }
.cover-orb.one {
  width: 220px; height: 220px;
  inset-inline-start: -60px;
  top: -120px;
  background: rgba(79, 110, 247, 0.14);
}
.cover-orb.two {
  width: 160px; height: 160px;
  inset-inline-end: 26%;
  top: -80px;
  background: rgba(45, 212, 191, 0.16);
}

.profile-hero-inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 64px 26px 24px;
}

.avatar-xl {
  width: 92px; height: 92px;
  border-radius: 26px;
  font-size: 32px;
  border: 4px solid #ffffff;
  box-shadow: 0 18px 34px -18px rgba(15, 23, 42, 0.45);
}

.profile-hero-text { flex: 1 1 300px; min-width: 0; }
.profile-name-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.profile-name-row h3 {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.profile-badge {
  font-size: 10.5px;
  font-weight: 700;
  color: #047857;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.22);
  padding: 2px 8px;
  border-radius: 99px;
  white-space: nowrap;
}
.profile-handle { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.profile-bio {
  margin-top: 8px;
  font-size: 13.5px;
  line-height: 1.6;
  color: #475569;
  max-width: 560px;
  overflow-wrap: anywhere;
}
.profile-bio.is-placeholder { color: var(--muted); font-style: italic; }
.profile-meta { margin-top: 7px; font-size: 11.5px; color: var(--muted); }

.profile-metrics {
  flex: 0 1 430px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.profile-metric { position: relative; min-width: 0; padding: 5px 10px; }
.profile-metric + .profile-metric::before {
  content: "";
  position: absolute;
  inset-block: 6px;
  inset-inline-start: 0;
  width: 1px;
  background: var(--border);
}
.metric-label {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-metric b {
  display: block;
  margin-top: 2px;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.is-green { color: var(--done); }
.is-accent { color: var(--accent-strong); }

.profile-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.profile-panel { padding: 22px; margin-top: 16px; }
.profile-columns .profile-panel { margin-top: 0; }

.section-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}
.section-icon {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  flex: 0 0 auto;
  border-radius: 12px;
  color: var(--accent-strong);
  background: rgba(79, 110, 247, 0.08);
  border: 1px solid rgba(79, 110, 247, 0.14);
}
.section-icon svg { width: 19px; height: 19px; }
.section-head-text { min-width: 0; }
.section-head-text h3 { font-size: 15px; font-weight: 700; line-height: 1.35; }
.section-head-text p { margin-top: 2px; font-size: 11.5px; color: var(--muted); line-height: 1.5; }

.profile-panel form { display: flex; flex-direction: column; gap: 16px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.field-full { grid-column: 1 / -1; }
.profile-panel textarea { min-height: 96px; }

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.form-hint { margin: 0; font-size: 11.5px; color: var(--muted); }

.password-form { display: flex; flex-direction: column; gap: 16px; }
.password-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.subject-progress-list { display: flex; flex-direction: column; gap: 10px; }
.subject-progress-item {
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.018);
}
.subject-progress-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
}
.subject-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.subject-percent {
  flex: 0 0 auto;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent-strong);
  background: rgba(79, 110, 247, 0.08);
  padding: 1px 7px;
  border-radius: 99px;
  font-variant-numeric: tabular-nums;
}
.subject-progress-item .mini-bar { width: 100%; height: 6px; }
.subject-progress-meta {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

.profile-empty {
  padding: 22px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.015);
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
}

/* ===== כותרת תחתונה ===== */
.app-footer {
  padding: 26px 4px 30px;
  text-align: center;
  font-size: 12px;
  color: #7c8ba1;
}
.app-footer code { direction: ltr; unicode-bidi: isolate; }

/* ===== דיאלוג ===== */
.edit-dialog {
  width: min(100% - 32px, 480px);
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  background: var(--panel-solid);
  color: var(--text);
  box-shadow: 0 40px 90px -20px rgba(15, 23, 42, 0.5);
}
.edit-dialog::backdrop {
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(3px);
}
.edit-dialog[open] { animation: dialog-in 0.18s ease both; }
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.dialog-head h2 { font-size: 16px; font-weight: 700; }
.dialog-body { display: flex; flex-direction: column; gap: 12px; padding: 18px 20px; }
.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border);
}

/* ===== טוסט ===== */
.toast {
  position: fixed;
  inset-inline: 0;
  bottom: 22px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 14px;
  width: fit-content;
  max-width: calc(100% - 32px);
  margin-inline: auto;
  padding: 11px 16px;
  font-size: 13.5px;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 20px 45px -16px rgba(15, 23, 42, 0.35);
  animation: toast-in 0.22s ease both;
}
.toast.is-error {
  border-color: rgba(225, 29, 72, 0.45);
  background: #fff5f7;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.toast-action {
  padding: 2px 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.toast-action:hover { background: rgba(79, 110, 247, 0.1); }

/* ===== רספונסיביות ===== */
@media (max-width: 900px) {
  .app-shell { display: block; }

  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: min(86vw, 320px);
    height: 100%;
    margin: 0;
    padding-top: calc(18px + env(safe-area-inset-top));
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
    border: 0;
    border-radius: 0;
    transform: translateX(100%);
    transition: transform 0.24s ease;
    box-shadow: -24px 0 60px -24px rgba(15, 23, 42, 0.5);
    background: #ffffff;
  }
  .sidebar.open { transform: none; }

  .sidebar-close {
    display: grid;
    top: calc(10px + env(safe-area-inset-top));
    inset-inline-end: 12px;
  }

  .drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(2px);
  }

  body.drawer-open { overflow: hidden; }

  .mobile-topbar { display: flex; }

  .content { width: min(100% - 32px, 1040px); padding-top: 18px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  body.route-calendar .content { width: min(100% - 32px, 1400px); }

  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    font-size: 16px !important;
    min-height: 44px;
  }
  .btn { min-height: 44px; }
  .btn.small { min-height: 38px; }
  .add-grid .add-btn { min-height: 44px; }
  .chip, .suggestion { min-height: 38px; }
  .nav-link { min-height: 48px; }
  .composer-box textarea { min-height: 44px; }
  .send-btn { width: 44px; height: 44px; }
  .avatar-edit { width: 36px; height: 36px; }
  .calendar-head .icon-btn { width: 40px; height: 40px; }
  .topic-actions .icon-btn { width: 36px; height: 36px; }
  .subtopic .icon-btn { width: 32px; height: 32px; }
  .group-collapse { width: 36px; height: 36px; }
  .topic-collapse { width: 32px; height: 32px; }
  .sub-collapse, .sub-collapse-spacer { width: 30px; height: 30px; }
  .group-add-btn { min-height: 38px; }
  .sub-add-btn { min-height: 36px; }
  .cal-day-plan { width: 22px; height: 22px; }
  .session-row .icon-btn { width: 34px; height: 34px; }
  .chat-item-delete { width: 34px; height: 34px; }
  .toast { bottom: calc(18px + env(safe-area-inset-bottom)); }
  .app-footer { padding-bottom: calc(30px + env(safe-area-inset-bottom)); }
  .chat-composer { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }

  .profile-columns { grid-template-columns: 1fr; }
  .profile-metrics { flex: 1 1 100%; }
  .password-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .calendar-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .timer-display { font-size: 38px; }

  body.route-coach .main { height: 100vh; height: 100dvh; }

  .coach-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: 8px;
    position: relative;
  }
  .coach-side {
    position: absolute;
    inset-block: 8px;
    inset-inline-start: 8px;
    width: min(82vw, 300px);
    height: auto;
    min-height: 0;
    max-height: none;
    z-index: 10;
    background: #ffffff;
    box-shadow: 0 24px 60px -24px rgba(15, 23, 42, 0.5);
  }
  .coach-layout.history-collapsed .coach-side { display: none; }
  .chat-list { max-height: none; }
  .coach-main { height: 100%; min-height: 0; max-height: none; }
  .chat-messages {
    max-height: none;
    padding-block: 14px;
    padding-inline: 14px;
  }
  .msg-bubble { max-width: 92%; }

  .coach-topbar { min-height: 54px; padding: 9px 12px; gap: 10px; }
  .coach-topbar-sub { display: none; }
  .coach-topbar h2 { font-size: 16px; }

  .page-head { align-items: flex-start; }
  .page-head h2 { font-size: 21px; }
  body.route-topics .page-head h2 { font-size: 21px; }
  .date-chip { display: none; }
}

@media (max-width: 1200px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .calendar-layout { grid-template-columns: 1fr; }
  .calendar-day-panel { position: static; }
}

@media (max-width: 1150px) {
  #groups { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .add-grid .field { flex: 1 1 100%; }
  .add-grid .add-btn { flex: 1 1 100%; }
  .progress-panel { grid-template-columns: 1fr; gap: 18px; padding: 20px; }
  .ring { justify-self: center; width: 104px; height: 104px; }
  .ring-label { font-size: 25px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 10px 12px; }
  .stat b { font-size: 22px; }
  .stat:nth-child(3) { border-inline-start: 0; border-block-start: 1px solid var(--border); }
  .stat:nth-child(4) { border-block-start: 1px solid var(--border); }
  .toolbar-selects { width: 100%; }
  .toolbar-selects .select-wrap { flex: 1; }
  .toolbar-selects select { max-width: none; }
  .topic { padding: 13px 14px; gap: 11px; }
  .topic-actions { opacity: 1; }
  .subtopic-children { margin-inline-start: 4px; padding-inline-start: 8px; }
  .group-head { padding: 12px 14px; }
  .group-add-form { padding: 10px 14px; }
  .mini-bar { width: 54px; }
  .profile-hero-inner { padding: 54px 18px 18px; gap: 14px; }
  .avatar-xl { width: 74px; height: 74px; border-radius: 21px; font-size: 26px; }
  .profile-name-row h3 { font-size: 20px; }
  .profile-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px;
    padding: 6px;
  }
  .profile-metric { padding: 6px 10px; }
  .profile-metric + .profile-metric::before { display: none; }
  .profile-panel { padding: 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .password-fields { grid-template-columns: 1fr; }
  .section-head { margin-bottom: 14px; }

  .page-head-actions { width: 100%; justify-content: flex-start; }
  .coach-topbar .page-head-actions {
    width: auto;
    margin-inline-start: auto;
    justify-content: flex-end;
    flex-wrap: nowrap;
  }
  .coach-main { min-height: 0; }
  .chat-head { padding: 12px 14px; }
  .chat-messages { padding: 14px; }
  .chat-composer { padding: 10px 12px calc(8px + env(safe-area-inset-bottom)); }
  .coach-welcome { padding: 24px 16px; }
  .coach-welcome h3 { font-size: 19px; }

  .timer-display { font-size: 36px; }
  .timer-foot { flex-wrap: wrap; }
  .timer-btn { flex: 1 1 100%; }

  .edit-dialog { max-height: calc(100dvh - 24px); overflow-y: auto; }
  .dialog-body { padding: 14px; }

  .calendar-panel { padding: 12px; }
  .calendar-weekdays { gap: 4px; font-size: 10px; padding-bottom: 6px; }
  .calendar-grid { gap: 4px; }
  .weekly-plan-panel { padding: 14px; }
  .weekly-plan-head { align-items: flex-start; }
  .weekly-goal-form { width: 100%; }
  .weekly-goal-form input { flex: 1 1 60px; }
  .cal-day { min-height: 58px; padding: 0; border-radius: 8px; }
  .cal-day.is-empty { min-height: 58px; }
  .cal-day-select { min-height: 56px; padding: 5px; gap: 2px; }
  .cal-day-plan { top: 4px; inset-inline-end: 4px; width: 22px; height: 22px; }
  .cal-day-num { font-size: 11px; }
  .cal-day-time { font-size: 9px; }
  .calendar-stat { padding: 10px 12px; }
  .calendar-stat b { font-size: 18px; }
  .calendar-day-panel { padding: 16px; }
  .calendar-legend { justify-content: center; }
}

@media (max-width: 520px) {
  .coach-topbar .model-chip { display: none; }
  .coach-history-btn span { display: none; }
  .coach-history-btn { padding: 9px 10px; }
}

@media (max-width: 420px) {
  .stat-label { font-size: 11px; }
  .subtopic-actions { opacity: 1; }
  .subtopic-child-count { display: none; }
}

@media (max-width: 360px) {
  .cal-day-plan { top: 2px; inset-inline-end: 2px; width: 18px; height: 18px; }
}

@media (hover: none) {
  .topic-actions,
  .subtopic-actions { opacity: 1; }
  .chat-item-delete { opacity: 1; }
  .cal-day-plan { opacity: 0.85; }
}

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