.search-groups.collapsed {
  display: none;
}
:root {
  color-scheme: light;
  font-family: "Noto Sans JP", "Segoe UI", system-ui, sans-serif;
  background-color: #eef2f7;
  color: #1f2933;
  
  /* Sidebar width (desktop) */
  --sidebar-width: 260px;
  
  /* EchoShadow Design Tokens */
  /* Base background + surface */
  --es-bg-main: #020617;            /* page background (slate-950) */
  --es-bg-surface: #020617;
  --es-bg-card: #020617;
  --es-border-subtle: rgba(148, 163, 184, 0.35);
  --es-border-strong: rgba(148, 163, 184, 0.7);
  
  /* Typography */
  --es-text-main: #e5e7eb;          /* slate-200 */
  --es-text-muted: #9ca3af;         /* slate-400 */
  --es-text-label: #94a3b8;         /* slate-400/500 */
  --es-text-strong: #f9fafb;
  
  /* Accent palette */
  --es-accent-blue: #3b82f6;
  --es-accent-green: #22c55e;
  --es-accent-amber: #eab308;
  --es-accent-pink: #ec4899;
  --es-accent-purple: #a855f7;
  --es-accent-orange: #f97316;
  
  /* Cards */
  --es-card-radius: 18px;
  --es-card-shadow: 0 18px 40px rgba(15, 23, 42, 0.65);
  
  /* Buttons */
  --es-btn-primary-bg: #2563eb;
  --es-btn-primary-border: rgba(191, 219, 254, 0.9);
  --es-btn-primary-text: #f9fafb;
  --es-btn-outline-border: rgba(148, 163, 184, 0.85);
  --es-btn-outline-text: #e5e7eb;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f8fbff 0%, #e2e8f0 100%);
  transition: background-color 0.3s ease, color 0.3s ease;
}

body.sidebar-locked {
  height: 100vh;
  overflow: hidden;
  /* Allow sidebar to scroll even when body is locked */
  position: relative;
}

body.sidebar-locked .sidebar {
  /* Sidebar can scroll independently */
  overflow-y: scroll !important;
  -webkit-overflow-scrolling: touch !important;
}

/* Dark mode styles */
body.theme-dark {
  background: radial-gradient(circle at top, var(--es-bg-main) 0%, var(--es-bg-main) 35%, var(--es-bg-main) 100%);
  color: var(--es-text-main);
}

body.theme-dark :root {
  color-scheme: dark;
  background-color: #0f172a;
  color: #f1f5f9;
}

.app-shell {
  display: flex;
  min-height: 100vh;
  position: relative;
  width: 100%;
  overflow-x: hidden;
  align-items: flex-start; /* Align items to start */
}

/* When view-home is active, make app-shell stretch to match view-home height */
.app-shell:has(#view-home.is-active) {
  align-items: stretch;
}

.mobile-nav-trigger,
.mobile-nav {
  display: none;
}

@media (max-width: 768px) {
  .mobile-nav-trigger {
    display: flex;
  }
  
  .sidebar-toggle {
    display: flex !important;
  }
}

/* DESKTOP sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-width: 220px;
  max-width: 360px;
  padding: 20px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: linear-gradient(180deg, #0f172a 0%, #0f172a 40%, #1e293b 100%);
  color: #e5e7eb;
  font-size: 0.9rem;
  line-height: 1.4;
  box-shadow: 12px 0 32px rgba(15, 23, 42, 0.22);
  resize: horizontal;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  position: sticky;
  top: 0;
  flex-shrink: 0;
  height: 100vh; /* Default: full viewport height */
  max-height: 100vh;
}

/* Make sidebar match view-home height when view-home is active (desktop only) */
@media (min-width: 769px) {
  .app-shell:has(#view-home.is-active) .sidebar {
    height: auto;
    min-height: 100vh;
    max-height: none;
    align-self: stretch;
  }
}

/* On mobile, always keep sidebar at fixed height for scrolling */
@media (max-width: 768px) {
  .app-shell:has(#view-home.is-active) .sidebar {
    height: 100vh !important;
    max-height: 100vh !important;
    overflow-y: scroll !important;
    -webkit-overflow-scrolling: touch !important;
  }
}

.sidebar .brand,
.sidebar .sidebar-section,
.sidebar .sidebar-footer {
  cursor: default;
}

.sidebar .brand-title {
  transition: opacity 0.2s ease;
}

.sidebar .brand-title:hover {
  opacity: 0.8;
}

.sidebar-section {
  margin-bottom: 4px;
}

.sidebar-nav-main {
  display: flex;
  flex-direction: column;
  gap: 10px; /* Increased from 6px */
}

.sidebar-nav-item {
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  border-radius: 10px; /* Changed from 999px for better appearance */
  border: 1px solid transparent;
  border-left: 3px solid transparent; /* Left accent border */
  background: rgba(30, 41, 59, 0.5);
  color: #e5e7eb;
  padding: 10px 14px; /* Increased from 6px 12px */
  font-size: 0.9rem; /* Increased from 0.86rem */
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px; /* Increased from 8px */
  cursor: pointer;
  transition: all 0.2s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  position: relative;
}

.sidebar-nav-item.is-active {
  background: rgba(37, 99, 235, 0.25);
  border-left-color: #3b82f6; /* Accent border */
  border-color: rgba(59, 130, 246, 0.3);
  color: #dbeafe;
  font-weight: 600;
}

.sidebar-nav-item:hover:not(.is-active) {
  background: rgba(37, 99, 235, 0.15);
  border-left-color: rgba(59, 130, 246, 0.5);
  transform: translateX(2px);
}

/* Topics */
.sidebar-section-title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9ca3af;
  margin: 14px 0 6px;
}

.sidebar-topics {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-topic-item {
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  border-radius: 12px;
  border: 1px solid transparent;
  background: rgba(15, 23, 42, 0.65);
  color: #e5e7eb;
  padding: 7px 10px;
  font-size: 0.84rem;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.sidebar-topic-item:hover,
.sidebar-topic-item.is-active {
  background: rgba(37, 99, 235, 0.85);
  border-color: rgba(191, 219, 254, 0.8);
}

/* Legacy support for old class names */
.sidebar-nav-btn {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  position: relative;
}

.sidebar-nav-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateX(2px);
}

.sidebar-nav-btn:active {
  background: rgba(255, 255, 255, 0.15);
  transform: translateX(1px) scale(0.98);
}

.sidebar-nav-btn.is-active {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.2);
}

.sidebar-nav-btn.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: #ffffff;
  border-radius: 0 2px 2px 0;
}

/* Desktop sidebar toggle */
@media (min-width: 769px) {
  .sidebar-toggle {
    position: fixed;
    top: 32px;
    transform: none;
    z-index: 60;
    width: 22px;
    height: 48px;
    padding: 0;
    border: none;
    border-radius: 0 999px 999px 0;
    background: rgba(15, 23, 42, 0.9);
    color: #e5e7eb;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 4px 0 16px rgba(15, 23, 42, 0.5);
    cursor: pointer;
    transition:
      background-color 0.15s ease,
      box-shadow 0.15s ease;
    /* QUAN TRỌNG: Không transition transform để tránh lệch khi hover */
  }

  .sidebar-toggle:hover {
    background: rgba(30, 64, 175, 0.95);
    box-shadow: 6px 0 20px rgba(15, 23, 42, 0.7);
    transform: none;
  }

  /* Expanded state: stick to sidebar edge */
  body.sidebar-expanded .sidebar-toggle,
  .app-shell:not(.sidebar-collapsed) .sidebar-toggle {
    left: 260px; /* or calc(var(--sidebar-width)) if you prefer */
    border-radius: 0 999px 999px 0;
    width: 22px;
    height: 48px;
    top: 32px;
    transform: none;
  }
  
  body.sidebar-expanded .sidebar-toggle:hover,
  .app-shell:not(.sidebar-collapsed) .sidebar-toggle:hover {
    background: rgba(30, 64, 175, 0.95);
    box-shadow: 6px 0 20px rgba(15, 23, 42, 0.7);
    top: 32px;
    transform: none;
  }
  
  body.sidebar-expanded .sidebar-toggle:active,
  .app-shell:not(.sidebar-collapsed) .sidebar-toggle:active {
    top: 32px;
    transform: scale(0.98);
  }

  /* Collapsed state: small button at left edge */
  body.sidebar-collapsed .sidebar-toggle,
  .app-shell.sidebar-collapsed .sidebar-toggle {
    left: 6px;
    border-radius: 999px;
    width: 26px;
    height: 26px;
    top: 32px;
    transform: none;
  }
  
  body.sidebar-collapsed .sidebar-toggle:hover,
  .app-shell.sidebar-collapsed .sidebar-toggle:hover {
    top: 32px;
    transform: none;
  }
  
  body.sidebar-collapsed .sidebar-toggle:active,
  .app-shell.sidebar-collapsed .sidebar-toggle:active {
    top: 32px;
    transform: scale(0.98);
  }
}

/* Hide sidebar toggle on mobile */
@media (max-width: 768px) {
  .sidebar-toggle {
    display: none !important;
  }
}

/* Mobile: use mobile-specific toggle styles (defined in mobile media query below) */

/* Desktop: active state with stable transform */
@media (min-width: 769px) {
  .sidebar-toggle:active {
    transform: translateY(-50%) scale(0.98);
  }
}
.sidebar-quick-panel {
  position: fixed;
  top: 80px;
  right: 24px;
  background: rgba(15, 23, 42, 0.95);
  border-radius: 16px;
  padding: 10px 12px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.3);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 100;
  border: 1px solid rgba(148, 163, 184, 0.25);
  min-width: 180px;
  backdrop-filter: blur(10px);
}

.sidebar-quick-panel.hidden {
  display: none;
}

.quick-item {
  border: none;
  background: rgba(248, 250, 252, 0.08);
  color: #f8fafc;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.quick-item:hover {
  background: rgba(248, 250, 252, 0.15);
  transform: translateX(2px);
}

.quick-item:active {
  transform: translateX(1px) scale(0.98);
}

.quick-item .quick-state {
  font-weight: 600;
  color: #facc15;
}

.sidebar-quick-panel::before {
  content: "";
  position: absolute;
  top: -8px;
  right: 20px;
  width: 16px;
  height: 16px;
  background: inherit;
  transform: rotate(45deg);
  border-top-left-radius: 4px;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  border-left: 1px solid rgba(148, 163, 184, 0.25);
}

@media (max-width: 768px) {
  .sidebar-quick-panel {
    display: none;
  }
}
.app-shell.sidebar-collapsed .sidebar {
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  padding: 0;
  border: none;
  box-shadow: none;
  resize: none;
  cursor: default;
}

/* On mobile, ignore desktop collapsed state */
@media (max-width: 768px) {
  .app-shell.sidebar-collapsed .sidebar {
    width: 280px !important;
    max-width: 85vw !important;
    min-width: auto !important;
    padding: 20px 18px 24px !important;
    border: none;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.3);
    resize: none;
    cursor: default;
  }
}


.brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brand-title {
  font-size: 1.5rem;
  font-weight: 600;
}

.brand-caption {
  font-size: 0.95rem;
  color: rgba(248, 250, 252, 0.7);
}

.btn-primary,
.btn-secondary {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease,
    background 0.2s ease, color 0.2s ease;
  font-size: 0.92rem;
}

.btn-primary {
  background: linear-gradient(135deg, #facc15, #f97316);
  color: #1f2933;
  box-shadow: 0 14px 30px rgba(250, 204, 21, 0.35);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: rgba(59, 130, 246, 0.15);
  color: #1d4ed8;
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary:hover:not(:disabled),
.btn-secondary:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.25);
}

.lesson-search {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #ffffff;
  color: #0f172a;
  padding: 6px 10px;
  font-size: 0.85rem;
  min-height: 34px;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
}

.lesson-search::placeholder {
  color: #94a3b8;
}

.level-filter {
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #ffffff;
  color: #0f172a;
  padding: 8px 10px;
  font-size: 0.9rem;
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-status {
  margin: 8px 0 0;
  padding: 8px 12px;
  font-size: 0.9rem;
  color: #475569;
  background: rgba(241, 245, 249, 0.6);
  border-radius: 8px;
  border-left: 3px solid #3b82f6;
  min-height: 20px;
  line-height: 1.5;
}

.search-status[hidden] {
  display: none;
}

.search-result-item {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: transparent;
  border: none;
  text-align: left;
  color: #0f172a;
}

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

.search-result-item:hover {
  background: rgba(59, 130, 246, 0.08);
}

.search-result-item strong {
  font-size: 0.95rem;
}

.search-result-meta {
  font-size: 0.8rem;
  color: #475569;
}

.search-result-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.search-groups {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 12px;
}

.search-group {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 18px;
  padding: 12px 14px 6px;
  background: rgba(248, 250, 252, 0.7);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.search-group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.search-group-head h3 {
  margin: 0;
  font-size: 1rem;
  color: #0f172a;
}

.group-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #475569;
}

.group-count {
  font-weight: 600;
  color: #1d4ed8;
}

.group-toggle {
  border: none;
  background: transparent;
  color: #2563eb;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.2s ease;
}

.group-toggle:hover {
  background: rgba(37, 99, 235, 0.1);
}

.search-group-body {
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
}

.search-group.hidden {
  display: none;
}

.search-group.collapsed .search-group-body {
  display: none;
}

.search-group.collapsed .group-toggle::after {
  content: " (đã thu gọn)";
  font-weight: normal;
  font-size: 0.8rem;
  color: #94a3b8;
}

.search-empty {
  padding: 12px 0;
  font-size: 0.9rem;
  color: #94a3b8;
}

.search-card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.search-card-item {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 16px;
  padding: 12px 16px;
  text-align: left;
  background: rgba(248, 250, 252, 0.9);
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease,
    transform 0.2s ease;
}

.search-card-item:hover {
  border-color: rgba(59, 130, 246, 0.4);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.1);
  transform: translateY(-1px);
}

.search-card-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #0f172a;
}

.search-card-text .primary-line {
  font-weight: 600;
}

.search-card-text .secondary-line {
  color: #475569;
  font-size: 0.92rem;
}

.search-card-text .tertiary-line {
  color: #94a3b8;
  font-size: 0.82rem;
}

