/* ============================================================
   P2A Study Portal — Shared Styles
   Design tokens, base reset, components, and responsive rules.
   ============================================================ */

/* --- Design Tokens ----------------------------------------- */
:root {
  --bg-dark: #0a0a0f;
  --bg-card: #12121a;
  --bg-elevated: #1a1a24;
  --bg-hover: #22222e;

  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-green: #10b981;
  --accent-orange: #f59e0b;
  --accent-red: #ef4444;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --border-color: #2a2a3a;
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --border-radius-lg: 16px;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: 0.2s ease;

  --panel-width: 280px;
}

/* --- Reset & Base ------------------------------------------ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-family);
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
}

/* --- Buttons ----------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--border-radius-sm);
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), opacity var(--transition);
  white-space: nowrap;
  min-height: 44px;
}
.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent-primary);
  color: #fff;
}
.btn-primary:hover {
  background: #5558e6;
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  text-decoration: none;
}

.btn-large {
  padding: 0.85rem 2rem;
  font-size: 1rem;
  border-radius: var(--border-radius);
}

.btn-login {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-primary);
  border: 1px solid var(--accent-primary);
  font-weight: 600;
}
.btn-login:hover {
  background: var(--accent-primary);
  color: #fff;
  text-decoration: none;
}

.btn-green {
  background: var(--accent-green);
  color: #fff;
}
.btn-green:hover {
  background: #0ea572;
  text-decoration: none;
}

.btn-danger {
  background: var(--accent-red);
  color: #fff;
}

/* --- Navigation -------------------------------------------- */
.p2a-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 64px;
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
}

.nav-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
}
.nav-logo span {
  color: var(--accent-primary);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Hamburger */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 10px;
  border: none;
  background: transparent;
  cursor: pointer;
}
.hamburger span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition);
}

/* --- Modal / Overlay --------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 2rem;
  width: 90%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 {
  font-size: 1.4rem;
  margin-bottom: 0.5rem;
}

.modal p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.form-group input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 16px; /* prevents iOS zoom */
  transition: border-color var(--transition);
}
.form-group input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.form-error {
  color: var(--accent-red);
  font-size: 0.8rem;
  margin-top: 0.3rem;
  min-height: 1.2em;
}

.form-footer {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.form-footer a {
  color: var(--accent-primary);
  cursor: pointer;
}

/* --- System Tabs ------------------------------------------- */
.system-tabs {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
  background: var(--bg-card);
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  border: 1px solid var(--border-color);
  border-bottom: none;
}
.system-tabs::-webkit-scrollbar {
  height: 4px;
}
.system-tabs::-webkit-scrollbar-track {
  background: transparent;
}
.system-tabs::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.system-tab {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--border-radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.system-tab:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.system-tab.active {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
}

/* --- Preview Container ------------------------------------- */
#preview-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 var(--border-radius) var(--border-radius);
  padding: 1.5rem;
  min-height: 400px;
}

/* Content renders in iframes — no overrides needed */
.content-iframe {
  width: 100%;
  border: none;
  display: block;
  min-height: 400px;
  border-radius: var(--border-radius-sm);
}

/* --- Unlock Bar (sticky bottom) ---------------------------- */
.unlock-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem 2rem;
  background: rgba(10, 10, 15, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
}

/* --- System Cards (dashboard) ------------------------------ */
.systems-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.system-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
  min-height: 44px;
}
.system-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
}

.system-card .card-icon {
  font-size: 2rem;
}

.system-card .card-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.system-card .card-badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.card-badge.unlocked {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
}

.card-badge.locked {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-muted);
}

.system-card .card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  width: 100%;
}
.system-card .card-actions .btn {
  flex: 1;
  font-size: 0.78rem;
  padding: 0.4rem 0.5rem;
}

