/* --- 1. CSS VARIABLES (DESIGN SYSTEM) --- */
:root {
  /* Base Colors */
  --white: #ffffff;
  --black: #000000;
  --transparent: transparent;

  /* Slate Palette */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --slate-950: #020617;

  /* Academic (Indigo) Palette */
  --acad-50: #eef2ff;
  --acad-100: #e0e7ff;
  --acad-200: #c7d2fe;
  --acad-300: #a5b4fc;
  --acad-400: #818cf8;
  --acad-500: #6366f1;
  --acad-600: #4f46e5;
  --acad-700: #4338ca;
  --acad-900: #312e81;

  /* Accent Colors */
  --emerald-400: #34d399;
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --emerald-700: #047857;

  --amber-200: #fde68a;
  --amber-300: #fcd34d;
  --amber-400: #fbbf24;
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  --amber-800: #92400e;

  --red-200: #fecaca;
  --red-400: #f87171;
  --red-500: #ef4444;
  --red-600: #dc2626;
  --red-900: #7f1d1d;

  --blue-400: #60a5fa;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;

  --purple-400: #c084fc;
  --purple-500: #a855f7;
  --purple-600: #9333ea;

  /* Light Theme Mapping */
  --bg-body: var(--slate-900);
  /* Hidden behind images */
  --text-main: var(--slate-800);
  --text-muted: var(--slate-500);
  --text-inverse: var(--slate-100);

  --glass-bg: rgba(255, 255, 255, 0.65);
  --glass-panel-bg: rgba(255, 255, 255, 0.94);
  --modal-body-bg: #f8fafc;
  --glass-border: rgba(255, 255, 255, 0.8);
  --glass-shadow:
    0 10px 40px -10px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);

  --glass-input-bg: rgba(255, 255, 255, 0.5);
  --glass-input-border: rgba(148, 163, 184, 0.65);
  --glass-input-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);

  --glass-btn-bg: rgba(255, 255, 255, 0.8);
  --glass-btn-border: rgba(255, 255, 255, 0.9);
  --glass-btn-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  --glass-btn-hover: rgba(255, 255, 255, 0.95);

  --nav-bg: rgba(255, 255, 255, 0.7);
  --nav-border: rgba(255, 255, 255, 0.8);
  --nav-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);

  --border-divider: rgba(255, 255, 255, 0.5);
  --modal-overlay: rgba(15, 23, 42, 0.5);

  /* Typography */
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-serif: "Times New Roman", Times, serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Dark Theme Mapping */
html.dark {
  --text-main: var(--slate-100);
  --text-muted: var(--slate-400);
  --text-inverse: var(--slate-900);

  --glass-bg: rgba(2, 6, 23, 0.75);
  --glass-panel-bg: rgba(15, 23, 42, 0.96);
  --modal-body-bg: #0f172a;
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow:
    0 10px 40px -10px rgba(0, 0, 0, 0.8),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);

  --glass-input-bg: rgba(0, 0, 0, 0.45);
  --glass-input-border: rgba(255, 255, 255, 0.05);
  --glass-input-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);

  --glass-btn-bg: rgba(255, 255, 255, 0.08);
  --glass-btn-border: rgba(255, 255, 255, 0.08);
  --glass-btn-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  --glass-btn-hover: rgba(255, 255, 255, 0.15);

  --nav-bg: rgba(2, 6, 23, 0.85);
  --nav-border: rgba(255, 255, 255, 0.08);
  --nav-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);

  --border-divider: rgba(255, 255, 255, 0.1);
  --modal-overlay: rgba(2, 6, 23, 0.7);
}

/* --- 2. RESET & BASE --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg-body);
  color: var(--text-main);
  transition: color 0.5s ease;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 100%;
  outline: none;
  border: none;
  background: none;
}

button {
  cursor: pointer;
}

a {
  text-decoration: none;
  color: inherit;
}

ul {
  list-style: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}

/* --- 3. BACKGROUND IMAGES --- */
.bg-img-layer {
  position: fixed;
  inset: -20px;
  background-size: cover;
  background-position: center;
  transition: opacity 1.5s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: -10;
}

.bg-light-img {
  background-image: url("https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?q=80&w=2564&auto=format&fit=crop");
  opacity: 1;
}

html.dark .bg-light-img {
  opacity: 0;
}

.bg-dark-img {
  background-image: url("https://images.unsplash.com/photo-1618005198919-d3d4b5a92ead?q=80&w=2000&auto=format&fit=crop");
  opacity: 0;
  filter: brightness(0.6) contrast(1.2);
}

html.dark .bg-dark-img {
  opacity: 1;
}