.search-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.search-tag {
  font-size: 0.7rem;
  padding: 2px 6px;
  background: rgba(59, 130, 246, 0.15);
  color: #2563eb;
  border-radius: 6px;
  font-weight: 500;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.search-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.search-tag {
  font-size: 0.7rem;
  padding: 2px 6px;
  background: rgba(59, 130, 246, 0.15);
  color: #2563eb;
  border-radius: 6px;
  font-weight: 500;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.search-card-meta {
  margin-top: 6px;
  font-size: 0.8rem;
  color: #64748b;
}

.search-panel {
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}
.top-layout {
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: 12px; /* Add gap between top-layout sections */
}

.top-layout .lesson-header {
  margin: 0;
  padding: 18px 20px; /* Reduced from 16px 18px */
  border-radius: 16px;
}

@media (max-width: 980px) {
  .top-layout {
    grid-template-columns: 1fr;
  }
}

.sidebar-search {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Sidebar search results */
.sidebar-search-results {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(248, 250, 252, 0.1);
  max-height: 400px;
  overflow-y: auto;
}

.sidebar-search-results.hidden {
  display: none;
}

.sidebar-search-status {
  font-size: 0.8rem;
  color: rgba(248, 250, 252, 0.7);
  margin-bottom: 8px;
  padding: 4px 8px;
  background: rgba(15, 23, 42, 0.3);
  border-radius: 6px;
}

.sidebar-search-detail {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-search-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-search-group.hidden {
  display: none;
}

.sidebar-search-group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: rgba(248, 250, 252, 0.6);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-search-group-title {
  color: rgba(248, 250, 252, 0.8);
}

.sidebar-search-count {
  background: rgba(37, 99, 235, 0.3);
  color: #93c5fd;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
}

.sidebar-search-results-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-search-item {
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(248, 250, 252, 0.1);
  border-radius: 6px;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.8rem;
  color: rgba(248, 250, 252, 0.9);
}

.sidebar-search-item:hover {
  background: rgba(15, 23, 42, 0.6);
  border-color: rgba(37, 99, 235, 0.4);
  transform: translateX(2px);
}

.sidebar-search-item-name {
  font-weight: 500;
  margin-bottom: 2px;
  line-height: 1.4;
}

.sidebar-search-item-meta {
  font-size: 0.75rem;
  color: rgba(248, 250, 252, 0.6);
  line-height: 1.3;
}

.search-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.2);
  border-radius: 999px;
  border: 1px solid rgba(248, 250, 252, 0.15);
  padding: 6px 12px;
  width: 100%;
  max-width: 240px;
}

.search-inline.compact {
  gap: 4px;
  padding: 4px 6px;
  height: 28px;
  width: auto;
  max-width: 200px;
  min-width: 120px;
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: nowrap;
}

.search-icon {
  font-size: 0.9rem;
  color: rgba(248, 250, 252, 0.8);
}

.search-inline .lesson-search {
  flex: 1;
  min-width: 120px;
  max-width: 160px;
  border: none;
  background: transparent;
  font-size: 0.92rem;
  padding: 4px 0;
  color: #f8fafc;
}

.search-inline.compact .lesson-search {
  min-width: 60px;
  max-width: 120px;
  font-size: 0.75rem;
  height: 16px;
  line-height: 16px;
  padding: 0;
  flex: 0 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  border: none;
  background: transparent;
}

.search-inline .lesson-search::placeholder {
  color: rgba(248, 250, 252, 0.55);
}

.search-inline.compact .lesson-search::placeholder {
  font-size: 0.75rem;
  line-height: 16px;
}

.search-inline .lesson-search:focus {
  outline: none;
}

.search-inline .icon-btn {
  background: rgba(248, 250, 252, 0.12);
  width: 32px;
  height: 32px;
  font-size: 0.85rem;
  color: #f8fafc;
  border: none;
}

.search-inline.compact .icon-btn {
  width: 20px;
  height: 20px;
  font-size: 0.65rem;
  padding: 0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  order: 3;
  margin-left: auto;
}

.search-inline.compact .search-icon {
  font-size: 0.75rem;
  flex-shrink: 0;
  line-height: 1;
  display: inline-block;
  vertical-align: middle;
}

.results-panel {
  margin-top: 16px;
  background: rgba(248, 250, 252, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 18px;
  padding: 14px 18px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
  display: block;
}

.results-panel.hidden {
  display: none;
}

.search-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.search-panel-head h2 {
  margin: 0;
  font-size: 1rem;
  color: #0f172a;
}

.search-toggle {
  background: rgba(37, 99, 235, 0.1);
  border: 1px solid rgba(37, 99, 235, 0.2);
  color: #2563eb;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.search-toggle:hover {
  background: rgba(37, 99, 235, 0.15);
  border-color: rgba(37, 99, 235, 0.3);
}

.search-toggle:active {
  transform: scale(0.98);
}

@media (max-width: 768px) {
  .search-panel,
  .search-shell {
    display: none;
  }
}

.icon-btn {
  border-radius: 999px;
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  background: rgba(15, 23, 42, 0.08);
  color: #0f172a;
}

@media (max-width: 768px) {
  .search-inline:not(.compact) {
    flex-direction: column;
    align-items: stretch;
  }

  .search-inline:not(.compact) .level-filter,
  .search-inline:not(.compact) .btn-secondary {
    width: 100%;
  }

  .search-inline.compact {
    flex-direction: row;
    align-items: center;
  }
}

.sidebar-section h2 {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(248, 250, 252, 0.65);
}

.category-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 240px);
  overflow-y: auto;
  overflow-x: hidden;
}

.category-item {
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  border-radius: 12px;
  border: 1px solid transparent;
  background: rgba(15, 23, 42, 0.65);
  color: #e5e7eb;
  padding: 7px 10px;
  font-size: 0.84rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
  margin-bottom: 4px;
  overflow: hidden;
  min-width: 0;
}

.category-item:hover {
  background: rgba(37, 99, 235, 0.85);
  border-color: rgba(191, 219, 254, 0.8);
}

.category-item.active {
  background: rgba(37, 99, 235, 0.85);
  border-color: rgba(191, 219, 254, 0.8);
  color: #e5e7eb;
}

.category-item:focus-visible {
  outline: 2px solid rgba(191, 219, 254, 0.9);
  outline-offset: 2px;
}

.category-name {
  font-weight: 600;
  letter-spacing: 0.02em;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.category-caption {
  font-size: 0.78em;
  color: rgba(248, 250, 252, 0.72);
  letter-spacing: 0.02em;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.category-item.active .category-caption {
  color: #1d4ed8;
}

.sidebar-footer {
  font-size: 0.85rem;
  line-height: 1.6;
  color: rgba(248, 250, 252, 0.7);
}

.main-view {
  flex: 1;
  padding: 20px 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  background: transparent;
  min-height: 100vh;
  min-width: 0;
  overflow-x: hidden;
}

@media (max-width: 1024px) {
  .main-view {
    padding: 16px 14px 20px;
  }
}

.welcome-panel {
  padding: 28px 32px;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.12), rgba(59, 130, 246, 0.08));
  border: 1px solid rgba(59, 130, 246, 0.25);
  box-shadow: 0 24px 40px rgba(59, 130, 246, 0.2);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.welcome-panel.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.welcome-hero {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
}

.welcome-hero h1 {
  margin: 8px 0;
  font-size: 2rem;
  color: #0f172a;
}

.welcome-hero p {
  margin: 0;
  color: #475569;
}

.welcome-hero .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.85rem;
  color: #1d4ed8;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 240px;
}

.hero-resume-meta {
  margin: 0;
  font-size: 0.85rem;
  color: #475569;
}

.quick-tips {
  margin: 0;
  padding-left: 18px;
  color: #475569;
  font-size: 0.95rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 24px;
}

.lesson-header {
  display: flex;
  flex-direction: column;
  gap: 12px; /* Reduced from 18px */
  padding: 18px 20px; /* Reduced from 24px 28px */
  background: rgba(255, 255, 255, 0.92);
  border-radius: 16px; /* Reduced from 20px */
  box-shadow: 0 16px 32px rgba(148, 163, 184, 0.18); /* Reduced shadow */
  backdrop-filter: blur(18px);
}

@media (min-width: 640px) {
  .lesson-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
  }
}

.lesson-header h1 {
  margin: 0;
  font-size: 1.35rem; /* Reduced from 1.5rem */
  color: #0f172a;
  line-height: 1.3; /* Tighter line height */
}

.lesson-header p {
  margin: 4px 0 0; /* Reduced from 6px */
  color: #64748b;
  font-size: 0.85rem; /* Reduced from 0.9rem */
  line-height: 1.4;
}

.chip-groups {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.group-chips,
.lesson-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Nhóm JLPT khi hiển thị trong sidebar */
.sidebar-group-chips {
  margin-top: 12px;
}

/* Lesson khi hiển thị trong sidebar, dưới JLPT */
.sidebar-lesson-chips {
  margin-top: 10px;
}

.group-chip {
  border: none;
  padding: 8px 16px;
  border-radius: 12px;
  background: rgba(148, 163, 184, 0.2);
  color: #0f172a;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease,
    background-color 0.2s ease, color 0.2s ease;
}

.group-chip:hover {
  background: rgba(96, 165, 250, 0.35);
  box-shadow: 0 10px 18px rgba(148, 163, 184, 0.24);
}

.group-chip.active {
  background: #1d4ed8;
  color: #ffffff;
  box-shadow: 0 14px 26px rgba(29, 78, 216, 0.35);
}

.lesson-chip {
  border: none;
  padding: 8px 16px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #1f2937;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease,
    background-color 0.2s ease, color 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  text-align: left;
}

.lesson-chip-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lesson-chip-name {
  flex: 1;
}

.lesson-chip-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.lesson-tag {
  font-size: 0.7rem;
  padding: 2px 6px;
  background: rgba(59, 130, 246, 0.15);
  color: #2563eb;
  border-radius: 6px;
  font-weight: 500;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.lesson-chip.active .lesson-tag {
  background: rgba(255, 255, 255, 0.3);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.4);
}

.lesson-chip:hover {
  background: #cbd5f5;
  box-shadow: 0 10px 20px rgba(148, 163, 184, 0.26);
}

.lesson-chip.active {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 16px 32px rgba(37, 99, 235, 0.35);
}

.lesson-chip.empty {
  background: rgba(226, 232, 240, 0.6);
  color: #475569;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px; /* Tăng spacing giữa các nhóm */
  align-items: center;
  justify-content: space-between; /* Primary bên trái, Secondary bên phải */
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(148, 163, 184, 0.18);
}

/* Primary controls group (Play/Pause/Auto-pause/Speed) */
.control-group.primary-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  flex: 0 0 auto;
}

/* Secondary controls group (Furigana/Vi/Grammar/Compact) */
.control-group.secondary-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto;
  margin-left: auto; /* Đẩy về bên phải */
}

.control-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.control-group.toggles {
  gap: 10px;
  margin-top: 2px;
}

/* Progress group styling */
.control-group.progress-group {
  flex: 1 1 auto;
  min-width: 200px;
  max-width: 400px;
  margin: 0 16px;
}

.inline-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.line-progress {
  font-size: 0.85rem;
  font-weight: 600;
  color: #0f172a;
  text-align: center;
}

button.toggle-chip {
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(148, 163, 184, 0.12);
  color: #0f172a;
  border-radius: 16px;
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: none;
  line-height: 1.2;
  transition: background-color 0.2s ease, border-color 0.2s ease,
    color 0.2s ease, transform 0.2s ease;
}

/* Primary controls: button lớn hơn, màu nổi */
.control-group.primary-controls button.toggle-chip {
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
}

.control-group.primary-controls button.toggle-chip.active {
  background: rgba(37, 99, 235, 0.15);
  border-color: rgba(37, 99, 235, 0.5);
  color: #1e40af;
}

/* Secondary controls: button nhỏ hơn, ghost style */
.control-group.secondary-controls button.toggle-chip {
  padding: 5px 10px;
  font-size: 0.75rem;
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.control-group.secondary-controls button.toggle-chip.active {
  background: rgba(148, 163, 184, 0.1);
  border-color: rgba(148, 163, 184, 0.4);
}

button.toggle-chip .chip-icon {
  width: 26px;
  height: 26px;
  border-radius: 10px;
  background: rgba(71, 85, 105, 0.18);
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  line-height: 1;
  flex-shrink: 0;
}

button.toggle-chip .chip-text {
  flex: 1;
  min-width: 0;
  text-align: left;
}

button.toggle-chip.active {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(5, 150, 105, 0.45);
  color: #065f46;
}

button.toggle-chip.active .chip-icon {
  background: rgba(34, 197, 94, 0.25);
  color: #047857;
}

button.toggle-chip:not(.active) {
  opacity: 0.85;
}

button.toggle-chip:hover {
  border-color: rgba(59, 130, 246, 0.45);
  transform: translateY(-1px);
}

button.toggle-chip:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.45);
  outline-offset: 2px;
}

button.toggle-chip.hidden {
  display: none;
}

button {
  border: none;
  background-color: #2563eb;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem; /* Reduced from 0.95rem */
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.26);
  transition: transform 0.1s ease, box-shadow 0.2s ease,
    background-color 0.2s ease;
}

button:hover {
  background-color: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(29, 78, 216, 0.35);
}

button:active {
  transform: scale(0.98);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: #334155;
}

.content-area {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.lines-wrapper {
  flex: 1 1 60%;
  overflow-y: auto;
  padding-bottom: 40px;
}

.lines {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px; /* Giảm từ 12px xuống 8px để các item gần nhau hơn */
}

/* Card câu - design premium cho shadowing */
.line {
  background: #ffffff; /* Nền trắng */
  border-radius: 16px; /* Bo góc */
  padding: 20px 24px; /* Spacing thoáng (tương đương p-4) */
  border: 1px solid rgba(148, 163, 184, 0.12);
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 2px 8px rgba(148, 163, 184, 0.08); /* Shadow nhẹ */
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px; /* Giảm từ 12px xuống 8px */
  margin-bottom: 10px; /* Giảm từ 16px xuống 10px để các item gần nhau hơn */
}

.line:hover {
  box-shadow: 0 4px 16px rgba(148, 163, 184, 0.15);
  transform: translateY(-1px);
  border-color: rgba(148, 163, 184, 0.2);
}

/* Active state cho câu đang phát */
.line.active {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-color: #3b82f6;
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.2);
}

/* Speaker dialogue styling */
.line.speaker {
  padding-left: 14px; /* Reduced from 16px */
  padding-right: 14px; /* Reduced from 16px */
  padding-top: 14px; /* Reduced from 16px */
  padding-bottom: 14px; /* Reduced from 16px */
}

.line-content {
  display: flex;
  flex-direction: column;
  gap: 2px; /* Giảm từ 4px xuống 2px */
  transition:
    background-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.15s ease;
}

/* .line-content.is-active {
  background-color: rgba(59, 130, 246, 0.08);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
} */

.speaker-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  align-self: flex-start;
  margin-bottom: 3px; /* Reduced from 4px */
  letter-spacing: 0.02em;
  text-transform: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Speaker-specific colors */
.line.speaker-さくら {
  background: linear-gradient(135deg, rgba(251, 207, 232, 0.4) 0%, rgba(244, 114, 182, 0.15) 100%);
  border-left: 3px solid #ec4899;
}

.line.speaker-さくら .speaker-badge {
  background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
  color: white;
}

