:root {
  /* Cyber-dark brand system: deep OLED navy canvas with a single
     violet -> cyan gradient identity (per brand spec). */
  --bg: #06060a;
  --surface: rgba(18, 18, 30, 0.6);
  --surface-2: rgba(18, 18, 30, 0.85);
  --surface-elevated: linear-gradient(145deg, rgba(18, 18, 30, 0.92), rgba(9, 10, 18, 0.78));
  --surface-soft: rgba(255,255,255,0.05);
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.14);
  --text: #eef2ff;
  --text-strong: #ffffff;
  --text-muted: rgba(238,242,255,0.68);
  --cyan: #06b6d4;
  --violet: #8b5cf6;
  --coral: #06b6d4;
  --coral-soft: rgba(6,182,212,0.14);
  --violet-soft: rgba(139,92,246,0.14);
  --cyan-soft: rgba(6,182,212,0.14);
  --success: #4ade80;
  --danger: #f87171;
  --font-display: "Sora", "Plus Jakarta Sans", sans-serif;
  --font-body: "Plus Jakarta Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", monospace;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --glow-cyan: 0 12px 30px rgba(6, 182, 212, 0.2);
  --glow-violet: 0 14px 34px rgba(139, 92, 246, 0.22);
  --glow-coral: 0 12px 30px rgba(6, 182, 212, 0.2);
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.32);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  scroll-behavior: smooth;
  overflow-x: hidden;
}

html {
  background: var(--bg);
}

body {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  background-color: var(--bg);
  /* faint chalk-dust / graph-paper grain, reinforces the "study room" feel */
  background-image: radial-gradient(rgba(238,242,255,0.035) 1px, transparent 1px);
  background-size: 24px 24px;
}

body::before,
body::after {
  content: "";
  position: fixed;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  filter: blur(150px);
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
}
body::before { top: -120px; left: -140px; background: rgba(139,92,246,0.3); }
body::after { right: -120px; bottom: -120px; background: rgba(6,182,212,0.24); }

::selection { background: rgba(139,92,246,0.35); color: #04040a; }

.hidden { display: none !important; }
button, input, textarea, select { font-family: inherit; }
button { cursor: pointer; }
input, textarea, select {
  outline: none;
  color: var(--text);
  background: rgba(6, 8, 18, 0.82);
  border: 1px solid rgba(238,242,255,0.16);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
input::placeholder, textarea::placeholder { color: rgba(238,242,255,0.55); }
input:focus, textarea:focus, select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px var(--cyan-soft), inset 0 1px 0 rgba(255,255,255,0.04);
}

code { font-family: var(--font-mono); background: rgba(255,255,255,0.05); padding: 2px 6px; border-radius: 6px; color: var(--cyan); }

@keyframes fadeInUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes typingDot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes blinkCursor { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes skeletonWave { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* Buttons */
.btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-weight: 700;
  font-size: 14px;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
  letter-spacing: 0.01em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.16);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(0.98); }
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--cyan-soft), inset 0 1px 0 rgba(255,255,255,0.16);
}

.btn-primary {
  background: linear-gradient(135deg, var(--violet), var(--coral));
  color: #04040a;
  box-shadow: var(--glow-violet), inset 0 1px 0 rgba(255,255,255,0.28);
}
.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 16px 40px rgba(6, 182, 212, 0.35), inset 0 1px 0 rgba(255,255,255,0.28);
}

.btn-ghost {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-muted);
}
.btn-ghost:hover { color: var(--text); border-color: rgba(139,92,246,0.45); box-shadow: var(--glow-violet); }

.btn.full { width: 100%; }

.link-btn { background: transparent; border: none; color: var(--text-muted); font-size: 12px; text-decoration: underline; padding: 0; }
.link-btn:hover { color: var(--cyan); }

/* Auth Screen */
.auth-screen {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 28px;
  position: relative;
  z-index: 1;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--glow-violet), var(--shadow-soft);
  backdrop-filter: blur(14px);
  animation: fadeInUp 0.5s ease;
}

.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 30px; }
.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  color: #fff;
  font-weight: 800;
  box-shadow: var(--glow-violet), inset 0 1px 0 rgba(255,255,255,0.25);
}
.brand-mark svg {
  width: 22px;
  height: 22px;
}
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 20px; letter-spacing: -0.02em; }
.brand-name em { font-style: normal; color: var(--cyan); }

.auth-tabs { display: flex; gap: 6px; background: rgba(255,255,255,0.04); padding: 6px; border-radius: 20px; margin-bottom: 22px; }
.auth-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 12px 0;
  border-radius: var(--radius-md);
  font-weight: 700;
  transition: all 0.25s ease;
}
.auth-tab.active { background: rgba(255,255,255,0.06); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }

.auth-form { display: none; flex-direction: column; gap: 16px; }
.auth-form.active { display: flex; }

.auth-form label { color: var(--text-muted); font-size: 12px; display: flex; flex-direction: column; gap: 8px; }
.auth-form input {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  color: var(--text);
  transition: all 0.3s ease;
}
.auth-form input:focus { border-color: var(--cyan); box-shadow: 0 0 0 4px var(--cyan-soft); }

.auth-msg { font-size: 13px; min-height: 18px; margin: 0; color: var(--danger); }
.auth-msg.success { color: var(--success); }