/* --- 4. CORE LAYOUT & UTILITIES --- */
.is-hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.flex {
  display: flex;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.items-start {
  align-items: flex-start;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-end {
  justify-content: flex-end;
}

.flex-1 {
  flex: 1 1 0%;
}

.shrink-0 {
  flex-shrink: 0;
}

.w-full {
  width: 100%;
}

.h-full {
  height: 100%;
}

.relative {
  position: relative;
}

.absolute {
  position: absolute;
}

.mx-auto {
  margin-left: auto;
  margin-right: auto;
}

.z-10 {
  z-index: 10;
}

.z-20 {
  z-index: 20;
}

.z-30 {
  z-index: 30;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.5);
  border-radius: 20px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

html.dark ::-webkit-scrollbar-thumb {
  background: rgba(71, 85, 105, 0.6);
}

::-webkit-scrollbar-thumb:hover {
  background-color: rgba(100, 116, 139, 0.8);
}

.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

/* Text Utilities */
.font-bold {
  font-weight: 700;
}

.font-black {
  font-weight: 900;
}

.text-xs {
  font-size: 0.75rem;
}

.text-sm {
  font-size: 0.875rem;
}

.text-base {
  font-size: 1rem;
}

.text-lg {
  font-size: 1.125rem;
}

.text-xl {
  font-size: 1.25rem;
}

.text-2xl {
  font-size: 1.5rem;
}

.text-3xl {
  font-size: 1.875rem;
}

.text-4xl {
  font-size: 2.25rem;
}

.text-5xl {
  font-size: 3rem;
}

.uppercase {
  text-transform: uppercase;
}

.tracking-widest {
  letter-spacing: 0.1em;
}

.tracking-tight {
  letter-spacing: -0.025em;
}

/* Colors */
.text-acad {
  color: var(--acad-600);
}

html.dark .text-acad {
  color: var(--acad-400);
}

.text-emerald {
  color: var(--emerald-600);
}

html.dark .text-emerald {
  color: var(--emerald-400);
}

.text-amber {
  color: var(--amber-600);
}

html.dark .text-amber {
  color: var(--amber-400);
}

.text-indigo {
  color: var(--acad-600);
}

html.dark .text-indigo {
  color: var(--acad-400);
}

.text-red {
  color: var(--red-600);
}

html.dark .text-red {
  color: var(--red-400);
}

.text-muted {
  color: var(--text-muted);
}

.text-white {
  color: var(--white);
}

/* --- 5. GLASSMORPHISM COMPONENTS --- */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  transition:
    background 0.5s ease,
    border 0.5s ease,
    box-shadow 0.5s ease;
}

.glass-input {
  background: var(--glass-input-bg);
  border: 1px solid var(--glass-input-border);
  box-shadow: var(--glass-input-shadow);
  color: var(--text-main);
  transition: all 0.3s ease;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.glass-input:focus-within,
.glass-input:focus {
  border-color: var(--acad-500);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

.glass-input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.glass-btn {
  background: var(--glass-btn-bg);
  border: 1px solid var(--glass-btn-border);
  box-shadow: var(--glass-btn-shadow);
  color: var(--text-main);
  transition: all 0.3s ease;
}

.glass-btn:hover {
  background: var(--glass-btn-hover);
  transform: scale(1.05);
}

.primary-btn {
  background: linear-gradient(to right, var(--acad-500), var(--acad-600));
  color: var(--white);
  border: none;
  box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.4);
  transition: all 0.3s ease;
}

.primary-btn:hover {
  background: linear-gradient(to right, var(--acad-600), var(--acad-700));
  transform: scale(1.05);
}

.btn-solid-dark {
  background: var(--slate-800);
  color: var(--white);
  transition: all 0.3s ease;
}

html.dark .btn-solid-dark {
  background: var(--slate-100);
  color: var(--slate-900);
}

.btn-solid-dark:hover {
  transform: scale(1.05);
}

/* --- 6. APP STRUCTURE --- */
.app-container {
  width: 100%;
  height: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: all 0.7s ease-in-out;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  position: relative;
  z-index: 10;
  padding-bottom: 8rem;
  /* Space for bottom nav */
}

.view-wrapper {
  padding: 1rem;
  max-width: 80rem;
  margin: 0 auto;
  width: 100%;
}

@media (min-width: 640px) {
  .view-wrapper {
    padding: 1.5rem;
  }
}

@media (min-width: 1024px) {
  .view-wrapper {
    padding: 2rem;
  }
}

/* Header */
.app-header {
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  margin: 1rem 1rem 0.5rem 1rem;
  border-radius: 9999px;
  flex-shrink: 0;
  z-index: 30;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.logo-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: linear-gradient(
    to bottom right,
    var(--acad-400),
    var(--acad-600)
  );
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.4);
}

.logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.logo-text {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.logo-text span {
  font-weight: 900;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

@media (min-width: 640px) {
  .header-actions {
    gap: 1rem;
  }
}

.icon-btn {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.notification-dot {
  position: absolute;
  top: 0;
  right: 0;
  width: 0.75rem;
  height: 0.75rem;
  background: var(--red-500);
  border-radius: 50%;
  border: 2px solid var(--white);
}

html.dark .notification-dot {
  border-color: var(--slate-800);
}

.user-profile-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-left: 0.5rem;
  border-left: 1px solid var(--border-divider);
  margin-left: 0.25rem;
}

@media (min-width: 640px) {
  .user-profile-btn {
    padding-left: 1rem;
  }
}

.user-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.tier-pill {
  font-size: 0.55rem;
  font-weight: 700;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  background: rgba(226, 232, 240, 0.8);
  color: var(--slate-600);
}

html.dark .tier-pill {
  background: rgba(51, 65, 85, 0.8);
  color: var(--slate-300);
}

.tier-pill.pro {
  background: var(--acad-600);
  color: white;
}

/* Keep the app inside the visible mobile viewport and make the header compact. */
@media (max-width: 639px) {
  html,
  body {
    touch-action: manipulation;
  }

  body {
    height: 100dvh;
    min-height: 100dvh;
    align-items: stretch;
  }

  .app-container {
    height: 100dvh;
    min-height: 100dvh;
  }

  .app-header {
    height: 3.25rem;
    min-height: 3.25rem;
    margin: max(0.5rem, env(safe-area-inset-top)) 0.5rem 0.5rem;
    padding: 0 0.75rem;
    border-radius: 1.25rem;
  }

  .logo-icon,
  .icon-btn,
  .user-avatar {
    width: 2.15rem;
    height: 2.15rem;
  }

  .header-logo {
    gap: 0.5rem;
  }

  .header-actions {
    gap: 0.2rem;
  }

  .user-profile-btn {
    gap: 0.25rem;
    padding-left: 0.4rem;
    margin-left: 0.1rem;
  }

  .notification-dot {
    width: 0.6rem;
    height: 0.6rem;
  }
}

/* Integrity Banner */
.integrity-banner {
  margin: 0.5rem 1rem;
  border-radius: 1rem;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  flex-shrink: 0;
  z-index: 20;
  border-left: 4px solid var(--amber-400);
}

.banner-text {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--amber-800);
  font-weight: 500;
}

html.dark .banner-text {
  color: var(--amber-200);
}

.banner-icon {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: rgba(251, 191, 36, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.banner-link {
  font-weight: 700;
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  background: rgba(251, 191, 36, 0.1);
  color: var(--amber-700);
  transition: opacity 0.3s;
}

html.dark .banner-link {
  background: rgba(251, 191, 36, 0.2);
  color: var(--amber-300);
}

.banner-link:hover {
  opacity: 0.7;
}

/* Bottom Nav (iOS Glass) */
.bottom-nav {
  position: absolute;
  bottom: 1.5rem;
  left: 1.5rem;
  right: 1.5rem;
  height: 5rem;
  border-radius: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 1.5rem;
  background: var(--nav-bg);
  backdrop-filter: blur(30px) saturate(200%);
  -webkit-backdrop-filter: blur(30px) saturate(200%);
  border: 1px solid var(--nav-border);
  box-shadow: var(--nav-shadow);
  z-index: 40;
  transition: all 0.3s ease;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  width: 4rem;
  color: var(--text-muted);
  transition: all 0.3s ease;
}

.nav-btn i {
  font-size: 1.25rem;
}

.nav-btn span {
  font-size: 0.6rem;
  font-weight: 900;
}

.nav-btn:hover {
  color: var(--acad-500);
  transform: translateY(-2px);
}

.nav-btn.active {
  color: var(--acad-600);
  transform: scale(1.1);
}

html.dark .nav-btn.active {
  color: var(--acad-400);
}

.nav-create-wrap {
  position: relative;
  margin-top: -2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.nav-create-glow {
  position: absolute;
  inset: 0;
  background: var(--acad-500);
  border-radius: 50%;
  filter: blur(12px);
  opacity: 0.4;
  transition: opacity 0.3s;
}

.nav-create-wrap:hover .nav-create-glow {
  opacity: 0.7;
}

.nav-create-btn {
  position: relative;
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(
    to bottom right,
    var(--acad-500),
    var(--acad-700)
  );
  color: white;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  border: 4px solid rgba(255, 255, 255, 0.5);
  transition: transform 0.3s;
}

html.dark .nav-create-btn {
  border-color: rgba(51, 65, 85, 0.5);
}

.nav-create-wrap:hover .nav-create-btn {
  transform: scale(1.1);
}

/* Desktop Side Nav Overrides */
@media (min-width: 1024px) {
  .app-container:not(.mobile-sim-active) .bottom-nav {
    top: 50%;
    bottom: auto;
    left: auto;
    right: 1.5rem;
    transform: translateY(-50%);
    width: 5.5rem;
    height: auto;
    flex-direction: column;
    padding: 2.5rem 0;
    gap: 2rem;
    border-radius: 2.5rem;
  }

  .app-container:not(.mobile-sim-active) .nav-create-wrap {
    margin-top: 0;
    margin-left: -2rem;
  }

  .app-container:not(.mobile-sim-active) .main-content {
    padding-bottom: 2rem;
    padding-right: 8rem;
  }
}

/* --- 7. DASHBOARD VIEWS --- */
.welcome-header {
  margin-top: 1rem;
  margin-bottom: 2.5rem;
}

@media (max-width: 640px) {
  .welcome-header {
    text-align: center;
  }
}

.quick-prompt {
  padding: 0.625rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
}

.quick-prompt input {
  width: 100%;
  padding: 0.75rem 0;
  font-size: 0.875rem;
  margin-left: 0.5rem;
}

.quick-prompt-btn {
  padding: 0.75rem 1.5rem;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.875rem;
  white-space: nowrap;
  margin-left: 0.5rem;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 2.5rem;
}

@media (min-width: 1024px) {
  .metrics-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 640px) {
  .metrics-grid {
    gap: 1.5rem;
  }
}

.metric-card {
  padding: 1.25rem;
  border-radius: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.3s;
}

.metric-card:hover {
  transform: translateY(-4px);
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.metric-icon-wrap {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.metric-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.metric-value {
  font-size: 1.5rem;
  font-weight: 900;
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
}

.progress-track {
  width: 100%;
  height: 0.5rem;
  background: rgba(226, 232, 240, 0.5);
  border-radius: 9999px;
  margin-top: 0.75rem;
  overflow: hidden;
}

html.dark .progress-track {
  background: rgba(51, 65, 85, 0.5);
}

.progress-fill {
  height: 100%;
  border-radius: 9999px;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding: 0 0.5rem;
}

.view-all-link {
  font-size: 0.875rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  transition: opacity 0.3s;
  color: var(--acad-600);
}

html.dark .view-all-link {
  color: var(--acad-400);
}

.view-all-link:hover {
  opacity: 0.7;
}

.assignments-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .assignments-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1280px) {
  .assignments-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.assignment-card {
  padding: 1.5rem;
  border-radius: 1.5rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s;
}

.assignment-card:hover {
  transform: translateY(-4px);
}

.card-bg-orb {
  position: absolute;
  top: -2.5rem;
  right: -2.5rem;
  width: 8rem;
  height: 8rem;
  border-radius: 50%;
  filter: blur(24px);
  transition: background 0.3s;
  z-index: 0;
}

.assignment-card:hover .card-bg-orb {
  background: rgba(99, 102, 241, 0.3);
}

.card-content {
  position: relative;
  z-index: 10;
}

.tag-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tag {
  font-size: 0.6rem;
  font-weight: 900;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  backdrop-filter: blur(4px);
}

.tag-default {
  background: rgba(226, 232, 240, 0.7);
  color: var(--slate-700);
}

html.dark .tag-default {
  background: rgba(51, 65, 85, 0.7);
  color: var(--slate-200);
}

.tag-primary {
  background: rgba(224, 231, 255, 0.7);
  color: var(--acad-700);
}

html.dark .tag-primary {
  background: rgba(49, 46, 129, 0.5);
  color: var(--acad-300);
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  padding: 0.5rem 1rem;
  border-radius: 0.75rem;
  margin-bottom: 0.75rem;
}

.action-row {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.btn-view-doc {
  flex: 1;
  font-weight: 700;
  font-size: 0.875rem;
  padding: 0.75rem;
  border-radius: 1rem;
  text-align: center;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-action-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
}

.create-prompt-card {
  border: 2px dashed rgba(148, 163, 184, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 18.75rem;
  cursor: pointer;
}

.create-prompt-card:hover {
  background: rgba(255, 255, 255, 0.2);
}

html.dark .create-prompt-card:hover {
  background: rgba(30, 41, 59, 0.3);
}

/* --- 8. LIBRARY & LAB VIEWS --- */
.search-container {
  position: relative;
  flex: 1;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-input {
  width: 100%;
  padding: 1rem 1rem 1rem 3rem;
  border-radius: 9999px;
  font-size: 0.875rem;
}

.filter-row {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  align-items: center;
}

.filter-btn {
  padding: 0.75rem 1.5rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 700;
  white-space: nowrap;
}

.list-item {
  padding: 1.25rem;
  border-radius: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: transform 0.3s;
  margin-bottom: 1rem;
}

@media (min-width: 640px) {
  .list-item {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.list-item:hover {
  transform: scale(1.01);
}

.list-icon-wrap {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 1rem;
  background: linear-gradient(
    to bottom right,
    var(--blue-400),
    var(--acad-500)
  );
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
  box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.3);
}

/* Lab specific */
.lab-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 1024px) {
  .lab-grid {
    grid-template-columns: 1fr 2fr;
  }
}

.gauge-card {
  padding: 1.5rem;
  border-radius: 1.5rem;
  position: relative;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.gauge-top-bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 0.375rem;
}

.bg-grad-emerald {
  background: linear-gradient(to right, var(--emerald-400), var(--emerald-600));
}

.bg-grad-indigo {
  background: linear-gradient(to right, var(--acad-400), var(--purple-500));
}

.comparison-panel {
  display: flex;
  flex-direction: column;
  height: 46rem;
  border-radius: 1.5rem;
  overflow: hidden;
}

.comparison-header {
  padding: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-divider);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
}

.comparison-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  overflow-y: auto;
}

@media (min-width: 768px) {
  .comparison-body {
    grid-template-columns: 1fr 1fr;
  }
}

.comp-col {
  padding: 1.5rem;
  border-right: 1px solid var(--border-divider);
}

.comp-col:last-child {
  border-right: none;
  background: rgba(0, 0, 0, 0.05);
}

html.dark .comp-col:last-child {
  background: rgba(255, 255, 255, 0.05);
}

.highlight-red {
  background: rgba(239, 68, 68, 0.2);
  color: var(--red-900);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  border: 1px solid rgba(239, 68, 68, 0.3);
  font-weight: 500;
}

html.dark .highlight-red {
  background: rgba(239, 68, 68, 0.3);
  color: var(--red-200);
}

/* --- 9. MODALS & WIZARD --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
  background: var(--modal-overlay);
}

@media (min-width: 768px) {
  .modal-overlay {
    padding: 2rem;
  }
}

.modal-close-btn {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 20;
}

/* Modals sizes */
.modal-sm {
  max-width: 24rem;
  border-radius: 2rem;
}

.modal-md {
  max-width: 32rem;
  border-radius: 2.5rem;
}

.modal-lg {
  max-width: 48rem;
  border-radius: 2.5rem;
  height: 43.75rem;
  display: flex;
  flex-direction: column;
}

/* Creation wizard redesign */
.create-modal-panel {
  width: min(100%, 70rem);
  max-width: 70rem;
  height: min(90vh, 54rem);
  border-radius: 1.75rem;
  overflow: hidden;
}

.create-modal-header {
  padding: 1.5rem 2rem 1.25rem;
  background: var(--glass-panel-bg);
}

.create-eyebrow,
.create-step-kicker {
  color: var(--acad-600);
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.create-subtitle,
.create-step-heading p {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 0.35rem;
}

.create-modal-header .mb-6 {
  margin-bottom: 1.25rem;
}

.create-modal-panel .wizard-progress-wrap {
  margin-top: 0.5rem;
}

.create-modal-panel .step-label {
  display: block;
  font-size: 0.65rem;
}

.create-modal-body {
  padding: 2rem;
  background: color-mix(in srgb, var(--bg-body) 45%, transparent);
}

.create-step {
  min-height: 100%;
}

.create-step-heading {
  margin-bottom: 1.5rem;
}

.create-step-heading h3 {
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  margin-top: 0.25rem;
}

#wizard-step-1 > .flex-col {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem !important;
}

#wizard-step-1 > .flex-col > .form-group:first-child,
#wizard-step-1 > .flex-col > .form-grid-2 {
  grid-column: 1 / -1;
}

#wizard-step-1 .form-group {
  margin-bottom: 0;
}

#wizard-step-1 .form-grid-2 {
  gap: 1rem;
}

#wizard-step-2 > .h-full {
  display: grid !important;
  grid-template-columns: minmax(0, 1.5fr) minmax(14rem, 0.75fr);
  align-items: stretch;
  gap: 1rem !important;
}

#wizard-step-2 .form-textarea {
  min-height: 18rem;
}

#wizard-step-2 .create-prompt-card {
  display: flex;
  min-height: 18rem !important;
  align-items: center;
  justify-content: center;
}

#wizard-step-3 > .flex-col {
  display: grid !important;
  grid-template-columns: minmax(0, 1.1fr) minmax(19rem, 0.9fr);
  grid-template-rows: auto auto 1fr;
  gap: 1rem !important;
}

#cover-generate-section:not(.is-hidden) {
  display: contents !important;
}

