/* ==========================================================================
   AI STUDY PLANNER - PRODUCTION DESIGN SYSTEM & STYLESHEET
   Pure CSS3, Zero Frameworks, Mobile-First, Accessible (WCAG 2.1 AA)
   ========================================================================== */

:root {
  /* Color Palette - Light Mode (Refined Slate & Indigo) */
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-muted: #e2e8f0;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --accent-primary: #4f46e5;
  --accent-hover: #4338ca;
  --accent-light: #eef2ff;
  --accent-border: #c7d2fe;

  --success-bg: #ecfdf5;
  --success-text: #065f46;
  --success-border: #a7f3d0;
  --success-accent: #10b981;

  --warning-bg: #fffbeb;
  --warning-text: #92400e;
  --warning-border: #fde68a;
  --warning-accent: #f59e0b;

  --danger-bg: #fef2f2;
  --danger-text: #991b1b;
  --danger-border: #fecaca;
  --danger-accent: #ef4444;

  --info-bg: #f0f9ff;
  --info-text: #075985;
  --info-border: #bae6fd;
  --info-accent: #0284c7;

  --border-color: #e2e8f0;
  --border-focus: #4f46e5;
  --ring-focus: rgba(79, 70, 229, 0.25);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --max-width: 1200px;
  --header-height: 64px;
}

@media (min-width: 768px) {
  :root {
    --header-height: 72px;
  }
}

[data-theme="dark"] {
  --bg-primary: #0b0f17;
  --bg-surface: #131b2e;
  --bg-surface-elevated: #1a243b;
  --bg-subtle: #1e293b;
  --bg-muted: #334155;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-inverse: #0b0f17;

  --accent-primary: #6366f1;
  --accent-hover: #818cf8;
  --accent-light: #1e1b4b;
  --accent-border: #3730a3;

  --success-bg: #064e3b;
  --success-text: #6ee7b7;
  --success-border: #047857;
  --success-accent: #34d399;

  --warning-bg: #78350f;
  --warning-text: #fde68a;
  --warning-border: #b45309;
  --warning-accent: #fbbf24;

  --danger-bg: #7f1d1d;
  --danger-text: #fca5a5;
  --danger-border: #b91c1c;
  --danger-accent: #f87171;

  --info-bg: #0c4a6e;
  --info-text: #7dd3fc;
  --info-border: #0369a1;
  --info-accent: #38bdf8;

  --border-color: #243048;
  --border-focus: #818cf8;
  --ring-focus: rgba(99, 102, 241, 0.35);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.55);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  position: relative;
}

body.drawer-open {
  overflow: hidden;
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

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

button, input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

/* Range input mobile optimization */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: var(--bg-muted);
  border-radius: var(--radius-full);
  outline: none;
  transition: background var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 3px solid var(--bg-surface);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: transform var(--transition-fast);
}

input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.15);
}

input[type="range"]::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 3px solid var(--bg-surface);
  box-shadow: var(--shadow-md);
  cursor: pointer;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(1.65rem, 5.5vw, 2.75rem); margin-bottom: 0.85rem; }
h2 { font-size: clamp(1.3rem, 4vw, 2rem); margin-top: 1.75rem; margin-bottom: 0.75rem; }
h3 { font-size: clamp(1.1rem, 3vw, 1.45rem); margin-top: 1.25rem; margin-bottom: 0.5rem; }
h4 { font-size: 1.05rem; margin-bottom: 0.5rem; }

p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

ul, ol {
  margin-bottom: 1.25rem;
  padding-left: 1.25rem;
  color: var(--text-secondary);
}

li {
  margin-bottom: 0.35rem;
}

code, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