/* --- Skeleton Loader --------------------------------------- */
.skeleton-loader {
  padding: 2rem;
}
.skeleton-line {
  height: 16px;
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
  margin-bottom: 1rem;
  width: 80%;
}
.skeleton-line.skeleton-wide {
  width: 100%;
}
.skeleton-line.skeleton-narrow {
  width: 50%;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* --- Toast Notifications ----------------------------------- */
.toast-container {
  position: fixed;
  top: 80px;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.8rem 1.2rem;
  border-radius: var(--border-radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: #fff;
  pointer-events: auto;
  opacity: 0;
  transform: translateX(40px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  max-width: 360px;
}
.toast-visible {
  opacity: 1;
  transform: translateX(0);
}

.toast-error {
  background: var(--accent-red);
}
.toast-success {
  background: var(--accent-green);
}
.toast-info {
  background: var(--accent-primary);
}

/* --- Guide Viewer Overlay (dashboard) ---------------------- */
.viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: var(--bg-dark);
  overflow-y: auto;
  display: none;
}
.viewer-overlay.active {
  display: block;
}

.viewer-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: rgba(10, 10, 15, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
}

.viewer-header .viewer-title {
  flex: 1;
  font-weight: 600;
  font-size: 1rem;
}

.btn-viewer-action {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent-primary);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-family);
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-viewer-action:hover {
  background: var(--accent-primary);
  color: #fff;
}
.btn-viewer-action svg {
  flex-shrink: 0;
}

.guide-viewer-content {
  padding: 2rem;
  max-width: 900px;
  margin: 0 auto;
}

/* Scroll-to-top button */
.scroll-top-btn {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: #fff;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.scroll-top-btn.visible {
  display: flex;
}

/* --- Feedback Bubble --------------------------------------- */
/* --- Support Bubble (bottom-right) -------------------------- */
.support-bubble {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1600;
}

.support-trigger {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
  transition: all var(--transition);
}
.support-trigger:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.5);
}

/* Support panels — shared base */
.support-panel {
  position: absolute;
  bottom: 64px;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  width: 320px;
  display: none;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: supportSlideUp 0.2s ease-out;
}
.support-panel.open {
  display: block;
}

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

.support-panel-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
}

.support-panel-body {
  padding: 0.5rem 0;
}

.support-back {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.25rem 0.4rem;
  border-radius: var(--border-radius-sm);
  font-family: var(--font-family);
  transition: all var(--transition);
}
.support-back:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* Menu options */
.support-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.85rem 1.25rem;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  color: var(--text-primary);
  font-family: var(--font-family);
  transition: background var(--transition);
}
.support-option:hover {
  background: var(--bg-hover);
}

.support-option-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border-radius: 8px;
}

.support-option > div {
  flex: 1;
}

.support-option-title {
  font-size: 0.9rem;
  font-weight: 500;
}

.support-option-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.support-option-arrow {
  color: var(--text-muted);
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* System selector list */
.support-system-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.support-system-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.65rem 1.25rem;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.9rem;
  transition: background var(--transition);
}
.support-system-item:hover {
  background: var(--bg-hover);
}

.support-system-icon {
  font-size: 1.1rem;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

/* Selected system badge in form */
.support-selected-system {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.25rem 1rem 0.75rem;
  padding: 0.5rem 0.75rem;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--accent-primary);
  font-weight: 500;
}

/* Message form */
.support-panel-body textarea {
  width: calc(100% - 2rem);
  min-height: 100px;
  padding: 0.75rem;
  margin: 0.25rem 1rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 14px;
  resize: vertical;
  transition: border-color var(--transition);
}
.support-panel-body textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.support-send-btn {
  margin: 0 1rem 1rem !important;
  width: calc(100% - 2rem) !important;
  border-radius: 10px !important;
}

/* --- Purchase Modal (dashboard) ---------------------------- */
.purchase-modal-inner {
  text-align: center;
}
.purchase-modal-inner .purchase-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* --- Dashboard Layout -------------------------------------- */
.dashboard-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--panel-width);
  background: var(--bg-card);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 800;
  padding: 1.5rem;
}

.sidebar-logo {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}
.sidebar-logo span {
  color: var(--accent-primary);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.sidebar-nav a,
.sidebar-nav button {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--border-radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: var(--font-family);
  transition: all var(--transition);
  width: 100%;
  text-align: left;
  text-decoration: none;
  min-height: 44px;
}
.sidebar-nav a:hover,
.sidebar-nav button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.sidebar-nav a.active {
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent-primary);
}

.sidebar-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 1rem 0.9rem 0.4rem;
}

