/* ==========================================================================
   TargetSheet Premium iOS-Native Design System (Light & True Black OLED Modes)
   ========================================================================== */

/* Design Tokens & Theme Variables */
:root {
  /* Fonts */
  --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", "Inter", sans-serif;
  
  /* Curated Accent Colors (Default: iOS Blue) */
  --accent-color: #007aff;
  --accent-color-rgb: 0, 122, 255;
  
  /* System Colors - Light Mode (Defaults) */
  --bg-color: #f2f2f7;
  --card-bg: #ffffff;
  --text-main: #000000;
  --text-secondary: #8e8e93;
  --border-color: rgba(60, 60, 67, 0.12);
  --header-bg: rgba(255, 255, 255, 0.72);
  --tab-bar-bg: rgba(255, 255, 255, 0.82);
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.02);
  --shadow-overlay: rgba(0, 0, 0, 0.2);
  
  /* Utility status colors */
  --text-success: #34c759;
  --text-danger: #ff2d55;
  --text-warning: #ff9500;
  --text-purple: #5856d6;
  --text-teal: #30b0c7;
  
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  
  --spring-easing: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ios-transition: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Dark Mode Overrides (Automatic & Forced) */
@media (prefers-color-scheme: dark) {
  body.theme-auto {
    --bg-color: #000000; /* OLED True Black */
    --card-bg: #1c1c1e;
    --text-main: #ffffff;
    --text-secondary: #8e8e93;
    --border-color: #2c2c2e;
    --header-bg: rgba(0, 0, 0, 0.72);
    --tab-bar-bg: rgba(28, 28, 30, 0.8);
    --shadow-card: none; /* iOS elevation: border instead of shadow in dark mode */
  }
}

body.theme-dark {
  --bg-color: #000000; /* OLED True Black */
  --card-bg: #1c1c1e;
  --text-main: #ffffff;
  --text-secondary: #8e8e93;
  --border-color: #2c2c2e;
  --header-bg: rgba(0, 0, 0, 0.72);
  --tab-bar-bg: rgba(28, 28, 30, 0.8);
  --shadow-card: none;
}

body.theme-light {
  --bg-color: #f2f2f7;
  --card-bg: #ffffff;
  --text-main: #000000;
  --text-secondary: #8e8e93;
  --border-color: rgba(60, 60, 67, 0.12);
  --header-bg: rgba(255, 255, 255, 0.72);
  --tab-bar-bg: rgba(255, 255, 255, 0.82);
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.04);
}

/* Base resets & layouts */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent; /* Disable webkit highlight */
}

body {
  font-family: var(--font-stack);
  background-color: var(--bg-color);
  color: var(--text-main);
  overflow-x: hidden;
  position: relative;
  min-height: 100vh;
  transition: background-color var(--ios-transition), color var(--ios-transition);
  display: flex;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Haptic Press scale-down animation */
.haptic-btn {
  transition: transform 0.1s var(--spring-easing), opacity var(--ios-transition);
  cursor: pointer;
}
.haptic-btn:active {
  transform: scale(0.95);
}

/* Icon style */
.icon {
  width: 22px;
  height: 22px;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: inline-block;
  vertical-align: middle;
}

/* Scrollbar styles */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(120, 120, 128, 0.3);
  border-radius: 4px;
}

/* ==========================================================================
   Header and Tab Bar (Mobile / Responsive Navigation)
   ========================================================================== */

/* Mobile Top Header */
.mobile-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(52px + var(--safe-area-top));
  padding-top: var(--safe-area-top);
  background-color: var(--header-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 16px;
  padding-right: 16px;
  z-index: 100;
  transition: background-color var(--ios-transition), border-color var(--ios-transition);
}

.app-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.profile-dropdown {
  background: rgba(120, 120, 128, 0.15);
  border: none;
  border-radius: 8px;
  color: var(--text-main);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  margin-right: 8px;
  outline: none;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--accent-color);
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.icon-btn:active {
  background-color: rgba(120, 120, 128, 0.1);
}

/* Mobile Bottom Tab Bar */
.mobile-tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(56px + var(--safe-area-bottom));
  padding-bottom: var(--safe-area-bottom);
  background-color: var(--tab-bar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  transition: background-color var(--ios-transition), border-color var(--ios-transition);
}

.tab-item {
  background: none;
  border: none;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-grow: 1;
  height: 100%;
  font-size: 10px;
  font-weight: 500;
  gap: 3px;
  transition: color 0.2s ease;
}

.tab-item.active {
  color: var(--accent-color);
}

.tab-item svg {
  width: 24px;
  height: 24px;
  transition: transform 0.1s var(--spring-easing);
}

.tab-item:active svg {
  transform: scale(0.88);
}