#guest-btn { margin-top: 20px; }

/* App Shell */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Topbar: premium sticky glass navigation */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px clamp(16px, 3vw, 32px);
  background: rgba(6, 6, 10, 0.7);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
  will-change: transform;
}
.topbar.nav-hidden { transform: translateY(-100%); }
@media (prefers-reduced-motion: reduce) {
  .topbar { transition: none; }
}
.topbar-brand { margin-bottom: 0; flex-shrink: 0; }
.topbar-brand .brand-mark { width: 38px; height: 38px; border-radius: 12px; }
.topbar-brand .brand-mark svg { width: 20px; height: 20px; }
.topbar-brand .brand-name { font-size: 16px; }

/* Centered app navigation inside the topbar */
.topnav {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
}

.topnav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13.5px;
  padding: 10px 14px;
  white-space: nowrap;
  transition: all 0.3s ease;
}

.topnav-link svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: all 0.3s ease;
}

.topnav-link::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 4px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--violet), var(--cyan));
  box-shadow: 0 0 10px rgba(6,182,212,0.55);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.3s ease;
}

.topnav-link:hover {
  color: #fff;
  background: rgba(238,242,255,0.05);
}

.topnav-link:hover::after { transform: scaleX(1); }

.topnav-link:hover svg {
  opacity: 1;
  color: var(--cyan);
}

.topnav-link.active {
  color: #fff;
  background: rgba(139,92,246,0.1);
}

.topnav-link.active::after { transform: scaleX(1); }

.topnav-link.active svg {
  opacity: 1;
  color: var(--cyan);
}


.topbar-right { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }

.lang-select {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 999px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.25s ease;
}
.lang-select:hover, .lang-select:focus { border-color: rgba(139,92,246,0.45); box-shadow: var(--glow-violet); outline: none; }
.lang-select option { background: #0d0d14; color: var(--text); }

/* Hands-free voice-mode toggle in the topbar */
.voice-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  transition: all 0.25s ease;
}
.voice-mode-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.voice-mode-btn:hover { color: #fff; border-color: rgba(139,92,246,0.45); box-shadow: var(--glow-violet); }
.voice-mode-btn.active {
  color: #fff;
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  border-color: transparent;
  box-shadow: var(--glow-violet);
}

.topbar .user-chip { display: flex; align-items: center; gap: 12px; }
.topbar .avatar { width: 40px; height: 40px; font-size: 15px; }
.topbar .user-info { align-items: flex-start; }
.topbar #user-name { font-size: 14px; }
.topbar .link-btn { font-size: 11px; text-decoration: none; color: var(--text-muted); }
.topbar .link-btn:hover { color: var(--danger); }

@media (max-width: 560px) {
  .topbar { padding: 14px 18px; }
  .topbar-brand .brand-name { display: none; }
}

/* Dashboard secondary chart grid */
.dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; margin-top: 22px; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }

.chart-panel { display: flex; flex-direction: column; }
.bar-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  height: 200px;
  padding-top: 10px;
}
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 1; min-width: 0; height: 100%; justify-content: flex-end; }
.bar-value, .bar-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track {
  width: 100%;
  max-width: 34px;
  height: 140px;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}
.bar-fill {
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--cyan), var(--violet));
  box-shadow: var(--glow-cyan);
  transition: height 0.6s cubic-bezier(0.4,0,0.2,1);
}
.bar-value { font-size: 11px; color: var(--text-muted); font-weight: 700; }
.bar-label { font-size: 12px; color: rgba(255,255,255,0.6); }

.progress-panel { display: flex; flex-direction: column; align-items: center; text-align: center; }
.donut-wrap { position: relative; width: 150px; height: 150px; margin: 6px auto 18px; }
.donut { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut-track { fill: none; stroke: rgba(255,255,255,0.08); stroke-width: 10; }
.donut-value { fill: none; stroke: url(#donutGradientFallback); stroke: var(--violet); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 0.8s ease; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-percent { font-family: var(--font-display); font-size: 28px; font-weight: 800; color: #fff; }
.donut-caption { font-size: 12px; color: var(--text-muted); }

.legend-list { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 12px; }
.legend-list li { display: flex; align-items: center; gap: 10px; font-size: 13px; color: rgba(255,255,255,0.82); background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px 14px; overflow: hidden; }
.legend-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-list li b { margin-left: auto; flex-shrink: 0; white-space: nowrap; padding-left: 8px; color: #fff; }
.legend-dot { width: 10px; height: 10px; border-radius: 999px; flex-shrink: 0; }
.dot-violet { background: var(--violet); box-shadow: 0 0 10px rgba(139,92,246,0.5); }
.dot-cyan { background: var(--cyan); box-shadow: 0 0 10px rgba(6,182,212,0.5); }
.dot-muted { background: rgba(255,255,255,0.4); }

/* Bottom app-like navbar for mobile */
.bottom-nav {
  display: flex;
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 20px;
  width: min(94vw, 760px);
  background: rgba(8, 8, 14, 0.86);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  gap: 8px;
  z-index: 9999;
  box-shadow: var(--glow-violet), var(--shadow-soft);
  backdrop-filter: blur(14px);
  align-items: center;
  pointer-events: auto;
  touch-action: manipulation;
}
.bottom-nav .nav-action { background: transparent; border: none; color: var(--text-muted); padding: 10px 8px; border-radius: var(--radius-md); display:flex; gap:8px; align-items:center; flex-direction:column; flex: 1; min-width:0; transition: all 0.3s ease; }
.bottom-nav .nav-action .nav-icon { width: 24px; height: 24px; }
.bottom-nav .nav-action .nav-label { display:block; font-size:11px; margin-top:4px; color:var(--text-muted); font-weight:700; }
.bottom-nav .nav-action.active { background: linear-gradient(180deg, rgba(139,92,246,0.12), rgba(6,182,212,0.06)); color:var(--text); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06); }
.bottom-nav .nav-action { cursor: pointer; }
.bottom-nav .nav-action:hover { transform: translateY(-2px); }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .main-content { padding-bottom: 120px; }
}

@media (min-width: 901px) {
  .app-shell { grid-template-columns: 1fr; }
  .main-content { padding-bottom: 110px; }
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 30px 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  backdrop-filter: blur(12px);
}

.sidebar-brand { display: flex; align-items: center; gap: 12px; padding-bottom: 28px; }
.sidebar-brand .brand-name { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }

.sidebar-nav { display: flex; flex-direction: column; gap: 10px; flex: 1; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  padding: 14px 16px;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
}
.nav-item:hover { transform: translateX(2px); background: rgba(255,255,255,0.06); color: var(--text); border-color: rgba(139,92,246,0.3); box-shadow: var(--glow-violet); }

.nav-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 4px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--violet), var(--cyan));
  opacity: 0;
  transform: scaleY(0.8);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.nav-item.active::before { opacity: 1; transform: scaleY(1); }