code {
  background: var(--bg-subtle);
  padding: 0.2em 0.4em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

/* ==========================================================================
   Layout Containers & Utilities
   ========================================================================== */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

@media (min-width: 640px) {
  .container {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

.container-narrow {
  width: 100%;
  max-width: 860px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

@media (min-width: 640px) {
  .container-narrow {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

.main-content {
  flex: 1 0 auto;
  padding-top: 1.25rem;
  padding-bottom: 3.5rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

.grid { display: grid; }
.grid-2 { grid-template-columns: 1fr; gap: 1rem; }
.grid-3 { grid-template-columns: 1fr; gap: 1rem; }
.grid-4 { grid-template-columns: 1fr; gap: 1rem; }

@media (min-width: 640px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
}

@media (min-width: 960px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
  .grid-4 { grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }
}

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }

/* Responsive Table Wrappers */
.table-responsive, .sr-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

/* ==========================================================================
   Header & Navigation (Mobile Friendly)
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  height: var(--header-height);
  display: flex;
  align-items: center;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 0.5rem;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: clamp(1rem, 3.8vw, 1.2rem);
  font-weight: 800;
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: -0.03em;
  flex-shrink: 0;
  min-height: 44px;
}

.brand-logo:hover {
  text-decoration: none;
  color: var(--text-primary);
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--accent-primary), #818cf8);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 3px 8px rgba(79, 70, 229, 0.3);
  flex-shrink: 0;
}

@media (min-width: 640px) {
  .brand-icon {
    width: 38px;
    height: 38px;
  }
}

.brand-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

@media (min-width: 640px) {
  .brand-icon svg {
    width: 20px;
    height: 20px;
  }
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

@media (min-width: 960px) {
  .header-right {
    gap: 1.5rem;
  }
}

.nav-desktop {
  display: none;
  align-items: center;
  gap: 1.15rem;
}

@media (min-width: 960px) {
  .nav-desktop {
    display: flex;
  }
}

.nav-link {
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
  padding: 0.45rem 0.2rem;
  position: relative;
  transition: color var(--transition-fast);
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text-primary);
  text-decoration: none;
}

.nav-link.active {
  color: var(--accent-primary);
  font-weight: 600;
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--accent-primary);
  border-radius: var(--radius-full);
}

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

.nav-cta-btn {
  display: none;
  font-size: 0.88rem;
  padding: 0.5rem 1rem;
}

@media (min-width: 640px) {
  .nav-cta-btn {
    display: inline-flex;
  }
}

/* Theme Toggle Button */
.btn-icon {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  touch-action: manipulation;
}

.btn-icon:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

/* Mobile Hamburger Toggle */
.mobile-menu-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  padding: 0;
  touch-action: manipulation;
}

@media (min-width: 960px) {
  .mobile-menu-btn {
    display: none;
  }
}

.hamburger-line {
  width: 18px;
  height: 2px;
  background-color: var(--text-primary);
  margin: 2.5px 0;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
  border-radius: 2px;
}

.mobile-menu-btn[aria-expanded="true"] .hamburger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.mobile-menu-btn[aria-expanded="true"] .hamburger-line:nth-child(2) {
  opacity: 0;
}
.mobile-menu-btn[aria-expanded="true"] .hamburger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Mobile Menu Drawer */
.mobile-drawer {
  display: none;
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-surface);
  z-index: 99;
  padding: 1.25rem 1.5rem 2rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-xl);
}

.mobile-drawer.is-open {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  animation: drawerSlideDown 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.mobile-nav-link {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  padding: 0.85rem 0;
  min-height: 48px;
  border-bottom: 1px solid var(--border-color);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: color var(--transition-fast);
}

.mobile-nav-link:hover {
  text-decoration: none;
  color: var(--accent-primary);
}

.mobile-nav-link.active {
  color: var(--accent-primary);
  font-weight: 700;
}

/* ==========================================================================
   Buttons & Interactive Elements (Touch-Friendly)
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
  min-height: 44px;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background-color: var(--accent-primary);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background-color: var(--accent-hover);
  color: #ffffff;
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-color);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
  background-color: var(--bg-subtle);
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.btn-outline {
  background: transparent;
  color: var(--accent-primary);
  border-color: var(--accent-border);
}
.btn-outline:hover {
  background-color: var(--accent-light);
  color: var(--accent-hover);
}

.btn-danger-outline {
  background: transparent;
  color: var(--danger-accent);
  border-color: var(--danger-border);
}
.btn-danger-outline:hover {
  background-color: var(--danger-bg);
}

.btn-sm {
  font-size: 0.85rem;
  min-height: 38px;
  padding: 0.4rem 0.85rem;
}

.btn-lg {
  font-size: 1.05rem;
  min-height: 48px;
  padding: 0.8rem 1.6rem;
  border-radius: var(--radius-lg);
}

.btn-block {
  width: 100%;
  display: flex;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ==========================================================================
   Badges, Pills & Status Indicators
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.775rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge-accent { background: var(--accent-light); color: var(--accent-primary); border: 1px solid var(--accent-border); }
.badge-success { background: var(--success-bg); color: var(--success-text); border: 1px solid var(--success-border); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); border: 1px solid var(--warning-border); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); border: 1px solid var(--danger-border); }
.badge-info { background: var(--info-bg); color: var(--info-text); border: 1px solid var(--info-border); }

/* ==========================================================================
   Cards & Content Containers
   ========================================================================== */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
}

@media (min-width: 640px) {
  .card {
    padding: 1.5rem;
  }
}

.card:hover {
  border-color: var(--border-focus);
}

.card-interactive:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

/* Hero Section */
.hero-section {
  padding: 1.75rem 0 1.5rem;
  text-align: center;
}

@media (min-width: 768px) {
  .hero-section {
    padding: 2.5rem 0 2rem;
  }
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--accent-light);
  color: var(--accent-primary);
  border: 1px solid var(--accent-border);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.85rem;
}

.hero-subtitle {
  font-size: clamp(0.95rem, 2.5vw, 1.2rem);
  color: var(--text-secondary);
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 1.5rem;
}

/* Homepage Hero Showcase */
.homepage-hero {
  padding: 2rem 0 2.5rem;
  text-align: center;
}

@media (min-width: 768px) {
  .homepage-hero {
    padding: 3rem 0 3.5rem;
  }
}

.hero-cta-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.5rem;
  margin-bottom: 2rem;
}

@media (min-width: 520px) {
  .hero-cta-group {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1rem;
  }
}

.hero-stats-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-top: 1.5rem;
}