#wizard-step-3 > .flex-col > .flex.glass-input {
  grid-column: 1 / -1;
  grid-row: 1;
  max-width: none !important;
  margin: 0 0 0.5rem !important;
}

#cover-generate-section > .form-label {
  grid-column: 1;
  grid-row: 2;
  margin: 0;
}

#cover-generate-section > .cover-grid {
  grid-column: 1;
  grid-row: 3;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  padding: 0;
  overflow: visible;
}

#cover-generate-section > .shrink-0 {
  grid-column: 2;
  grid-row: 2 / 4;
  margin: 0 !important;
  padding: 0 !important;
  border-top: 0 !important;
  gap: 0.75rem !important;
}

#cover-generate-section > .shrink-0 .form-grid-2 {
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

#cover-upload-section {
  grid-column: 1 / -1;
}

#cover-generate-section > .shrink-0 .form-input,
#cover-generate-section > .shrink-0 .color-input {
  min-height: 2.75rem;
}

#cover-generate-section > .shrink-0 .form-label {
  margin-left: 0;
}

.template-coming-soon {
  cursor: default;
  opacity: 0.65;
}

.template-coming-soon:hover {
  border-color: var(--border-divider);
  transform: none;
}

.create-compile-step .create-step-heading {
  margin-bottom: 0;
}

