/* ===== 2% MARATHON — NEUMORPHISM DESIGN SYSTEM ===== */

/* --- Tokens --- */
:root {
  --primary:   #006666;
  --primary-light: #008080;
  --primary-dark:  #004d4d;
  --secondary: #F1F2F5;
  --success:   #00A63D;
  --warning:   #FE9900;
  --danger:    #FF2157;
  --info:      #0099cc;
  --surface:   #E7E5E4;
  --surface-alt:#DDDBD9;
  --text:      #1E2938;
  --text-muted:#6B7280;
  --text-light:#9CA3AF;

  /* Neumorphic shadows (on --surface background) */
  --shadow-out: 6px 6px 14px #c9c7c5, -6px -6px 14px #ffffff;
  --shadow-in:  inset 4px 4px 10px #c9c7c5, inset -4px -4px 10px #ffffff;
  --shadow-sm:  3px 3px 8px #c9c7c5, -3px -3px 8px #ffffff;
  --shadow-card:8px 8px 18px #c0bebb, -8px -8px 18px #ffffff;

  --radius:    14px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --radius-pill:50px;

  --font-main: 'Space Mono', monospace;
  --font-mono: 'JetBrains Mono', monospace;

  --nav-h: 64px;
  --transition: 0.2s ease;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--font-main);
  background: var(--surface);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
button { cursor: pointer; font-family: var(--font-main); border: none; background: none; }
input, textarea, select { font-family: var(--font-main); }
a { text-decoration: none; color: inherit; }

/* --- Utilities --- */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }

/* --- Loading Screen --- */
#loading-screen {
  position: fixed; inset: 0;
  background: var(--surface);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 24px; z-index: 9999;
  transition: opacity 0.4s ease;
}
.loader-logo {
  font-size: 56px; font-weight: 700;
  color: var(--primary);
  text-shadow: 4px 4px 10px #c9c7c5, -2px -2px 8px #ffffff;
  letter-spacing: -2px;
}
.loader-spinner {
  width: 40px; height: 40px;
  border: 3px solid #c9c7c5;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Bottom Nav --- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--surface);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  display: flex; align-items: stretch;
  z-index: 100; padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; color: var(--text-muted);
  transition: color var(--transition);
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.nav-btn svg { width: 20px; height: 20px; transition: stroke var(--transition); }
.nav-btn.active { color: var(--primary); }
.nav-btn.active svg { stroke: var(--primary); }

/* --- Page Layout --- */
#page-content {
  padding: 16px 16px calc(var(--nav-h) + 16px);
  min-height: 100vh;
}

/* --- Neumorphic Components --- */
.neu-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 18px;
}
.neu-card-sm {
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 14px;
}
.neu-inset {
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-in);
  padding: 12px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 12px 20px;
  border-radius: var(--radius-pill);
  font-family: var(--font-main); font-size: 13px; font-weight: 700;
  letter-spacing: 0.5px; text-transform: uppercase;
  background: var(--surface);
  box-shadow: var(--shadow-out);
  color: var(--text);
  transition: box-shadow var(--transition), transform var(--transition);
  white-space: nowrap;
}
.btn:hover { box-shadow: var(--shadow-sm); }
.btn:active { box-shadow: var(--shadow-in); transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 4px 4px 12px rgba(0,102,102,0.4), -2px -2px 8px rgba(255,255,255,0.8); }
.btn-primary:hover { background: var(--primary-light); }
.btn-primary:active { box-shadow: inset 3px 3px 8px rgba(0,0,0,0.2); }
.btn-danger  { background: var(--danger); color: #fff; box-shadow: 4px 4px 12px rgba(255,33,87,0.3), -2px -2px 8px rgba(255,255,255,0.8); }
.btn-success { background: var(--success); color: #fff; box-shadow: 4px 4px 12px rgba(0,166,61,0.3), -2px -2px 8px rgba(255,255,255,0.8); }
.btn-sm { padding: 8px 14px; font-size: 11px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; pointer-events: none; }

/* --- Inputs --- */
.neu-input {
  width: 100%; padding: 12px 16px;
  border: none; outline: none;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-in);
  color: var(--text); font-family: var(--font-main); font-size: 14px;
  transition: box-shadow var(--transition);
}
.neu-input:focus { box-shadow: var(--shadow-in), 0 0 0 2px var(--primary); }
.neu-input::placeholder { color: var(--text-light); }
.neu-select { appearance: none; cursor: pointer; }

label.form-label {
  display: block; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); margin-bottom: 6px;
}
.form-group { margin-bottom: 16px; }

/* --- Tabs --- */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 4px; }
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  flex-shrink: 0; padding: 8px 18px;
  border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted);
  background: var(--surface); box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}
.tab-btn.active { background: var(--primary); color: #fff; box-shadow: 3px 3px 8px rgba(0,102,102,0.35), -2px -2px 6px rgba(255,255,255,0.7); }

/* --- Badges --- */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: 10px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase;
}
.badge-success { background: rgba(0,166,61,0.15); color: var(--success); }
.badge-danger  { background: rgba(255,33,87,0.12); color: var(--danger); }
.badge-warning { background: rgba(254,153,0,0.15); color: var(--warning); }
.badge-primary { background: rgba(0,102,102,0.12); color: var(--primary); }
.badge-muted   { background: var(--surface-alt); color: var(--text-muted); }