@media (min-width: 768px) {
  .hero-stats-row {
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-top: 2rem;
  }
}

.hero-stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem 0.75rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.hero-stat-number {
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  font-weight: 800;
  color: var(--accent-primary);
  line-height: 1.2;
}

.hero-stat-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  margin-bottom: 0;
}

.hero-preview-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-xl);
  text-align: left;
  position: relative;
  overflow: hidden;
  margin-top: 1.75rem;
}

@media (min-width: 768px) {
  .hero-preview-box {
    border-radius: var(--radius-xl);
    padding: 1.75rem;
  }
}

.step-number-badge {
  width: 34px;
  height: 34px;
  background: var(--accent-light);
  color: var(--accent-primary);
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.85rem;
  border: 1px solid var(--accent-border);
}

.testimonial-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.testimonial-author {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.author-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: var(--accent-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

/* ==========================================================================
   Tool Form Inputs & Subject Manager (Mobile-Optimized)
   ========================================================================== */
.tool-app-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.25rem 1rem;
  margin-bottom: 2.5rem;
}

@media (min-width: 640px) {
  .tool-app-card {
    border-radius: var(--radius-xl);
    padding: 1.75rem;
  }
}

@media (min-width: 768px) {
  .tool-app-card {
    padding: 2.25rem;
  }
}

.form-section-title {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  color: var(--text-primary);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .form-grid-2 {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
  }
  .form-grid-3 {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

.form-control {
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 0.85rem;
  font-size: 16px; /* Prevents iOS auto-zoom */
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--ring-focus);
}

select.form-control {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 16px;
  padding-right: 2.25rem;
  appearance: none;
  -webkit-appearance: none;
}

/* Subject Item Rows (Responsive Card Layout) */
.subject-list-container, .subject-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 0.75rem;
  margin-bottom: 1.5rem;
}

.subject-item-row {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  align-items: center;
  position: relative;
}

@media (min-width: 768px) {
  .subject-item-row {
    grid-template-columns: 2fr 1.2fr 1.1fr 1.2fr auto;
    padding: 0.85rem 1rem;
    gap: 0.75rem;
  }
}

.confidence-range-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  background: var(--bg-surface);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.confidence-value {
  font-weight: 700;
  font-size: 0.85rem;
  min-width: 32px;
  text-align: center;
  color: var(--accent-primary);
}

.remove-subj-btn {
  width: 100%;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

@media (min-width: 768px) {
  .remove-subj-btn {
    width: 40px;
    height: 40px;
    min-height: 40px;
  }
}

/* ==========================================================================
   Output Views: Timetable Grid & Lists (Mobile-Friendly)
   ========================================================================== */
.results-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

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

.results-stats-bar {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  background: var(--bg-subtle);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-color);
}

@media (min-width: 640px) {
  .results-stats-bar {
    grid-template-columns: repeat(4, 1fr);
    padding: 1rem 1.25rem;
    gap: 1rem;
  }
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.stat-value {
  font-size: clamp(1.15rem, 3.5vw, 1.4rem);
  font-weight: 800;
  color: var(--accent-primary);
}

/* Tab Switcher */
.tab-group {
  display: flex;
  width: 100%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 640px) {
  .tab-group {
    display: inline-flex;
    width: auto;
  }
}

.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.825rem;
  min-height: 40px;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-align: center;
  touch-action: manipulation;
}

.tab-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}