@media (max-width: 767px) {
  .create-modal-panel {
    height: calc(100dvh - 1rem);
    border-radius: 1.25rem;
  }

  .create-modal-header,
  .create-modal-body {
    padding: 1.25rem;
  }

  .create-modal-panel .step-label {
    font-size: 0.55rem;
    letter-spacing: 0.04em;
  }

  .create-modal-panel .step-circle {
    width: 2rem;
    height: 2rem;
    border-width: 3px;
  }

  #wizard-step-1 > .flex-col,
  #wizard-step-2 > .h-full,
  #wizard-step-3 > .flex-col {
    display: flex !important;
    flex-direction: column;
    gap: 0.875rem !important;
  }

  #wizard-step-1 > .flex-col > .form-group:first-child,
  #wizard-step-1 > .flex-col > .form-grid-2,
  #cover-generate-section > .form-label,
  #cover-generate-section > .cover-grid,
  #cover-generate-section > .shrink-0,
  #wizard-step-3 > .flex-col > .flex.glass-input {
    width: 100%;
  }

  #cover-generate-section > .cover-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    display: grid !important;
  }

  #wizard-step-2 .create-prompt-card,
  #wizard-step-2 .form-textarea {
    min-height: 12rem !important;
  }
}

.modal-xl {
  max-width: 64rem;
  border-radius: 3rem;
}