.line.speaker-アイン {
  background: linear-gradient(135deg, rgba(191, 219, 254, 0.4) 0%, rgba(96, 165, 250, 0.15) 100%);
  border-left: 3px solid #3b82f6;
}

.line.speaker-アイン .speaker-badge {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
}

/* Generic speaker colors for A/B */
.line.speaker-A {
  background: linear-gradient(135deg, rgba(191, 219, 254, 0.4) 0%, rgba(96, 165, 250, 0.15) 100%);
  border-left: 3px solid #3b82f6;
}

.line.speaker-A .speaker-badge {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
}

.line.speaker-B {
  background: linear-gradient(135deg, rgba(251, 207, 232, 0.4) 0%, rgba(244, 114, 182, 0.15) 100%);
  border-left: 3px solid #ec4899;
}

.line.speaker-B .speaker-badge {
  background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
  color: white;
}

.line:hover {
  border-color: #93c5fd;
  transform: translateY(-2px);
  box-shadow: 0 20px 34px rgba(148, 163, 184, 0.28);
}

.line.speaker:hover {
  transform: translateY(-2px) translateX(2px);
}

.line.speaker-さくら:hover {
  border-color: #f472b6;
  box-shadow: 0 20px 34px rgba(236, 72, 153, 0.2);
}

.line.speaker-アイン:hover {
  border-color: #60a5fa;
  box-shadow: 0 20px 34px rgba(59, 130, 246, 0.2);
}

/* .line.active đã được định nghĩa ở trên với design mới */

/* Active state for speaker lines */
.line.speaker.active.speaker-さくら {
  background: linear-gradient(135deg, rgba(251, 207, 232, 0.7) 0%, rgba(244, 114, 182, 0.4) 100%);
  border-left-color: #ec4899;
  border-color: #ec4899;
  box-shadow: 0 28px 40px rgba(236, 72, 153, 0.25);
}

.line.speaker.active.speaker-アイン {
  background: linear-gradient(135deg, rgba(191, 219, 254, 0.7) 0%, rgba(96, 165, 250, 0.4) 100%);
  border-left-color: #3b82f6;
  border-color: #3b82f6;
  box-shadow: 0 28px 40px rgba(59, 130, 246, 0.25);
}

.line.speaker.active.speaker-A {
  background: linear-gradient(135deg, rgba(191, 219, 254, 0.7) 0%, rgba(96, 165, 250, 0.4) 100%);
  border-left-color: #3b82f6;
  border-color: #3b82f6;
  box-shadow: 0 28px 40px rgba(59, 130, 246, 0.25);
}

.line.speaker.active.speaker-B {
  background: linear-gradient(135deg, rgba(251, 207, 232, 0.7) 0%, rgba(244, 114, 182, 0.4) 100%);
  border-left-color: #ec4899;
  border-color: #ec4899;
  box-shadow: 0 28px 40px rgba(236, 72, 153, 0.25);
}

.line.error {
  border-color: #f87171;
  background: #fee2e2;
  color: #991b1b;
  cursor: default;
  box-shadow: none;
}

.line.info {
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(226, 232, 240, 0.6);
  color: #475569;
  cursor: default;
}

/* Container cho câu JP với replay button */
.sentence-jp-container {
  position: relative;
  padding-right: 36px; /* Space for replay button (desktop only) */
}

@media (max-width: 768px) {
  .sentence-jp-container {
    padding-right: 0; /* Không cần space trên mobile */
  }
}

/* Câu tiếng Nhật - class sentence-jp để sau này có thể highlight từng token */
.jp,
.sentence-jp {
  font-size: 1.05rem;
  line-height: 1.9; /* Tăng line-height cho dễ đọc khi shadowing */
  color: #0f172a;
  word-break: break-word;
  font-weight: 400;
}

/* Replay button cho mỗi câu (desktop only) */
.sentence-replay-btn {
  position: absolute;
  top: 0;
  right: 0;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.sentence-replay-btn:hover {
  background: rgba(37, 99, 235, 0.15);
  border-color: rgba(37, 99, 235, 0.4);
  transform: scale(1.1);
}

.sentence-replay-btn:active {
  transform: scale(0.95);
}

@media (max-width: 768px) {
  .sentence-replay-btn {
    display: none; /* Ẩn trên mobile */
  }
}

.romaji {
  font-size: 0.75rem;
  color: #475569;
  margin-top: 8px;
}

/* Câu tiếng Việt - nhỏ hơn JP 1 bậc font, màu xám hơn */
.vi {
  font-size: 0.88rem; /* Nhỏ hơn JP 1 bậc */
  color: #64748b; /* Màu xám hơn */
  margin-top: 4px; /* Giảm từ 10px xuống 4px để gần JP hơn */
  display: block;
  line-height: 1.7; /* Tăng line-height cho dễ đọc */
  padding: 2px 0; /* Giảm từ 4px xuống 2px */
  font-weight: 400;
}

/* Compact Mode - Tighter spacing for advanced users */
body.compact-mode .lines {
  gap: 6px; /* Reduced from 12px */
}

body.compact-mode .line {
  margin-bottom: 0; /* Remove any extra margin */
  padding: 8px 12px; /* Reduced from 14px 18px */
  gap: 4px; /* Reduced from 6px */
}

body.compact-mode .line.speaker {
  padding-left: 10px; /* Reduced from 14px */
  padding-right: 10px; /* Reduced from 14px */
  padding-top: 10px; /* Reduced from 14px */
  padding-bottom: 10px; /* Reduced from 14px */
}

body.compact-mode .line-content {
  gap: 2px; /* Reduced from 4px */
}

body.compact-mode .speaker-badge {
  margin-bottom: 2px; /* Reduced from 3px */
  padding: 3px 8px; /* Slightly smaller */
  font-size: 0.7rem; /* Slightly smaller */
}

/* Slightly smaller fonts but still readable */
body.compact-mode .jp {
  font-size: 1rem; /* Reduced from 1.1rem */
  line-height: 1.7; /* Slightly tighter */
}

body.compact-mode .vi {
  font-size: 0.85rem; /* Reduced from 0.92rem */
  margin-top: 4px; /* Reduced from 6px */
  padding: 2px 0; /* Reduced from 4px 0 */
}

body.compact-mode .romaji {
  font-size: 0.85rem; /* Reduced from 0.9rem */
  margin-top: 4px; /* Reduced from 6px */
}

/* Compact mode - Recording Controls */
body.compact-mode .recording-controls {
  margin-top: 0; /* No margin when inside line-controls */
  padding: 3px; /* Reduced from 4px */
  border-radius: 4px; /* Reduced from 6px */
}

body.compact-mode .recording-status {
  font-size: 0.65rem; /* Reduced from 0.75rem */
  margin-bottom: 2px; /* Reduced from 4px */
}

body.compact-mode .recording-buttons {
  gap: 2px; /* Reduced from 4px */
}

body.compact-mode .recording-controls .icon-btn {
  padding: 3px 6px; /* Reduced from 4px 8px */
  font-size: 0.65rem; /* Reduced from 0.75rem */
  border-radius: 3px; /* Reduced from 4px */
}

body.compact-mode .recording-controls .btn-play-original,
body.compact-mode .recording-controls .btn-play-user {
  min-width: 55px; /* Reduced from 70px */
  width: 55px; /* Reduced from 70px */
}

.vocab-panel {
  flex: 0 0 280px;
  max-width: 320px;
  background: rgba(17, 24, 39, 0.92);
  color: #f8fafc;
  border-radius: 20px;
  padding: 24px 22px;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.35);
  position: sticky;
  top: 36px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

/* Khi không có dữ liệu từ vựng, thu nhỏ panel tối đa */
.vocab-panel.vocab-panel-empty {
  padding-top: 10px;
  padding-bottom: 10px;
}

.vocab-panel.vocab-panel-empty .vocab-empty {
  padding: 4px 0;
  font-size: 0.8rem;
}

.vocab-panel.vocab-panel-empty .vocab-summary {
  margin: 2px 0 6px;
}

.vocab-header h2 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(248, 250, 252, 0.78);
}

.vocab-summary {
  margin: 6px 0 16px;
  font-size: 0.85rem;
  color: rgba(248, 250, 252, 0.6);
}

.vocab-entries {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.vocab-entry {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 14px 16px;
  border: 1px solid transparent;
  transition: border-color 0.2s ease, transform 0.2s ease,
    background 0.2s ease, box-shadow 0.2s ease;
}

.vocab-entry:hover {
  border-color: rgba(96, 165, 250, 0.5);
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.38);
}

.vocab-entry.active {
  border-color: rgba(59, 130, 246, 0.85);
  background: rgba(59, 130, 246, 0.35);
  box-shadow: 0 16px 32px rgba(37, 99, 235, 0.45);
}

.vocab-term {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #f8fafc;
}

.vocab-reading {
  font-size: 0.9rem;
  color: rgba(224, 231, 255, 0.85);
  margin-top: 4px;
}

.vocab-meaning {
  margin-top: 6px;
  font-size: 0.9rem;
  color: rgba(226, 232, 240, 0.92);
}

.vocab-note {
  margin-top: 6px;
  font-size: 0.85rem;
  color: rgba(226, 232, 240, 0.72);
}

.vocab-empty {
  font-size: 0.88rem;
  color: rgba(148, 163, 184, 0.75);
  padding: 14px 0;
  text-align: center;
}

.vocab-empty-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: rgba(148, 163, 184, 0.9);
  margin-bottom: 8px;
}

.vocab-empty-hint {
  font-size: 0.85rem;
  color: rgba(148, 163, 184, 0.65);
  margin-top: 4px;
}

.vocab-remove-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
  opacity: 0.7;
}

.vocab-remove-btn:hover {
  background: rgba(239, 68, 68, 0.35);
  transform: scale(1.1);
  opacity: 1;
}

.vocab-entry {
  position: relative;
  padding-right: 40px; /* Space for remove button */
}

/* Highlight saved vocabulary in sentences */
.echolex-token.vocab-saved,
.jp .vocab-saved {
  background: rgba(59, 130, 246, 0.2);
  border-bottom: 2px solid rgba(59, 130, 246, 0.6);
  border-radius: 3px;
  padding: 2px 4px;
  transition: background 0.2s ease;
}

.echolex-token.vocab-saved:hover {
  background: rgba(59, 130, 246, 0.3);
}

/* Tốc độ + tiến độ câu */
.speed-progress {
  justify-content: space-between;
  align-items: center;
}

.inline-progress {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
}

.progress-bar-sm {
  width: 100%;
  height: 10px; /* Tăng từ 6px lên 10px để rõ ràng hơn */
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.25); /* Màu xám nhạt cho phần chưa học */
  overflow: hidden;
  cursor: pointer; /* Cho phép click để seek */
  position: relative;
}

#lesson-progress-bar-inline {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #1d4ed8); /* Màu accent xanh nổi bật */
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1); /* Animation mượt hơn */
  position: relative;
}

/* Hover effect cho progress bar */
.progress-bar-sm:hover {
  background: rgba(148, 163, 184, 0.35);
}

.progress-bar-sm:hover #lesson-progress-bar-inline {
  background: linear-gradient(90deg, #3b82f6, #2563eb); /* Sáng hơn khi hover */
}

.control-pill {
  display: flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.05);
  color: #0f172a;
  font-size: 0.8rem; /* Reduced from 0.88rem */
  font-weight: 500;
  margin-left: auto;
}

.speed-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem; /* Reduced from 0.85rem */
  color: #475569;
}

.speed-select {
  border-radius: 999px;
  border: 1px solid #cbd5f5;
  padding: 4px 10px;
  font-size: 0.8rem; /* Reduced from 0.85rem */
  background-color: #ffffff;
}

.line-progress {
  font-size: 0.85rem; /* Reduced from 0.9rem */
  font-weight: 500;
  color: #1f2933;
}

/* Nút cuộn lên/xuống */
.scroll-actions {
  position: fixed;
  right: 16px;
  bottom: 60px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
}

.scroll-btn {
  border-radius: 999px;
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background-color: rgba(15, 23, 42, 0.85);
  color: #f9fafb;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.5);
}

.scroll-btn:hover {
  background-color: rgba(37, 99, 235, 0.95);
}

/* Ẩn/hiện nội dung theo tùy chọn */
.app-shell.hide-furigana ruby rt {
  display: none;
}

.app-shell.hide-vi .vi {
  display: none;
}

ruby {
  ruby-position: over;
}

rt {
  font-size: 0.6em;
  color: #334155;
}