.nav-item.active { background: var(--violet-soft); color: var(--text); box-shadow: var(--glow-violet); border-color: rgba(139,92,246,0.3); }

.nav-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; flex-shrink: 0; }
.nav-sub { margin-left: auto; font-size: 10px; color: var(--text-muted); line-height: 1.1; }

.sidebar-footer { border-top: 1px solid var(--border); padding-top: 22px; margin-top: 24px; }
.user-chip { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  color: #04040a;
  font-weight: 700;
  box-shadow: var(--glow-cyan);
}
.user-info { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
#user-name { font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Main content */
/* width: 100% is required here, not just reliance on flex stretch:
   .main-content is a flex item of .app-shell (column direction, width is
   the cross axis). A wide descendant many levels down (the activity
   table's min-width:460px) was still forcing this box to its content's
   width instead of the container's, even with min-width:0 set — an
   explicit width removes the ambiguity outright. Without this, content
   renders past the right edge and gets silently clipped by overflow-x. */
.main-content { width: 100%; padding: 32px 42px; max-width: 1320px; margin: 0 auto; overflow-x: hidden; min-width: 0; box-sizing: border-box; }

.view { display: none; animation: fadeInUp 0.35s ease both; }
.view.active { display: block; }

.view-header { margin-bottom: 30px; padding-top: 6px; }
.view-header h1 {
  font-size: 34px;
  letter-spacing: -0.03em;
  color: var(--text-strong);
  margin-bottom: 8px;
  display: inline-block;
}
.view-header h1::after {
  content: "";
  display: block;
  width: 72px;
  height: 3px;
  margin-top: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--violet), var(--cyan));
}
.view-sub, .view-sub-inline { color: var(--text-muted); font-size: 14px; margin-top: 8px; line-height: 1.7; }
.view-sub-inline { display: inline-block; margin-left: 10px; font-weight: 400; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 28px; }
.stat-card {
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 24px 26px;
  box-shadow: var(--glow-violet), var(--shadow-soft);
  transition: all 0.3s ease;
  backdrop-filter: blur(14px);
  color: var(--text);
}
.stat-card:hover { transform: translateY(-4px); border-color: rgba(139,92,246,0.6); box-shadow: 0 12px 30px rgba(6, 182, 212, 0.2), var(--shadow-soft); }
.stat-label { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(238,242,255,0.68); }
.stat-value { font-family: var(--font-display); font-size: 28px; font-weight: 800; color: #fff; }
.accent-cyan { color: var(--cyan); }
.accent-violet { color: var(--violet); }

.panel {
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 32px;
  box-shadow: var(--glow-violet), var(--shadow-soft);
  backdrop-filter: blur(14px);
  overflow: hidden;
  position: relative;
}
.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--violet), var(--cyan));
  opacity: 0.8;
}
.panel h2 { font-size: 18px; margin-bottom: 24px; color: #fff; }

.panel table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 10px;
  /* Bootstrap paints every cell with --bs-table-bg (white by default) —
     neutralize it so our glassmorphic row styling shows through. */
  --bs-table-bg: transparent;
  --bs-table-color: #f4f4f6;
  --bs-table-border-color: transparent;
  --bs-table-hover-bg: transparent;
  --bs-table-hover-color: #fff;
}
.panel th,
.panel td {
  padding: 14px 16px;
  text-align: left;
  font-size: 14px;
  color: #f4f4f6;
}
.panel thead th {
  color: rgba(255,255,255,0.76);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  background: transparent;
  border: none;
}
/* Glassmorphic rows: the radius and borders live on the cells, because
   border-radius on <tr> is ignored with border-collapse: separate. */