/* Desktop Sidebar Hidden on Mobile */
.desktop-sidebar {
  display: none;
}

/* Main View Layout */
.view-container {
  flex-grow: 1;
  width: 100%;
  padding: calc(68px + var(--safe-area-top)) 16px calc(76px + var(--safe-area-bottom)) 16px;
  max-width: 800px;
  margin: 0 auto;
  min-height: 100vh;
}

/* Views Navigation */
.app-view {
  display: none;
  animation: view-fade 0.25s ease-out;
}
.app-view.active {
  display: block;
}

@keyframes view-fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.view-header h2 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.7px;
}

.accent-text-btn {
  background: none;
  border: none;
  color: var(--accent-color);
  font-size: 15px;
  font-weight: 600;
}

.icon-circle-btn {
  background-color: rgba(120, 120, 128, 0.12);
  border: none;
  color: var(--accent-color);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Desktop Styles (Media Query) */
@media (min-width: 768px) {
  body {
    padding-left: 240px;
  }
  .mobile-header, .mobile-tab-bar {
    display: none;
  }
  .desktop-sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    background-color: var(--card-bg);
    border-right: 1px solid var(--border-color);
    padding: 24px 16px;
    z-index: 90;
  }
  .sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding-left: 8px;
  }
  .sidebar-logo-icon {
    width: 32px;
    height: 32px;
    background-color: var(--accent-color);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
  }
  .sidebar-app-name {
    font-weight: 700;
    font-size: 18px;
  }
  .sidebar-profile-box {
    margin-bottom: 20px;
    padding: 0 8px;
  }
  .sidebar-profile-box select {
    width: 100%;
    margin-right: 0;
  }
  .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .nav-item {
    background: none;
    border: none;
    text-align: left;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
  }
  .nav-item:hover {
    background-color: rgba(120, 120, 128, 0.08);
    color: var(--text-main);
  }
  .nav-item.active {
    background-color: rgba(var(--accent-color-rgb), 0.12);
    color: var(--accent-color);
  }
  .nav-item.active svg {
    color: var(--accent-color);
  }
  .view-container {
    padding-top: 32px;
    padding-bottom: 40px;
    max-width: 800px;
  }
}

/* ==========================================================================
   UI Components (Cards, List Views, Forms)
   ========================================================================== */

/* iOS Style Cards */
.card {
  background-color: var(--card-bg);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-color);
  transition: background-color var(--ios-transition), border-color var(--ios-transition);
}

.flex-row-space {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-grow {
  flex-grow: 1;
}

/* Labels and Texts */
.card-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.card-hero-num {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1px;
}

.section-tag {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Segmented Control (Apple style) */
.segmented-control {
  display: flex;
  background-color: rgba(120, 120, 128, 0.16);
  border-radius: 8px;
  padding: 2px;
  position: relative;
  margin-bottom: 16px;
  z-index: 1;
}

.segmented-control-bg {
  position: absolute;
  top: 2px;
  bottom: 2px;
  background-color: var(--card-bg);
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.08);
  transition: transform 0.25s cubic-bezier(0.25, 0.8, 0.25, 1), width 0.25s;
  z-index: -1;
}

.segmented-option {
  flex: 1;
  background: none;
  border: none;
  padding: 6px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  text-align: center;
  border-radius: 6px;
  outline: none;
  cursor: pointer;
  transition: color 0.2s ease;
}
.segmented-option.active {
  color: var(--text-main);
}

/* iOS Toggle Switches */
.ios-switch {
  position: relative;
  display: inline-block;
  width: 51px;
  height: 31px;
}
.ios-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(120, 120, 128, 0.2);
  border-radius: 31px;
  transition: 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  cursor: pointer;
}
.switch-slider::before {
  content: "";
  position: absolute;
  height: 27px;
  width: 27px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  border-radius: 50%;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.04);
  transition: transform 0.2s var(--spring-easing);
}
.ios-switch input:checked + .switch-slider {
  background-color: var(--accent-color);
}
.ios-switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}

/* Inputs and Forms */
.ios-input {
  background-color: rgba(120, 120, 128, 0.12);
  border: none;
  border-radius: 10px;
  color: var(--text-main);
  font-family: var(--font-stack);
  padding: 10px 14px;
  font-size: 15px;
  width: 100%;
  outline: none;
  transition: background-color var(--ios-transition);
}
.ios-input:focus {
  background-color: rgba(120, 120, 128, 0.18);
}

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

.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.small-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
}

.action-btn {
  background-color: var(--accent-color);
  color: white;
  border: none;
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 10px;
  width: 100%;
  display: block;
  text-align: center;
}
.sub-btn {
  background-color: rgba(120, 120, 128, 0.15);
  color: var(--text-main);
  border: none;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
}