/* Weekly Grid View */
.timetable-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

@media (min-width: 640px) {
  .timetable-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.15rem;
  }
}

@media (min-width: 1024px) {
  .timetable-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
  }
}

.day-column {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.day-column-header {
  background: var(--bg-surface);
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.day-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-primary);
}

.day-hours-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.day-blocks-list {
  padding: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.study-block-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-primary);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.study-block-card.is-break {
  border-left-color: var(--warning-accent);
  background-color: var(--warning-bg);
  opacity: 0.9;
}

.study-block-card.is-review {
  border-left-color: var(--success-accent);
}

.study-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.block-subject {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-primary);
  word-break: break-word;
}

.block-time {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.block-technique {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Daily Checklist View */
.checklist-container {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 2rem;
}

.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  min-height: 48px;
  transition: all var(--transition-fast);
  touch-action: manipulation;
}

.checklist-item:hover {
  border-color: var(--border-focus);
}

.checklist-item.is-completed {
  background: var(--bg-subtle);
  opacity: 0.75;
}

.checklist-item.is-completed .task-label {
  text-decoration: line-through;
  color: var(--text-muted);
}

.custom-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  display: grid;
  place-content: center;
  margin-top: 2px;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.custom-checkbox:checked {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.custom-checkbox:checked::before {
  content: "";
  width: 6px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

.task-info {
  flex: 1;
}

.task-label {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-primary);
  display: block;
  cursor: pointer;
}

.task-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin-top: 0.25rem;
}

/* Spaced Repetition Table */
.sr-table {
  width: 100%;
  min-width: 500px;
  border-collapse: collapse;
  text-align: left;
  background: var(--bg-surface);
  font-size: 0.88rem;
}

.sr-table th {
  background: var(--bg-subtle);
  padding: 0.75rem 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.sr-table td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.sr-table tr:last-child td {
  border-bottom: none;
}

/* Action Export Bar */
.results-actions-bar {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-color);
  width: 100%;
}

@media (min-width: 540px) {
  .results-actions-bar {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .results-actions-bar .btn {
    width: auto;
  }
}

/* ==========================================================================
   Pomodoro Timer Component (Mobile-Optimized)
   ========================================================================== */
.pomodoro-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 1.75rem 1rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 540px;
  margin: 0 auto 2rem;
}

@media (min-width: 640px) {
  .pomodoro-box {
    padding: 2.5rem 1.5rem;
  }
}

.timer-display {
  font-size: clamp(3rem, 15vw, 5rem);
  font-weight: 800;
  font-family: var(--font-mono);
  letter-spacing: -0.04em;
  color: var(--accent-primary);
  margin: 1rem 0;
  line-height: 1;
}

.timer-mode-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
  background: var(--bg-subtle);
  padding: 0.35rem;
  border-radius: var(--radius-full);
  margin-bottom: 0.75rem;
  width: 100%;
}

.timer-mode-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.825rem;
  font-weight: 600;
  min-height: 38px;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  touch-action: manipulation;
  flex: 1 1 auto;
}

.timer-mode-btn.active {
  background: var(--accent-primary);
  color: #ffffff;
}

.pomodoro-btn-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

@media (min-width: 480px) {
  .pomodoro-btn-group {
    flex-direction: row;
    justify-content: center;
  }
  .pomodoro-btn-group .btn {
    width: auto;
  }
}

/* ==========================================================================
   Countdown Component (Mobile-Optimized)
   ========================================================================== */
.countdown-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  max-width: 480px;
  margin: 1.25rem auto;
}

