:root {
  --bg: #f6f8f5;
  --bg-soft: #eef4ec;
  --surface: #ffffff;
  --surface-soft: #f8fbf7;
  --text: #1f2a1f;
  --muted: #637064;
  --line: #d7e0d5;
  --brand: #1f7a5a;
  --brand-2: #e59f3a;
  --brand-deep: #14553e;
  --danger-soft: #fff2ef;
  --ok-soft: #effbf4;
  --shadow: 0 14px 30px rgba(22, 53, 40, 0.11);
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
}

* {
  box-sizing: border-box;
}

body.app-body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Zen Kaku Gothic New", sans-serif;
  background:
    radial-gradient(circle at 8% 12%, #dfefe7 0, transparent 35%),
    radial-gradient(circle at 92% 22%, #fbeccf 0, transparent 28%),
    linear-gradient(180deg, var(--bg-soft) 0%, var(--bg) 45%, #f2f6f0 100%);
  padding-top: 84px;
}

h1,
h2,
h3,
h4,
h5,
h6,
.navbar-brand,
.btn {
  font-family: "M PLUS Rounded 1c", sans-serif;
}

.app-nav {
  background: linear-gradient(120deg, var(--brand-deep), var(--brand)) !important;
  box-shadow: 0 6px 24px rgba(20, 53, 39, 0.22);
}

.app-nav .navbar-brand {
  font-weight: 800;
  letter-spacing: 0.02em;
}

.app-nav .navbar-brand .brand-dot {
  color: #ffe7ac;
  margin-right: 0.35rem;
}

.app-nav .nav-link {
  color: rgba(255, 255, 255, 0.88);
  font-weight: 600;
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  margin-left: 0.25rem;
  white-space: nowrap;
  transition: all 0.25s ease;
}

.app-nav .nav-link:hover,
.app-nav .nav-link.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
}

.app-nav .nav-item-logout {
  display: flex;
  align-items: center;
  margin-left: 0.35rem;
}

.nav-logout-btn {
  border-radius: 999px;
  font-weight: 700;
}

.site-content {
  position: relative;
  z-index: 1;
}

.reveal {
  animation: rise 0.5s ease-out both;
}

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

.hero-panel,
.panel-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: 2rem;
  margin-bottom: 1.4rem;
  background:
    linear-gradient(145deg, #f8fcfa 0%, #ffffff 60%),
    linear-gradient(180deg, #ffffff, #ffffff);
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--brand-deep);
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  background: #e6f5ed;
}

.hero-panel h1 {
  margin-top: 0.85rem;
  margin-bottom: 0.55rem;
  font-size: clamp(1.5rem, 3.4vw, 2.2rem);
  font-weight: 800;
}

.hero-panel p {
  color: var(--muted);
  margin-bottom: 0;
}

.ad-shell {
  border: 1px dashed #c5d2c2;
  background: rgba(255, 255, 255, 0.72);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1rem;
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.ad-label {
  margin-bottom: 0.45rem;
  color: #758274;
  font-size: 0.82rem;
  font-weight: 600;
}

.level-grid {
  margin-bottom: 1rem;
}

.level-card {
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdfb 100%);
  box-shadow: 0 10px 22px rgba(30, 58, 45, 0.08);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.level-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 26px rgba(30, 58, 45, 0.14);
}

.level-card .card-body {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.level-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  background: #edf5f1;
  color: var(--brand);
}

.btn-level {
  margin-top: auto;
  border-radius: 999px;
  font-weight: 700;
}

.panel-card {
  padding: var(--space-5);
}

.page-title {
  font-size: clamp(1.2rem, 2.4vw, 1.6rem);
  font-weight: 800;
  margin-bottom: 1rem;
}

.table-modern {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}

/* On mobile/tablet, allow horizontal scroll for wide tables. */
.table-responsive.table-modern {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.table-modern thead th {
  background: #eef4ec;
  color: #2a392b;
  border-bottom: 1px solid var(--line);
  font-size: 0.87rem;
}

.table-modern td,
.table-modern th {
  vertical-align: middle;
  word-break: normal;
  overflow-wrap: normal;
}

.table-modern table {
  min-width: 720px;
}

.quiz-shell {
  max-width: 760px;
}

.quiz-shell .card-header {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.quiz-shell .progress {
  height: 12px;
  background: #e8efe6;
  border-radius: 999px;
}

.quiz-shell #englishWord {
  font-weight: 800;
  color: #17392a;
  letter-spacing: 0.02em;
}

.quiz-snapshot {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
}

.quiz-kpi {
  border: 1px solid #dce8da;
  border-radius: var(--radius-md);
  background: #f7fbf6;
  padding: var(--space-3);
  text-align: center;
}

.quiz-kpi .kpi-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.quiz-kpi strong {
  font-size: 1.15rem;
  color: #17392a;
}

.quiz-action-primary {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.quiz-action-primary .btn,
.quiz-action-primary a.btn {
  flex: 1 1 180px;
}

.quiz-actions .btn,
.quiz-actions a.btn {
  border-radius: 999px;
  font-weight: 700;
}

.btn-grade {
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.btn-grade-correct {
  color: #fff;
  border-color: #208b60;
  background: linear-gradient(135deg, #1d8a5f, #38a676);
}

.btn-grade-correct:hover {
  color: #fff;
  border-color: #1a7b54;
  background: linear-gradient(135deg, #17774f, #34996e);
}

.btn-grade-wrong {
  color: #fff;
  border-color: #be4c2f;
  background: linear-gradient(135deg, #d15b3d, #c64844);
}

.btn-grade-wrong:hover {
  color: #fff;
  border-color: #ab432a;
  background: linear-gradient(135deg, #bd4d31, #af3f3d);
}

.btn-next-primary {
  color: #fff;
  border-color: #1c4f92;
  background: linear-gradient(135deg, #2360b1, #2a78ce);
}

.btn-next-primary:hover {
  color: #fff;
  border-color: #19467f;
  background: linear-gradient(135deg, #1f569d, #236cb9);
}

#gradeStatus {
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  background: #f4f8f3;
  border: 1px solid #e1e9df;
}

.answer-box {
  border-radius: var(--radius-md);
  border: 1px solid #d8e2d7;
  background: #f7fbf6;
}

.mobile-action-bar {
  position: fixed;
  bottom: 0.75rem;
  left: 0.65rem;
  right: 0.65rem;
  z-index: 1040;
}

.mobile-action-inner {
  display: flex;
  gap: var(--space-2);
  border: 1px solid #d9e5d6;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 12px 30px rgba(18, 43, 31, 0.16);
  padding: var(--space-2);
}

.mobile-action-inner .btn,
.mobile-action-inner a.btn {
  flex: 1 1 0;
}

.mobile-action-spacer {
  height: 96px;
}

.review-shell .review-summary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.account-shell {
  max-width: 960px;
}

.account-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fbfdfb;
  padding: var(--space-4);
  height: 100%;
}

.review-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-2);
}

.review-filter-group {
  width: fit-content;
}

.review-filter-group .btn {
  white-space: nowrap;
}

.review-item > div:first-child {
  flex: 1 1 300px;
  min-width: 220px;
}

.review-item .fw-semibold {
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.stats-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.stat-showcase {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #ffffff 0%, #f8fbf7 100%);
  padding: var(--space-4);
}

.stat-showcase-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
}

.stat-showcase-head h3 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 800;
}

.kpi-tile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

.kpi-tile {
  border: 1px solid #dde8da;
  border-radius: var(--radius-md);
  background: #fff;
  padding: var(--space-3);
}

.kpi-tile span {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

.kpi-tile strong {
  font-size: 1.18rem;
  color: #153b2b;
}

.stats-trend {
  border: 1px solid #dce7da;
  border-radius: var(--radius-lg);
  background: #fbfdfb;
  padding: var(--space-4);
}

.trend-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0;
}

.trend-title {
  color: #2f3e32;
}

.trend-value {
  font-weight: 800;
  color: #153b2b;
}

.trend-bars .progress {
  height: 10px;
  border-radius: 999px;
  background: #e7efe5;
}

.weak-progress {
  height: 9px;
  border-radius: 999px;
  background: #edf2eb;
}

.btn-primary,
.btn-success,
.btn-outline-primary,
.btn-outline-success,
.btn-outline-warning,
.btn-outline-danger,
.btn-outline-secondary,
.btn-warning,
.btn-danger,
.btn-dark,
.btn-info {
  border-radius: 999px;
  font-weight: 700;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn {
  white-space: nowrap;
}

.flash-box {
  border-radius: var(--radius-md);
  border: 1px solid #ffe4a8;
  background: #fff8e5;
}

.app-footer {
  margin-top: 1.2rem;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
}

@media (max-width: 991px) {
  .app-nav .nav-link {
    margin-left: 0;
    margin-top: 0.3rem;
    width: fit-content;
  }

  body.app-body {
    padding-top: 76px;
  }

  .app-nav .nav-item-logout {
    margin-left: 0;
    margin-top: 0.3rem;
  }
}

@media (max-width: 767px) {
  .quiz-action-primary {
    display: none;
  }

  .stats-kpi-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 576px) {
  .hero-panel,
  .panel-card {
    padding: 1rem;
    border-radius: var(--radius-lg);
  }

  .quiz-snapshot {
    grid-template-columns: 1fr;
  }

  .quiz-action-primary {
    flex-direction: column;
  }

  .quiz-actions-secondary {
    gap: 0.5rem !important;
  }

  .quiz-actions-secondary .btn,
  .quiz-actions-secondary a.btn {
    width: 100%;
  }

  .review-controls {
    grid-template-columns: 1fr;
  }

  .review-filter-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
  }

  .review-filter-group .btn {
    width: 100%;
  }

  .review-item {
    align-items: flex-start !important;
  }

  .review-item > a.btn {
    align-self: stretch;
    text-align: center;
  }
}

@media (min-width: 768px) {
  .mobile-action-bar,
  .mobile-action-spacer {
    display: none !important;
  }
}

@media (max-width: 420px) {
  .mobile-action-inner {
    flex-wrap: wrap;
  }

  .mobile-action-inner .btn,
  .mobile-action-inner a.btn {
    width: 100%;
  }

  .kpi-tile-grid {
    grid-template-columns: 1fr;
  }
}