/* ---------- Mobile-first tweaks for better lesson layout ---------- */

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    max-height: 100vh;
    overflow-y: scroll; /* Use scroll instead of auto */
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.3);
    /* Ensure sidebar is hidden by default on mobile */
    visibility: visible;
    /* Force scroll container */
    display: flex;
    flex-direction: column;
    /* Ensure content can overflow */
    min-height: 0;
    /* Enable touch scrolling */
    touch-action: pan-y;
    /* Force scrollbar to always be available (even if hidden) */
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
    /* Ensure pointer events work */
    pointer-events: auto;
  }
  
  .sidebar::-webkit-scrollbar {
    width: 6px;
  }
  
  .sidebar::-webkit-scrollbar-track {
    background: transparent;
  }
  
  .sidebar::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 3px;
  }
  
  .sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
  }
  
  /* Ensure sidebar content doesn't prevent scrolling */
  .sidebar > * {
    pointer-events: auto;
  }

  .sidebar.mobile-open {
    transform: translateX(0) !important;
    overflow-y: scroll !important; /* Use scroll instead of auto for better mobile support */
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    /* Force hardware acceleration for smooth scrolling */
    will-change: scroll-position;
    /* Ensure height is set correctly */
    min-height: 100vh;
    max-height: 100vh;
    /* Enable touch scrolling */
    touch-action: pan-y;
  }
  
  /* Prevent desktop collapsed state from affecting mobile */
  .app-shell.sidebar-collapsed .sidebar {
    width: 280px !important;
    max-width: 85vw !important;
    padding: 20px 18px 24px !important;
  }
  
  /* When mobile drawer is open, prevent background scroll */
  body.sidebar-locked {
    height: 100vh;
    overflow: hidden;
  }

  .sidebar-toggle {
    display: flex !important;
    position: fixed;
    top: 16px;
    left: 16px !important;
    z-index: 10001;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;
    pointer-events: auto;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    font-size: 1.2rem;
    border: none;
    align-items: center;
    justify-content: center;
    /* Override desktop styles for mobile */
    transform: none !important;
  }

  .sidebar-toggle:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.5);
  }

  .sidebar-toggle:active {
    transform: scale(0.95);
  }

  .sidebar-search {
    padding: 8px 10px;
  }

  .search-inline.compact {
    gap: 4px;
    padding: 4px 6px;
    width: auto;
    max-width: 180px;
    min-width: 100px;
    height: 28px;
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
  }

  .search-inline.compact .search-icon {
    font-size: 0.75rem;
    flex-shrink: 0;
    line-height: 1;
    display: inline-block;
    vertical-align: middle;
  }

  .search-inline.compact .lesson-search {
    font-size: 0.75rem;
    padding: 0;
    min-width: 50px;
    max-width: 100px;
    height: 16px;
    line-height: 16px;
    border: none;
    background: transparent;
    flex: 0 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
  }

  .search-inline.compact .lesson-search::placeholder {
    font-size: 0.75rem;
    line-height: 16px;
  }

  .search-inline.compact .icon-btn {
    width: 20px;
    height: 20px;
    font-size: 0.65rem;
    flex-shrink: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
  }

  .sidebar-section:not(.sidebar-search) {
    display: none;
  }

  .mobile-nav-trigger {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 14px 22px rgba(37, 99, 235, 0.35);
    z-index: 10000;
    cursor: pointer;
    pointer-events: auto;
  }
  
  .mobile-nav-trigger:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    box-shadow: 0 16px 24px rgba(37, 99, 235, 0.45);
  }
  
  .mobile-nav-trigger:active {
    transform: scale(0.95);
  }

  .mobile-nav {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 60px 16px 80px; /* Tăng padding-bottom từ 16px lên 80px để tránh bị che bởi mobile-bottom-nav (60px) */
    z-index: 70;
    overflow-y: auto;
  }

  .mobile-nav[hidden] {
    display: none;
  }

  .mobile-nav-panel {
    width: min(420px, 100%);
    max-height: calc(100vh - 140px); /* Giảm từ 80px xuống 140px để tính cả mobile-bottom-nav (60px) */
    background: #fff;
    border-radius: 18px;
    padding: 18px 20px 24px;
    box-shadow: 0 -20px 40px rgba(15, 23, 42, 0.35);
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .mobile-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .mobile-nav-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #0f172a;
    flex: 1;
    text-align: center;
  }

  .mobile-nav-icon {
    border: none;
    background: rgba(148, 163, 184, 0.2);
    color: #0f172a;
    border-radius: 999px;
    width: 38px;
    height: 32px;
    font-size: 1rem;
    cursor: pointer;
  }

  .mobile-nav-icon[hidden] {
    visibility: hidden;
  }

  .mobile-nav-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 20px; /* Thêm padding-bottom để content không bị che */
  }

  .mobile-nav-category,
  .mobile-nav-group {
    background: rgba(248, 250, 252, 0.9);
    border: 1px solid rgba(15, 23, 42, 0.05);
    border-radius: 16px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
  }

  .mobile-nav-cat-toggle,
  .mobile-nav-group-toggle {
    width: 100%;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-size: 1rem;
    color: #0f172a;
    cursor: pointer;
  }

  .mobile-nav-category + .mobile-nav-category {
    margin-top: 8px;
  }

  .mobile-nav-cat-panel,
  .mobile-nav-lesson-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 12px 12px 16px;
  }

  .mobile-nav-group {
    margin: 6px 0;
  }

  .mobile-nav-lesson {
    border: none;
    background: rgba(59, 130, 246, 0.1);
    color: #1d4ed8;
    border-radius: 12px;
    padding: 10px 12px;
    text-align: left;
    font-size: 0.92rem;
    cursor: pointer;
  }

  .mobile-nav-lesson.active {
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff;
  }

  .nav-arrow {
    font-size: 0.8rem;
    color: #475569;
  }

  .mobile-nav-empty {
    font-size: 0.9rem;
    color: #475569;
    padding: 4px 0;
  }

  .main-view {
    padding: 16px;
  }

  /* Trên mobile: nội dung tiếng Nhật cuộn cùng trang, không có scroll riêng */
  .lines-wrapper {
    max-height: none;
    overflow-y: visible;
    flex: 1 1 auto;
    padding-bottom: 24px;
  }

  .scroll-actions {
    right: 4px;
    bottom: 80px;
  }

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

  .lesson-chip {
    width: 100%;
    justify-content: center;
    text-align: center;
    padding: 6px 10px;
    font-size: 0.8rem;
  }
}

@media (max-width: 1024px) {
  .category-list {
    max-height: 220px;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .category-item {
    flex: 1 1 140px;
  }

  .main-view {
    padding: 24px;
  }

  /* Trên tablet/mobile, xếp dọc: câu ở trên, từ vựng ở dưới cho thoáng hơn */
  .content-area {
    flex-direction: column;
    gap: 16px;
    align-items: stretch;
  }

  /* Để nội dung cuộn mượt một khối, bỏ scroll riêng trong lines-wrapper */
  .lines-wrapper {
    max-height: none;
    overflow-y: visible;
    flex: 1 1 auto;
  }

  .vocab-panel {
    position: static;
    max-height: none;
    width: 100%;
    max-width: 100%;
    flex: 1 1 auto;
    margin-top: 0;
    padding: 18px 16px;
  }

  .vocab-panel.vocab-panel-empty {
    padding-top: 8px;
    padding-bottom: 8px;
  }
}

@media (max-width: 640px) {
  .lesson-header,
  .controls {
    padding: 12px 14px; /* Reduced from 16px */
  }

  .sidebar {
    flex-direction: column;
    align-items: stretch;
    height: 100vh;
  }

  .sidebar-toggle {
    margin: 10px auto;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
  }

  button {
    font-size: 0.8rem;
    padding: 7px 12px;
  }

  /* Trên mobile, panel từ vựng hẹp hơn một chút so với nội dung câu JP */
  .vocab-panel {
    width: min(340px, 82vw);
    max-width: 82vw;
    margin: 0 auto;
    padding: 14px 14px;
  }

  .vocab-entry {
    padding: 10px 12px;
  }

  .jp {
    font-size: 0.82rem; /* Reduced from 0.85rem */
  }

  .romaji {
    font-size: 0.68rem; /* Reduced from 0.7rem */
  }

  .vi {
    font-size: 0.72rem; /* Reduced from 0.75rem */
  }

  .line {
    padding: 14px 16px;
  }

  .speed-progress {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}

/* ============================================
   Dark Mode Styles
   ============================================ */

/* Base dark mode */
body.theme-dark {
  color-scheme: dark;
}

body.theme-dark :root {
  color-scheme: dark;
  background-color: #0f172a;
  color: #f1f5f9;
}

/* Main view and content */
body.theme-dark .main-view {
  background: #0f172a;
  color: #f1f5f9;
}

body.theme-dark .content-area {
  background: #0f172a;
}

body.theme-dark .lines-wrapper {
  background: transparent;
}

/* Lesson header */
body.theme-dark .lesson-header {
  background: rgba(30, 41, 59, 0.8);
  color: #f1f5f9;
  border-bottom-color: rgba(148, 163, 184, 0.2);
  box-shadow: 0 24px 40px rgba(0, 0, 0, 0.4);
}

body.theme-dark .lesson-header h1 {
  color: #f1f5f9;
}

body.theme-dark .lesson-header p {
  color: #cbd5e1;
}

/* Controls section */
body.theme-dark .controls {
  background: rgba(30, 41, 59, 0.6);
  border-bottom-color: rgba(148, 163, 184, 0.2);
  color: #f1f5f9;
}

/* Buttons - all types */
body.theme-dark button {
  background-color: #3b82f6;
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(59, 130, 246, 0.3);
}

body.theme-dark button:hover {
  background-color: #2563eb;
  box-shadow: 0 16px 32px rgba(37, 99, 235, 0.4);
}

body.theme-dark .control-group button {
  background: #3b82f6;
  border-color: transparent;
  color: #ffffff;
}

body.theme-dark .control-group button:hover {
  background: #2563eb;
  border-color: #3b82f6;
}

body.theme-dark .btn-primary {
  background: linear-gradient(135deg, #facc15, #f97316);
  color: #1f2933;
  box-shadow: 0 14px 30px rgba(250, 204, 21, 0.4);
}

body.theme-dark .btn-secondary {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.5);
}

body.theme-dark .btn-secondary:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.3);
}

/* Scroll buttons */
body.theme-dark .scroll-btn {
  background-color: rgba(59, 130, 246, 0.9);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(59, 130, 246, 0.5);
}

body.theme-dark .scroll-btn:hover {
  background-color: #3b82f6;
}

/* Lines and content */
body.theme-dark .line {
  background: rgba(71, 85, 105, 0.95);
  border-color: rgba(148, 163, 184, 0.4);
  color: #f8fafc;
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.3);
}

body.theme-dark .line:hover:not(.active) {
  background: rgba(100, 116, 139, 1);
  border-color: rgba(96, 165, 250, 0.6);
  box-shadow: 0 20px 34px rgba(0, 0, 0, 0.4);
}

body.theme-dark .line.active {
  background: rgba(59, 130, 246, 0.4);
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5), 0 28px 40px rgba(59, 130, 246, 0.35);
}

/* Dark mode speaker styles */
body.theme-dark .line.speaker-さくら {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.15) 0%, rgba(219, 39, 119, 0.08) 100%);
  border-left-color: #ec4899;
}

body.theme-dark .line.speaker-さくら .speaker-badge {
  background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
  color: white;
}

body.theme-dark .line.speaker-アイン {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(37, 99, 235, 0.08) 100%);
  border-left-color: #3b82f6;
}

body.theme-dark .line.speaker-アイン .speaker-badge {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
}

body.theme-dark .line.speaker-A {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(37, 99, 235, 0.08) 100%);
  border-left-color: #3b82f6;
}

body.theme-dark .line.speaker-A .speaker-badge {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
}

body.theme-dark .line.speaker-B {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.15) 0%, rgba(219, 39, 119, 0.08) 100%);
  border-left-color: #ec4899;
}

body.theme-dark .line.speaker-B .speaker-badge {
  background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
  color: white;
}

body.theme-dark .line.speaker.active.speaker-さくら {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.3) 0%, rgba(219, 39, 119, 0.15) 100%);
  border-left-color: #ec4899;
  border-color: #ec4899;
  box-shadow: 0 0 0 2px rgba(236, 72, 153, 0.3), 0 28px 40px rgba(236, 72, 153, 0.2);
}

body.theme-dark .line.speaker.active.speaker-アイン {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.3) 0%, rgba(37, 99, 235, 0.15) 100%);
  border-left-color: #3b82f6;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3), 0 28px 40px rgba(59, 130, 246, 0.2);
}

body.theme-dark .line.speaker:hover.speaker-さくら {
  border-color: #f472b6;
  box-shadow: 0 20px 34px rgba(236, 72, 153, 0.15);
}

body.theme-dark .line.speaker:hover.speaker-アイン {
  border-color: #60a5fa;
  box-shadow: 0 20px 34px rgba(59, 130, 246, 0.15);
}

body.theme-dark .line.error {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  color: #fca5a5;
}

body.theme-dark .line.info {
  background: rgba(30, 41, 59, 0.5);
  border-color: rgba(148, 163, 184, 0.3);
  color: #cbd5e1;
}

/* Japanese and Vietnamese text */
body.theme-dark .jp {
  color: #f1f5f9;
}

body.theme-dark .vi {
  color: #cbd5e1;
}

body.theme-dark .romaji {
  color: #94a3b8;
}

/* Furigana (ruby) */
body.theme-dark rt {
  color: #60a5fa;
}

body.theme-dark ruby {
  color: #f1f5f9;
}

/* Vocab panel */
body.theme-dark .vocab-panel {
  background: rgba(30, 41, 59, 0.8);
  border-left-color: rgba(148, 163, 184, 0.3);
  color: #f1f5f9;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
}

body.theme-dark .vocab-header h2 {
  color: #e2e8f0;
}

body.theme-dark .vocab-summary {
  color: #cbd5e1;
}

body.theme-dark .vocab-entry {
  background: rgba(15, 23, 42, 0.6);
  border-color: rgba(148, 163, 184, 0.2);
  color: #f1f5f9;
}

body.theme-dark .vocab-entry:hover {
  background: rgba(30, 41, 59, 0.8);
  border-color: rgba(96, 165, 250, 0.5);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
}

body.theme-dark .vocab-entry.active {
  background: rgba(59, 130, 246, 0.25);
  border-color: #3b82f6;
  box-shadow: 0 16px 32px rgba(59, 130, 246, 0.3);
}

body.theme-dark .vocab-term {
  color: #f1f5f9;
}

body.theme-dark .vocab-reading {
  color: #93c5fd;
}

body.theme-dark .vocab-meaning {
  color: #cbd5e1;
}

body.theme-dark .vocab-note {
  color: #94a3b8;
}

body.theme-dark .vocab-empty {
  color: #64748b;
}

/* Inputs and selects */
body.theme-dark .lesson-search,
body.theme-dark .level-filter,
body.theme-dark select,
body.theme-dark input[type="search"],
body.theme-dark input[type="text"],
body.theme-dark .speed-select {
  background: rgba(30, 41, 59, 0.8);
  border-color: rgba(148, 163, 184, 0.4);
  color: #f1f5f9;
}

body.theme-dark .lesson-search::placeholder {
  color: #64748b;
}

body.theme-dark select option {
  background: #1e293b;
  color: #f1f5f9;
}

/* Checkboxes and labels */
body.theme-dark .checkbox {
  color: #e2e8f0;
}

body.theme-dark .checkbox input[type="checkbox"] {
  accent-color: #3b82f6;
}

body.theme-dark label {
  color: #e2e8f0;
}

body.theme-dark .speed-label {
  color: #cbd5e1;
}

/* Progress bars */
body.theme-dark .progress-bar-sm {
  background: rgba(30, 41, 59, 0.6); /* Xám nhạt hơn cho dark mode */
}

body.theme-dark .progress-fill,
body.theme-dark #lesson-progress-bar-inline {
  background: linear-gradient(90deg, #3b82f6, #2563eb); /* Giữ màu accent xanh */
}

body.theme-dark .progress-bar-sm:hover {
  background: rgba(30, 41, 59, 0.8);
}

body.theme-dark .line-progress {
  color: #e2e8f0;
}

/* Focus Mode: Ẩn sidebar và header */
body.focus-mode .sidebar {
  display: none;
}

body.focus-mode .top-layout {
  opacity: 0.3;
  transition: opacity 0.3s ease;
}

body.focus-mode .app-shell {
  margin-left: 0;
}

body.focus-mode #view-lesson .content-area {
  max-width: 100%;
  margin: 0 auto;
}