/* Pill Search bar */
.search-field-pill {
  position: relative;
  width: 100%;
}
.search-field-pill input {
  width: 100%;
  border-radius: 10px;
  background-color: rgba(120, 120, 128, 0.12);
  padding: 10px 12px 10px 38px;
  border: none;
  color: var(--text-main);
  font-size: 14px;
  font-family: var(--font-stack);
  outline: none;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
  width: 18px;
  height: 18px;
}

/* PWA Install Instructions Alert */
#ios-install-instructions strong {
  font-weight: 700;
}

/* Accent Preset Selector style */
.color-presets-row {
  display: flex;
  gap: 8px;
}
.color-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s var(--spring-easing);
}
.color-dot.active {
  border-color: var(--text-main);
  transform: scale(1.1);
}

/* ==========================================================================
   Home Widgets Screen (Customizable)
   ========================================================================== */
.widgets-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Countdown Widget */
.countdown-widget-card {
  background: linear-gradient(135deg, rgba(var(--accent-color-rgb), 0.9) 0%, rgba(var(--accent-color-rgb), 0.7) 100%);
  color: white;
  border: none;
}
.countdown-widget-card .card-label {
  color: rgba(255, 255, 255, 0.75);
}
.countdown-layout {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 4px;
}
.countdown-days {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -2px;
  line-height: 1;
}
.countdown-label {
  font-size: 16px;
  font-weight: 600;
  opacity: 0.95;
}