.panel tbody tr td {
  background: rgba(18, 18, 30, 0.4);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: #f4f4f6;
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, color 0.3s ease;
}
.panel tbody tr td:first-child {
  border-left: 1px solid rgba(255, 255, 255, 0.05);
  border-top-left-radius: 12px;
  border-bottom-left-radius: 12px;
}
.panel tbody tr td:last-child {
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  border-top-right-radius: 12px;
  border-bottom-right-radius: 12px;
}
.panel tbody tr:hover td {
  background: rgba(139, 92, 246, 0.08);
  border-color: rgba(139, 92, 246, 0.28);
  box-shadow: 0 6px 18px rgba(6, 182, 212, 0.1);
  color: #fff;
}

.status-pill { min-width: 96px; }

.diagram-wrap {
  position: relative;
  min-height: 360px;
  width: 100%;
  border-radius: var(--radius-md);
  background: radial-gradient(circle at top left, rgba(139,92,246,0.08), transparent 24%),
              radial-gradient(circle at bottom right, rgba(6,182,212,0.08), transparent 22%),
              var(--surface);
  overflow: hidden;
  border: 1px solid var(--border);
}

.diagram-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent 55%);
  pointer-events: none;
}

.diagram-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.diagram-canvas path {
  fill: none;
  stroke: rgba(139,92,246,0.78);
  stroke-width: 3;
  stroke-linecap: round;
  filter: drop-shadow(0 0 10px rgba(139,92,246,0.25));
}
.diagram-canvas marker path { opacity: 0.9; }

.skill-node {
  position: absolute;
  width: 160px;
  min-height: 98px;
  padding: 18px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: var(--glow-violet);
  backdrop-filter: blur(14px);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), border-color 0.3s ease, box-shadow 0.3s ease;
}
.skill-node:hover { transform: translateY(-4px) scale(1.02); border-color: rgba(139,92,246,0.7); box-shadow: 0 12px 30px rgba(6, 182, 212, 0.2); }

.skill-node .node-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  box-shadow: 0 0 16px rgba(139,92,246,0.35), 0 0 22px rgba(6,182,212,0.18);
  margin-bottom: 12px;
}

.skill-node .node-label { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.skill-node .node-meta { font-size: 12px; color: rgba(255,255,255,0.72); line-height: 1.5; }
.skill-node::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 3px rgba(139,92,246,0.08);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.skill-node:hover::after { opacity: 1; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
}
.status-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
}
.status-today::before { background: var(--success); box-shadow: 0 0 10px rgba(74,222,128,0.35); }
.status-yesterday::before { background: var(--cyan); box-shadow: 0 0 10px rgba(6,182,212,0.35); }
.status-old::before { background: var(--violet); box-shadow: 0 0 10px rgba(139,92,246,0.28); }

.search-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 22px;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-soft);
}
.search-bar:focus-within { border-color: var(--cyan); box-shadow: 0 0 0 4px var(--cyan-soft), var(--shadow-soft); }
.search-icon { width: 18px; height: 18px; fill: none; stroke: rgba(255,255,255,0.74); flex-shrink: 0; }
.search-bar input { flex: 1; background: transparent; border: none; outline: none; color: var(--text); font-size: 15px; min-width: 0; box-shadow: none; }
.search-bar input::placeholder { color: rgba(255,255,255,0.55); }

.sample-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
  transition: opacity 0.28s ease, transform 0.28s ease;
}
/* Collapses (fade + lift) when a search starts; .hidden lands after the fade */
.sample-topics.collapsed {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}
.sample-topic-btn {
  flex: 1 1 calc(50% - 16px);
  max-width: calc(50% - 16px);
  min-width: 240px;
  min-height: 136px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 18px;
  text-align: left;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
  color: var(--text);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sample-topics-header {
  width: 100%;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

@media (max-width: 760px) {
  .sample-topic-btn {
    flex: 1 1 100%;
    max-width: 100%;
  }
}
.sample-topic-btn:hover { transform: translateY(-4px); border-color: rgba(6,182,212,0.35); box-shadow: var(--glow-cyan); background: rgba(6,182,212,0.08); }
.sample-topic-title { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.sample-topic-desc { color: rgba(255,255,255,0.72); font-size: 13px; line-height: 1.7; }

.lesson-result { display: flex; flex-direction: column; gap: 22px; }
.lesson-card {
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 28px;
  box-shadow: var(--glow-violet), var(--shadow-soft);
  backdrop-filter: blur(14px);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}
.lesson-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--violet), var(--cyan));
  opacity: 0.9;
}
.lesson-card:hover { transform: translateY(-4px); border-color: rgba(139,92,246,0.6); box-shadow: 0 12px 30px rgba(6, 182, 212, 0.2), var(--shadow-soft); }
.lesson-card h3 { font-size: 22px; margin-bottom: 12px; color: #fff; }
.lesson-source-tag { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-family: var(--font-mono); padding: 7px 12px; border-radius: 999px; background: rgba(139,92,246,0.16); color: #e9d5ff; border: 1px solid rgba(139,92,246,0.28); margin-bottom: 18px; }
.lesson-body { color: rgba(255,255,255,0.92); line-height: 1.85; font-size: 15px; }
.lesson-body p { margin: 0 0 14px; }
.lesson-body strong { color: var(--cyan); }

/* Full-size fade-up reveal for freshly-loaded lesson content (see
   runLessonSearch in app.js) — opacity/transform only, so the card never
   resizes mid-reveal regardless of screen width. */
.lesson-body-reveal { animation: fadeInUp 0.45s ease both; }
@media (prefers-reduced-motion: reduce) {
  .lesson-body-reveal { animation: none; }
}
.lesson-body ul { margin: 0 0 14px; padding-left: 20px; }
.lesson-body li { margin-bottom: 8px; }

/* Section headings inside AI-generated lessons */
.lesson-heading {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  margin: 26px 0 12px;
  padding-left: 12px;
  border-left: 3px solid var(--violet);
  border-image: linear-gradient(180deg, var(--violet), var(--cyan)) 1;
}
.lesson-heading:first-child { margin-top: 0; }

/* Fenced code blocks (```lang ... ```) */
.code-block {
  background: rgba(6, 8, 18, 0.9);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  margin: 0 0 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
.code-block code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  color: #dbeafe;
  white-space: pre;
}
.code-block[data-lang]::before {
  content: attr(data-lang);
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 10px;
}

.video-btn {
  margin-top: 20px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  color: #04040a;
  padding: 14px 22px;
  border-radius: var(--radius-md);
  border: none;
  font-weight: 700;
  box-shadow: var(--glow-violet);
  transition: all 0.3s ease;
}
.video-btn:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 16px 40px rgba(6, 182, 212, 0.35); }
.video-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.video-embed { margin-top: 24px; border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border); }
.video-embed iframe { width: 100%; aspect-ratio: 16/9; border: none; display: block; }