body.theme-dark .control-pill {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

/* Search */
body.theme-dark .search-group {
  background: rgba(30, 41, 59, 0.6);
  border-color: rgba(148, 163, 184, 0.3);
}

body.theme-dark .search-group-head h3 {
  color: #f1f5f9;
}

body.theme-dark .group-actions {
  color: #cbd5e1;
}

body.theme-dark .search-result-item {
  color: #f1f5f9;
  border-bottom-color: rgba(148, 163, 184, 0.2);
}

body.theme-dark .search-result-item:hover {
  background: rgba(59, 130, 246, 0.15);
}

body.theme-dark .search-result-item strong {
  color: #f1f5f9;
}

body.theme-dark .search-result-meta {
  color: #94a3b8;
}

body.theme-dark .search-status {
  background: rgba(30, 41, 59, 0.8);
  color: #cbd5e1;
  border-left-color: #3b82f6;
}

body.theme-dark .search-card-item {
  background: rgba(30, 41, 59, 0.5);
  border-color: rgba(148, 163, 184, 0.2);
  color: #f1f5f9;
}

body.theme-dark .search-card-item:hover {
  background: rgba(59, 130, 246, 0.15);
}

body.theme-dark .search-card-text .primary-line {
  color: #f1f5f9;
}

body.theme-dark .search-card-text .secondary-line {
  color: #cbd5e1;
}

body.theme-dark .search-card-meta {
  color: #94a3b8;
}

/* Welcome panel */
body.theme-dark .welcome-panel {
  background: rgba(30, 41, 59, 0.6);
  border-color: rgba(59, 130, 246, 0.3);
  color: #f1f5f9;
  box-shadow: 0 24px 40px rgba(0, 0, 0, 0.4);
}

body.theme-dark .welcome-hero h1 {
  color: #f1f5f9;
}

body.theme-dark .welcome-hero p {
  color: #cbd5e1;
}

body.theme-dark .welcome-hero .eyebrow {
  color: #60a5fa;
}

body.theme-dark .quick-tips {
  color: #cbd5e1;
}

body.theme-dark .hero-resume-meta {
  color: #94a3b8;
}

/* Chips */
body.theme-dark .group-chip {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

body.theme-dark .group-chip:hover {
  background: rgba(59, 130, 246, 0.25);
}

body.theme-dark .group-chip.active {
  background: #3b82f6;
  color: #ffffff;
}

body.theme-dark .lesson-chip {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.3);
}

body.theme-dark .lesson-chip:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: #3b82f6;
}

body.theme-dark .lesson-chip.active {
  background: #3b82f6;
  color: #ffffff;
  border-color: #3b82f6;
}

body.theme-dark .lesson-chip.empty {
  color: #64748b;
}

/* Sidebar quick panel */
body.theme-dark .sidebar-quick-panel {
  background: rgba(15, 23, 42, 0.98);
  border-color: rgba(148, 163, 184, 0.3);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

body.theme-dark .quick-item {
  background: rgba(30, 41, 59, 0.7);
  color: #f1f5f9;
}

body.theme-dark .quick-item:hover {
  background: rgba(59, 130, 246, 0.25);
}

body.theme-dark .quick-item .quick-state {
  color: #facc15;
}

/* Icons and emojis - ensure they're visible */
body.theme-dark .icon-btn,
body.theme-dark .sidebar-toggle,
body.theme-dark .mobile-nav-trigger,
body.theme-dark .mobile-nav-icon {
  color: #f1f5f9;
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.4);
}

body.theme-dark .icon-btn:hover,
body.theme-dark .sidebar-toggle:hover {
  background: rgba(59, 130, 246, 0.4);
  color: #ffffff;
  /* QUAN TRỌNG: Giữ nguyên transform để không bị lệch */
  transform: translateY(-50%);
}

/* Sidebar in dark mode */
body.theme-dark .sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: #f8fafc;
}

body.theme-dark .sidebar .brand-title {
  color: #f8fafc;
}

body.theme-dark .sidebar .brand-caption {
  color: rgba(248, 250, 252, 0.7);
}

body.theme-dark .category-item {
  color: #f8fafc;
}

body.theme-dark .category-item:hover {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

body.theme-dark .category-item.active {
  background: rgba(59, 130, 246, 0.25);
  color: #ffffff;
}

body.theme-dark .sidebar-footer {
  color: rgba(248, 250, 252, 0.7);
}

/* Mobile nav */
body.theme-dark .mobile-nav {
  background: rgba(15, 23, 42, 0.98);
  color: #f1f5f9;
}

body.theme-dark .mobile-nav-header h3 {
  color: #f1f5f9;
}

body.theme-dark .mobile-nav-cat-toggle,
body.theme-dark .mobile-nav-group-toggle,
body.theme-dark .mobile-nav-lesson {
  color: #f1f5f9;
}

body.theme-dark .mobile-nav-cat-toggle:hover,
body.theme-dark .mobile-nav-group-toggle:hover,
body.theme-dark .mobile-nav-lesson:hover {
  background: rgba(59, 130, 246, 0.15);
}

body.theme-dark .mobile-nav-lesson.active {
  background: rgba(59, 130, 246, 0.25);
  color: #ffffff;
}

/* Mark/highlight in search results */
body.theme-dark mark {
  background: rgba(250, 204, 21, 0.3);
  color: #facc15;
}

/* Group toggles and counts */
body.theme-dark .group-toggle,
body.theme-dark .group-count {
  color: #cbd5e1;
}

body.theme-dark .group-toggle:hover {
  color: #93c5fd;
}

/* Sidebar search results */
body.theme-dark .sidebar-search-item {
  color: #f1f5f9;
}

body.theme-dark .sidebar-search-item:hover {
  background: rgba(59, 130, 246, 0.15);
}

body.theme-dark .sidebar-search-item-name {
  color: #f1f5f9;
}

body.theme-dark .sidebar-search-item-meta {
  color: #94a3b8;
}

body.theme-dark .sidebar-search-group-title {
  color: #e2e8f0;
}

body.theme-dark .sidebar-search-count {
  color: #93c5fd;
}

/* Top layout */
body.theme-dark .top-layout {
  background: transparent;
}

/* Ensure all text is visible */
body.theme-dark h1,
body.theme-dark h2,
body.theme-dark h3,
body.theme-dark p,
body.theme-dark span {
  color: inherit;
}

body.theme-dark .lesson-meta {
  color: #cbd5e1;
}

/* Daily duration and stats */
body.theme-dark #daily-duration {
  color: #93c5fd;
}

/* Category list items */
body.theme-dark .category-item {
  color: #e2e8f0;
}

body.theme-dark .category-item:hover {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

body.theme-dark .category-item.active {
  background: rgba(59, 130, 246, 0.25);
  color: #ffffff;
}

/* Group toggles */
body.theme-dark .group-toggle {
  color: #cbd5e1;
}

body.theme-dark .group-toggle:hover {
  color: #93c5fd;
}

body.theme-dark .group-count {
  color: #94a3b8;
}

/* Sidebar sections */
body.theme-dark .sidebar-section h2 {
  color: #e2e8f0;
}

/* Hero actions and resume */
body.theme-dark .hero-actions {
  color: #f1f5f9;
}

body.theme-dark .hero-resume-meta {
  color: #94a3b8;
}

body.theme-dark .eyebrow {
  color: #60a5fa;
}

/* Ensure emoji icons are visible */
body.theme-dark .icon-btn,
body.theme-dark button[class*="icon"],
body.theme-dark .search-icon,
body.theme-dark .mobile-nav-icon {
  filter: brightness(1.3) contrast(1.1);
  opacity: 1;
  color: #f1f5f9;
}

/* Ensure emoji text is visible */
body.theme-dark .icon-btn::before,
body.theme-dark button::before {
  filter: brightness(1.3);
}

/* Make sure all button text and emojis are visible */
body.theme-dark button {
  color: #ffffff;
}

body.theme-dark .icon-btn {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.4);
  color: #f1f5f9;
}

body.theme-dark .icon-btn:hover {
  background: rgba(59, 130, 246, 0.4);
  color: #ffffff;
  filter: brightness(1.4);
}

/* Top layout and main container */
body.theme-dark .top-layout {
  background: transparent;
}

body.theme-dark .main-container {
  background: transparent;
}

/* Ensure all text elements inherit proper colors */
body.theme-dark * {
  border-color: inherit;
}

/* Override any remaining hardcoded colors */
body.theme-dark .lesson-meta,
body.theme-dark .lesson-info {
  color: #cbd5e1;
}

/* Mobile nav specific */
body.theme-dark .mobile-nav-trigger {
  background: rgba(59, 130, 246, 0.2);
  color: #f1f5f9;
  border-color: rgba(59, 130, 246, 0.4);
}

body.theme-dark .mobile-nav-trigger:hover {
  background: rgba(59, 130, 246, 0.4);
}

/* Ensure disabled buttons are visible but muted */
body.theme-dark button:disabled {
  opacity: 0.5;
  background: rgba(59, 130, 246, 0.2);
  color: #94a3b8;
}

/* Search inline compact */
body.theme-dark .search-inline.compact {
  background: rgba(30, 41, 59, 0.6);
  border-color: rgba(148, 163, 184, 0.3);
}

/* Additional text elements */
body.theme-dark .brand-title {
  color: #f8fafc;
}

body.theme-dark .brand-caption {
  color: rgba(248, 250, 252, 0.7);
}

body.theme-dark .sidebar-footer p {
  color: rgba(248, 250, 252, 0.7);
}

/* Ensure all interactive elements have proper contrast */
body.theme-dark a {
  color: #60a5fa;
}

body.theme-dark a:hover {
  color: #93c5fd;
}

/* Fix any remaining visibility issues */
body.theme-dark .group-actions {
  color: #cbd5e1;
}

body.theme-dark .group-actions:hover {
  color: #93c5fd;
}

/* Vocab panel highlight animation */
.vocab-panel-highlight {
  animation: vocabPanelPulse 2s ease;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.3) !important;
}

@keyframes vocabPanelPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.2);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
  }
}

/* Notification animation */
@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Dark mode cho vocab panel highlight */
body.theme-dark .vocab-panel-highlight {
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.4) !important;
}

@keyframes vocabPanelPulseDark {
  0% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.6);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.3);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
  }
}

body.theme-dark .vocab-panel-highlight {
  animation: vocabPanelPulseDark 2s ease;
}

/* Notification styles */
#vocab-notification {
  font-family: "Noto Sans JP", "Segoe UI", system-ui, sans-serif;
  word-wrap: break-word;
}

/* Dark mode cho notification */
body.theme-dark #vocab-notification {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Additional comprehensive dark mode fixes */

/* Ensure all text content is visible */
body.theme-dark .line * {
  color: inherit;
}

body.theme-dark .jp,
body.theme-dark .vi,
body.theme-dark .romaji {
  opacity: 1;
}

/* Fix any remaining hardcoded dark text on dark background */
body.theme-dark .line .jp {
  color: #f1f5f9 !important;
}

body.theme-dark .line .vi {
  color: #cbd5e1 !important;
}

body.theme-dark .line .romaji {
  color: #94a3b8 !important;
}

/* Ensure buttons have proper contrast */
body.theme-dark button:not(:disabled) {
  color: #ffffff !important;
}

/* Fix search inline icon button specifically */
body.theme-dark .search-inline .icon-btn,
body.theme-dark .search-inline.compact .icon-btn {
  background: rgba(59, 130, 246, 0.3);
  color: #f1f5f9;
  border: 1px solid rgba(59, 130, 246, 0.5);
}

body.theme-dark .search-inline .icon-btn:hover,
body.theme-dark .search-inline.compact .icon-btn:hover {
  background: rgba(59, 130, 246, 0.5);
  color: #ffffff;
}

/* Ensure all emoji and special characters are visible */
body.theme-dark * {
  text-shadow: none;
}

/* Fix any elements that might have transparent or same-color text */
body.theme-dark .lesson-header *,
body.theme-dark .controls *,
body.theme-dark .content-area * {
  color: inherit;
}

/* Ensure proper contrast for all interactive elements */
body.theme-dark .chip,
body.theme-dark .group-chip,
body.theme-dark .lesson-chip {
  border-color: rgba(148, 163, 184, 0.3);
}

/* Fix sidebar toggle button */
body.theme-dark .sidebar-toggle {
  background: rgba(59, 130, 246, 0.3);
  color: #f1f5f9;
  border-color: rgba(59, 130, 246, 0.5);
}

/* Mobile: Reduce font sizes globally */
@media (max-width: 768px) {
  /* Base font size reduction */
  body {
    font-size: 0.875rem;
  }

  /* Brand */
  .brand-title {
    font-size: 1.2rem;
  }

  .brand-caption {
    font-size: 0.8rem;
  }

  /* Sidebar */
  .sidebar {
    font-size: 0.8rem;
  }

  .category-item {
    font-size: 0.85rem;
    padding: 10px 14px;
  }

  /* Main content */
  .main-view {
    font-size: 0.875rem;
  }

  .lesson-header h1 {
    font-size: 1.4rem;
  }

  .lesson-header p {
    font-size: 0.875rem;
  }

  .lesson-header .lesson-meta {
    font-size: 0.8rem;
  }

  /* Lines */
  .line {
    font-size: 0.875rem;
    padding: 10px 12px;
  }

  .line .jp {
    font-size: 0.85rem; /* Reduced from 0.88rem */
  }

  .line .vi {
    font-size: 0.72rem; /* Reduced from 0.75rem */
  }

  .line .romaji {
    font-size: 0.63rem; /* Reduced from 0.65rem */
  }

  .line .speaker-badge {
    font-size: 0.7rem;
    padding: 3px 8px;
  }

  /* Controls */
  .controls {
    font-size: 0.8rem;
  }

  .control-pill {
    font-size: 0.75rem;
    padding: 6px 12px;
  }

  .btn-primary,
  .btn-secondary {
    font-size: 0.8rem;
    padding: 8px 14px;
  }

  /* Search */
  .search-card-text .primary-line {
    font-size: 0.875rem;
  }

  .search-card-text .secondary-line {
    font-size: 0.8rem;
  }

  .search-card-text .tertiary-line {
    font-size: 0.7rem;
  }

  .search-result-item strong {
    font-size: 0.875rem;
  }

  .search-result-meta {
    font-size: 0.75rem;
  }

  .sidebar-search-status {
    font-size: 0.7rem;
  }

  /* Vocab */
  .vocab-header h2 {
    font-size: 1rem;
  }

  .vocab-summary {
    font-size: 0.75rem;
  }

  .vocab-entry {
    font-size: 0.8rem;
  }

  .vocab-word {
    font-size: 0.9rem;
  }

  .vocab-reading {
    font-size: 0.7rem;
  }

  .vocab-meaning {
    font-size: 0.8rem;
  }

  /* Welcome panel */
  .welcome-panel h1 {
    font-size: 1.6rem;
  }

  .welcome-panel p {
    font-size: 0.875rem;
  }

  .welcome-hero h1 {
    font-size: 1.75rem;
  }

  /* Chips */
  .chip,
  .group-chip,
  .lesson-chip {
    font-size: 0.75rem;
    padding: 6px 12px;
  }

  .lesson-chip-name {
    font-size: 0.75rem;
  }

  /* Progress */
  .line-progress {
    font-size: 0.75rem;
  }

  /* Header controls */
  .header-controls {
    font-size: 0.8rem;
  }

  /* Tags */
  .lesson-tag,
  .search-tag {
    font-size: 0.6rem;
    padding: 2px 5px;
  }

  .lesson-chip-tags {
    gap: 3px;
  }

  /* Mobile nav */
  .mobile-nav-header h3 {
    font-size: 0.9rem;
  }

  .mobile-nav-cat-toggle,
  .mobile-nav-group-toggle {
    font-size: 0.9rem;
    padding: 12px 16px;
  }

  .mobile-nav-lesson {
    font-size: 0.85rem;
    padding: 10px 14px;
  }

  /* Tags */
  .lesson-tag,
  .search-tag {
    font-size: 0.65rem;
    padding: 2px 5px;
  }

  .lesson-chip-tags {
    gap: 3px;
  }
}