.countdown-secondary-scroller {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-top: 14px;
  padding-bottom: 2px;
}
.countdown-secondary-scroller::-webkit-scrollbar {
  display: none; /* Hide scrollbar for clean chip feel */
}
.chip-countdown {
  background: rgba(255, 255, 255, 0.18);
  padding: 6px 12px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* Thick stroked progress rings (Apple-Health style) */
.ring-container {
  position: relative;
  width: 70px;
  height: 70px;
  flex-shrink: 0;
}
.progress-ring-svg {
  transform: rotate(-90deg);
}
.ring-bg {
  fill: none;
  stroke: rgba(120, 120, 128, 0.16);
  stroke-width: 6.5px;
}
.ring-indicator {
  fill: none;
  stroke: var(--accent-color);
  stroke-width: 6.5px;
  stroke-linecap: round;
  stroke-dasharray: 176; /* 2 * PI * r (r=28) */
  stroke-dashoffset: 176;
  transition: stroke-dashoffset 0.6s var(--spring-easing);
  filter: drop-shadow(0px 0px 3px rgba(var(--accent-color-rgb), 0.3));
}
.ring-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.task-progress-card {
  display: flex;
  align-items: center;
  gap: 16px;
}
.progress-detail {
  flex-grow: 1;
}

.pill {
  display: inline-block;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 12px;
}
.accent-pill {
  background-color: rgba(var(--accent-color-rgb), 0.12);
  color: var(--accent-color);
}
.danger-pill {
  background-color: rgba(255, 45, 85, 0.12);
  color: var(--text-danger);
}
.success-pill {
  background-color: rgba(52, 199, 89, 0.12);
  color: var(--text-success);
}
.warning-pill {
  background-color: rgba(255, 149, 0, 0.12);
  color: var(--text-warning);
}
.secondary-pill {
  background-color: rgba(120, 120, 128, 0.15);
  color: var(--text-secondary);
}

/* Streak companion growth visuals */
.streak-companion-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.companion-graphic {
  font-size: 40px;
  transition: transform 0.3s var(--spring-easing);
}
.companion-graphic:hover {
  transform: rotate(10deg) scale(1.1);
}

/* ==========================================================================
   Tasks Screen (checklists, Snooze, Week strip)
   ========================================================================== */

/* Week strip scroll navigator */
.week-strip-wrapper {
  overflow-x: auto;
  margin-bottom: 14px;
  padding-bottom: 4px;
}
.week-strip-wrapper::-webkit-scrollbar {
  display: none;
}
.week-strip {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  min-width: 320px;
}
.week-day-btn {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  flex: 1;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-main);
}
.week-day-name {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.week-day-num {
  font-size: 16px;
  font-weight: 700;
}
.week-day-btn.active {
  background-color: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}
.week-day-btn.active .week-day-name {
  color: rgba(255, 255, 255, 0.8);
}
.week-day-btn.has-tasks::after {
  content: "";
  width: 4px;
  height: 4px;
  background-color: var(--accent-color);
  border-radius: 50%;
}
.week-day-btn.active.has-tasks::after {
  background-color: white;
}

/* checklist layout */
.checklist {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checklist-row {
  background-color: var(--card-bg);
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.checklist-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-grow: 1;
}

.checklist-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.checklist-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  transition: text-decoration 0.2s ease;
}
.checklist-subtext {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.checklist-row.completed .checklist-text {
  text-decoration: line-through;
  color: var(--text-secondary);
}
.checklist-row.completed {
  opacity: 0.7;
}

/* Custom iOS Checklist Checkbox */
.ios-checkbox {
  position: relative;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
}
.ios-checkbox input {
  opacity: 0;
  width: 0;
  height: 0;
}
.checkbox-mark {
  position: absolute;
  top: 0;
  left: 0;
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  transition: background-color 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.checkbox-mark::after {
  content: "";
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.ios-checkbox input:checked + .checkbox-mark {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
}
.ios-checkbox input:checked + .checkbox-mark::after {
  opacity: 1;
}

/* Row action buttons limit (Max 2 action buttons per row) */
.checklist-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.checklist-action-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}
.checklist-action-btn:hover {
  color: var(--text-main);
  background-color: rgba(120, 120, 128, 0.08);
}

.empty-state {
  text-align: center;
  padding: 30px 16px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

.reflection-card textarea {
  width: 100%;
  margin-top: 8px;
  background: rgba(120, 120, 128, 0.06);
  border: none;
  outline: none;
  color: var(--text-main);
  padding: 8px;
  border-radius: 8px;
  font-family: var(--font-stack);
  font-size: 13px;
  resize: vertical;
}

/* Sticky Quick Add bar */
.quick-add-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  position: fixed;
  bottom: calc(56px + var(--safe-area-bottom));
  left: 0;
  right: 0;
  background: var(--header-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 8px 16px;
  border-top: 1px solid var(--border-color);
  z-index: 80;
}
@media (min-width: 768px) {
  .quick-add-bar {
    left: 240px;
    bottom: 0;
  }
}
.speech-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.speech-btn.listening {
  color: var(--text-danger);
  animation: pulse-mic 1s infinite alternate;
}
@keyframes pulse-mic {
  from { opacity: 0.6; transform: translateY(-50%) scale(0.9); }
  to { opacity: 1; transform: translateY(-50%) scale(1.1); }
}

.icon-circle-btn {
  flex-shrink: 0;
}

/* ==========================================================================
   Syllabus / Plan Subviews
   ========================================================================== */
.subview-container {
  display: none;
}
.subview-container.active {
  display: block;
}

.subjects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.subject-badge-card {
  border-radius: 12px;
  padding: 12px;
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 110px;
  border: none;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.subject-badge-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(0,0,0,0.3) 100%);
  pointer-events: none;
}
.subject-meta-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 1;
}
.subject-emoji-tag {
  font-size: 20px;
}
.subject-info-bot {
  z-index: 1;
}
.subject-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.3px;
  line-height: 1.2;
}
.subject-sub {
  font-size: 11px;
  opacity: 0.85;
  font-weight: 500;
  margin-top: 2px;
}

/* Timetable & Routines */
.timetable-card {
  padding: 12px;
  overflow: hidden;
}
.timetable-scroller {
  overflow-x: auto;
  width: 100%;
}
.timetable-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  text-align: center;
  min-width: 500px;
}
.timetable-table th {
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 8px 4px;
  border-bottom: 1px solid var(--border-color);
}
.timetable-table td {
  padding: 6px 4px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 500;
}
.timetable-table th:first-child, .timetable-table td:first-child {
  text-align: left;
  font-weight: 700;
  color: var(--text-secondary);
  border-right: 1px solid var(--border-color);
}
.timetable-block-pill {
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  color: white;
  display: inline-block;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Subject picker color list inside Modal */
.subject-color-picker-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.picker-color-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
}
.picker-color-dot.active {
  border-color: var(--text-main);
  transform: scale(1.1);
}

/* ==========================================================================
   Bottom Sheets & Modals (iOS spring slide-up)
   ========================================================================== */
.bottom-sheet-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--shadow-overlay);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  display: flex;
  align-items: flex-end;
}
.bottom-sheet-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  background-color: var(--card-bg);
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  width: 100%;
  max-height: 80vh;
  padding: 8px 16px 24px 16px;
  transform: translateY(100%);
  transition: transform 0.4s var(--spring-easing);
  display: flex;
  flex-direction: column;
}
.bottom-sheet-overlay.active .bottom-sheet {
  transform: translateY(0);
}

/* Desktop Bottom Sheet fallback to Centered Modal */
@media (min-width: 768px) {
  .bottom-sheet-overlay {
    align-items: center;
    justify-content: center;
  }
  .bottom-sheet {
    max-width: 500px;
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
    transform: scale(0.9);
    padding-bottom: 24px;
  }
  .bottom-sheet-overlay.active .bottom-sheet {
    transform: scale(1);
  }
}