.lesson-loading { display: grid; gap: 18px; }
.skeleton-card { position: relative; overflow: hidden; background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 24px; }
.skeleton-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.14), transparent); transform: translateX(-100%); animation: skeletonWave 1.8s infinite; }
.skeleton-block { position: relative; z-index: 1; background: rgba(255,255,255,0.06); border-radius: 999px; }
.skeleton-title { width: 48%; height: 18px; margin-bottom: 16px; }
.skeleton-line { width: 100%; height: 12px; margin-bottom: 12px; }
.skeleton-line.short { width: 62%; }
.skeleton-pill { width: 30%; height: 28px; margin-top: 14px; }

.note-container { margin-top: 26px; padding-top: 26px; border-top: 1px solid var(--border); }
.note-container h4 { color: rgba(255,255,255,0.7); font-size: 14px; margin-bottom: 12px; }
.note-textarea { width: 100%; min-height: 130px; border-radius: var(--radius-md); border: 1px solid rgba(255,255,255,0.08); background: rgba(255,255,255,0.04); padding: 18px; color: var(--text); resize: vertical; transition: all 0.3s ease; }
.note-textarea:focus { box-shadow: 0 0 0 4px var(--cyan-soft); border-color: var(--cyan); }
.note-save-btn { margin-top: 18px; }
.note-save-btn.saved { background: linear-gradient(135deg, var(--success), var(--cyan)); color: #04040a; }
.note-title-input { width: 100%; padding: 10px; border-radius: var(--radius-md); border: 1px solid rgba(255,255,255,0.08); background: rgba(255,255,255,0.04); color: var(--text); transition: all 0.3s ease; }
.note-title-input:focus { border-color: var(--cyan); box-shadow: 0 0 0 4px var(--cyan-soft); }
.note-content-input { width: 100%; margin-top: 10px; padding: 12px; border-radius: var(--radius-md); min-height: 120px; border: 1px solid rgba(255,255,255,0.08); background: rgba(255,255,255,0.04); color: var(--text); transition: all 0.3s ease; }
.note-content-input:focus { border-color: var(--cyan); box-shadow: 0 0 0 4px var(--cyan-soft); }
.note-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px 18px; margin-bottom: 12px; backdrop-filter: blur(14px); transition: all 0.3s ease; }
.note-card:hover { transform: translateY(-2px); border-color: rgba(139,92,246,0.4); box-shadow: var(--glow-violet); }
.note-card.removing { opacity: 0; transform: translateY(-8px) scale(0.98); }
.note-card-header { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.note-card-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.note-card-date { font-size: 12px; color: var(--text-muted); }
.note-card-body { margin-top: 8px; color: rgba(255,255,255,0.9); line-height: 1.6; white-space: pre-wrap; }

/* Small square icon buttons (edit / delete / confirm / cancel) */
.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: all 0.25s ease;
  flex-shrink: 0;
}
.icon-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { color: #fff; border-color: rgba(139,92,246,0.45); box-shadow: var(--glow-violet); transform: translateY(-1px); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.danger:hover { color: var(--danger); border-color: rgba(248,113,113,0.45); box-shadow: 0 8px 20px rgba(248,113,113,0.18); }
.icon-btn.confirm { background: linear-gradient(135deg, var(--violet), var(--cyan)); color: #fff; border: none; box-shadow: var(--glow-violet); }
.icon-btn.confirm:hover { color: #fff; transform: translateY(-1px) scale(1.05); }

/* "Save this AI reply as a note" action under a finished chat bubble */
.chat-bubble-actions { margin-top: 12px; display: flex; }
.chat-save-note-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  transition: all 0.25s ease;
}
.chat-save-note-btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.chat-save-note-btn:hover { color: #fff; border-color: rgba(139,92,246,0.45); box-shadow: var(--glow-violet); transform: translateY(-1px); }
.chat-save-note-btn:active { transform: scale(0.96); }
.chat-save-note-btn:disabled { opacity: 0.6; cursor: default; transform: none; }

/* Lesson card action row: video button + "AI'dan so'rash" deep-link */
.lesson-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }
.lesson-actions .video-btn { margin-top: 0; }
.ask-ai-btn {
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border: 1px solid rgba(139,92,246,0.35);
  box-shadow: none;
}
.ask-ai-btn:hover {
  border-color: rgba(139,92,246,0.6);
  box-shadow: var(--glow-violet);
  background: rgba(139,92,246,0.08);
  transform: translateY(-2px) scale(1.02);
}

.note-edit-row { display: flex; gap: 8px; margin-top: 10px; justify-content: flex-end; }

.chat-panel { display: flex; flex-direction: column; min-height: 560px; background: var(--surface-elevated); border: 1px solid var(--border-strong); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--glow-violet), var(--shadow-soft); backdrop-filter: blur(14px); }
.chat-window { flex: 1; overflow-y: auto; padding: 26px 30px; display: flex; flex-direction: column; gap: 20px; }
.chat-bubble { display: flex; gap: 14px; max-width: 85%; width: fit-content; animation: fadeInUp 0.25s ease; }
.chat-bubble.bot { align-self: flex-start; }
.chat-bubble.user { align-self: flex-end; flex-direction: row-reverse; }

.bubble-avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; background: linear-gradient(135deg, var(--violet), var(--cyan)); color: #04040a; box-shadow: var(--glow-violet); flex-shrink: 0; }
.chat-bubble.user .bubble-avatar { background: rgba(255,255,255,0.08); color: #fff; box-shadow: 0 0 0 1px var(--border); }

.bubble-content { position: relative; border-radius: var(--radius-md); padding: 16px 20px; border: 1px solid var(--border); background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.95); line-height: 1.75; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02); transition: all 0.3s ease; min-width: 0; max-width: 100%; overflow-wrap: break-word; }
.bubble-content p { margin: 0 0 10px; }
.bubble-content p:last-child { margin-bottom: 0; }
.chat-bubble.user .bubble-content { background: linear-gradient(90deg, rgba(139,92,246,0.16), rgba(6,182,212,0.16)); border-color: rgba(139,92,246,0.18); }