.sidebar-recent {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-recent-item {
  display: block;
  padding: 0.5rem 0.9rem;
  border-radius: var(--border-radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: var(--font-family);
  text-align: left;
  text-decoration: none;
  transition: all var(--transition);
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-recent-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-recent-item .recent-page-detail {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
.sidebar-recent-search .recent-search-icon {
  flex-shrink: 0;
  font-size: 0.75rem;
}
.sidebar-recent-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.4rem 0.9rem;
  font-style: italic;
}

.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}

.profile-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.profile-info {
  flex: 1;
  min-width: 0;
}

.profile-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-profile .profile-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-signout-btn {
  color: var(--text-muted) !important;
}
.sidebar-signout-btn:hover {
  color: var(--accent-red) !important;
  background: rgba(239, 68, 68, 0.1) !important;
}

.main-stage {
  flex: 1;
  margin-left: var(--panel-width);
  padding: 2rem;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- Mobile Top Bar (dashboard) ---------------------------- */
.mobile-top-bar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 900;
  height: 56px;
  background: rgba(10, 10, 15, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
}

.mobile-top-bar .mobile-logo {
  font-weight: 700;
  font-size: 1.1rem;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 799;
  background: rgba(0, 0, 0, 0.5);
}

/* --- Header (index.html) ----------------------------------- */
.hero {
  text-align: center;
  padding: 7rem 2rem 3rem;
}

.hero h1 {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 1.15rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.6;
}

/* --- Auth Overlay (dashboard, full-screen gate) ------------ */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-dark);
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 2.5rem;
  width: 90%;
  max-width: 420px;
}

.auth-card h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.auth-card .auth-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.75rem;
  line-height: 1.5;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.25rem 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.btn-google {
  width: 100%;
  background: #fff;
  color: #333;
  font-weight: 600;
  border: 1px solid #ddd;
}
.btn-google:hover {
  background: #f5f5f5;
}

/* --- Search Bar (dashboard) -------------------------------- */
.search-bar-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 0 1rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-bar-wrapper:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.search-bar-icon {
  flex-shrink: 0;
  color: var(--text-muted);
}

.search-input {
  flex: 1;
  padding: 0.75rem 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.95rem;
  outline: none;
  min-height: 44px;
}
.search-input::placeholder {
  color: var(--text-muted);
}

.search-shortcut {
  flex-shrink: 0;
  padding: 0.2rem 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-family: var(--font-family);
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1;
}

/* Hero search bar (landing page) */
.hero-search {
  max-width: 600px;
  margin: 2rem auto 0;
  background: rgba(15, 15, 25, 0.7);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(99, 102, 241, 0.25);
}
.hero-search:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2), 0 8px 32px rgba(0, 0, 0, 0.3);
}
.hero-search .search-input {
  font-size: 1rem;
  padding: 0.85rem 0.75rem;
}

/* --- Search Sidebar (right panel) -------------------------- */
.search-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 100vw;
  background: rgba(10, 10, 15, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-left: 1px solid var(--border-color);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}
.search-sidebar.open {
  transform: translateX(0);
}

.search-sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 1199;
  background: rgba(0, 0, 0, 0.4);
}

.search-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.search-sidebar-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.search-sidebar-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--border-radius-sm);
  transition: all var(--transition);
  line-height: 1;
}
.search-sidebar-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.search-sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
}

/* --- Search Results ---------------------------------------- */
.search-loading {
  padding: 1rem 0;
}

.search-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}
.search-empty-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}
.search-empty p {
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}
.search-empty-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Primary card */
.search-primary-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.search-breadcrumb {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.search-page-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

/* Section bubbles */
.search-section-bubbles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.section-bubble {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.7rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 99px;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.section-bubble:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}
.section-bubble.active {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

/* Expanded section content */
.search-section-content {
  display: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 1rem;
  margin-bottom: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text-secondary);
}
.search-section-content p {
  margin-bottom: 0.75rem;
}
.search-section-content p:last-child {
  margin-bottom: 0;
}

/* MCQ styling in search */
.search-mcq .mcq-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 1rem;
  margin-bottom: 0.75rem;
}
.search-mcq .mcq-card:last-child {
  margin-bottom: 0;
}
.search-mcq .mcq-stem {
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}
.search-mcq .mcq-options {
  margin-bottom: 0.75rem;
}
.search-mcq .mcq-option {
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.3rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.85rem;
}
.search-mcq .mcq-reveal-btn {
  width: 100%;
  font-size: 0.85rem;
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  margin-bottom: 0;
}
.search-mcq .mcq-answer {
  color: var(--accent-green);
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.search-mcq .mcq-explanation {
  margin-bottom: 0.5rem;
}
.search-mcq .mcq-trap {
  color: var(--accent-orange);
  font-style: italic;
}

/* Open full page button */
.search-open-full {
  width: 100%;
  margin-top: 0.25rem;
  text-align: center;
  text-decoration: none;
}

/* Lock message */
.search-lock-message {
  text-align: center;
  padding: 1rem 0 0.5rem;
}
.search-lock-message .lock-icon {
  font-size: 1.5rem;
  display: block;
  margin-bottom: 0.5rem;
}
.search-lock-message p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}
.search-lock-message .btn {
  width: 100%;
  margin-bottom: 0.5rem;
}