/* --- Level badges --- */
.level-badge { font-size: 10px; font-weight: 700; letter-spacing: 1px; padding: 4px 12px; border-radius: var(--radius-pill); }
.level-beginner { background: rgba(0,166,61,0.12); color: var(--success); }
.level-middle   { background: rgba(0,153,204,0.12); color: var(--info); }
.level-advanced { background: rgba(254,153,0,0.15); color: var(--warning); }
.level-pro      { background: rgba(255,33,87,0.12); color: var(--danger); }

/* --- Page Header --- */
.page-header {
  margin-bottom: 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* --- Stats row --- */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-card); padding: 16px 14px; text-align: center;
}
.stat-value { font-size: 28px; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }

/* --- Topic Card --- */
.topic-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-card); padding: 16px;
  margin-bottom: 12px; transition: box-shadow var(--transition);
}
.topic-card.mine { box-shadow: var(--shadow-card), 0 0 0 2px var(--primary); }
.topic-card.taken { opacity: 0.55; }
.topic-title { font-size: 14px; font-weight: 700; margin-bottom: 6px; line-height: 1.4; }
.topic-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* --- Book Card --- */
.book-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-card); padding: 16px;
  margin-bottom: 12px; position: relative; overflow: hidden;
  transition: box-shadow var(--transition);
}
.book-card.locked { opacity: 0.6; }
.book-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.book-title { font-size: 15px; font-weight: 700; line-height: 1.3; }
.book-author { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.book-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }

/* --- Test UI --- */
.test-progress { margin-bottom: 20px; }
.progress-bar {
  height: 6px; border-radius: 3px;
  background: var(--surface-alt); box-shadow: var(--shadow-in);
  overflow: hidden; margin-top: 8px;
}
.progress-fill {
  height: 100%; background: var(--primary);
  border-radius: 3px; transition: width 0.4s ease;
}
.question-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-card); padding: 20px; margin-bottom: 16px;
}
.question-text { font-size: 15px; font-weight: 700; line-height: 1.5; margin-bottom: 16px; }
.option-label {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--surface); box-shadow: var(--shadow-sm);
  cursor: pointer; margin-bottom: 10px;
  transition: box-shadow var(--transition), background var(--transition);
  font-size: 13px; line-height: 1.4;
}
.option-label:hover { box-shadow: var(--shadow-out); }
.option-label input[type="radio"] { display: none; }
.option-label.selected { background: rgba(0,102,102,0.08); box-shadow: var(--shadow-in); }
.option-dot {
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0;
  background: var(--surface); box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: center;
}
.option-label.selected .option-dot { background: var(--primary); box-shadow: 2px 2px 5px rgba(0,102,102,0.3); }
.option-label.selected .option-dot::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #fff; display: block; }

/* --- Result screen --- */
.result-screen { text-align: center; padding: 24px 16px; }
.result-score-ring {
  width: 120px; height: 120px; margin: 0 auto 20px;
  border-radius: 50%; background: var(--surface);
  box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.result-score-val { font-size: 32px; font-weight: 700; color: var(--primary); }
.result-score-pct { font-size: 12px; color: var(--text-muted); }
.result-status { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.result-status.passed { color: var(--success); }
.result-status.failed { color: var(--danger); }

/* --- Toast --- */
#toast {
  position: fixed; bottom: calc(var(--nav-h) + 16px); left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff;
  padding: 12px 20px; border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 700; z-index: 9000;
  opacity: 0; transition: opacity 0.3s, transform 0.3s;
  pointer-events: none; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.success { background: var(--success); }
#toast.error   { background: var(--danger); }

/* --- Modal --- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  z-index: 500; display: flex; align-items: flex-end; justify-content: center;
  padding: 0 0 env(safe-area-inset-bottom);
  opacity: 0; transition: opacity 0.25s;
}
.modal-overlay.open { opacity: 1; }
.modal-box {
  background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 24px 20px; width: 100%; max-height: 85vh;
  overflow-y: auto; box-shadow: 0 -8px 30px rgba(0,0,0,0.15);
  transform: translateY(40px); transition: transform 0.3s ease;
}
.modal-overlay.open .modal-box { transform: translateY(0); }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }

/* --- Admin table --- */
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th { text-align: left; padding: 8px 10px; color: var(--text-muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--surface-alt); }
.data-table td { padding: 10px; border-bottom: 1px solid var(--surface-alt); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }

/* --- Admin layout with side nav for larger screens --- */
.admin-layout { display: flex; flex-direction: column; }
.admin-nav { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 16px; padding-bottom: 4px; }
.admin-nav::-webkit-scrollbar { display: none; }
.admin-nav-btn {
  flex-shrink: 0; padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); background: var(--surface); box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}
.admin-nav-btn.active { background: var(--primary); color: #fff; }

/* --- Empty state --- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 13px; }

/* --- Misc --- */
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 12px; }
.divider { height: 1px; background: var(--surface-alt); margin: 16px 0; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: var(--radius-pill); background: var(--surface-alt); font-size: 11px; color: var(--text-muted); }
.lock-icon { font-size: 18px; opacity: 0.5; }
.cooldown-badge { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--warning); font-weight: 700; }

/* --- Animations --- */
@keyframes fadeInUp { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:translateY(0); } }
.page-enter { animation: fadeInUp 0.3s ease both; }