.chat-input-row { display: flex; gap: 14px; padding: 18px 24px; border-top: 1px solid var(--border); background: rgba(8, 8, 14, 0.95); align-items: center; }
#chat-input { flex: 1; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); border-radius: var(--radius-md); padding: 16px 18px; color: var(--text); font-size: 14px; transition: all 0.3s ease; }
#chat-input:focus { border-color: var(--cyan); box-shadow: 0 0 0 4px var(--cyan-soft); }

/* Voice input (mic) button in the chat input row */
.mic-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-muted);
  transition: all 0.25s ease;
}
.mic-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.mic-btn:hover { color: #fff; border-color: rgba(139,92,246,0.45); box-shadow: var(--glow-violet); }
.mic-btn:disabled { cursor: default; }
.mic-btn.listening {
  color: #fff;
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  border-color: transparent;
  box-shadow: 0 0 0 0 rgba(139,92,246,0.55);
  animation: micPulse 1.4s ease-out infinite;
}
@keyframes micPulse {
  0% { box-shadow: 0 0 0 0 rgba(139,92,246,0.55); }
  70% { box-shadow: 0 0 0 14px rgba(139,92,246,0); }
  100% { box-shadow: 0 0 0 0 rgba(139,92,246,0); }
}
@media (prefers-reduced-motion: reduce) {
  .mic-btn.listening { animation: none; }
}

/* Voice output toggle: shows the "on" icon by default, "off" when muted */
#voice-toggle-btn .icon-voice-off { display: none; }
#voice-toggle-btn.muted { color: var(--danger); border-color: rgba(248,113,113,0.4); }
#voice-toggle-btn.muted .icon-voice-on { display: none; }
#voice-toggle-btn.muted .icon-voice-off { display: block; }
#voice-toggle-btn.muted:hover { color: var(--danger); box-shadow: 0 8px 20px rgba(248,113,113,0.18); border-color: rgba(248,113,113,0.5); }

/* ============ Floating Siri-style voice overlay ============ */
.voice-overlay {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  z-index: 200;
  pointer-events: none;
}
.voice-overlay-card {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  min-width: 260px;
  max-width: min(90vw, 380px);
  padding: 22px 26px;
  border-radius: var(--radius-lg);
  background: rgba(10, 10, 16, 0.82);
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(139,92,246,0.15);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  animation: fadeInUp 0.3s ease;
}

/* Real waveform: bars scale to live mic amplitude (JS sets scaleY per frame) */
.voice-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 54px;
}
.voice-wave span {
  display: block;
  width: 5px;
  height: 46px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--violet), var(--cyan));
  transform: scaleY(0.15);
  transform-origin: center;
  will-change: transform;
}
/* Speaking state recolors the bars so the user can tell listen vs. speak */
.voice-overlay.state-speaking .voice-wave span {
  background: linear-gradient(180deg, var(--cyan), var(--violet));
}
.voice-overlay.state-thinking .voice-wave span {
  background: linear-gradient(180deg, rgba(255,255,255,0.5), rgba(255,255,255,0.25));
}

