/* ==========================================================================
   BrightPath - UI/UX Polish Layer
   Loads after style.css. Smooth motion, glass surfaces, refined focus states,
   Command Palette, Study Hub, Today card, toasts. Fully theme + dark-mode aware.
   ========================================================================== */

:root {
  --bp-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --bp-glass: color-mix(in srgb, var(--bg-card) 78%, transparent);
  --bp-ring: color-mix(in srgb, var(--primary) 24%, transparent);
  --bp-grad: linear-gradient(135deg, #4F46E5 0%, #7C3AED 55%, #EC4899 100%);
}

/* ---------- Global feel ---------- */
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color 0.35s ease, color 0.35s ease;
}
::selection { background: var(--bp-ring); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--text-muted) 40%, transparent) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text-muted) 38%, transparent);
  border-radius: 99px; border: 3px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--text-muted) 60%, transparent); background-clip: content-box; border: 3px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Surfaces ---------- */
#appHeader {
  background: var(--bp-glass) !important;
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  box-shadow: 0 1px 0 var(--border-color), 0 8px 24px -16px rgba(15, 23, 42, 0.18);
}
.mobile-bottom-nav {
  background: var(--bp-glass) !important;
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.app-sidebar { scrollbar-gutter: stable; }

.card { transition: transform 0.28s var(--bp-ease), box-shadow 0.28s var(--bp-ease), border-color 0.28s ease, background-color 0.3s ease; }
.card[onclick]:hover, .card-hover:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border-color));
}
.card[onclick]:active, .card-hover:active { transform: translateY(-1px) scale(0.995); }

.btn { transition: transform 0.18s var(--bp-ease), box-shadow 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, filter 0.2s ease; }
.btn:not(:disabled):hover { transform: translateY(-1px); }
.btn:not(:disabled):active { transform: translateY(0) scale(0.97); }
.btn-primary:not(:disabled):hover { box-shadow: 0 8px 20px -6px color-mix(in srgb, var(--primary) 60%, transparent); filter: brightness(1.04); }

.sidebar-link { position: relative; transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s var(--bp-ease); }
.sidebar-link:hover { transform: translateX(3px); }
.sidebar-link.active { color: var(--primary); background: var(--primary-light); }
.sidebar-link.active::before {
  content: ''; position: absolute; left: -6px; top: 22%; bottom: 22%; width: 4px;
  border-radius: 4px; background: var(--primary);
}
.header-nav-link { transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s var(--bp-ease); }
.header-nav-link:hover { transform: translateY(-1px); }
.mobile-nav-item { transition: transform 0.2s var(--bp-ease), color 0.2s ease; }
.mobile-nav-item:active { transform: scale(0.92); }
.mobile-nav-item.active { color: var(--primary); }

input, select, textarea { transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--bp-ring);
}
img { max-width: 100%; }

/* ---------- Page transitions ---------- */
@keyframes bpViewIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes bpCardIn { from { opacity: 0; transform: translateY(14px) scale(0.985); } to { opacity: 1; transform: none; } }
#viewContainer.bp-view-in { animation: bpViewIn 0.4s var(--bp-ease); }
#viewContainer.bp-view-in .card { animation: bpCardIn 0.5s var(--bp-ease) backwards; animation-delay: calc(var(--bp-i, 0) * 35ms); }

/* ---------- Scroll progress + back to top ---------- */
.bp-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 100%;
  transform-origin: 0 50%; transform: scaleX(0);
  background: var(--bp-grad); z-index: 1000002; pointer-events: none;
}
.bp-top {
  position: fixed; left: 18px; bottom: 22px; width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-main);
  box-shadow: var(--shadow-md); font-size: 1.05rem; cursor: pointer; z-index: 900;
  opacity: 0; transform: translateY(14px) scale(0.9); pointer-events: none;
  transition: opacity 0.25s ease, transform 0.3s var(--bp-ease);
}
.bp-top.show { opacity: 1; transform: none; pointer-events: auto; }
.bp-top:hover { color: var(--primary); border-color: var(--primary); }

.bp-skip {
  position: fixed; left: 12px; top: -60px; z-index: 1000003; background: var(--primary); color: #fff;
  padding: 0.6rem 1rem; border-radius: 10px; font-weight: 700; text-decoration: none; transition: top 0.2s ease;
}
.bp-skip:focus { top: 12px; }

