:root {
  /* Color Palette */
  --bg-body: #F8FAFC;
  --bg-surface: #FFFFFF;
  --text-main: #0F172A;
  --text-muted: #64748B;
  --primary-blue: #2563EB;
  --primary-hover: #1D4ED8;
  --border-light: #E2E8F0;
  --card-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
  --card-shadow-hover: 0 10px 25px -3px rgba(37, 99, 235, 0.12), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --drawer-overlay: rgba(15, 23, 42, 0.45);

  /* Device Safe Area Insets */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  /* Container Max Width */
  --content-max-width: 960px;
}

/* Base Reset & Box-Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  min-height: 100%;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

/* Focus Visible for Keyboard Accessibility */
:focus-visible {
  outline: 2px solid var(--primary-blue);
  outline-offset: 3px;
}

/* ===================================================
   Header & Navigation
   =================================================== */
header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  background-color: rgba(255, 255, 255, 0.95);
  padding-top: var(--safe-top);
}

.nav-container {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 12px 20px;
  padding-left: max(20px, var(--safe-left));
  padding-right: max(20px, var(--safe-right));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.brand-link {
  text-decoration: none;
  color: inherit;
  display: inline-flex;
  flex-direction: column;
}

.brand-title {
  font-size: clamp(18px, 4.5vw, 22px);
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.15;
  color: var(--text-main);
}

.brand-title span {
  color: var(--primary-blue);
}

.brand-subtag {
  font-size: clamp(10px, 2.8vw, 11px);
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.2px;
  margin-top: 2px;
}

/* Touch-Friendly Hamburger Button */
.menu-btn {
  background: transparent;
  border: 1px solid var(--border-light);
  min-width: 44px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  touch-action: manipulation;
}

.menu-btn:hover {
  background: #F1F5F9;
  border-color: #CBD5E1;
}

.menu-btn:active {
  background: #E2E8F0;
  transform: scale(0.96);
}

.menu-btn .bar {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-main);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Touch-Friendly Home / Back Navigation Button */
.back-nav,
.home-link {
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-blue);
  background: #EFF6FF;
  padding: 8px 14px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid rgba(37, 99, 235, 0.15);
  transition: all 0.15s ease;
  touch-action: manipulation;
  cursor: pointer;
}

.back-nav:hover,
.home-link:hover {
  background: #DBEAFE;
  border-color: rgba(37, 99, 235, 0.3);
}

.back-nav:active,
.home-link:active {
  transform: scale(0.96);
  background: #BFDBFE;
}

/* ===================================================
   Drawer & Backdrop (Off-Canvas Navigation)
   =================================================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--drawer-overlay);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.25s;
  z-index: 200;
  backdrop-filter: blur(2px);
}

.drawer-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(320px, 86vw);
  height: 100%;
  background: var(--bg-surface);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
  z-index: 201;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  overflow-y: auto;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.close-btn {
  background: none;
  border: none;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 8px;
  transition: color 0.15s, background-color 0.15s;
}

.close-btn:hover {
  color: var(--text-main);
  background: #F1F5F9;
}

.close-btn:active {
  transform: scale(0.92);
}

/* ===================================================
   Drawer Top Auth Section (Login / Profile)
   =================================================== */
.drawer-auth-panel {
  padding: 12px 16px;
  background: #F8FAFC;
  border-bottom: 1px solid var(--border-light);
}

.drawer-login-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--primary-blue);
  color: #FFFFFF;
  border: none;
  border-radius: 14px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  touch-action: manipulation;
  text-align: left;
  transition: background-color 0.15s ease, transform 0.1s ease;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.drawer-login-btn:hover {
  background: var(--primary-hover);
}

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