.voice-status {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.01em;
}
.voice-caption {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
  min-height: 18px;
  max-height: 60px;
  overflow: hidden;
}
.voice-stop-btn {
  margin-top: 2px;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(248,113,113,0.12);
  border: 1px solid rgba(248,113,113,0.35);
  color: #fecaca;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.25s ease;
}
.voice-stop-btn:hover { background: rgba(248,113,113,0.2); color: #fff; transform: translateY(-1px); }

@media (max-width: 480px) {
  .voice-overlay { bottom: 88px; }
  .voice-mode-btn .voice-mode-label { display: none; }
  .voice-mode-btn { padding: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .voice-overlay-card { animation: none; }
  .voice-wave span { transition: none; }
}

.typing-indicator { display: flex; gap: 8px; }
.typing-indicator span { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.32); animation: typingDot 1s infinite ease-in-out; }
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

.typing-cursor { display: inline-block; width: 1px; height: 1.1em; background: var(--cyan); margin-left: 2px; animation: blinkCursor 0.8s steps(2, start) infinite; }

@media (max-width: 1024px) { .app-shell { grid-template-columns: 1fr; } .sidebar { position: relative; height: auto; border-right: none; border-bottom: 1px solid var(--border); } .main-content { padding: 24px 24px 32px; } .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .sidebar-footer { padding-bottom: 20px; } }
@media (max-width: 720px) {
  .auth-screen { padding: 16px; align-items: stretch; }
  .auth-card { padding: 24px 18px; max-width: none; }
  .auth-tabs { padding: 5px; }
  .auth-tab { padding: 10px 8px; font-size: 13px; }
  .main-content { padding: 20px 16px 112px; }
  .view-header h1 { font-size: 24px; }
  .view-header h1::after { width: 56px; }
  .stat-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .panel { padding: 20px; }
  .search-bar { flex-direction: column; align-items: stretch; }
  .search-bar input { width: 100%; }
  .sample-topic-btn { min-width: 0; flex-basis: 100%; max-width: 100%; }
  .lesson-card { padding: 20px; }
  .lesson-body { font-size: 14px; }
  .nav-item { justify-content: space-between; }
  .nav-sub { display: none; }
  .sidebar { padding: 18px 16px; }
  .topbar { padding: 14px 16px; }
  .dash-grid { gap: 16px; }
  .bottom-nav { left: 10px; right: 10px; transform: none; bottom: 10px; justify-content: space-between; gap: 6px; padding: 10px 8px; width: auto; }
  .bottom-nav .nav-action { flex: 1; min-width: 0; padding: 10px 8px; }
  .bottom-nav .nav-action .nav-label { font-size: 11px; }

  /* Architecture diagram: the desktop version absolutely-positions 160px
     cards by percentage, which overflows/clips on narrow screens (this was
     the "dashboard breaks and spills off the edge" bug). Below 720px it
     becomes a plain vertical stack instead — the !important rules are
     required because diagram.js sets left/top/transform as inline styles. */
  .diagram-wrap {
    /* index.html sets an inline height:350px meant for the desktop canvas —
       override it so the stacked cards below can expand to their full
       natural height instead of being boxed into 350px. */
    height: auto !important;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    overflow: visible;
  }
  .diagram-canvas { display: none; }
  .skill-node {
    position: static !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    width: 100% !important;
    box-sizing: border-box;
  }
  .skill-node:hover { transform: translateY(-2px) !important; }
}

@media (max-width: 480px) {
  .auth-screen { padding: 10px; }
  .auth-card { padding: 20px 14px; border-radius: 18px; }
  .brand { margin-bottom: 20px; }
  .brand-name { font-size: 18px; }
  .main-content { padding: 16px 12px 124px; }
  .view-header h1 { font-size: 22px; }
  .panel { padding: 16px; }
  .stat-card { padding: 18px 16px; }
  .lesson-card { padding: 16px; }
  .bubble-content { padding: 14px 15px; }
  .chat-panel { min-height: 420px; }
}

/* ============ 320px floor: smallest real devices (iPhone SE, old Android) ============
   Everything above already scales down to ~480px; this tier exists purely to
   remove the last bit of cramped spacing/overflow risk at the true minimum. */
@media (max-width: 360px) {
  .main-content { padding: 14px 10px 118px; }
  .view-header { margin-bottom: 18px; }
  .view-header h1 { font-size: 19px; }
  .view-header h1::after { width: 44px; height: 2px; }
  .view-sub { font-size: 13px; }

  .auth-card { padding: 18px 12px; }
  .brand-name { font-size: 15px; }
  .brand-mark { width: 38px; height: 38px; }

  .topbar { padding: 10px 12px; gap: 8px; }
  .topbar .avatar { width: 32px; height: 32px; font-size: 12px; }
  #user-name { font-size: 12px; }
  .topbar .link-btn { font-size: 10px; }
  .topbar-right { gap: 8px; }
  .lang-select { padding: 6px 8px; font-size: 11px; }
  .mic-btn { width: 38px; height: 38px; }
  .mic-btn svg { width: 16px; height: 16px; }

  .panel { padding: 12px; }
  .panel h2 { font-size: 16px; }
  .stat-grid { gap: 10px; }
  .stat-card { padding: 14px 12px; }
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 11px; }

  .search-bar { padding: 11px 14px; gap: 10px; }
  .lesson-card { padding: 12px; }
  .lesson-card h3 { font-size: 18px; }
  .lesson-body { font-size: 13px; }
  .lesson-heading { font-size: 14px; margin: 16px 0 8px; }
  .code-block { padding: 10px 12px; font-size: 11px; }
  .video-btn { padding: 12px 16px; font-size: 13px; }

  .chat-panel { min-height: 360px; }
  .chat-window { padding: 14px 10px; gap: 12px; }
  .bubble-avatar { width: 26px; height: 26px; font-size: 10px; }
  .bubble-content { padding: 12px 14px; font-size: 13px; }
  .chat-input-row { padding: 10px 10px; }
  #chat-input { padding: 11px 12px; font-size: 13px; }

  .note-card { padding: 11px 12px; }
  .icon-btn { width: 28px; height: 28px; }
  .icon-btn svg { width: 13px; height: 13px; }
  .notes-search { margin-bottom: 14px; }

  .bar-chart { height: 150px; gap: 4px; }
  .bar-track { max-width: 26px; height: 100px; }
  .bar-value, .bar-label { font-size: 9.5px; }
  .donut-wrap { width: 108px; height: 108px; margin: 4px auto 14px; }
  .donut-percent { font-size: 22px; }
  .legend-list li { font-size: 12px; padding: 8px 11px; gap: 8px; }

  .status-pill { min-width: 0; font-size: 10px; padding: 4px 8px; }
  .panel th, .panel td { padding: 9px 8px; font-size: 12px; }

  /* 6-item bottom dock at its tightest — icons and labels shrink one more step */
  .bottom-nav { padding: 6px 4px; gap: 1px; border-radius: 18px; }
  .bottom-nav .nav-action { padding: 6px 1px; }
  .bottom-nav .nav-action .nav-icon { width: 18px; height: 18px; }
  .bottom-nav .nav-action .nav-label { font-size: 9px; margin-top: 1px; }
}