/* Wizard */
.wizard-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border-divider);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
}

html.dark .wizard-header {
  background: rgba(15, 23, 42, 0.1);
}

.wizard-progress-wrap {
  position: relative;
  display: flex;
  justify-content: space-between;
  padding: 0 1rem;
  margin-top: 1rem;
}

.progress-line-bg {
  position: absolute;
  left: 1.5rem;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  height: 0.375rem;
  border-radius: 9999px;
  z-index: 0;
}

.progress-line-fill {
  position: absolute;
  left: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  height: 0.375rem;
  border-radius: 9999px;
  z-index: 0;
  background: linear-gradient(to right, var(--acad-400), var(--acad-600));
  transition: width 0.5s ease;
}

.step-nav-item {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: 25%;
}

.step-circle {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 0.875rem;
  border: 4px solid var(--white);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  transition: all 0.3s;
}

html.dark .step-circle {
  border-color: rgba(255, 255, 255, 0.1);
}

.step-label {
  font-size: 0.625rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: none;
}

@media (min-width: 640px) {
  .step-label {
    display: block;
  }
}

/* Step States */
.step-circle.active {
  background: var(--acad-600);
  color: white;
  border-color: var(--white);
}

html.dark .step-circle.active {
  border-color: var(--slate-800);
}

.step-label.active {
  color: var(--acad-600);
}

html.dark .step-label.active {
  color: var(--acad-400);
}