body.theme-dark .sidebar-toggle:hover {
  background: rgba(59, 130, 246, 0.5);
  color: #ffffff;
  /* QUAN TRỌNG: Giữ nguyên transform để không bị lệch */
  transform: translateY(-50%);
}

/* Ensure scroll buttons are visible */
body.theme-dark .scroll-btn {
  background-color: rgba(59, 130, 246, 0.9) !important;
  color: #ffffff !important;
}

body.theme-dark .scroll-btn:hover {
  background-color: #3b82f6 !important;
}

/* Fix any remaining visibility issues with specific overrides */
body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
  color: #f1f5f9;
  background-color: rgba(30, 41, 59, 0.8);
}

body.theme-dark ::placeholder {
  color: #64748b;
  opacity: 1;
}

/* Feedback Button Styles */
.lesson-header-actions {
  display: flex;
  align-items: center;
  gap: 8px; /* Reduced from 12px */
  margin-top: 0;
  flex-shrink: 0;
}

@media (max-width: 639px) {
  .lesson-header-actions {
    margin-top: 8px; /* Reduced from 12px */
  }
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.85rem;
}

/* Feedback Modal Styles */
.feedback-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  box-sizing: border-box;
}

.feedback-backdrop.is-open {
  display: flex;
}

.feedback-dialog {
  background: #ffffff;
  color: #1f2933;
  max-width: 420px;
  width: 100%;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.6);
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-height: 80vh;
  overflow-y: auto;
}

.feedback-dialog-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feedback-dialog-header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: #0f172a;
  font-weight: 600;
}

.feedback-lesson-label {
  margin: 0;
  font-size: 0.8rem;
  color: #64748b;
}

.feedback-lesson-label span {
  font-weight: 600;
  color: #1d4ed8;
}

.feedback-dialog-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.feedback-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.feedback-field label {
  font-size: 0.8rem;
  font-weight: 500;
  color: #1f2933;
}

.feedback-field .required {
  color: #ef4444;
}

.feedback-select,
.feedback-input,
.feedback-textarea {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 8px;
  font-size: 0.8rem;
  font-family: inherit;
  background: #ffffff;
  color: #1f2933;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.feedback-select:focus,
.feedback-input:focus,
.feedback-textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.feedback-textarea {
  resize: vertical;
  min-height: 56px;
}

.feedback-error {
  font-size: 0.85rem;
  color: #ef4444;
  margin-top: -4px;
}

.feedback-error.hidden {
  display: none;
}

.feedback-dialog-footer {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
}

.feedback-dialog-footer .btn-primary,
.feedback-dialog-footer .btn-secondary {
  flex: 0 0 auto;
}

/* Dark mode styles for feedback modal */
body.theme-dark .feedback-dialog {
  background: #0b1120;
  color: #e5e7eb;
}

body.theme-dark .feedback-dialog-header h2 {
  color: #f1f5f9;
}

body.theme-dark .feedback-lesson-label {
  color: #94a3b8;
}

body.theme-dark .feedback-lesson-label span {
  color: #60a5fa;
}

body.theme-dark .feedback-field label {
  color: #e5e7eb;
}

body.theme-dark .feedback-select,
body.theme-dark .feedback-input,
body.theme-dark .feedback-textarea {
  background: #1e293b;
  color: #e5e7eb;
  border-color: rgba(148, 163, 184, 0.3);
}

body.theme-dark .feedback-select:focus,
body.theme-dark .feedback-input:focus,
body.theme-dark .feedback-textarea:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Mobile styles for feedback modal */
@media (max-width: 640px) {
  .feedback-backdrop {
    padding: 0;
    align-items: flex-end;
  }

  .feedback-dialog {
    border-radius: 16px 16px 0 0;
    width: 100vw;
    max-width: 100vw;
    max-height: 64vh;
    padding: 16px;
    margin-bottom: 70px; /* chừa chỗ cho mobile-bottom-nav để không che nút Gửi */
  }

  .feedback-dialog-footer {
    flex-direction: row;
    justify-content: center; /* Canh giữa 2 nút trên mobile */
  }
}

/* Review View Styles */
/* On desktop, always hide review view (it's mobile-only) */
@media (min-width: 769px) {
  .view-review {
    display: none !important;
  }
  
  .view-page.is-active.view-review {
    display: none !important;
  }
}

/* On mobile, hide by default, show only when active */
@media (max-width: 768px) {
  .view-review {
    display: none;
  }
  
  .view-page.is-active.view-review {
    display: block;
  }
}

.review-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px 16px 80px; /* bottom padding for mobile bottom nav */
  background: transparent;
  box-sizing: border-box;
}

.review-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #1f2933;
  margin-bottom: 16px;
  text-align: center;
}

body.theme-dark .review-title {
  color: #e5e7eb;
}

.review-tabs {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  padding: 2px;
  margin-bottom: 16px;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

body.theme-dark .review-tabs {
  background: rgba(15, 23, 42, 0.9);
  border-color: rgba(148, 163, 184, 0.5);
}

.review-tab-button {
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 0.875rem;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  font-weight: 500;
}

body.theme-dark .review-tab-button {
  color: #cbd5f5;
}

.review-tab-button:hover {
  background: rgba(148, 163, 184, 0.1);
}

body.theme-dark .review-tab-button:hover {
  background: rgba(148, 163, 184, 0.2);
}

.review-tab-button.is-active {
  background: #1d4ed8;
  color: #ffffff;
}

body.theme-dark .review-tab-button.is-active {
  background: #2563eb;
  color: #f9fafb;
}

.review-tab-content {
  margin-top: 8px;
}

.review-tab-panel {
  display: none;
}

.review-tab-panel.is-active {
  display: block;
}

/* Saved words list */
.review-empty-state {
  font-size: 0.875rem;
  color: #64748b;
  padding: 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.6);
  margin-top: 8px;
  text-align: center;
  line-height: 1.6;
}

body.theme-dark .review-empty-state {
  background: rgba(15, 23, 42, 0.6);
  color: #9ca3af;
}

.saved-words-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.saved-word-item {
  border-radius: 12px;
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.25);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

body.theme-dark .saved-word-item {
  background: #020617;
  border-color: rgba(148, 163, 184, 0.35);
}

.saved-word-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border-color: rgba(148, 163, 184, 0.4);
}

body.theme-dark .saved-word-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  border-color: rgba(148, 163, 184, 0.5);
}

.saved-word-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.saved-word-jp {
  font-size: 1rem;
  color: #1f2933;
  font-weight: 500;
}

body.theme-dark .saved-word-jp {
  color: #e5e7eb;
}

.saved-word-reading {
  font-size: 0.8125rem;
  color: #64748b;
}

body.theme-dark .saved-word-reading {
  color: #cbd5f5;
}

.saved-word-vi {
  font-size: 0.875rem;
  color: #475569;
  margin-top: 2px;
}

body.theme-dark .saved-word-vi {
  color: #9ca3af;
}

.saved-word-meta {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 4px;
}

body.theme-dark .saved-word-meta {
  color: #64748b;
}

.saved-word-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}

/* Base button style */
.saved-word-btn {
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  font-weight: 500;
  white-space: nowrap;
}

/* "Đã nhớ" / "Đánh dấu đã nhớ" = primary, safe, green */
.saved-word-btn-known {
  background: rgba(22, 163, 74, 0.12);
  border-color: rgba(34, 197, 94, 0.7);
  color: #16a34a;
  font-weight: 600;
}

body.theme-dark .saved-word-btn-known {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.4);
}

.saved-word-btn-known:hover {
  background: rgba(34, 197, 94, 0.2);
  border-color: rgba(34, 197, 94, 0.7);
  color: #15803d;
}

body.theme-dark .saved-word-btn-known:hover {
  background: rgba(34, 197, 94, 0.25);
  border-color: rgba(34, 197, 94, 0.6);
  color: #86efac;
}

/* When card is marked mastered - button becomes "Hoàn tác" */
.saved-word-item--mastered .saved-word-btn-known {
  background: rgba(22, 163, 74, 0.08);
  border-color: rgba(34, 197, 94, 0.4);
  color: #86efac;
  font-weight: 500;
}

body.theme-dark .saved-word-item--mastered .saved-word-btn-known {
  background: rgba(34, 197, 94, 0.1);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.3);
}

.saved-word-item--mastered .saved-word-btn-known:hover {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.5);
  color: #4ade80;
}

body.theme-dark .saved-word-item--mastered .saved-word-btn-known:hover {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.4);
  color: #86efac;
}

/* "Xóa" = dangerous, red, secondary */
.saved-word-btn-delete {
  background: rgba(127, 29, 29, 0.08);
  border-color: rgba(248, 113, 113, 0.7);
  color: #ef4444;
}

body.theme-dark .saved-word-btn-delete {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
}

.saved-word-btn-delete:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.7);
  color: #b91c1c;
}

body.theme-dark .saved-word-btn-delete:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.6);
  color: #fca5a5;
}

/* Card background when mastered */
.saved-word-item--mastered {
  opacity: 0.85;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(240, 253, 244, 0.8));
  border-color: rgba(34, 197, 94, 0.3);
}

body.theme-dark .saved-word-item--mastered {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(6, 78, 59, 0.3));
  border-color: rgba(34, 197, 94, 0.25);
}

.saved-word-item--mastered:hover {
  opacity: 0.95;
  border-color: rgba(34, 197, 94, 0.4);
}

body.theme-dark .saved-word-item--mastered:hover {
  opacity: 0.9;
  border-color: rgba(34, 197, 94, 0.35);
}

/* Quiz area */
.review-quiz-description {
  font-size: 0.875rem;
  color: #475569;
  margin-bottom: 12px;
  line-height: 1.6;
}

body.theme-dark .review-quiz-description {
  color: #cbd5f5;
}

.review-quiz-area {
  margin-top: 16px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.25);
  padding: 16px;
  display: none; /* hidden until quiz started */
}

body.theme-dark .review-quiz-area {
  background: #020617;
  border-color: rgba(148, 163, 184, 0.35);
}

.review-quiz-question {
  font-size: 1rem;
  color: #1f2933;
  margin-bottom: 12px;
  font-weight: 500;
  line-height: 1.6;
}

body.theme-dark .review-quiz-question {
  color: #e5e7eb;
}

.review-quiz-question strong {
  font-size: 1.125rem;
  color: #1d4ed8;
}

body.theme-dark .review-quiz-question strong {
  color: #60a5fa;
}

.review-quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.review-quiz-option {
  width: 100%;
  text-align: left;
  font-size: 0.875rem;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(255, 255, 255, 0.9);
  color: #1f2933;
  cursor: pointer;
  transition: all 0.15s ease;
}

body.theme-dark .review-quiz-option {
  background: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
  border-color: rgba(148, 163, 184, 0.5);
}

.review-quiz-option:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: rgba(148, 163, 184, 0.6);
}

body.theme-dark .review-quiz-option:hover:not(:disabled) {
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(148, 163, 184, 0.7);
}

.review-quiz-option:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.review-quiz-option.is-correct {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.12);
  color: #15803d;
}

body.theme-dark .review-quiz-option.is-correct {
  background: rgba(22, 163, 74, 0.2);
  color: #4ade80;
}

.review-quiz-option.is-wrong {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}

body.theme-dark .review-quiz-option.is-wrong {
  background: rgba(248, 113, 113, 0.2);
  color: #f87171;
}

.review-quiz-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8125rem;
  color: #64748b;
  margin-top: 12px;
}

body.theme-dark .review-quiz-footer {
  color: #9ca3af;
}

.review-quiz-footer button {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: #1d4ed8;
  color: #ffffff;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

body.theme-dark .review-quiz-footer button {
  background: #2563eb;
  border-color: rgba(148, 163, 184, 0.5);
}

.review-quiz-footer button:hover {
  background: #1e40af;
}

body.theme-dark .review-quiz-footer button:hover {
  background: #1d4ed8;
}

.review-quiz-feedback {
  margin-bottom: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.1);
  color: #1e40af;
}

body.theme-dark .review-quiz-feedback {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

/* Mobile styles */
@media (max-width: 768px) {
  .review-container {
    padding: 8px 8px 80px;
    font-size: 0.78rem;
    margin: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  
  .review-title {
    padding: 0;
    margin: 0 0 8px 0;
    text-align: center;
    width: 100%;
  }
  
  /* Ensure all items inside review-container have consistent alignment */
  .review-container > * {
    width: 100%;
    box-sizing: border-box;
    padding-left: 0;
    padding-right: 0;
  }
  
  .review-container .review-tabs,
  .review-container .review-tab-content {
    padding-left: 0;
    padding-right: 0;
    margin-left: 0;
    margin-right: 0;
  }

  .review-title {
    font-size: 1rem;
    margin-bottom: 8px;
    text-align: center;
  }

  .review-tabs {
    margin: 0 0 8px;
    display: flex;
    justify-content: center;
    width: 100%;
    padding: 0;
    box-sizing: border-box;
  }

  .review-tab-button {
    font-size: 0.7rem;
    padding: 5px 10px;
  }

  .review-tab-content {
    width: 100%;
    margin: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
  }

  .review-tab-panel {
    width: 100%;
    margin: 0;
    box-sizing: border-box;
    padding: 0;
  }

  .saved-words-list {
    gap: 6px;
    margin: 8px 0 0;
    width: 100%;
    max-width: 100%;
    padding: 0;
    box-sizing: border-box;
    list-style: none;
  }

  .saved-word-item {
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 0.78rem;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
  }

  .saved-word-jp {
    font-size: 0.9rem;
  }

  .saved-word-reading {
    font-size: 0.75rem;
  }

  .saved-word-vi {
    font-size: 0.8rem;
  }

  .saved-word-meta {
    font-size: 0.7rem;
  }

  .saved-word-btn {
    font-size: 0.68rem;
    padding: 3px 6px;
  }

  .review-empty-state,
  #saved-words-empty {
    font-size: 0.75rem;
    padding: 10px;
  }
}

/* Focus Session Styles */

/* Lesson session panel (inside view-lesson) - Hidden on all screens */
.lesson-session-panel,
.control-group.lesson-session-panel,
#lesson-session-panel {
  display: none !important;
  visibility: hidden !important;
}