.steps-list { padding-left: 20px; }
.steps-list li { margin-bottom: 10px; line-height: 1.7; }
.ext-status { display: inline-flex; align-items: center; gap: 10px; margin-top: 18px; padding: 12px 18px; border-radius: var(--radius-md); background: rgba(255,255,255,0.03); border: 1px solid var(--border); }
.ext-dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,0.25); }
.ext-dot.online { background: var(--success); box-shadow: 0 0 10px rgba(74,222,128,0.35); }

/* Navigation split: topnav on desktop, bottom dock on smaller screens.
   Placed last so it wins the cascade over the base .bottom-nav rules. */
@media (max-width: 1200px) {
  .topnav { display: none; }
}
@media (min-width: 1201px) {
  .bottom-nav { display: none; }
  .main-content { padding-bottom: 48px; }
}

/* Standalone Qaydlar view */
.notes-search { margin-bottom: 22px; }
.notes-list { display: flex; flex-direction: column; margin-top: 22px; }

/* ============ Small-screen refinements ============ */

/* Wide tables scroll inside their own container instead of breaking layout */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 460px; }

@media (max-width: 720px) {
  /* Chat: bubbles get room to breathe on narrow screens */
  .chat-window { padding: 18px 14px; gap: 14px; }
  .chat-bubble { max-width: 95%; gap: 10px; }
  .bubble-avatar { width: 30px; height: 30px; font-size: 11px; }
  .chat-input-row { padding: 12px 14px; gap: 10px; }
  #chat-input { padding: 13px 14px; }
  .chat-panel { min-height: 480px; }

  /* Lesson content */
  .lesson-heading { font-size: 15px; margin: 20px 0 10px; }
  .code-block { padding: 12px 14px; font-size: 12px; border-radius: 10px; }
  .video-btn { width: 100%; justify-content: center; }

  /* Notes: header wraps gracefully (title + date + action buttons) */
  .note-card-header { flex-wrap: wrap; }
  .note-card-actions { margin-left: auto; }
  .notes-search { margin-bottom: 16px; }

  .view-header { margin-bottom: 22px; }
}

@media (max-width: 480px) {
  /* 6-item bottom dock: tighter cells, labels never overflow */
  .bottom-nav { gap: 2px; padding: 8px 6px; }
  .bottom-nav .nav-action { padding: 8px 2px; gap: 3px; }
  .bottom-nav .nav-action .nav-icon { width: 20px; height: 20px; }
  .bottom-nav .nav-action .nav-label {
    font-size: 9.5px;
    margin-top: 2px;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Dashboard charts */
  .bar-chart { gap: 6px; height: 170px; }
  .bar-track { height: 115px; }
  .bar-value { font-size: 10px; }
  .bar-label { font-size: 10px; }
  .donut-wrap { width: 130px; height: 130px; }

  /* Activity table */
  .panel th, .panel td { padding: 11px 12px; font-size: 13px; }
  .status-pill { min-width: 0; font-size: 11px; padding: 5px 10px; }

  /* Topbar */
  .topbar { gap: 10px; }
  .topbar .avatar { width: 34px; height: 34px; font-size: 13px; }

  /* Notes editor */
  .note-card { padding: 12px 14px; }
  .icon-btn { width: 32px; height: 32px; }
}