.step-circle.inactive {
  background: var(--glass-input-bg);
  color: var(--text-muted);
}

.step-label.inactive {
  color: var(--text-muted);
}

.wizard-body {
  padding: 1.5rem;
  flex: 1;
  overflow-y: auto;
  position: relative;
  z-index: 10;
}

@media (min-width: 768px) {
  .wizard-body {
    padding: 2.5rem;
  }
}

.wizard-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border-divider);
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  backdrop-filter: blur(12px);
}

@media (max-width: 640px) {
  .wizard-footer {
    padding: 0.75rem 1rem;
    gap: 0.75rem;
  }

  .wizard-nav-btn {
    padding: 0.625rem 1rem !important;
    border-radius: 0.75rem !important;
    font-size: 0.7rem;
    line-height: 1.1;
    white-space: nowrap;
  }
}

/* Guided creation flow: one decision per screen */
.guided-create-modal {
  width: min(100%, 60rem);
  max-width: 60rem;
  height: min(90vh, 52rem);
  border-radius: 1.5rem;
  overflow: hidden;
}

.guided-header {
  padding: 1.75rem 2.25rem 1.5rem;
  border-bottom: 1px solid var(--border-divider);
  background: var(--glass-panel-bg);
}

.guided-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.guided-title-row h2 {
  font-size: 1.7rem;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.guided-brand {
  color: var(--acad-600);
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}

.guided-muted,
.guided-question p {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 0.4rem;
}

.guided-progress {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  position: relative;
  gap: 0.35rem;
}

.guided-progress::before {
  content: '';
  position: absolute;
  top: 1.05rem;
  left: 7%;
  right: 7%;
  height: 0.2rem;
  border-radius: 99px;
  background: var(--glass-input-bg);
}

.guided-progress-fill {
  position: absolute;
  top: 1.05rem;
  left: 7%;
  height: 0.2rem;
  max-width: 86%;
  border-radius: 99px;
  background: linear-gradient(to right, var(--acad-400), var(--acad-600));
  transition: width 0.35s ease;
  z-index: 1;
}

.guided-step-marker {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
}

.guided-step-marker .step-circle {
  width: 2.1rem;
  height: 2.1rem;
  border-width: 3px;
  font-size: 0.72rem;
}

.guided-step-marker .step-label {
  display: block;
  font-size: 0.55rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.guided-body {
  display: flex;
  flex-direction: column;
  padding: 2.5rem;
  background: var(--modal-body-bg);
  color: var(--text-main);
  overflow-x: hidden;
}

.guided-step-page {
  width: min(100%, 48rem);
  min-width: 0;
  margin: auto;
}

.guided-question {
  margin-bottom: 2rem;
}

.guided-question > span {
  color: var(--acad-600);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.guided-question h3 {
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 1.05;
  margin-top: 0.5rem;
}

.guided-choice-list {
  display: grid;
  gap: 0.9rem;
}

.guided-choice {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  border: 1px solid var(--border-divider);
  border-radius: 1.25rem;
  background: var(--glass-panel-bg);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.guided-choice:hover {
  border-color: var(--acad-400);
  transform: translateY(-1px);
}

.guided-choice:has(input:checked) {
  border-color: var(--acad-500);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.guided-choice input {
  accent-color: var(--acad-600);
}

.guided-choice span {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.25rem;
}

.guided-choice strong {
  font-size: 1rem;
  font-weight: 900;
}

.guided-choice small,
.guided-upload-card small,
.guided-upload-cover span {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.guided-choice > i {
  color: var(--acad-500);
  font-size: 1.2rem;
}

.guided-hidden-select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.guided-single-field {
  max-width: 42rem;
}

.guided-large-input {
  min-height: 4.25rem;
  font-size: 1.15rem;
}

.guided-fields-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.guided-fields-grid > div {
  min-width: 0;
}

.guided-brief-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(13rem, 0.75fr);
  gap: 1rem;
}

.guided-brief-area {
  min-height: 18rem;
}

.guided-upload-card,
.guided-upload-cover {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 18rem;
  padding: 1.5rem;
  text-align: center;
  border: 1px dashed var(--border-divider);
  border-radius: 1.25rem;
  background: var(--glass-panel-bg);
}

.guided-upload-card > i,
.guided-upload-cover > i {
  color: var(--acad-500);
  font-size: 2rem;
}

.guided-upload-card strong,
.guided-upload-cover strong {
  font-size: 0.95rem;
  font-weight: 900;
}

.guided-mode-toggle {
  width: min(100%, 25rem);
  gap: 0.35rem;
  padding: 0.35rem;
  border-radius: 0.9rem;
}

.guided-mode-toggle button {
  min-height: 2.7rem;
  border-radius: 0.65rem;
}

.guided-template-section {
  margin-top: 1.5rem;
}

.guided-template-section .cover-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  padding: 0;
  overflow: visible;
}

.guided-template-section .cover-template {
  min-height: 190px;
}

.guided-upload-cover {
  margin-top: 1.5rem;
}

.guided-cover-fields {
  width: min(100%, 42rem);
  margin: auto;
}

.guided-cover-fields .form-grid-2 {
  gap: 0.9rem;
}

.guided-preview-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 0.5rem;
  min-height: 3rem;
  margin-top: 1rem;
  border-radius: 0.9rem;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.guided-step-page .form-group {
  margin-bottom: 0;
}

@media (max-width: 767px) {
  .modal-overlay {
    align-items: stretch;
    padding: 0;
  }

  .modal-overlay > .glass-panel {
    width: 100% !important;
    max-width: none !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
  }

  .guided-create-modal {
    width: 100%;
    height: 100dvh;
    border-radius: 0;
  }

  .guided-header,
  .guided-body {
    padding: 1.25rem;
  }

  .guided-step-page,
  #wizard-step-6,
  .guided-cover-fields,
  .guided-cover-fields .form-grid-2 {
    width: 100%;
    min-width: 0;
  }

  #wizard-step-6 .form-input,
  #wizard-step-6 select,
  #wizard-step-6 input {
    min-width: 0;
    max-width: 100%;
  }

  .guided-title-row h2 {
    font-size: 1.35rem;
  }

  .guided-muted {
    font-size: 0.72rem;
  }

  .guided-step-marker .step-label {
    display: none;
  }

  .guided-step-marker .step-circle {
    width: 1.8rem;
    height: 1.8rem;
  }

  .guided-question {
    margin-bottom: 1.25rem;
  }

  .guided-fields-grid,
  .guided-brief-layout {
    grid-template-columns: 1fr;
  }

  .guided-brief-area,
  .guided-upload-card {
    min-height: 12rem;
  }

  .guided-template-section .cover-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .guided-template-section .cover-template {
    min-height: 145px;
  }
}

html.dark .wizard-footer {
  background: rgba(15, 23, 42, 0.1);
}

/* Wizard Steps (Fixed animation & hiding logic) */
.wizard-step {
  display: none;
  opacity: 0;
}

.wizard-step.active {
  display: block;
  animation: smoothFade 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes smoothFade {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Form grids inside wizard */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 640px) {
  .form-grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.form-input {
  width: 100%;
  padding: 1rem;
  border-radius: 1rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.form-textarea {
  width: 100%;
  padding: 1.25rem;
  border-radius: 1.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.6;
  resize: none;
  min-height: 12rem;
}

.cover-preview-logo {
  width: 1.25in;
  height: 0.9in;
  object-fit: contain;
  margin-bottom: 0.3in;
}

.cover-signature-preview {
  font-family: "Times New Roman", Times, serif;
  font-style: italic;
  font-size: 1.1rem;
  margin-top: 0.35rem;
}

.cover-pdf-preview {
  width: 100%;
  height: 11in;
  border: 0;
  background: white;
}

.cover-preview-frame-wrap {
  height: 75vh;
  min-height: 0;
  overflow: hidden;
}

.cover-preview-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: white;
}

.institution-manual-field,
.institution-logo-field {
  min-width: 0;
}

.institution-color-field {
  min-width: 0;
}

.color-input {
  height: 3.125rem;
  padding: 0.35rem;
  cursor: pointer;
}

.merge-cover-section {
  border-top: 1px solid var(--border-divider);
  padding-top: 1rem;
}

.institution-logo-field .form-input {
  padding: 0.75rem;
  font-size: 0.75rem;
}

.institution-logo-field .form-input::file-selector-button {
  margin-right: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-radius: 0.5rem;
  background: var(--acad-100);
  color: var(--acad-700);
  font-weight: 800;
  cursor: pointer;
}

.signature-upload-field {
  min-width: 0;
}

.signature-upload-field .form-input {
  padding: 0.75rem;
  font-size: 0.75rem;
}

.signature-upload-field .form-input::file-selector-button {
  margin-right: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 0;
  border-radius: 0.5rem;
  background: var(--acad-100);
  color: var(--acad-700);
  font-weight: 800;
  cursor: pointer;
}

/* Cover Page Selection Grid */
.cover-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  padding-bottom: 1.5rem;
  align-content: flex-start;
  align-items: flex-start;
  min-height: 0;
}

@media (min-width: 640px) {
  .cover-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 768px) {
  .cover-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

.cover-template {
  position: relative;
  border-radius: 1rem;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 3/4;
  min-height: 130px;
  display: flex;
  flex-direction: column;
  border: 2px solid var(--border-divider);
  transition: all 0.3s;
}

.cover-template:hover {
  border-color: var(--acad-400);
}

.cover-template.selected {
  border-color: var(--acad-500);
  transform: scale(1.02);
  box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.3);
  z-index: 10;
}

.cover-check {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 1.25rem;
  height: 1.25rem;
  background: var(--acad-600);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 20;
}

.cover-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(4px);
  color: white;
  font-size: 0.625rem;
  font-weight: 700;
  text-align: center;
  padding: 0.375rem;
}

/* Loading Sim */
.sim-orb-wrap {
  position: relative;
  width: 8rem;
  height: 8rem;
  margin-bottom: 2rem;
}

.spin-border {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 4px solid transparent;
  border-top-color: var(--acad-500);
  border-right-color: var(--acad-500);
  animation: spin 1s linear infinite;
  opacity: 0.8;
}

.spin-border-rev {
  position: absolute;
  inset: 0.5rem;
  border-radius: 50%;
  border: 4px solid transparent;
  border-bottom-color: var(--acad-300);
  border-left-color: var(--acad-300);
  animation: spin 1.5s linear infinite reverse;
  opacity: 0.6;
}

.sim-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sim-icon-inner {
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.875rem;
  color: var(--acad-600);
}

html.dark .sim-icon-inner {
  color: var(--acad-400);
}

@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

.shimmer-bg {
  position: relative;
  overflow: hidden;
}

.shimmer-effect {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to right,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent
  );
  transform: translateX(-100%);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

/* --- 10. DOCUMENT PREVIEW (ISOLATED) --- */
.doc-viewer-toolbar {
  padding: 0.75rem;
  border-radius: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-shrink: 0;
  gap: 0.75rem;
}

/* The paper document - strictly overrides dark mode */
.academic-preview {
  background: white !important;
  color: black !important;
  font-family: var(--font-serif);
  font-size: 12pt;
  line-height: 2;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  padding: 1in;
  min-height: 11in;
  text-align: left;
  border-radius: 8px;
  width: 100%;
  max-width: 8.5in;
  margin: 0 auto;
}

.academic-preview p {
  margin-bottom: 0;
  text-indent: 0.5in;
}

.academic-preview .no-indent {
  text-indent: 0;
}

.academic-preview h1,
.academic-preview h2,
.academic-preview h3 {
  text-align: center;
  font-weight: bold;
  font-size: 12pt;
  margin: 12pt 0;
}

.academic-preview .cover-page {
  height: 9in;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.academic-preview .cover-page p {
  text-indent: 0;
}

.academic-preview .reference-item {
  text-indent: -0.5in;
  padding-left: 0.5in;
  margin-bottom: 12pt;
}

.academic-preview table {
  width: 100%;
  border-collapse: collapse;
  margin: 12pt 0;
  text-indent: 0;
}

.academic-preview th,
.academic-preview td {
  border-top: 1px solid black;
  border-bottom: 1px solid black;
  padding: 4px 8px;
  text-align: left;
}

.page-break-visual {
  width: 100%;
  border-bottom: 2px dashed #d1d5db;
  margin: 2rem 0;
  position: relative;
}

.page-break-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 0 0.75rem;
  font-size: 0.625rem;
  color: #9ca3af;
  font-family: var(--font-sans);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.1em;
}

/* Tiers Specifics */
.tier-card {
  padding: 2rem;
  border-radius: 2rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s;
}

.tier-card:hover {
  transform: translateY(-8px);
}

.tier-pro-wrap {
  position: relative;
  padding: 2rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  border-radius: 2rem;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

@media (min-width: 768px) {
  .tier-pro-wrap {
    transform: translateY(-2rem);
  }

  .tier-pro-wrap:hover {
    transform: translateY(-2.5rem);
  }
}

.tier-pro-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom right,
    var(--acad-500),
    var(--acad-700)
  );
  opacity: 0.9;
  z-index: 0;
}

.tier-pro-badge {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--amber-400);
  color: var(--amber-900);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
  padding: 0.375rem 1rem;
  border-bottom-left-radius: 1rem;
  z-index: 10;
}

/* Mobile Sim Frame */
.mobile-sim-active {
  max-width: 420px !important;
  height: 850px !important;
  max-height: 95vh;
  margin: 20px auto;
  border-radius: 55px;
  border: 14px solid #000;
  box-shadow:
    0 30px 60px -12px rgba(0, 0, 0, 0.7),
    inset 0 0 0 2px #333;
  position: relative;
  overflow: hidden;
  background-color: transparent;
}

/* Final creation step: one clear decision, then one final PDF action */
.guided-result-state {
  width: min(100%, 42rem);
  margin: auto;
  text-align: center;
}

.guided-result-icon {
  width: 4.5rem;
  height: 4.5rem;
  margin: 0 auto 1.25rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 1rem 2rem rgba(16, 185, 129, 0.24);
  font-size: 1.75rem;
}

.guided-result-title {
  margin: 0;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 900;
  letter-spacing: -0.04em;
}

.guided-result-subtitle {
  max-width: 34rem;
  margin: 0.75rem auto 0;
  color: var(--text-muted);
  line-height: 1.6;
}

.guided-outcome-choice {
  width: 100%;
  margin-top: 1.75rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.guided-outcome-card {
  min-height: 7.5rem;
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  padding: 1.25rem;
  text-align: left;
  color: inherit;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-divider);
  border-radius: 1.1rem;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.guided-outcome-card:hover,
.guided-outcome-card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--acad-400);
  background: rgba(99, 102, 241, 0.12);
  outline: none;
}