.bottom-sheet-drag-handle {
  width: 36px;
  height: 5px;
  background-color: rgba(120, 120, 128, 0.3);
  border-radius: 2.5px;
  margin: 0 auto 12px auto;
}

.bottom-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.bottom-sheet-header h3 {
  font-size: 18px;
  font-weight: 700;
}
.sheet-close-btn {
  background: rgba(120, 120, 128, 0.15);
  border: none;
  color: var(--text-secondary);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bottom-sheet-content {
  overflow-y: auto;
}

.widget-customizer-list {
  list-style: none;
}
.widget-customizer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
}
.widget-customizer-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.widget-drag-arrows {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.arrow-btn {
  background: none;
  border: none;
  color: var(--accent-color);
  font-size: 10px;
  padding: 2px;
}

/* Action Sheet lists */
.action-sheet-buttons-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.action-sheet-row {
  background: rgba(120, 120, 128, 0.08);
  border: none;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  width: 100%;
}
.action-sheet-row.text-danger {
  color: var(--text-danger);
}

/* Mistakes creator rows */
.mistakes-entry-box {
  background: rgba(120, 120, 128, 0.06);
  padding: 10px;
  border-radius: 8px;
}
.mistake-input-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  align-items: center;
}
.mistake-qnum {
  width: 45px;
  text-align: center;
}
.mistake-subject-select {
  width: 100px;
}
.mistake-reason-select {
  flex-grow: 1;
}

/* ==========================================================================
   Mock Tests screen, Flashcards, and Challenges
   ========================================================================== */

/* Test lists */
.tests-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.test-row-card {
  padding: 12px 14px;
}
.test-row-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.test-row-title {
  font-weight: 700;
  font-size: 15px;
}
.test-row-meta {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 2px;
}
.test-row-score-box {
  text-align: right;
}
.test-score-big {
  font-size: 16px;
  font-weight: 800;
}
.test-percentile {
  font-size: 11px;
  font-weight: 600;
}

/* Spaced Repetition Flashcards */
.flashcards-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.flashcard-row-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
}
.flashcard-row-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.flashcard-row-q {
  font-size: 14px;
  font-weight: 600;
}

/* Flashcard Reviewer Widget (3D Flip Effect) */
.flash-card-widget {
  width: 100%;
  height: 250px;
  perspective: 1000px;
  cursor: pointer;
}
.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.5s cubic-bezier(0.2, 0.85, 0.4, 1.15);
  transform-style: preserve-3d;
}
.flash-card-widget.flipped .card-inner {
  transform: rotateY(180deg);
}
.card-front, .card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-card);
}
.card-front {
  background-color: var(--card-bg);
}
.card-back {
  background-color: var(--card-bg);
  transform: rotateY(180deg);
}
.card-text {
  font-size: 18px;
  font-weight: 700;
  margin: auto 0;
  text-align: center;
  max-width: 90%;
  line-height: 1.4;
}
.card-back-scrollable {
  overflow-y: auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: auto 0;
  max-height: 160px;
}
.card-hint {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
}
.card-subject-tag {
  font-size: 12px;
}

/* Challenges tracker calendar grid */
.challenges-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.challenge-card {
  padding: 16px;
}
.challenge-calendar-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 5px;
  margin-top: 12px;
}
.challenge-day-dot {
  aspect-ratio: 1/1;
  border-radius: 4px;
  background-color: rgba(120, 120, 128, 0.15);
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  border: 1px solid transparent;
}
.challenge-day-dot.done {
  background-color: var(--text-success);
  color: white;
}
.challenge-day-dot.missed {
  background-color: var(--text-danger);
  color: white;
}
.challenge-day-dot.rest {
  background-color: var(--text-warning);
  color: white;
}

/* ==========================================================================
   Analytics screen elements (Canvas lines, pie)
   ========================================================================== */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 8px;
}
.analytics-stat-card {
  padding: 12px;
  margin-bottom: 0;
}
.analytics-stat-card .card-hero-num {
  font-size: 26px;
}

.narrative-content p {
  margin-bottom: 8px;
}

.danger-card {
  border-color: rgba(255, 45, 85, 0.3);
  background-color: rgba(255, 45, 85, 0.04);
}

.blind-spot-list li {
  margin-bottom: 4px;
}

.analytics-canvas {
  width: 100%;
  height: 200px;
  border-radius: 6px;
  background-color: rgba(120, 120, 128, 0.05);
}