/* ---------- Toasts ---------- */
.bp-toasts {
  position: fixed; top: 78px; right: 18px; z-index: 1000003; display: flex; flex-direction: column;
  gap: 10px; width: min(360px, calc(100vw - 36px)); pointer-events: none;
}
.bp-toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 0.8rem 1rem; border-radius: 14px;
  background: var(--bg-card); color: var(--text-main); border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg); font-size: 0.9rem; font-weight: 600; pointer-events: auto;
  animation: bpToastIn 0.4s var(--bp-ease);
}
.bp-toast.out { animation: bpToastOut 0.3s ease forwards; }
.bp-toast .bp-toast-ico { font-size: 1.15rem; line-height: 1.3; }
.bp-toast.success { border-left: 4px solid var(--success); }
.bp-toast.warn { border-left: 4px solid var(--secondary); }
.bp-toast.error { border-left: 4px solid var(--danger); }
.bp-toast.info { border-left: 4px solid var(--primary); }
@keyframes bpToastIn { from { opacity: 0; transform: translateX(24px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes bpToastOut { to { opacity: 0; transform: translateX(24px) scale(0.96); } }

/* ---------- Modal / overlay ---------- */
.bp-overlay {
  position: fixed; inset: 0; z-index: 1000004; background: rgba(8, 11, 24, 0.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px;
  animation: bpFade 0.2s ease;
}
.bp-overlay.center { align-items: center; padding-top: 16px; }
@keyframes bpFade { from { opacity: 0; } to { opacity: 1; } }
.bp-modal {
  width: min(560px, 100%); max-height: 78vh; overflow: auto; background: var(--bg-card); color: var(--text-main);
  border: 1px solid var(--border-color); border-radius: 20px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.55);
  animation: bpPop 0.35s var(--bp-ease);
}
@keyframes bpPop { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }
.bp-modal-pad { padding: 1.4rem 1.5rem; }
.bp-modal h3 { font-family: var(--font-heading); font-size: 1.15rem; margin-bottom: 0.75rem; }

/* ---------- Command palette ---------- */
.bp-pal-input-wrap { display: flex; align-items: center; gap: 10px; padding: 0.9rem 1.1rem; border-bottom: 1px solid var(--border-color); }
.bp-pal-input-wrap input {
  flex: 1; border: none !important; background: transparent !important; box-shadow: none !important;
  font-size: 1.05rem; color: var(--text-main); font-family: var(--font-body);
}
.bp-kbd {
  white-space: nowrap;
  font-family: var(--font-mono); font-size: 0.7rem; font-weight: 700; padding: 2px 7px; border-radius: 6px;
  border: 1px solid var(--border-color); border-bottom-width: 2px; background: var(--bg-app); color: var(--text-muted);
}
.bp-pal-list { padding: 8px; max-height: 52vh; overflow: auto; }
.bp-pal-group { font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); padding: 10px 10px 4px; }
.bp-pal-item {
  display: flex; align-items: center; gap: 12px; padding: 0.65rem 0.75rem; border-radius: 12px; cursor: pointer;
  font-weight: 600; font-size: 0.95rem; transition: background-color 0.12s ease;
}
.bp-pal-item .ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-light); font-size: 1rem; }
.bp-pal-item .hint { margin-left: auto; font-size: 0.75rem; color: var(--text-muted); font-weight: 600; }
.bp-pal-item.sel { background: var(--primary-light); color: var(--primary); }
.bp-pal-empty { padding: 2rem 1rem; text-align: center; color: var(--text-muted); font-weight: 600; }
.bp-pal-foot { display: flex; gap: 14px; padding: 0.6rem 1rem; border-top: 1px solid var(--border-color); font-size: 0.74rem; color: var(--text-muted); }

.bp-search-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 0.45rem 0.8rem; border-radius: 12px;
  border: 1px solid var(--border-color); background: var(--bg-app); color: var(--text-muted);
  font-weight: 600; font-size: 0.85rem; cursor: pointer; margin-left: 12px;
  transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s var(--bp-ease);
}
.bp-search-btn:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.bp-side-search { width: 100%; margin: 0 0 12px; justify-content: flex-start; padding: 0.65rem 0.9rem; }
.bp-side-search .bp-kbd { margin-left: auto; }