.guided-outcome-card > i {
  flex: 0 0 auto;
  margin-top: 0.1rem;
  color: var(--acad-400);
  font-size: 1.25rem;
}

.guided-outcome-card span {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.guided-outcome-card strong {
  font-size: 0.95rem;
  line-height: 1.3;
}

.guided-outcome-card small {
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.guided-final-download,
.guided-merge-panel {
  width: 100%;
  margin-top: 1.5rem;
}

.guided-final-download p {
  margin: 0 0 1rem;
  color: var(--text-muted);
}

.guided-download-button {
  width: 100%;
  min-height: 3.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.guided-merge-panel {
  padding: 1.25rem;
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-divider);
  border-radius: 1.1rem;
}

.guided-back-choice {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
  padding: 0;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 800;
}

.guided-back-choice:hover {
  color: var(--text-primary);
}

.guided-merge-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.guided-merge-button {
  min-height: 2.75rem;
  flex: 0 0 auto;
  padding: 0 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  white-space: nowrap;
}

.guided-merge-button:disabled {
  opacity: 0.82;
  cursor: wait;
  filter: saturate(0.7);
}

.guided-merge-panel .text-xs {
  min-height: 1.25rem;
  margin: 0.75rem 0 0;
}

@media (max-width: 640px) {
  .guided-outcome-choice {
    grid-template-columns: 1fr;
  }

  .guided-merge-row {
    flex-direction: column;
    align-items: stretch;
  }

  .guided-merge-button {
    width: 100%;
  }
}