@media (min-width: 480px) {
  .countdown-grid {
    gap: 0.75rem;
    margin: 1.5rem auto;
  }
}

.countdown-unit {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.25rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

@media (min-width: 480px) {
  .countdown-unit {
    padding: 0.85rem 0.5rem;
  }
}

.countdown-num {
  font-size: clamp(1.25rem, 5.5vw, 1.8rem);
  font-weight: 800;
  color: var(--accent-primary);
  font-family: var(--font-mono);
  display: block;
  line-height: 1.1;
}

.countdown-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

@media (min-width: 480px) {
  .countdown-label {
    font-size: 0.75rem;
  }
}

/* ==========================================================================
   Editorial Content & SEO Guide Styles
   ========================================================================== */
.guide-article {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1rem;
  margin-top: 2.5rem;
  box-shadow: var(--shadow-sm);
}

@media (min-width: 768px) {
  .guide-article {
    border-radius: var(--radius-xl);
    padding: 3rem 2.5rem;
    margin-top: 3rem;
  }
}

.guide-article h2 {
  border-top: 1px solid var(--border-color);
  padding-top: 1.75rem;
  margin-top: 2rem;
}

.guide-article h2:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.callout-box {
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
  border-left: 4px solid var(--accent-primary);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  margin: 1.25rem 0;
}

.callout-box p:last-child {
  margin-bottom: 0;
}

.author-bio-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-top: 2.5rem;
}

@media (min-width: 640px) {
  .author-bio-card {
    flex-direction: row;
    align-items: center;
    padding: 1.5rem;
    gap: 1.25rem;
  }
}

.author-bio-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), #ec4899);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 1.4rem;
  flex-shrink: 0;
}

/* ==========================================================================
   Accordion / FAQs (Touch-Friendly)
   ========================================================================== */
.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.faq-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

.faq-item:hover {
  border-color: var(--border-focus);
}

.faq-trigger {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  min-height: 48px;
  padding: 0.95rem 1.1rem;
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: pointer;
  touch-action: manipulation;
}

.faq-icon {
  width: 18px;
  height: 18px;
  transition: transform var(--transition-fast);
  flex-shrink: 0;
  color: var(--accent-primary);
}

.faq-item.is-open .faq-icon {
  transform: rotate(180deg);
}

.faq-content {
  display: none;
  padding: 0 1.1rem 1.1rem 1.1rem;
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.faq-item.is-open .faq-content {
  display: block;
}

/* ==========================================================================
   Footer (Mobile Stack)
   ========================================================================== */
.site-footer {
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 2.5rem 0 2rem;
  margin-top: auto;
  font-size: 0.88rem;
}

@media (min-width: 640px) {
  .site-footer {
    padding: 3.5rem 0 2rem;
  }
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

@media (min-width: 640px) {
  .footer-grid {
    grid-template-columns: 1.5fr repeat(3, 1fr);
  }
}

.footer-col h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  display: inline-block;
  min-height: 24px;
  transition: color var(--transition-fast);
}

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

.footer-bottom {
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  color: var(--text-muted);
  font-size: 0.825rem;
  text-align: center;
}

@media (min-width: 640px) {
  .footer-bottom {
    flex-direction: row;
    text-align: left;
  }
}

/* ==========================================================================
   Toast Notifications (Mobile Screen Safe)
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

@media (min-width: 640px) {
  .toast-container {
    left: auto;
    right: 1.5rem;
    bottom: 1.5rem;
    max-width: 380px;
  }
}

.toast {
  background: var(--text-primary);
  color: var(--bg-surface);
  padding: 0.75rem 1.15rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  pointer-events: auto;
  animation: slideInUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* ==========================================================================
   Print Styles (PDF Export Optimization)
   ========================================================================== */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 11pt;
  }
  .site-header, .site-footer, .btn, .tab-group, .hero-section, .guide-article, .mobile-drawer, .toast-container, .tool-inputs-area {
    display: none !important;
  }
  .tool-app-card, .card, .timetable-grid, .checklist-container {
    box-shadow: none !important;
    border: 1px solid #cccccc !important;
    page-break-inside: avoid;
  }
  .main-content {
    padding: 0 !important;
  }
  .timetable-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  a {
    color: #000000 !important;
    text-decoration: none !important;
  }
}