.lesson-session-chip {
  border: none;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #e5e7eb;
  color: #374151;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.1s ease;
}

.lesson-session-chip:hover {
  background: #dbeafe;
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
}

.lesson-session-chip.is-running {
  background: #22c55e;
  color: #052e16;
  box-shadow: 0 0 0 1px rgba(22, 163, 74, 0.5);
}

body.theme-dark .lesson-session-chip {
  background: rgba(148, 163, 184, 0.3);
  color: #e5e7eb;
}

body.theme-dark .lesson-session-chip:hover {
  background: rgba(59, 130, 246, 0.3);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.5);
}

body.theme-dark .lesson-session-chip.is-running {
  background: #22c55e;
  color: #052e16;
  box-shadow: 0 0 0 1px rgba(22, 163, 74, 0.6);
}

.session-duration-btn {
  flex: 0 0 auto;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(59, 130, 246, 0.9);
  background: rgba(37, 99, 235, 0.15);
  color: #e5e7eb;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.session-duration-btn:hover {
  background: rgba(37, 99, 235, 0.3);
  border-color: rgba(59, 130, 246, 1);
}

/* Hide lesson-session-custom on all screens */
.lesson-session-custom {
  display: none !important;
  visibility: hidden !important;
}

.session-custom-input {
  flex: 1;
  min-width: 120px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: #ffffff;
  color: #1e293b;
  font-size: 0.8rem;
  outline: none;
  transition: all 0.2s ease;
  box-sizing: border-box;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.session-custom-input:focus {
  border-color: rgba(59, 130, 246, 0.7);
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.15), 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.session-custom-input:hover:not(:focus) {
  border-color: rgba(148, 163, 184, 0.6);
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.1);
}

.session-custom-input::placeholder {
  color: #94a3b8;
  opacity: 0.7;
}

body.theme-dark .session-custom-input {
  background: rgba(51, 65, 85, 0.8);
  color: #e5e7eb;
  border-color: rgba(148, 163, 184, 0.5);
}

body.theme-dark .session-custom-input:focus {
  background: rgba(51, 65, 85, 0.95);
  border-color: rgba(59, 130, 246, 0.8);
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.2), 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.session-custom-btn {
  flex: 0 0 auto;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid rgba(34, 197, 94, 0.7);
  background: rgba(34, 197, 94, 0.9);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(34, 197, 94, 0.25);
}

.session-custom-btn:hover {
  background: rgba(22, 163, 74, 0.95);
  border-color: rgba(34, 197, 94, 1);
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(34, 197, 94, 0.35);
}

.session-custom-btn:active {
  background: rgba(21, 128, 61, 0.95);
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(34, 197, 94, 0.25);
}

/* Hide lesson-session-note on all screens */
.lesson-session-note {
  display: none !important;
  visibility: hidden !important;
}

/* Focus timer widget */
.focus-timer-widget {
  position: fixed;
  right: 16px;
  bottom: 80px; /* leave space for bottom nav on mobile */
  z-index: 150;
  background: rgba(15, 23, 42, 0.98);
  border-radius: 16px;
  padding: 10px 12px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(59, 130, 246, 0.7);
  color: #e5e7eb;
  display: none; /* hidden by default */
  min-width: 180px;
}

.focus-timer-widget.is-visible {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.focus-timer-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.focus-timer-title {
  font-size: 0.78rem;
  font-weight: 600;
}

.focus-timer-time {
  font-size: 1.1rem;
  font-weight: 700;
}

.focus-timer-progress {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(30, 64, 175, 0.5);
  overflow: hidden;
}

.focus-timer-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22c55e, #eab308);
  transition: width 0.3s ease;
}

.focus-timer-controls {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.focus-timer-btn {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
  font-size: 0.72rem;
  padding: 3px 8px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.focus-timer-btn:hover {
  background: rgba(30, 41, 59, 0.95);
  border-color: rgba(148, 163, 184, 0.8);
}

.focus-timer-btn-stop {
  border-color: rgba(248, 113, 113, 0.8);
  color: #fecaca;
}

.focus-timer-btn-stop:hover {
  background: rgba(127, 29, 29, 0.2);
  border-color: rgba(248, 113, 113, 1);
}

/* Timer widget animations */
@keyframes timer-warning-flash {
  0%, 100% {
    border-color: rgba(59, 130, 246, 0.7);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.7);
  }
  50% {
    border-color: rgba(234, 179, 8, 0.9);
    box-shadow: 0 16px 40px rgba(234, 179, 8, 0.4), 0 0 20px rgba(234, 179, 8, 0.3);
  }
}

@keyframes timer-complete-flash {
  0%, 100% {
    border-color: rgba(59, 130, 246, 0.7);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.7);
  }
  50% {
    border-color: rgba(34, 197, 94, 0.9);
    box-shadow: 0 16px 40px rgba(34, 197, 94, 0.4), 0 0 30px rgba(34, 197, 94, 0.3);
    transform: scale(1.02);
  }
}

/* Home focus summary card */
/* Legacy home-focus-card - update to light theme if used */
.home-focus-card {
  border-radius: 16px;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-top: 3px solid #22c55e;
  color: #0f172a;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

body.theme-dark .home-focus-card {
  background: #ffffff;
  color: #0f172a;
}

.home-focus-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.home-focus-time {
  font-size: 1.1rem;
  font-weight: 700;
  color: #111827;
}

.home-focus-sessions {
  font-size: 0.82rem;
  color: #6b7280;
}

.home-focus-meta {
  font-size: 0.78rem;
  color: #374151;
}

/* Desktop Home Dashboard Styles */
/* Generic view-page helper */
.view-page {
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  flex: 1;
  min-height: auto;
  background: inherit;
  align-items: flex-start;
  flex-direction: column;
  gap: 24px;
}

.view-page.is-active {
  display: flex;
  flex-direction: column;
  opacity: 1;
  animation: fadeInView 0.3s ease;
}

/* Ensure only one view is visible at a time - high specificity */
.view-page:not(.is-active),
#view-home:not(.is-active),
#view-lesson:not(.is-active),
#view-review:not(.is-active) {
  display: none !important;
}

/* Ensure controls and content-area are only visible when view-lesson is active */
#view-lesson:not(.is-active) .controls,
#view-lesson:not(.is-active) .content-area {
  display: none;
}

/* Ensure view-lesson has proper layout */
#view-lesson {
  width: 100%;
}

#view-lesson.is-active {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
}

#view-lesson.is-active > .top-layout,
#view-lesson.is-active > .controls,
#view-lesson.is-active > .content-area {
  width: 100%;
  box-sizing: border-box;
}

/* Responsive adjustments for view-lesson */
@media (max-width: 768px) {
  #view-lesson.is-active {
    gap: 16px;
  }
  
  #view-lesson.is-active > .controls {
    display: flex;
  }
  
  #view-lesson.is-active > .content-area {
    display: flex;
  }
}

/* Home view: light background */
#view-home {
  background: transparent;
}

#view-home.is-active {
  display: flex !important;
  flex-direction: column;
  background: #f3f4f6;
}

@media (max-width: 768px) {
  #view-home.is-active {
    display: flex !important;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
  }
  
  #view-home.is-active .home-container {
    width: 100%;
    display: block;
  }
}

@keyframes fadeInView {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Home container (desktop) */
.home-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 24px 28px;
  flex: 1;
  width: 100%;
  min-height: auto;
  box-sizing: border-box;
  background: #f3f4f6;
  align-items: flex-start;
}

@media (max-width: 1024px) {
  .home-container {
    padding: 16px 14px 20px;
  }
}

.home-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.home-row-main {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.8fr);
  gap: 16px;
}

.home-grid-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (max-width: 768px) {
  .home-grid-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  
  /* Session card should be full width on mobile */
  .home-row:has(.home-card-session) {
    grid-template-columns: 1fr;
  }
  
  .home-row:has(.home-card-session) .home-card-session {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1024px) {
  .home-grid-row {
    grid-template-columns: 1.1fr 0.9fr;
  }
}

.home-row-top {
  max-width: 520px;
}

/* Featured container with navigation buttons */
.home-featured-container {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Featured grid - Horizontal scroll layout */
.home-featured-grid {
  display: flex;
  gap: 16px;
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scrollbar-width: none; /* Hide scrollbar */
  -ms-overflow-style: none; /* Hide scrollbar for IE/Edge */
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-width: 0;
}

.home-featured-grid::-webkit-scrollbar {
  display: none; /* Hide scrollbar for Chrome/Safari */
}

/* Navigation buttons */
.home-featured-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(255, 255, 255, 0.9);
  color: #64748b;
  font-size: 20px;
  font-weight: 300;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  z-index: 10;
}

.home-featured-nav-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 1);
  border-color: rgba(59, 130, 246, 0.5);
  color: #3b82f6;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  transform: scale(1.05);
}

.home-featured-nav-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.home-featured-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

/* Hide buttons on mobile */
@media (max-width: 768px) {
  .home-featured-nav-btn {
    display: none;
  }
  
  .home-featured-grid {
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
  }
  
  .home-featured-grid::-webkit-scrollbar {
    display: block;
    height: 6px;
  }
  
  .home-featured-grid::-webkit-scrollbar-track {
    background: transparent;
  }
  
  .home-featured-grid::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 3px;
  }
  
  .home-featured-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
  }
}

/* Mobile ticker - hidden by default, only show on mobile */
.home-featured-ticker {
  display: none !important;
}

/* Desktop: ensure ticker is always hidden */
@media (min-width: 769px) {
  .home-featured-ticker {
    display: none !important;
  }
  
  .home-featured-grid {
    display: flex !important; /* Horizontal layout */
    flex-direction: row !important;
  }
}

.home-featured-card {
  border-radius: 12px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.2);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  transition: all 0.3s ease;
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  cursor: pointer;
  flex-shrink: 0;
  min-width: 280px; /* Fixed width for horizontal layout */
  max-width: 320px;
  width: 280px; /* Fixed width, not 100% */
}

.home-featured-card:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(59, 130, 246, 0.3);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.home-featured-card-header {
  font-weight: 500;
  color: #334155;
  font-size: 0.9rem;
  line-height: 1.4;
}

.home-featured-card-meta {
  font-size: 0.8rem;
  color: #64748b;
  line-height: 1.3;
}

.home-featured-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.72rem;
  margin-top: 4px;
}

.home-featured-tag {
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(241, 245, 249, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: #64748b;
}

.home-featured-card-footer {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}

.home-featured-card-btn {
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.8rem;
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
}

.home-featured-card-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  color: #2563eb;
  transform: translateY(-1px);
}

/* Daily Quote Card */
.home-card-quote {
  padding: 10px 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, #eef2ff, #f9fafb);
  border: 1px solid rgba(129, 140, 248, 0.5);
  font-size: 0.9rem;
}

.home-card-quote .quote-jp {
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 4px;
  font-size: 1rem;
}

.home-card-quote .quote-vi {
  font-size: 0.84rem;
  color: #4b5563;
  line-height: 1.4;
}

/* Mobile: slightly smaller */
@media (max-width: 768px) {
  .home-card-quote {
    padding: 8px 10px;
    font-size: 0.86rem;
  }
  
  .home-card-quote .quote-jp {
    font-size: 0.92rem;
  }
  
  .home-card-quote .quote-vi {
    font-size: 0.8rem;
  }
}

.home-featured-empty {
  padding: 20px;
  text-align: center;
  color: #6b7280;
  font-style: italic;
}

/* Disabled button state */
.home-btn-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.home-btn-disabled:hover {
  transform: none;
}

.home-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: #111827;
  margin-bottom: 6px;
}

.home-section {
  margin-bottom: 16px;
}

.home-section:last-of-type {
  margin-bottom: 24px;
}

/* Cards - Light Theme */
.home-card {
  border-radius: 18px;
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: #0f172a;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  position: relative;
  overflow: hidden;
  font-size: 0.86rem;
}

/* Remove any left-over before-accents from previous dark theme */
.home-card::before {
  content: none;
}

.home-card-section-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #6b7280;
  margin-bottom: 4px;
}