/* Comparison bar styling */
.comp-bars-container {
  display: flex;
  flex-direction: column;
}
.comp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.comp-label {
  width: 70px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
}
.comp-bars {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.comp-bar-track {
  height: 8px;
  background-color: rgba(120, 120, 128, 0.12);
  border-radius: 4px;
  width: 100%;
  overflow: hidden;
}
.comp-bar {
  height: 100%;
  border-radius: 4px;
  width: 0%;
  transition: width 0.6s ease;
}
.comp-bar.prev {
  background-color: var(--text-secondary);
}
.comp-bar.curr {
  background-color: var(--accent-color);
}
.comp-vals {
  font-size: 11px;
  font-weight: 700;
  width: 70px;
  text-align: right;
}

/* ==========================================================================
   Calendar Month view
   ========================================================================== */
.calendar-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.nav-arrow-btn {
  background: none;
  border: none;
  color: var(--accent-color);
  font-size: 16px;
  padding: 8px 12px;
}

.calendar-grid-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.calendar-grid-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.calendar-day {
  aspect-ratio: 1/1;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  background-color: rgba(120, 120, 128, 0.05);
}
.calendar-day.empty {
  background: none;
  pointer-events: none;
}
.calendar-day.today {
  border: 2px solid var(--accent-color);
}
.calendar-day.selected {
  background-color: var(--accent-color);
  color: white;
}
.calendar-day.selected .cal-dot {
  background-color: white !important;
}

.cal-dots-container {
  display: flex;
  gap: 2px;
  position: absolute;
  bottom: 3px;
}
.cal-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
}

/* Settings lists */
.settings-group-card {
  padding: 12px 16px;
}
.settings-group-title {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
}
.settings-row:last-child {
  border-bottom: none;
}
.settings-row-label {
  font-size: 14px;
  font-weight: 500;
}

.settings-actions-list {
  display: flex;
  flex-direction: column;
}
.settings-action-row {
  background: none;
  border: none;
  padding: 10px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-main);
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
  font-weight: 500;
  width: 100%;
}
.settings-action-row:last-child {
  border-bottom: none;
}

.profile-settings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.profile-row-item {
  background: rgba(120, 120, 128, 0.08);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.profile-row-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.profile-row-name {
  font-size: 14px;
  font-weight: 600;
}
.profile-row-date {
  font-size: 11px;
  color: var(--text-secondary);
}

.search-results-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.search-result-item {
  padding: 8px 12px;
  background-color: rgba(120, 120, 128, 0.05);
  border-radius: 6px;
  cursor: pointer;
}
.search-result-title {
  font-size: 13px;
  font-weight: 600;
}
.search-result-meta {
  font-size: 10px;
  color: var(--text-secondary);
}

/* ==========================================================================
   Focus Mode / Distraction-free full overlay
   ========================================================================== */
.focus-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #000000;
  z-index: 2000;
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(24px + var(--safe-area-top)) 24px calc(24px + var(--safe-area-bottom)) 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.focus-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.focus-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.focus-subtitle {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  opacity: 0.6;
}
.focus-close-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.focus-center-body {
  text-align: center;
  max-width: 500px;
  margin: 0 auto;
}
.focus-center-body h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 24px;
  line-height: 1.4;
}
.focus-timer-text {
  font-size: 72px;
  font-weight: 800;
  letter-spacing: -2px;
  font-family: monospace;
}
.focus-timer-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 32px;
}
.focus-ctrl-btn {
  background-color: white;
  color: black;
  border: none;
  padding: 10px 24px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
}
.focus-ctrl-btn.secondary-btn {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
}

.focus-break-notice {
  background: var(--text-warning);
  color: black;
  padding: 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.4s var(--spring-easing);
}
.focus-break-notice.active {
  transform: translateY(0);
  opacity: 1;
}

/* ==========================================================================
   Toast Notification Banner system & Confetti Canvas
   ========================================================================== */
.toast-container {
  position: fixed;
  top: calc(16px + var(--safe-area-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 90%;
  max-width: 380px;
  pointer-events: none;
}

.toast {
  background-color: #1c1c1e;
  color: white;
  border: 1px solid rgba(255,255,255,0.1);
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  pointer-events: auto;
  animation: toast-in 0.35s var(--spring-easing);
  transition: opacity 0.3s, transform 0.3s;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-20px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.toast-undo-btn {
  background: var(--accent-color);
  border: none;
  color: white;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}

.confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2500;
  display: none;
}

/* ==========================================================================
   Print Stylesheet
   ========================================================================== */
@media print {
  body {
    background-color: white !important;
    color: black !important;
    font-size: 12pt;
    padding: 0 !important;
  }
  .desktop-sidebar,
  .mobile-header,
  .mobile-tab-bar,
  .quick-add-bar,
  .icon-btn,
  .icon-circle-btn,
  .accent-text-btn,
  .nav-arrow-btn,
  .settings-group-card,
  #ios-install-instructions,
  .sub-btn {
    display: none !important;
  }
  .view-container {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }
  .app-view {
    display: none !important;
  }
  #view-tasks {
    display: block !important;
  }
  .card {
    border: 1px solid #000000 !important;
    box-shadow: none !important;
    background: transparent !important;
    page-break-inside: avoid;
  }
  .checklist-row {
    border: 1px solid #000000 !important;
    opacity: 1 !important;
  }
  .checkbox-mark {
    border-color: black !important;
  }
}

/* ==========================================================================
   Onboarding Welcome Screen
   ========================================================================== */
.onboarding-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-color);
  z-index: 5000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: onboarding-fade 0.35s ease-out;
}
.onboarding-overlay.active {
  display: flex;
}
.onboarding-card {
  width: 100%;
  max-width: 400px;
  padding: 32px 24px;
  text-align: center;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}