/* ---------- Study Hub dock ---------- */
.bp-hub-fab {
  position: fixed; right: 24px; bottom: 92px; z-index: 998; height: 48px; min-width: 48px; padding: 0 14px;
  border-radius: 99px; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-main);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  font-weight: 800; font-size: 0.9rem; box-shadow: var(--shadow-lg);
  transition: transform 0.25s var(--bp-ease), box-shadow 0.25s ease, border-color 0.2s ease;
}
.bp-hub-fab:hover { transform: translateY(-2px); border-color: var(--primary); }
.bp-hub-fab.running { background: var(--bp-grad); color: #fff; border-color: transparent; font-family: var(--font-mono); }
.bp-hub {
  position: fixed; right: 24px; bottom: 150px; z-index: 1000001; width: min(380px, calc(100vw - 32px));
  background: var(--bg-card); color: var(--text-main); border: 1px solid var(--border-color);
  border-radius: 22px; box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.5); overflow: hidden;
  transform-origin: 90% 100%; animation: bpPop 0.35s var(--bp-ease);
}
.bp-hub[hidden] { display: none; }
.bp-hub-head { display: flex; align-items: center; justify-content: space-between; padding: 0.9rem 1.1rem 0.4rem; }
.bp-hub-head strong { font-family: var(--font-heading); font-size: 1.05rem; }
.bp-x { border: none; background: var(--bg-app); color: var(--text-muted); width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 1rem; }
.bp-x:hover { color: var(--danger); }
.bp-tabs { display: flex; gap: 4px; padding: 0.4rem 0.8rem; }
.bp-tab {
  flex: 1; padding: 0.5rem 0.2rem; border: none; border-radius: 10px; background: transparent; color: var(--text-muted);
  font-weight: 700; font-size: 0.8rem; cursor: pointer; transition: background-color 0.2s ease, color 0.2s ease;
}
.bp-tab.active { background: var(--primary-light); color: var(--primary); }
.bp-pane { padding: 0.6rem 1.1rem 1.2rem; min-height: 290px; }
.bp-chips { display: flex; gap: 6px; justify-content: center; margin-bottom: 0.8rem; flex-wrap: wrap; }
.bp-chip {
  border: 1px solid var(--border-color); background: var(--bg-app); color: var(--text-main); padding: 0.35rem 0.8rem;
  border-radius: 99px; font-weight: 700; font-size: 0.78rem; cursor: pointer; transition: all 0.2s ease;
}
.bp-chip:hover { border-color: var(--primary); }
.bp-chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.bp-ring-wrap { position: relative; width: 168px; height: 168px; margin: 0.2rem auto 0.8rem; }
.bp-ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.bp-ring-bg { stroke: var(--border-color); }
.bp-ring-fg { stroke: url(#bpGrad); stroke-linecap: round; transition: stroke-dashoffset 0.6s var(--bp-ease); }
.bp-ring-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.bp-ring-time { font-family: var(--font-mono); font-size: 2.1rem; font-weight: 700; letter-spacing: -0.03em; }
.bp-ring-sub { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.bp-row { display: flex; gap: 8px; justify-content: center; align-items: center; }
.bp-row .btn { padding: 0.55rem 1.1rem; font-size: 0.88rem; }
.bp-meta { text-align: center; font-size: 0.78rem; color: var(--text-muted); font-weight: 600; margin-top: 0.8rem; }
.bp-input, .bp-textarea {
  width: 100%; border: 1.5px solid var(--border-color); background: var(--bg-app); color: var(--text-main);
  border-radius: 12px; padding: 0.6rem 0.8rem; font-family: var(--font-body); font-size: 0.92rem;
}
.bp-textarea { min-height: 200px; resize: vertical; line-height: 1.55; }
.bp-task { display: flex; align-items: center; gap: 10px; padding: 0.5rem 0.2rem; border-bottom: 1px dashed var(--border-color); animation: bpFade 0.25s ease; }
.bp-task input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.bp-task span { flex: 1; font-size: 0.92rem; font-weight: 600; word-break: break-word; }
.bp-task.done span { text-decoration: line-through; color: var(--text-muted); }
.bp-task button { border: none; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 0.95rem; }
.bp-task button:hover { color: var(--danger); }
.bp-tasks-scroll { max-height: 190px; overflow: auto; margin-top: 0.6rem; }
.bp-set { display: flex; align-items: center; justify-content: space-between; padding: 0.7rem 0; border-bottom: 1px solid var(--border-color); font-weight: 700; font-size: 0.92rem; }
.bp-switch { position: relative; width: 44px; height: 26px; border-radius: 99px; background: var(--border-color); border: none; cursor: pointer; transition: background-color 0.25s ease; }
.bp-switch::after { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3); transition: transform 0.28s var(--bp-ease); }
.bp-switch.on { background: var(--primary); }
.bp-switch.on::after { transform: translateX(18px); }

/* ---------- Today card (dashboard) ---------- */
.bp-today {
  position: relative; overflow: hidden; margin-bottom: 1.5rem; padding: 1.5rem 1.6rem; border-radius: 22px; color: #fff;
  background: radial-gradient(1200px 400px at 0% 0%, rgba(255,255,255,0.18), transparent 60%), var(--bp-grad);
  box-shadow: 0 22px 50px -22px rgba(79, 70, 229, 0.65);
  display: grid; grid-template-columns: 1fr auto; gap: 1.2rem 1.6rem; align-items: center;
}
.bp-today::after {
  content: ''; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.1); pointer-events: none;
}
.bp-today-greet { font-family: var(--font-heading); font-size: clamp(1.35rem, 2.6vw, 1.9rem); font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.bp-today-sub { margin-top: 0.35rem; opacity: 0.92; font-size: 0.92rem; font-weight: 500; max-width: 60ch; }
.bp-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 1rem; }
.bp-stat {
  background: rgba(255, 255, 255, 0.16); border: 1px solid rgba(255, 255, 255, 0.22); border-radius: 14px;
  padding: 0.55rem 0.9rem; min-width: 92px; backdrop-filter: blur(6px); color: #fff; text-align: left; font: inherit; cursor: default;
}
button.bp-stat { cursor: pointer; transition: transform 0.2s var(--bp-ease), background-color 0.2s ease; }
button.bp-stat:hover { transform: translateY(-2px); background: rgba(255, 255, 255, 0.26); }
.bp-stat b { display: block; font-family: var(--font-heading); font-size: 1.2rem; line-height: 1.2; }
.bp-stat small { font-size: 0.68rem; font-weight: 700; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.06em; }
.bp-goal { position: relative; width: 116px; height: 116px; }
.bp-goal svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.bp-goal .bg { stroke: rgba(255, 255, 255, 0.25); }
.bp-goal .fg { stroke: #fff; stroke-linecap: round; transition: stroke-dashoffset 0.8s var(--bp-ease); }
.bp-goal-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; cursor: pointer; background: none; border: none; color: #fff; font: inherit; }
.bp-goal-text b { font-family: var(--font-heading); font-size: 1.35rem; line-height: 1; }
.bp-goal-text small { font-size: 0.64rem; font-weight: 700; opacity: 0.9; text-transform: uppercase; letter-spacing: 0.06em; }
.bp-quick { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; position: relative; z-index: 1; }
.bp-quick button {
  border: 1px solid rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.14); color: #fff; padding: 0.5rem 0.95rem;
  border-radius: 99px; font-weight: 700; font-size: 0.84rem; cursor: pointer; transition: transform 0.2s var(--bp-ease), background-color 0.2s ease;
}
.bp-quick button:hover { background: rgba(255, 255, 255, 0.28); transform: translateY(-2px); }

/* ---------- Shortcuts sheet ---------- */
.bp-sc-grid { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center; font-size: 0.92rem; font-weight: 600; }
.bp-sc-grid .k { display: flex; gap: 4px; justify-content: flex-end; }

/* header search = compact icon button (full search lives in the sidebar) */
.bp-head-search { flex: none; margin-left: 0; padding: 0.5rem 0.65rem; }
.bp-head-search .lbl, .bp-head-search .bp-kbd { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .bp-hub-fab { right: 14px; bottom: calc(var(--bottom-nav-height) + 82px + env(safe-area-inset-bottom, 0px)); }
  .bp-hub {
    right: 8px; left: 8px; width: auto; bottom: calc(var(--bottom-nav-height) + 8px + env(safe-area-inset-bottom, 0px));
    border-radius: 22px 22px 18px 18px;
  }
  .bp-top { left: 12px; bottom: calc(var(--bottom-nav-height) + 14px); }
  .bp-toasts { top: 74px; right: 12px; }
  .bp-today { grid-template-columns: 1fr; padding: 1.25rem; }
  .bp-goal { width: 96px; height: 96px; position: absolute; right: 14px; top: 14px; }
  .bp-today-main { padding-right: 96px; }
  .bp-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .bp-stat { min-width: 0; padding: 0.5rem 0.7rem; }
  .bp-stat b { font-size: 1.05rem; }
  .bp-quick button { font-size: 0.8rem; padding: 0.45rem 0.8rem; }
  .bp-search-btn span.lbl, .bp-search-btn .bp-kbd { display: none; }
  .bp-search-btn { margin-left: 8px; padding: 0.5rem 0.65rem; }
  .bp-overlay { padding-top: 8vh; }
}

/* ---------- Accessibility: respect reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
html.bp-reduce-motion *, html.bp-reduce-motion *::before, html.bp-reduce-motion *::after {
  animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important;
}
@media print { .bp-hub-fab, .bp-hub, .bp-top, .bp-progress, .bp-toasts, .bp-search-btn { display: none !important; } }

/* ==========================================================================
   v12 additions: PIN dialogs & gates, security card, Pro Club grid, sidebar
   labels, shared page layout, Flashcards, Insights
   ========================================================================== */

/* ---------- Sidebar polish ---------- */
.sidebar-label {
  font-size: 0.68rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted); padding: 1rem 0.9rem 0.3rem; margin-top: 0.4rem; border-top: 1px dashed var(--border-color);
}
.sidebar-link .badge { margin-left: auto; font-size: 0.65rem; font-weight: 800; padding: 2px 7px; border-radius: 99px; color: #fff; }
.badge-new { background: linear-gradient(135deg, #10b981, #059669); }
.pro-count-badge { background: linear-gradient(135deg, #f59e0b, #d97706); }
.sidebar-pro { background: linear-gradient(135deg, rgba(245, 158, 11, 0.14), rgba(217, 119, 6, 0.08)); }
.sidebar-pro span:nth-child(2) { color: #b45309; font-weight: 800; }
body.dark-mode .sidebar-pro span:nth-child(2) { color: #fbbf24; }

/* ---------- PIN dialog + gate ---------- */
.bp-pinmodal { max-width: 400px; }
.bp-pinicon { font-size: 2.4rem; margin-bottom: 0.3rem; }
.bp-pintext { color: var(--text-muted); font-size: 0.9rem; line-height: 1.5; margin: 0 0 1rem; }
.bp-pinlbl { display: block; text-align: left; font-weight: 700; font-size: 0.82rem; margin: 0.7rem 0 4px; }
.bp-pininput {
  width: 100%; text-align: center; font-size: 1.5rem; letter-spacing: 0.4em; font-family: var(--font-mono); padding: 0.6rem 0.8rem;
  border: 2px solid var(--border-color); border-radius: 14px; background: var(--bg-app); color: var(--text-main); margin-bottom: 0.5rem;
}
.bp-pinerr { background: rgba(239, 68, 68, 0.12); color: var(--danger); border-radius: 10px; padding: 0.5rem 0.75rem; font-weight: 700; font-size: 0.85rem; margin-top: 0.4rem; }
.bp-pinerr[hidden] { display: none; }
.bp-pinhint { color: var(--text-muted); font-size: 0.78rem; margin-top: 1rem; }
.bp-gate {
  max-width: 460px; margin: 3rem auto; padding: 2.2rem 1.8rem; text-align: center; background: var(--bg-card);
  border: 1px solid var(--border-color); border-radius: 24px; box-shadow: var(--shadow-lg);
}
.bp-gate-icon { width: 72px; height: 72px; margin: 0 auto 1rem; border-radius: 50%; display: grid; place-items: center; font-size: 2rem; background: var(--bp-grad); box-shadow: 0 12px 30px -10px rgba(79, 70, 229, 0.6); }
.bp-gate-badge { display: inline-block; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.08em; padding: 4px 12px; border-radius: 99px; background: var(--primary-light); color: var(--primary); }
.bp-gate h2 { font-family: var(--font-heading); font-size: 1.5rem; margin: 0.8rem 0 0.4rem; }
.bp-gate p { color: var(--text-muted); font-size: 0.92rem; line-height: 1.5; margin-bottom: 1.2rem; }
.bp-gate-btn { margin: 0.4rem 0 0.8rem; padding: 0.85rem; border-radius: 14px; font-weight: 800; }

/* ---------- Settings security card ---------- */
.bp-seccard { padding: 1.3rem 1.4rem; margin-bottom: 1.5rem; border-radius: 20px; }
.bp-sechead { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.bp-sechead h3 { font-family: var(--font-heading); font-size: 1.15rem; margin: 0; }
.bp-secnote { color: var(--text-muted); font-size: 0.85rem; margin: 0.3rem 0 0.8rem; }
.bp-secrow { display: flex; align-items: center; gap: 12px; padding: 0.75rem 0; border-top: 1px solid var(--border-color); flex-wrap: wrap; }
.bp-secico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-light); font-size: 1.2rem; }
.bp-sectxt { flex: 1; min-width: 150px; display: flex; flex-direction: column; }
.bp-sectxt small { color: var(--text-muted); font-size: 0.78rem; }
.bp-secstat { font-size: 0.72rem; font-weight: 800; padding: 3px 10px; border-radius: 99px; background: var(--bg-app); color: var(--text-muted); border: 1px solid var(--border-color); }
.bp-secstat.on { background: rgba(16, 185, 129, 0.14); color: var(--success); border-color: transparent; }
.bp-secbtns { display: flex; gap: 6px; }
.bp-secbtns .btn { padding: 0.4rem 0.85rem; font-size: 0.82rem; }

/* ---------- Pro Club grid ---------- */
.bp-progrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.4rem; }
.bp-procard { position: relative; display: flex; flex-direction: column; gap: 0.2rem; border: 1.5px solid color-mix(in srgb, var(--accent) 30%, var(--border-color)); overflow: hidden; }
.bp-procard::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--accent); }
.bp-procard h3 { font-size: 1.15rem; margin: 0.2rem 0 0.4rem; }
.bp-procard p { flex: 1; font-size: 0.88rem; color: var(--text-muted); line-height: 1.55; margin: 0 0 1rem; }
.bp-proico { font-size: 2.1rem; width: 54px; height: 54px; display: grid; place-items: center; border-radius: 16px; background: color-mix(in srgb, var(--accent) 12%, transparent); margin-top: 0.4rem; }
.bp-pronum { position: absolute; top: 14px; right: 14px; font-size: 0.66rem; font-weight: 800; padding: 3px 9px; border-radius: 99px; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }

/* ---------- Shared page layout ---------- */
.bp-page { max-width: 1040px; margin: 0 auto; padding-bottom: 3rem; }
.bp-page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.bp-page-head h1 { font-family: var(--font-heading); font-size: clamp(1.6rem, 3vw, 2.2rem); margin: 0 0 0.3rem; letter-spacing: -0.02em; }
.bp-page-head p { color: var(--text-muted); max-width: 62ch; margin: 0; line-height: 1.55; }
.bp-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.8rem; margin-bottom: 1rem; }
.bp-tile { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 16px; padding: 0.9rem 1rem; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow-sm); }
.bp-tile span { font-size: 1.2rem; }
.bp-tile b { font-family: var(--font-heading); font-size: 1.55rem; line-height: 1.1; }
.bp-tile small { color: var(--text-muted); font-weight: 600; font-size: 0.76rem; }
.bp-pad { padding: 1.2rem 1.3rem; }
.bp-pad h3 { font-family: var(--font-heading); font-size: 1.08rem; margin: 0 0 0.7rem; }
.bp-muted { color: var(--text-muted); font-size: 0.86rem; line-height: 1.5; }
.bp-lbl { display: block; font-weight: 700; font-size: 0.82rem; margin: 0.7rem 0 4px; }
.bp-twocol { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.bp-bar { height: 8px; border-radius: 99px; background: var(--border-color); overflow: hidden; }
.bp-bar i { display: block; height: 100%; border-radius: 99px; background: var(--bp-grad); transition: width 0.5s var(--bp-ease); }
.bp-pill { font-size: 0.72rem; font-weight: 800; padding: 3px 10px; border-radius: 99px; background: var(--bg-app); color: var(--text-muted); border: 1px solid var(--border-color); white-space: nowrap; }
.bp-pill.hot { background: rgba(245, 158, 11, 0.14); color: #b45309; border-color: transparent; }

/* ---------- Flashcards ---------- */
.bp-fc-actions { display: flex; gap: 0.8rem; flex-wrap: wrap; align-items: center; margin: 0.4rem 0 1.2rem; }
.bp-inline { display: flex; gap: 6px; flex: 1; min-width: 260px; }
.bp-deckgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }
.bp-deck { padding: 1.1rem 1.2rem; }
.bp-deck-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; margin-bottom: 0.3rem; }
.bp-deck h3 { font-size: 1.05rem; margin: 0; word-break: break-word; }
.bp-cardlist { display: flex; flex-direction: column; }
.bp-cardrow { display: flex; align-items: center; gap: 10px; padding: 0.65rem 0; border-top: 1px solid var(--border-color); }
.bp-cardrow > div:first-child { flex: 1; min-width: 0; word-break: break-word; }
.bp-study { max-width: 720px; }
.bp-study-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.8rem; }
.bp-flash { min-height: 260px; padding: 2rem 1.6rem; text-align: center; display: flex; flex-direction: column; justify-content: center; cursor: pointer; border-radius: 24px; animation: bpPop 0.35s var(--bp-ease); }
.bp-flash-label { font-size: 0.68rem; font-weight: 800; letter-spacing: 0.14em; color: var(--text-muted); margin-bottom: 0.6rem; }
.bp-flash-q { font-family: var(--font-heading); font-size: clamp(1.25rem, 3vw, 1.7rem); font-weight: 700; line-height: 1.35; }
.bp-flash-a { font-size: clamp(1.1rem, 2.6vw, 1.4rem); font-weight: 600; color: var(--primary); line-height: 1.45; }
.bp-hr { border: none; border-top: 1px dashed var(--border-color); margin: 1.4rem 0; width: 100%; }
.bp-rate { display: flex; gap: 10px; justify-content: center; margin-top: 1.2rem; flex-wrap: wrap; }
.bp-rate .btn { min-width: 120px; padding: 0.8rem 1.2rem; font-weight: 800; border-radius: 14px; display: inline-flex; gap: 8px; align-items: center; justify-content: center; color: #fff; }
.bp-rate .btn small { opacity: 0.7; font-family: var(--font-mono); }
.bp-again { background: #ef4444; } .bp-good { background: #4f46e5; } .bp-easy { background: #10b981; }
.bp-rate .btn-primary { color: #fff; }

/* ---------- Insights ---------- */
.bp-insight-banner { background: var(--primary-light); color: var(--primary); font-weight: 700; border-radius: 14px; padding: 0.8rem 1rem; margin-bottom: 1rem; }
.bp-chart { width: 100%; height: auto; display: block; }
.bp-bar-mid { fill: color-mix(in srgb, var(--primary) 55%, transparent); }
.bp-bar-hit { fill: var(--success); }
.bp-chart-v { font-size: 11px; font-weight: 700; fill: var(--text-main); }
.bp-chart-l { font-size: 11px; font-weight: 600; fill: var(--text-muted); }
.bp-goalline { stroke: var(--secondary); stroke-width: 1.5; stroke-dasharray: 5 5; }
.bp-heat { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 4px; }
.bp-hcol { display: flex; flex-direction: column; gap: 5px; }
.bp-hcell { display: block; width: 22px; height: 22px; border-radius: 6px; background: var(--border-color); }
.bp-hcell.empty { background: transparent; }
.bp-hcell.l1 { background: color-mix(in srgb, var(--primary) 28%, var(--border-color)); }
.bp-hcell.l2 { background: color-mix(in srgb, var(--primary) 52%, var(--border-color)); }
.bp-hcell.l3 { background: color-mix(in srgb, var(--primary) 78%, var(--border-color)); }
.bp-hcell.l4 { background: var(--primary); }
.bp-legend { display: flex; gap: 5px; align-items: center; justify-content: flex-end; color: var(--text-muted); font-size: 0.75rem; font-weight: 600; margin-top: 0.7rem; }
.bp-legend .bp-hcell { width: 14px; height: 14px; border-radius: 4px; }

@media (max-width: 760px) {
  .bp-twocol { grid-template-columns: 1fr; }
  .bp-hcell { width: 17px; height: 17px; }
  .bp-gate { margin: 1.5rem auto; padding: 1.6rem 1.2rem; }
}

/* ---------- Fix: top menu wider than the screen made the whole page scroll sideways ---------- */
html, body { max-width: 100%; overflow-x: clip; }
#appHeader { min-width: 0; }
#appHeader nav {
  flex: 1 1 auto; min-width: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; white-space: nowrap;
  -webkit-mask-image: linear-gradient(90deg, #000 94%, transparent); mask-image: linear-gradient(90deg, #000 94%, transparent);
}
#appHeader nav::-webkit-scrollbar { display: none; }
#appHeader .header-nav-link { flex: none; }
#appHeader .header-actions { flex: none; }

/* ---------- Mobile: compact AI Tutor button, cleaner bottom nav ---------- */
.mobile-bottom-nav { background: color-mix(in srgb, var(--bg-card) 95%, transparent) !important; }
@media (max-width: 900px) {
  .tutor-fab { padding: 0.7rem !important; right: 14px !important; bottom: calc(var(--bottom-nav-height) + 16px + env(safe-area-inset-bottom, 0px)) !important; }
  .tutor-fab .tutor-fab-text { display: none !important; }
  .tutor-fab .tutor-fab-icon { font-size: 1.5rem; }
}

/* ---------- Daily Challenge + Study Planner ---------- */
.bp-opts { display: grid; gap: 0.6rem; margin-top: 1.1rem; }
.bp-opt {
  display: flex; align-items: center; gap: 12px; text-align: left; padding: 0.8rem 1rem; border-radius: 14px; cursor: pointer;
  border: 2px solid var(--border-color); background: var(--bg-app); color: var(--text-main); font: inherit; font-weight: 600;
  transition: transform 0.18s var(--bp-ease), border-color 0.2s ease, background-color 0.2s ease;
}
.bp-opt:not(:disabled):hover { border-color: var(--primary); transform: translateX(3px); }
.bp-optk { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--bg-card); border: 1px solid var(--border-color); font-weight: 800; font-size: 0.85rem; flex: none; }
.bp-opt.good { border-color: var(--success); background: rgba(16, 185, 129, 0.12); }
.bp-opt.bad { border-color: var(--danger); background: rgba(239, 68, 68, 0.1); }
.bp-opt:disabled { cursor: default; }
.bp-explain { margin-top: 1rem; padding: 0.8rem 1rem; border-radius: 12px; font-size: 0.92rem; line-height: 1.5; }
.bp-explain.ok { background: rgba(16, 185, 129, 0.12); }
.bp-explain.no { background: rgba(239, 68, 68, 0.09); }
.bp-checks { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 0.4rem; }
.bp-check { display: inline-flex; align-items: center; gap: 6px; padding: 0.4rem 0.8rem; border: 1.5px solid var(--border-color); border-radius: 99px; cursor: pointer; font-weight: 600; font-size: 0.85rem; background: var(--bg-app); }
.bp-check:has(input:checked) { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.bp-check input { accent-color: var(--primary); }
.bp-plan { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.9rem; }
.bp-day { padding: 0.9rem 1rem; }
.bp-day.today { border-color: var(--primary); box-shadow: 0 0 0 3px var(--bp-ring); }
.bp-day.past { opacity: 0.72; }
.bp-day-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.3rem; }
.bp-day .bp-task { cursor: pointer; }
.bp-day .bp-task small { white-space: nowrap; }

/* ---------- Security checkup ---------- */
.bp-checkup { background: var(--bg-app); border: 1px solid var(--border-color); border-radius: 14px; padding: 0.9rem 1rem; margin: 0.4rem 0 0.8rem; }
.bp-checkrow { display: flex; gap: 8px; font-size: 0.88rem; font-weight: 600; padding: 3px 0; }

/* ==========================================================================
   v17: Beautiful sign-in, accent colours, focus mode, compact sidebar
   ========================================================================== */

/* ---------- Sign-in dialog (one Google button) ---------- */
.google-modal-overlay { z-index: 1000005; animation: bpFade 0.25s ease; }
.google-modal-card { max-width: 420px !important; border-radius: 28px !important; animation: bpPop 0.4s var(--bp-ease); box-shadow: 0 40px 90px -25px rgba(30, 27, 75, 0.6) !important; }
.bp-signin { position: relative; padding: 2.1rem 2rem 1.4rem; text-align: center; color: #0f172a;
  background: radial-gradient(520px 220px at 50% -40px, rgba(99, 102, 241, 0.18), transparent 70%), #fff; }
body.dark-mode .bp-signin { color: #f8fafc; background: radial-gradient(520px 220px at 50% -40px, rgba(99, 102, 241, 0.3), transparent 70%), #1e293b; }
.bp-signin-x { position: absolute; top: 12px; right: 14px; width: 34px; height: 34px; border-radius: 50%; border: none; background: rgba(100, 116, 139, 0.12); color: #475569; font-size: 1.4rem; line-height: 1; cursor: pointer; transition: background-color 0.2s ease, transform 0.2s var(--bp-ease); }
.bp-signin-x:hover { background: rgba(239, 68, 68, 0.14); color: #dc2626; transform: rotate(90deg); }
.bp-signin-logo { width: 84px; height: 84px; object-fit: contain; margin: 0 auto 0.6rem; display: block; filter: drop-shadow(0 8px 16px rgba(79, 70, 229, 0.25)); }
.bp-signin-hero h2 { font-family: var(--font-heading); font-size: 1.55rem; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 0.4rem; }
.bp-signin-hero p { color: #64748b; font-size: 0.95rem; line-height: 1.55; margin: 0 auto; max-width: 30ch; }
body.dark-mode .bp-signin-hero p { color: #cbd5e1; }
.bp-signin-perks { list-style: none; margin: 1.3rem 0 1.4rem; padding: 0.4rem 0.2rem; text-align: left; display: grid; gap: 0.15rem; }
.bp-signin-perks li { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 0.92rem; padding: 0.45rem 0.7rem; border-radius: 12px; }
.bp-signin-perks li span { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; background: rgba(99, 102, 241, 0.12); font-size: 1.05rem; flex: none; }
.bp-signin-action { display: flex; flex-direction: column; align-items: center; gap: 0.7rem; }
.bp-signin-slot { min-height: 44px; display: flex; justify-content: center; width: 100%; }
.bp-signin-slot::before { content: ''; position: absolute; }
.bp-signin-err { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; border-radius: 12px; padding: 0.65rem 0.85rem; font-size: 0.85rem; font-weight: 600; line-height: 1.45; text-align: left; width: 100%; }
.bp-signin-err[hidden] { display: none; }
.bp-signin-offline { font-size: 0.85rem; color: #b45309; background: #fffbeb; border-radius: 12px; padding: 0.7rem 0.9rem; line-height: 1.5; }
.bp-signin-offline button { background: none; border: none; color: #1d4ed8; font-weight: 700; cursor: pointer; text-decoration: underline; padding: 0; font: inherit; }
.bp-signin-privacy { color: #64748b; font-size: 0.78rem; line-height: 1.5; margin: 1.1rem 0 0.4rem; }
body.dark-mode .bp-signin-privacy { color: #94a3b8; }
.bp-signin-later { background: none; border: none; color: #64748b; font-weight: 600; font-size: 0.85rem; cursor: pointer; padding: 0.4rem 0.8rem; border-radius: 10px; }
.bp-signin-later:hover { background: rgba(100, 116, 139, 0.12); }

/* ---------- Accent colours ---------- */
html.bp-accent body { --primary-light: color-mix(in srgb, var(--primary) 12%, var(--bg-card)); }
html.bp-accent .btn-primary { background: var(--primary); }
html.bp-accent .btn-primary:hover { background: var(--primary-hover); }
:root { --bp-grad: linear-gradient(135deg, var(--primary) 0%, #7C3AED 55%, #EC4899 100%); }
html.bp-accent[style*="0284C7"] { --bp-grad: linear-gradient(135deg, #0284C7 0%, #0D9488 60%, #10B981 100%); }
.bp-swatches { display: inline-flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.bp-swatch { width: 24px; height: 24px; border-radius: 50%; border: 3px solid var(--bg-card); box-shadow: 0 0 0 1.5px var(--border-color); cursor: pointer; transition: transform 0.2s var(--bp-ease), box-shadow 0.2s ease; }
.bp-swatch:hover { transform: scale(1.18); }
.bp-swatch.on { box-shadow: 0 0 0 2.5px var(--text-main); }

/* ---------- Focus mode ---------- */
html.bp-focus #appSidebar, html.bp-focus #appHeader, html.bp-focus .mobile-bottom-nav,
html.bp-focus .bp-hub-fab, html.bp-focus .bp-top { display: none !important; }
html.bp-focus .app-main-content { margin-left: 0 !important; max-width: 920px; margin-inline: auto !important; padding-bottom: 3rem !important; }
html.bp-focus body::after { content: 'Focus mode · Alt+Z to exit'; position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); background: rgba(15, 23, 42, 0.78); color: #fff; font-size: 0.74rem; font-weight: 700; padding: 5px 14px; border-radius: 99px; z-index: 900; pointer-events: none; opacity: 0.8; }

/* ---------- Confetti ---------- */
.bp-confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1000010; }

/* ---------- Easier sidebar: tighter rows, clear sections ---------- */
.sidebar-link { padding: 0.62rem 0.9rem; font-size: 0.92rem; gap: 0.75rem; border-radius: 14px; }
.sidebar-link .sidebar-icon { width: 28px; text-align: center; font-size: 1.15rem; flex: none; }
.sidebar-label { border-top: none; margin-top: 0.9rem; padding: 0.5rem 0.9rem 0.25rem; }
.sidebar-label.first { margin-top: 0.2rem; }
.sidebar-label::after { content: ''; display: inline-block; vertical-align: middle; width: 24px; height: 1px; margin-left: 8px; background: var(--border-color); }
.app-sidebar { padding-bottom: 5rem; }

/* ---------- Dashboard cards: softer, more modern ---------- */
.card { border-radius: 20px; }
.card-shadow { box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 30px -14px rgba(15, 23, 42, 0.16); }
.badge { letter-spacing: 0.02em; }
.btn { border-radius: 12px; }
.btn-large { border-radius: 14px; }
h1, h2, h3 { letter-spacing: -0.015em; }

/* ==========================================================================
   v18: AI Keys manager + model picker polish
   ========================================================================== */
.bp-aik { max-width: 720px; }
.bp-aik .bp-sechead h3 { display: flex; gap: 10px; align-items: center; }
.bp-aik-note { background: var(--bg-app); border: 1px solid var(--border-color); border-radius: 14px; padding: 0.8rem 1rem; font-size: 0.86rem; line-height: 1.55; margin: 0.6rem 0 0.9rem; }
.bp-aik-list { display: grid; gap: 0.7rem; max-height: 50vh; overflow: auto; padding-right: 4px; }
.bp-aik-card { border: 1px solid var(--border-color); border-radius: 16px; padding: 0.8rem 0.9rem; background: var(--bg-card); }
.bp-aik-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 0.55rem; }
.bp-aik-head > div { flex: 1; min-width: 150px; display: flex; flex-direction: column; }
.bp-aik-head small { color: var(--text-muted); font-size: 0.74rem; }
.bp-aik-ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-light); font-size: 1.2rem; }
.bp-aik-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.bp-aik-grid { display: grid; grid-template-columns: 1.6fr 1fr auto; gap: 8px; }
.bp-aik-res { font-size: 0.82rem; font-weight: 700; margin-top: 0.45rem; min-height: 1.1em; color: var(--text-muted); }
.bp-aik-res.ok { color: var(--success); }
.bp-aik-res.bad { color: var(--danger); }
@media (max-width: 640px) { .bp-aik-grid { grid-template-columns: 1fr; } }

/* tutor model pills: show which models are connected */
.tutor-model-pill { position: relative; }
.tutor-model-pill.ready::after { content: ''; position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25); }
.tutor-model-pill.off { opacity: 0.6; }
.tutor-engine { display: inline-flex; align-items: center; gap: 4px; margin-top: 0.5rem; padding: 2px 9px; border-radius: 99px; font-size: 0.7rem; font-weight: 800; color: #4338ca; background: rgba(99, 102, 241, 0.12); }
