:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==================== HEADER & NAV ==================== */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.brand {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #10b981);
}

.nav-tabs {
  display: flex;
  gap: 0.4rem;
  background: #f1f5f9;
  padding: 0.25rem;
  border-radius: 10px;
}

.nav-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.nav-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tutor-cta {
  border: none;
  background: linear-gradient(135deg, #4f46e5, #10b981);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.22);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.tutor-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.3);
}

.btn-sm-cta {
  font-size: 0.8rem;
  padding: 0.4rem 0.85rem;
}

/* ==================== WARNING BANNER ==================== */
.warn-banner {
  background: var(--warn-soft);
  border-bottom: 1px solid #fde68a;
  color: #92400e;
  font-size: 0.83rem;
  padding: 0.55rem 1rem;
}

.warn-inner {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.warn-close {
  background: none;
  border: none;
  color: #92400e;
  font-size: 1.15rem;
  cursor: pointer;
  padding: 0 0.25rem;
}

/* ==================== MAIN LAYOUT ==================== */
main {
  max-width: 1040px;
  width: 100%;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  flex: 1;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.section-header {
  margin-bottom: 1.25rem;
}

.section-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.section-header p {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

/* ==================== PROGRESS BAR ==================== */
.progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.progress-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.55rem;
}

.progress-track {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2563eb, #10b981);
  border-radius: 999px;
  transition: width 0.35s ease;
}

/* ==================== TOPIC GRIDS ==================== */
.partial-group {
  margin-bottom: 2rem;
}

.partial-title {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.85rem;
}

.topic-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.55rem;
  text-align: left;
}

.topic-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.08);
}

.topic-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}

.topic-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.badge-done {
  background: var(--success-soft);
  color: var(--success);
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
}

.badge-prog {
  background: #f1f5f9;
  color: #475569;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
}

/* ==================== BUTTONS ==================== */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.55rem 1rem;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn:hover:not(:disabled) {
  background: #f1f5f9;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: #ffffff;
}

.btn-success:hover:not(:disabled) {
  opacity: 0.92;
}

.btn-warn {
  background: var(--warn-soft);
  border-color: #fcd34d;
  color: #92400e;
}

.btn-warn:hover:not(:disabled) {
  background: #fef3c7;
}

.btn-lg {
  padding: 0.75rem 1.75rem;
  font-size: 1rem;
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
}

/* ==================== LEARN DETAIL ==================== */
.top-bar-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.learn-box h2 {
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.learn-summary {
  color: #334155;
  font-size: 0.96rem;
  margin-bottom: 1.25rem;
}

.learn-img-gallery {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.learn-img {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
}

.learn-placeholder {
  border: 1.5px dashed #cbd5e1;
  background: #f8fafc;
  border-radius: 10px;
  padding: 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.86rem;
  margin-bottom: 1.25rem;
}

.learn-block {
  margin-bottom: 1.15rem;
}

.learn-block h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  margin-bottom: 0.45rem;
}

.learn-block ul {
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.93rem;
}

.tip-box {
  background: var(--primary-soft);
  border-left: 4px solid var(--primary);
  padding: 0.85rem 1rem;
  border-radius: 0 10px 10px 0;
  font-size: 0.9rem;
  color: #1e3a8a;
}

/* ==================== PRACTICE & QUIZ ==================== */
.practice-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.practice-topic-label {
  font-weight: 700;
  color: var(--primary);
}

.practice-counter-label {
  font-weight: 600;
}

.question-text {
  font-size: 1.12rem;
  font-weight: 600;
  margin: 1rem 0 1.25rem;
  overflow-x: auto;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.option-btn {
  width: 100%;
  text-align: left;
  padding: 0.9rem 1.1rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 0.98rem;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.option-btn.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  font-weight: 600;
}

.option-btn.correct {
  border-color: var(--success);
  background: var(--success-soft);
  color: #14532d;
  font-weight: 600;
}

.option-btn.wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: #7f1d1d;
}

.feedback-box {
  margin-top: 1.15rem;
  padding: 1rem 1.15rem;
  border-radius: 10px;
  font-size: 0.92rem;
  display: none;
}

.feedback-box.show {
  display: block;
}

.feedback-box.ok {
  background: var(--success-soft);
  border: 1px solid #bbf7d0;
  color: #14532d;
}

.feedback-box.err {
  background: var(--danger-soft);
  border: 1px solid #fecaca;
  color: #7f1d1d;
}

.card-footer-right {
  margin-top: 1.25rem;
  display: flex;
  justify-content: flex-end;
}

.complete-card {
  text-align: center;
  padding: 2.25rem 1.5rem;
}

.complete-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.complete-card h2 {
  font-size: 1.45rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.complete-card p {
  color: var(--muted);
  max-width: 460px;
  margin: 0 auto 1.5rem;
}

.complete-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Quiz Specific */
.quiz-intro-card {
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
}

.quiz-intro-card h1 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.quiz-intro-sub {
  color: var(--muted);
  margin-bottom: 1.25rem;
}

.quiz-rules-box {
  text-align: left;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.quiz-rules-box ul {
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.quiz-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.quiz-prog-label {
  font-weight: 700;
  font-size: 0.95rem;
}

.quiz-topic-badge {
  margin-left: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.quiz-top-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.timer-pill {
  background: #0f172a;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.88rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
}

.q-nav-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
}

.q-pill {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
}

.q-pill.current {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.q-pill.answered {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1e40af;
}

.q-pill.hinted {
  background: #fef3c7;
  border-color: #fcd34d;
  color: #92400e;
}

.quiz-bottom-actions {
  margin-top: 1.35rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.quiz-nav-arrows {
  display: flex;
  gap: 0.5rem;
}

/* ==================== MODALS ==================== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.overlay.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border-radius: 16px;
  max-width: 520px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
  position: relative;
}

.modal-wide {
  max-width: 640px;
}

.modal-narrow {
  max-width: 440px;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  border: none;
  background: #f1f5f9;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
}

.modal-title {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 0.4rem;
}

.modal-title-sm {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.modal-text {
  color: #334155;
  font-size: 0.95rem;
}

.modal-sub {
  color: var(--muted);
  font-size: 0.86rem;
  margin-top: 0.6rem;
}

.phone-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  margin: 1rem 0;
  font-weight: 700;
  font-size: 1.05rem;
}

.modal-footer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.modal-footer-right {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ==================== FOOTER ==================== */
footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 1.25rem 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.footer-inner {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.footer-actions {
  display: flex;
  gap: 0.65rem;
  align-items: center;
}

@media (max-width: 640px) {
  .nav-wrap {
    justify-content: center;
  }
  .card {
    padding: 1.15rem;
  }
}