@keyframes onboarding-fade {
  from { opacity: 0; transform: scale(1.03); }
  to { opacity: 1; transform: scale(1); }
}

/* ==========================================================================
   Mobile-Only Visibility & Navigation Styles
   ========================================================================== */
.mobile-only {
  display: block;
}
@media (min-width: 768px) {
  .mobile-only {
    display: none !important;
  }
}

.back-to-more-btn {
  background: none;
  border: none;
  color: var(--accent-color);
  font-size: 15px;
  font-weight: 600;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}
/* ==========================================================================
   AI Coach Widget & AI Analyzed Tag Styles
   ========================================================================== */
.ai-analyzed-tag {
  background: linear-gradient(135deg, #af52de, #5856d6);
  color: white !important;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.1);
  padding: 3px 8px;
  font-size: 10px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.ai-move-list {
  list-style: none;
  margin-top: 10px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ai-move-item {
  background: rgba(120, 120, 128, 0.08);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  border-left: 3px solid #5856d6;
}
.ai-voice-btn {
  background: linear-gradient(135deg, var(--accent-color) 0%, rgba(var(--accent-color-rgb), 0.85) 100%);
  color: white;
  border: none;
  font-weight: 600;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-coach-card {
  border: 1px solid rgba(88, 86, 214, 0.3) !important;
}
body.theme-dark .ai-coach-card {
  border: 1px solid rgba(88, 86, 214, 0.4) !important;
}

/* ==========================================================================
   SSC / NTA Ditto Exam Portal Engine & Local Test Series Styles
   ========================================================================== */
.exam-portal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  background-color: #f8fafc;
  color: #0f172a;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.exam-header-bar {
  background-color: #ffffff;
  padding: 8px 16px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 48px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.exam-badge-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background-color: #1e3a8a;
  color: #ffffff;
  border-radius: 4px;
  font-weight: 800;
  font-size: 13px;
}

.exam-header-title {
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.exam-timer-pill {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 600;
  background-color: #ffffff;
  color: #0f172a;
}

.timer-clock-text {
  color: #dc2626;
  font-weight: 800;
}

.exam-icon-btn {
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #1e3a8a;
}

.exam-icon-btn.grid-btn {
  background-color: #1e3a8a;
  color: #ffffff;
  border: none;
}

.exam-action-bar {
  background-color: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  padding: 8px 16px;
  font-size: 13px;
  flex-wrap: wrap;
  gap: 8px;
}

.exam-instructions-link {
  color: #dc2626;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.exam-ans-stats {
  font-size: 12px;
  color: #0f172a;
  margin-top: 2px;
}

.exam-btn {
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}

.btn-secondary-gray {
  background-color: #94a3b8;
  color: #ffffff;
}

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

.btn-navy {
  background-color: #1e3a8a;
  color: #ffffff;
}

.btn-navy:hover {
  background-color: #1e40af;
}

.btn-navy-submit {
  background-color: #1e3a8a;
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(30,58,138,0.25);
}

.exam-section-pills-bar {
  background-color: #f1f5f9;
  padding: 8px 16px;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid #e2e8f0;
  overflow-x: auto;
}

.exam-section-pill {
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  color: #475569;
  cursor: pointer;
  flex-shrink: 0;
}

.exam-section-pill.active {
  background-color: #1e3a8a;
  color: #ffffff;
  border-color: #1e3a8a;
}

.exam-main-body {
  display: flex;
  flex: 1;
  padding: 16px;
  gap: 16px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.exam-q-container {
  flex: 1;
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.exam-q-num {
  font-size: 18px;
  font-weight: 800;
  color: #0f172a;
  margin: 0;
}

.exam-select-input {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  background-color: #ffffff;
  color: #0f172a;
  cursor: pointer;
}

.exam-hr {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 14px 0;
}

.exam-q-stem {
  font-size: 14px;
  line-height: 1.65;
  color: #0f172a;
  font-weight: 600;
  margin-bottom: 18px;
}

.exam-options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.exam-option-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 16px;
  background-color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  transition: all 0.15s ease;
}

.exam-option-card:hover {
  border-color: #94a3b8;
  background-color: #f8fafc;
}

.exam-option-card.selected {
  border-color: #0284c7;
  background-color: rgba(2, 132, 199, 0.04);
  font-weight: 700;
  box-shadow: 0 0 0 1px #0284c7;
}

.exam-radio-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #94a3b8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.exam-option-card.selected .exam-radio-dot {
  border-color: #0284c7;
  background-color: #0284c7;
}

.exam-radio-inner {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #ffffff;
}

.exam-clear-btn {
  color: #dc2626;
  font-weight: 800;
  font-size: 13px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.exam-marks-text {
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
}

.exam-palette-panel {
  width: 280px;
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.exam-palette-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 11px;
  color: #475569;
  padding-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.legend-box {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

.box-not-visited {
  background-color: #f1f5f9;
  border: 1px solid #cbd5e1;
}

.box-not-answered {
  background-color: #ef4444;
}

.box-answered {
  background-color: #22c55e;
}

.box-marked {
  background-color: #8b5cf6;
}

.box-ans-marked {
  background-color: #8b5cf6;
  position: relative;
}

.exam-palette-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 12px;
  max-height: 420px;
  overflow-y: auto;
}

.palette-q-btn {
  height: 36px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.palette-q-btn.not-visited {
  background-color: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.palette-q-btn.not-answered {
  background-color: #ef4444;
  color: #ffffff;
}

.palette-q-btn.answered {
  background-color: #22c55e;
  color: #ffffff;
}

.palette-q-btn.marked {
  background-color: #8b5cf6;
  color: #ffffff;
}

.palette-q-btn.ans-marked {
  background-color: #8b5cf6;
  color: #ffffff;
}

.palette-q-btn.ans-marked::after {
  content: '';
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 6px;
  height: 6px;
  background-color: #22c55e;
  border-radius: 50%;
  border: 1px solid #ffffff;
}

.palette-q-btn.active {
  outline: 2px solid #0284c7;
  outline-offset: 1px;
}

/* Series Folder Cards */
.series-folder-card {
  margin-bottom: 16px;
  border-radius: 12px;
  overflow: hidden;
}

.series-folder-header {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.series-test-item {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.series-test-item:last-child {
  border-bottom: none;
}

@media (min-width: 769px) {
  .exam-palette-panel {
    display: flex !important;
  }
}

@media (max-width: 768px) {
  #view-tests .view-header {
    gap: 8px;
    margin-bottom: 12px;
  }
  #btn-import-json-test-trigger {
    display: none !important;
  }
  #local-series-tools-select {
    width: 100% !important;
    margin-top: 10px;
    height: 42px !important;
    font-size: 13px !important;
  }
  .series-folder-card {
    margin-bottom: 14px;
    border: 1px solid var(--border-color);
  }
  .series-folder-header {
    padding: 14px 16px;
  }
  .series-folder-header h4 {
    font-size: 15px !important;
  }
  .exam-portal-overlay {
    background-color: #ffffff;
  }
  .exam-header-bar {
    padding: 6px 10px;
    min-height: 42px;
  }
  .exam-header-title {
    max-width: 42vw;
    font-size: 12px;
    font-weight: 700;
  }
  .exam-badge-box {
    width: 22px;
    height: 22px;
    font-size: 11px;
  }
  .exam-timer-pill {
    padding: 2px 6px;
    font-size: 11px;
  }
  .exam-icon-btn {
    width: 28px;
    height: 28px;
  }
  .exam-action-bar {
    padding: 6px 10px;
    font-size: 11px;
    gap: 6px;
  }
  .exam-instructions-link {
    font-size: 11px;
  }
  .exam-ans-stats {
    font-size: 11px;
  }
  .exam-btn {
    padding: 5px 10px;
    font-size: 11px;
    border-radius: 4px;
  }
  .exam-main-body {
    flex-direction: column;
    padding: 8px;
    gap: 8px;
  }
  .exam-q-container {
    padding: 12px;
    border-radius: 6px;
    border-color: #e2e8f0;
  }
  .exam-q-num {
    font-size: 15px;
  }
  .exam-select-input {
    font-size: 11px;
    padding: 2px 6px;
  }
  .exam-q-stem {
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 12px;
  }
  .exam-option-card {
    padding: 10px 12px;
    font-size: 12px;
    gap: 10px;
  }
  .exam-palette-panel {
    width: 100%;
    padding: 12px;
  }
}

/* Scorecard Result Modal (Centered Clean Dialog) */
.exam-result-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10005;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.exam-result-card {
  background: #ffffff !important;
  color: #0f172a !important;
  border-radius: 16px;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
  border: 1px solid #e2e8f0;
}