.drawer-login-icon {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.drawer-login-content {
  flex: 1;
  min-width: 0;
}

.drawer-login-title {
  font-size: 13.5px;
  font-weight: 800;
  line-height: 1.2;
}

.drawer-login-sub {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.9;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-login-arrow {
  font-size: 15px;
  font-weight: 800;
  opacity: 0.85;
  margin-left: 2px;
}

/* User Card when Logged In */
.drawer-user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 10px 12px;
}

.drawer-user-avatar {
  width: 34px;
  height: 34px;
  background: #EFF6FF;
  color: var(--primary-blue);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

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

.drawer-user-name {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-user-id {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 2px;
}

.drawer-user-id .badge-active {
  color: #10B981;
  font-weight: 700;
}

.drawer-logout-btn {
  background: #FEE2E2;
  color: #EF4444;
  border: 1px solid #FECACA;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.drawer-logout-btn:hover {
  background: #FCA5A5;
  color: #DC2626;
}

.drawer-logout-btn:active {
  transform: scale(0.96);
}

.drawer-links {
  list-style: none;
  padding: 12px 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.drawer-links a {
  min-height: 48px;
  padding: 12px 24px;
  color: var(--text-main);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: background-color 0.15s ease, color 0.15s ease;
  touch-action: manipulation;
}

.drawer-links a .link-icon {
  font-size: 18px;
}

.drawer-links a:hover,
.drawer-links a:focus {
  background: #EFF6FF;
  color: var(--primary-blue);
}

.drawer-links a:active {
  background: #DBEAFE;
}

.drawer-footer {
  padding: 18px 24px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-light);
}

/* ===================================================
   Hero Section & Quotation Banner
   =================================================== */
.hero {
  max-width: var(--content-max-width);
  margin: 18px auto 8px;
  padding: 0 20px;
  padding-left: max(20px, var(--safe-left));
  padding-right: max(20px, var(--safe-right));
  width: 100%;
}

.quote-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: clamp(16px, 3.5vw, 22px);
  box-shadow: var(--card-shadow);
  position: relative;
  overflow: hidden;
}

.quote-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: var(--primary-blue);
  border-radius: 4px 0 0 4px;
}

.quote-text {
  font-size: clamp(13px, 2.8vw, 15px);
  font-style: italic;
  color: var(--text-main);
  line-height: 1.55;
  min-height: 44px;
  transition: opacity 0.25s ease;
  display: flex;
  align-items: center;
}

.quote-author {
  margin-top: 10px;
  font-size: clamp(11px, 2.5vw, 13px);
  font-weight: 700;
  color: var(--text-muted);
  text-align: right;
  letter-spacing: 0.2px;
}

/* ===================================================
   Main Content & Adaptive Grid Layout
   =================================================== */
main {
  flex: 1;
  max-width: var(--content-max-width);
  margin: 8px auto 32px;
  padding: 0 20px;
  padding-left: max(20px, var(--safe-left));
  padding-right: max(20px, var(--safe-right));
  width: 100%;
}

.section-header {
  margin: 16px 0 14px 2px;
}

.section-title {
  font-size: clamp(12px, 2.8vw, 14px);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 700;
}

.section-subtitle {
  font-size: clamp(12px, 2.5vw, 13px);
  color: var(--text-muted);
  margin-top: 2px;
  opacity: 0.85;
}

/* Fully Responsive Action Grid */
.action-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

/* Tablet screens (>= 560px) */
@media (min-width: 560px) {
  .action-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
}

/* Desktop & Large screens (>= 860px) */
@media (min-width: 860px) {
  .action-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
}

/* Feature Cards */
.feature-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: clamp(14px, 3vw, 18px);
  min-height: 74px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--card-shadow);
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), 
              box-shadow 0.18s ease, 
              border-color 0.18s ease;
  touch-action: manipulation;
}

/* Touch active feedback (for phones & tablets) */
.feature-card:active {
  transform: scale(0.98);
}

/* Mouse hover effects (only applies on devices supporting hover, avoiding sticky touch effects) */
@media (hover: hover) and (pointer: fine) {
  .feature-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-shadow-hover);
    border-color: #BFDBFE;
  }

  .feature-card:hover .card-arrow {
    transform: translateX(3px);
    color: var(--primary-blue);
  }
}

.card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #EFF6FF;
  color: var(--primary-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.card-info {
  flex: 1;
  min-width: 0; /* Prevents text overflow */
  display: flex;
  flex-direction: column;
}

.card-title {
  font-size: clamp(15px, 3.2vw, 16px);
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-desc {
  font-size: clamp(11.5px, 2.6vw, 12.5px);
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.35;
  white-space: normal;
}

.card-arrow {
  font-size: 16px;
  color: #CBD5E1;
  margin-left: auto;
  flex-shrink: 0;
  transition: transform 0.15s ease, color 0.15s ease;
}

/* Primary Highlighted Card (Mock Test) */
.feature-card.primary-card {
  background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
  color: #FFFFFF;
  border: none;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25);
}

.feature-card.primary-card .card-title {
  color: #FFFFFF;
}

.feature-card.primary-card .card-icon {
  background: rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
}

.feature-card.primary-card .card-desc {
  color: rgba(255, 255, 255, 0.88);
}

.feature-card.primary-card .card-arrow {
  color: rgba(255, 255, 255, 0.7);
}

@media (hover: hover) and (pointer: fine) {
  .feature-card.primary-card:hover {
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.35);
  }

  .feature-card.primary-card:hover .card-arrow {
    color: #FFFFFF;
  }
}

/* Badge for primary card */
.badge {
  background: #DC2626;
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 20px;
  animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.85;
    transform: scale(1.05);
  }
}

/* On medium+ screens, make the primary card span 2 cols or be prominent if desired */
@media (min-width: 560px) and (max-width: 859px) {
  .feature-card.primary-card {
    grid-column: span 2;
  }
}

/* ===================================================
   Footer with Safe Area Inset Support
   =================================================== */
footer {
  margin-top: auto;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-light);
  padding: 20px;
  padding-bottom: max(20px, var(--safe-bottom));
  padding-left: max(20px, var(--safe-left));
  padding-right: max(20px, var(--safe-right));
}

.footer-content {
  max-width: var(--content-max-width);
  margin: 0 auto;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ===================================================
   Native-Like Exit Confirmation Toast
   =================================================== */
.app-toast {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(30px);
  background: rgba(15, 23, 42, 0.92);
  color: #FFFFFF;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(8px);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  white-space: nowrap;
}

.app-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===================================================
   Print Optimization & Reduced Motion
   =================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