/* Reference pages */
.search-references {
  margin-top: 0.5rem;
}
.search-references h5 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.search-ref-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  margin-bottom: 0.4rem;
  cursor: pointer;
  transition: all var(--transition);
}
.search-ref-item:hover {
  border-color: var(--accent-primary);
  background: var(--bg-elevated);
}

.search-ref-item .ref-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.search-ref-item .ref-info {
  flex: 1;
  min-width: 0;
}

.search-ref-item .ref-system {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.search-ref-item .ref-page {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-ref-item .ref-action {
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--accent-primary);
  font-weight: 500;
}

.search-ref-locked .ref-action {
  color: var(--text-muted);
}

/* ============================================================
   RESPONSIVE — Mobile (max-width: 768px)
   ============================================================ */
@media (max-width: 768px) {
  /* --- Nav --- */
  .p2a-nav {
    padding: 0 1rem;
  }

  .nav-actions .btn:not(.hamburger) {
    display: none;
  }

  .hamburger {
    display: flex;
  }

  .p2a-nav.mobile-open .nav-actions {
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
  }
  .p2a-nav.mobile-open .nav-actions .btn:not(.hamburger) {
    display: flex;
    width: 100%;
    justify-content: center;
  }

  /* --- Hero --- */
  .hero {
    padding: 5rem 1.25rem 2rem;
  }
  .hero h1 {
    font-size: 1.8rem;
  }
  .hero p {
    font-size: 1rem;
  }

  /* --- System Tabs --- */
  .system-tabs {
    padding: 0.5rem;
    gap: 0.35rem;
    border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0;
  }
  .system-tab {
    padding: 0.4rem 0.75rem;
    font-size: 0.78rem;
    min-height: 44px;
  }

  /* --- Preview Container --- */
  #preview-container {
    padding: 1rem;
    border-radius: 0 0 var(--border-radius-sm) var(--border-radius-sm);
  }

  /* --- Unlock Bar --- */
  .unlock-bar {
    flex-direction: column;
    padding: 0.75rem 1rem;
    gap: 0.5rem;
  }
  .unlock-bar .btn {
    width: 100%;
  }

  /* --- Dashboard --- */
  .sidebar {
    left: -100%;
    transition: left 0.3s ease;
    width: 280px;
  }
  .sidebar.open {
    left: 0;
  }

  .mobile-top-bar {
    display: flex;
  }

  .main-stage {
    margin-left: 0;
    padding: 80px 16px 40px;
  }

  .systems-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
  }

  .system-card {
    padding: 1rem;
  }

  /* --- Viewer --- */
  .guide-viewer-content {
    padding: 1rem;
  }

  .viewer-header {
    padding: 0.6rem 1rem;
  }

  /* --- Auth Overlay --- */
  .auth-card {
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2rem 1.5rem;
  }

  /* --- Search --- */
  .search-shortcut {
    display: none;
  }

  .search-sidebar {
    width: 100%;
  }

  .search-sidebar-overlay {
    display: none;
  }

  /* --- Feedback Bubble --- */
  .feedback-modal {
    left: auto;
    right: -100px;
    width: 280px;
  }

  /* --- Modals --- */
  .modal {
    width: 95%;
    padding: 1.5rem;
  }
}

/* ============================================================
   RESPONSIVE — Small phones (max-width: 380px)
   ============================================================ */
@media (max-width: 380px) {
  .hero h1 {
    font-size: 1.5rem;
  }

  .systems-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .system-tab {
    padding: 0.4rem 0.6rem;
    font-size: 0.72rem;
  }
}