/* Streak card */
.home-card-streak {
  border-top: 3px solid #f97316;
  background: linear-gradient(to bottom, rgba(249, 115, 22, 0.06), #ffffff);
}

.home-streak-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.home-streak-day {
  font-size: 1.1rem;
  font-weight: 700;
  color: #111827;
}

.home-streak-goal {
  font-size: 0.82rem;
  color: #374151;
}

/* Continue lesson: blue accent */
.home-card-continue {
  border-top: 3px solid #2563eb;
  background: linear-gradient(to bottom, rgba(37, 99, 235, 0.06), #ffffff);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
}

.home-card-review {
  padding: 12px 16px;
}

.home-continue-title {
  font-size: 0.98rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: #111827;
}

.home-continue-meta {
  font-size: 0.8rem;
  color: #374151;
}

/* Focus: green accent */
/* Session Clock Widget */
.home-card-session {
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 14px 18px;
  background: radial-gradient(
    circle at top left,
    rgba(59, 130, 246, 0.12),
    #ffffff 55%,
    #eef2ff
  );
  border: 1px solid rgba(129, 140, 248, 0.5);
}

.session-widget {
  display: flex;
  gap: 18px;
  align-items: center;
  width: 100%;
  position: relative;
}

/* Running state */
.session-widget.session-running .session-clock-progress {
  filter: drop-shadow(0 0 6px rgba(34, 197, 94, 0.7));
}

/* Clock */
.session-clock {
  position: relative;
  width: 140px;
  height: 140px;
  flex-shrink: 0;
}

/* Moving dot along ring */
.session-clock-dot {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #22c55e;
  top: 50%;
  left: 50%;
  transform-origin: -44px 0;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.session-widget.session-running .session-clock-dot {
  opacity: 1;
  animation: session-dot-spin 6s linear infinite;
}

@keyframes session-dot-spin {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

.session-clock-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.session-clock-bg {
  fill: none;
  stroke: #e5e7eb;
  stroke-width: 7;
}

.session-clock-progress {
  fill: none;
  stroke: #22c55e;
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 276; /* 2 * PI * r (r ~ 44) */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.2s linear, stroke 0.2s linear;
  filter: drop-shadow(0 0 4px rgba(34, 197, 94, 0.6));
}

.session-clock-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.session-clock-time {
  font-size: 1.3rem;
  font-weight: 600;
  color: #111827;
  line-height: 1.2;
}

.session-clock-label {
  font-size: 0.8rem;
  color: #6b7280;
  margin-top: 2px;
  line-height: 1.2;
}

/* Controls */
.session-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.session-presets {
  display: inline-flex;
  gap: 6px;
}

.session-preset-btn {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: #ffffff;
  font-size: 0.8rem;
  padding: 4px 10px;
  cursor: pointer;
  color: #374151;
  transition: all 0.16s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
  user-select: none;
  position: relative;
  z-index: 1;
}

.session-preset-btn:hover {
  background: #f3f4f6;
  border-color: rgba(148, 163, 184, 0.9);
}

.session-preset-btn.is-active {
  background: #2563eb;
  color: #f9fafb;
  border-color: transparent;
}

.session-main-buttons {
  display: flex;
  gap: 8px;
}

.session-btn {
  border-radius: 999px;
  font-size: 0.84rem;
  padding: 6px 16px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.16s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
  user-select: none;
  position: relative;
  z-index: 1;
}

.session-btn-primary {
  background: linear-gradient(90deg, #22c55e, #16a34a);
  color: #ecfdf5;
  font-weight: 600;
}

.session-btn-primary:hover {
  background: linear-gradient(90deg, #16a34a, #15803d);
  transform: translateY(-1px);
}

.session-btn-primary.is-paused {
  background: linear-gradient(90deg, #f97316, #ea580c);
  color: #fff7ed;
}

.session-btn-primary.is-paused:hover {
  background: linear-gradient(90deg, #ea580c, #c2410c);
}

.session-btn-secondary {
  background: #e5e7eb;
  color: #374151;
}

.session-btn-secondary:hover {
  background: #d1d5db;
}

.session-stats {
  font-size: 0.8rem;
  color: #6b7280;
  text-align: center;
}

/* Mobile: stack vertically and compact */
@media (max-width: 768px) {
  /* Hide specific sections on mobile */
  .home-section-mobile-hidden,
  .home-card-mobile-hidden {
    display: none !important;
  }
  
  /* General container padding */
  .main-view,
  .home-container {
    padding: 14px 10px 18px;
  }
  
  /* Section spacing */
  .home-section {
    margin-bottom: 10px;
    padding-left: 0;
    padding-right: 0;
    display: block !important;
    visibility: visible !important;
  }
  
  .home-section-title,
  .section-title {
    font-size: 0.9rem;
    margin-bottom: 4px;
  }
  
  /* Base card style on mobile */
  .home-card {
    border-radius: 14px;
    padding: 8px 10px;
    font-size: 0.82rem;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
  }
  
  .home-card-streak {
    padding: 8px 10px;
  }
  
  /* Tiếp tục học + Ôn tập nhanh - nhỏ lại và cùng hàng */
  .home-card-continue,
  .home-card-review {
    padding: 6px 8px;
    gap: 4px;
  }
  
  .home-card-continue .home-card-section-label,
  .home-card-review .home-card-section-label {
    font-size: 0.7rem;
    margin-bottom: 2px;
  }
  
  .home-card-continue .home-card-title,
  .home-card-review .home-card-title,
  .home-continue-title {
    font-size: 0.75rem;
    margin-bottom: 2px;
    line-height: 1.3;
  }
  
  .home-continue-meta {
    font-size: 0.68rem;
    line-height: 1.2;
  }
  
  .home-btn {
    padding: 4px 8px;
    font-size: 0.7rem;
    margin-top: 4px;
  }
  
  .home-review-main {
    font-size: 0.72rem;
  }
  
  .home-review-line {
    font-size: 0.7rem;
    margin-bottom: 2px;
  }
  
  .quick-review-info {
    font-size: 0.68rem;
  }
  
  .home-review-actions {
    margin-top: 4px;
    gap: 4px;
    flex-wrap: wrap;
  }
  
  .home-review-actions .home-btn {
    padding: 3px 6px;
    font-size: 0.68rem;
    white-space: nowrap;
  }
  
  /* Session card - full width on mobile */
  .home-card-session {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0;
    display: block;
    padding: 10px 12px;
    box-sizing: border-box;
  }
  
  /* Session widget on mobile: narrower clock + less margin */
  .session-widget {
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }
  
  .session-clock {
    width: 110px;
    height: 110px;
  }
  
  .session-clock-time {
    font-size: 1.1rem;
  }
  
  .session-controls {
    gap: 6px;
  }
  
  .session-main-buttons .session-btn {
    padding: 5px 10px;
    font-size: 0.78rem;
    min-height: 32px;
    min-width: 60px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(37, 99, 235, 0.2);
  }
  
  .session-presets .session-preset-btn {
    padding: 3px 8px;
    font-size: 0.76rem;
    min-height: 28px;
    min-width: 40px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(37, 99, 235, 0.2);
  }
  
  /* Ensure session card and widget are interactive on mobile */
  .home-card-session {
    pointer-events: auto;
    position: relative;
    z-index: 1;
  }
  
  .session-widget {
    pointer-events: auto;
    position: relative;
    z-index: 1;
  }
  
  .session-controls {
    pointer-events: auto;
    position: relative;
    z-index: 2;
  }
  
  /* Featured cards */
  /* Hide featured grid on mobile, show ticker */
  .home-featured-grid {
    display: none;
  }
  
  .home-featured-ticker {
    display: flex !important;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.06);
    border: 1px solid rgba(59, 130, 246, 0.4);
    font-size: 0.82rem;
    overflow: hidden;
    cursor: pointer;
    transition: background 0.2s ease;
  }
  
  .home-featured-ticker:hover {
    background: rgba(37, 99, 235, 0.1);
  }
  
  .home-featured-ticker-label {
    font-weight: 600;
    color: #2563eb;
    flex-shrink: 0;
  }
  
  .home-featured-ticker-title {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    flex: 1;
    color: #111827;
    min-width: 0;
  }
  
  .home-featured-ticker-next {
    flex-shrink: 0;
    font-size: 0.75rem;
    color: #6b7280;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin: 0;
  }
  
  .home-featured-card {
    padding: 8px 10px;
    font-size: 0.82rem;
  }
  
  /* Topic cards (News Shadowing, Shadowing JLPT, Story Shadowing, Mimikara Oboeru) */
  .home-topic-list,
  .home-topic-row,
  .home-topic-grid {
    gap: 8px;
  }
  
  .home-topic-card {
    padding: 8px 10px;
    border-radius: 12px;
    font-size: 0.82rem;
  }
  
  /* Hide history section on mobile */
  #home-history {
    display: none !important;
  }

  /* Legacy - keep for reference */
  #home-history-old {
    display: none;
  }
}

/* Hide history section on all screen sizes */
#home-history {
  display: none !important;
}

.home-card-focus {
  border-top: 3px solid #22c55e;
  background: linear-gradient(to bottom, rgba(34, 197, 94, 0.06), #ffffff);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Review: pink accent */
.home-card-review {
  border-top: 3px solid #ec4899;
  background: linear-gradient(to bottom, rgba(236, 72, 153, 0.06), #ffffff);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
}

.home-review-main {
  font-size: 0.8rem;
  color: #374151;
}

.home-review-line + .home-review-line {
  margin-top: 2px;
}

.home-review-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

/* Buttons - Light Theme */
.home-btn {
  border-radius: 999px;
  font-size: 0.8rem;
  padding: 7px 16px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.08s ease;
  font-weight: 500;
}

/* Primary = solid blue */
.home-btn-primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #f9fafb;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.35);
}

.home-btn-primary:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
  transform: translateY(-1px);
}

/* Outline = white pill with blue/gray border */
.home-btn-outline {
  background: #ffffff;
  border-color: rgba(148, 163, 184, 0.7);
  color: #111827;
}

.home-btn-outline:hover {
  border-color: rgba(37, 99, 235, 0.5);
  background: #f9fafb;
  color: #111827;
  transform: translateY(-1px);
}

/* Topics - Light Theme */
.home-topic-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.home-topic-card {
  border-radius: 14px;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.35);
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  text-align: left;
  color: #111827;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.14s ease, transform 0.08s ease, border-color 0.14s ease;
}

/* Colored left bar instead of full gradient */
.home-topic-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: #2563eb;
}

/* Accent colors per topic */
.home-topic-accent.news { background: #22c55e; }
.home-topic-accent.jlpt { background: #2563eb; }
.home-topic-accent.story { background: #a855f7; }
.home-topic-accent.mimikara { background: #f97316; }

/* Per-topic colors for left bar */
.home-topic-card[data-topic="news"]::before {
  background: #22c55e;
}

.home-topic-card[data-topic="jlpt"]::before {
  background: #2563eb;
}

.home-topic-card[data-topic="story"]::before {
  background: #a855f7;
}

.home-topic-card[data-topic="mimikara"]::before {
  background: #f97316;
}

.home-topic-card:hover {
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.15);
  border-color: rgba(37, 99, 235, 0.4);
  background: #f9fafb;
  transform: translateY(-2px);
}

.home-topic-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #111827;
}

.home-topic-caption {
  font-size: 0.78rem;
  color: #6b7280;
}

/* Proverb: amber accent */
.home-card-proverb {
  border-top: 3px solid #eab308;
  background: linear-gradient(to bottom, rgba(234, 179, 8, 0.06), #ffffff);
}

.home-proverb-text {
  font-size: 0.84rem;
  line-height: 1.5;
  color: #374151;
}

/* Activity: neutral accent */
.home-card-activity {
  border-top: 3px solid rgba(148, 163, 184, 0.8);
  background: #ffffff;
}

.home-activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.8rem;
  color: #374151;
}

.home-activity-list li + li {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
}

/* DESKTOP ONLY: show home grid layout */
@media (min-width: 1024px) {
  .home-container {
    max-width: 1200px;
    margin: 0 auto;
  }
}

/* MOBILE: do not force home; keep current behavior */
@media (max-width: 768px) {
  .home-container {
    padding: 12px;
    gap: 12px;
  }
  
  .home-row-main {
    grid-template-columns: 1fr;
  }
  
  .home-topic-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  
  .home-review-actions {
    flex-direction: column;
  }
  
  .home-btn {
    width: 100%;
  }
}

/* Mobile tweaks */
@media (max-width: 768px) {
  /* Hide lesson session panel and custom on mobile */
  .lesson-session-panel,
  .control-group.lesson-session-panel {
    display: none !important;
  }
  
  .lesson-session-custom {
    display: none !important;
  }

  .focus-timer-widget {
    left: 12px;
    right: 12px;
    bottom: 72px; /* above bottom nav */
    min-width: auto;
  }
}

/* Top navbar - desktop only */
.top-nav {
  display: none;
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(10px);
  background: linear-gradient(
    90deg,
    rgba(248, 250, 252, 0.92),
    rgba(239, 246, 255, 0.92)
  );
  border-bottom: 1px solid rgba(148, 163, 184, 0.3);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.top-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  gap: 12px;
}

/* Brand */
.top-nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-nav-logo-circle {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: linear-gradient(135deg, #2563eb, #ec4899);
  color: #f9fafb;
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.35);
  flex-shrink: 0;
}

.top-nav-brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.top-nav-brand-title {
  font-size: 0.86rem;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.2;
}

.top-nav-brand-sub {
  font-size: 0.72rem;
  color: #6b7280;
  line-height: 1.2;
}

/* Tabs */
.top-nav-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  justify-content: center;
}

/* Right section */
.top-nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-nav-streak {
  font-size: 0.78rem;
  color: #6b7280;
  white-space: nowrap;
}

.top-nav-item {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  cursor: pointer;
  color: #4b5563;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.top-nav-item-root {
  font-weight: 600;
}

.top-nav-item:hover {
  background: rgba(209, 213, 219, 0.6);
  color: #111827;
}

.top-nav-item.is-active {
  background: #2563eb;
  color: #f9fafb;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.35);
}

.top-nav-pill {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: #ffffff;
  color: #111827;
  font-size: 0.78rem;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.12);
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.08s ease;
}

.top-nav-pill:hover {
  background: #eff6ff;
  border-color: #2563eb;
  transform: translateY(-1px);
}

/* Group with dropdown */
.top-nav-group {
  position: relative;
}

.top-nav-item-mode::after {
  content: "▾";
  margin-left: 4px;
  font-size: 0.7rem;
}

/* Dropdown base */
.top-nav-dropdown {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  min-width: 420px;
  max-width: 600px;
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.15);
  display: none;
  z-index: 50;
}

.top-nav-dropdown-inner {
  display: grid;
  grid-template-columns: 220px minmax(260px, 1fr);
  gap: 0;
}

/* Columns */
.top-nav-dropdown-col {
  padding: 10px 12px;
  max-height: 400px;
  overflow-y: auto;
  overflow-x: hidden;
}

.top-nav-dropdown-col + .top-nav-dropdown-col {
  border-left: 1px solid rgba(229, 231, 235, 0.9);
}

.top-nav-dropdown-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
  margin-bottom: 4px;
  position: sticky;
  top: 0;
  background: #ffffff;
  padding-bottom: 4px;
  z-index: 1;
}

/* Topic list */
.top-nav-topics-list,
.top-nav-lessons-list {
  list-style: none;
  margin: 0;
  padding: 4px 0 0;
}

.top-nav-topic-item {
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.84rem;
  color: #4b5563;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.top-nav-topic-item:hover,
.top-nav-topic-item.is-active {
  background: #eff6ff;
  color: #1d4ed8;
}

/* Lesson list */
.top-nav-lesson-item {
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.top-nav-lesson-title {
  font-weight: 600;
  color: #111827;
}

.top-nav-lesson-meta {
  font-size: 0.75rem;
  color: #6b7280;
}

/* Lesson item hover */
.top-nav-lesson-item:hover {
  background: #f3f4f6;
}

/* Desktop only */
@media (min-width: 1024px) {
  .top-nav {
    display: block;
  }
}

/* Mobile: keep nav hidden */
@media (max-width: 768px) {
  .top-nav {
    display: none;
  }
  
  /* Hide lesson session panel, custom, and note on mobile - ensure this is at the end */
  .lesson-session-panel,
  .control-group.lesson-session-panel,
  #lesson-session-panel {
    display: none !important;
    visibility: hidden !important;
  }
  
  .lesson-session-custom {
    display: none !important;
    visibility: hidden !important;
  }
  
  .lesson-session-note {
    display: none !important;
    visibility: hidden !important;
  }
}

/* ============================================================================
 * DESKTOP: Hide sidebar learning section (topics, groups, lessons)
 * Mobile: Keep visible for navigation
 * ============================================================================ */
@media (min-width: 769px) {
  /* Hide the entire learning section on desktop */
  #sidebar-learning-section,
  .sidebar-learning,
  .sidebar-topics,
  .sidebar-section-groups,
  #category-list,
  #group-chips,
  #lesson-chips,
  .category-list,
  .group-chips,
  .lesson-chips,
  .sidebar-group-chips,
  .sidebar-lesson-chips {
    display: none !important;
  }
}

/* Mobile: keep learning section visible */
@media (max-width: 768px) {
  #sidebar-learning-section,
  .sidebar-learning {
    display: block;
  }
  
  .sidebar-topics,
  .sidebar-section-groups {
    display: block;
  }
}

/* Hide focus-mode-toggle button */
#focus-mode-toggle {
  display: none !important;
  visibility: hidden !important;
}

