:root {
  --sw-bg: #faf9fe;
  --sw-surface: #ffffff;
  --sw-surface-soft: #f4f3f8;
  --sw-line: #e3e2e7;
  --sw-text: #1a1b1f;
  --sw-muted: #656b78;
  --sw-blue: #0070eb;
  --sw-blue-dark: #0058bc;
  --sw-blue-soft: #d8e2ff;
  --sw-orange: #fe9400;
  --sw-orange-soft: #ffdcbf;
  --sw-green: #008733;
  --sw-green-soft: #72fe88;
  --sw-danger: #ba1a1a;
  --sw-shadow: 0 8px 24px rgba(26, 27, 31, 0.08);
  --sw-shadow-soft: 0 4px 18px rgba(26, 27, 31, 0.05);
  --sw-radius: 16px;
}

html {
  background: var(--sw-bg);
}

body {
  background: var(--sw-bg) !important;
  color: var(--sw-text);
  font-family:
    "Plus Jakarta Sans", "Be Vietnam Pro", "Noto Sans SC", "Microsoft YaHei",
    "Noto Sans Thai", "Leelawadee UI", system-ui, sans-serif;
}

.app {
  width: min(430px, 100%);
  min-height: 100vh;
  padding: 0 20px 104px;
  background: var(--sw-bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  margin: 0 -20px;
  padding: 16px 20px 14px;
  background: rgba(250, 249, 254, 0.96);
  border-bottom: 1px solid var(--sw-line);
}

h1 {
  color: var(--sw-blue-dark);
  font-size: 22px;
  line-height: 1.18;
  letter-spacing: 0;
}

.subtitle {
  margin-top: 5px;
  color: var(--sw-muted);
  font-size: 13px;
}

.hint {
  display: none;
}

.progress {
  min-width: 86px;
  padding: 8px 10px;
  border: 0;
  border-radius: 14px;
  background: var(--sw-surface);
  box-shadow: var(--sw-shadow-soft);
}

.progress strong {
  color: var(--sw-blue);
  font-size: 22px;
}

.free-style-bar {
  position: sticky;
  top: 103px;
  z-index: 19;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 -20px;
  padding: 10px 20px;
  background: rgba(250, 249, 254, 0.96);
  border-bottom: 1px solid var(--sw-line);
}

.free-style-bar a {
  display: grid;
  place-items: center;
  min-height: 38px;
  border-radius: 999px;
  background: var(--sw-surface);
  color: var(--sw-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 900;
  box-shadow: var(--sw-shadow-soft);
}

html.theme-a .free-style-bar .theme-a-link,
html.theme-b .free-style-bar .theme-b-link {
  background: var(--sw-blue-soft);
  color: var(--sw-blue-dark);
}

.tabs {
  position: relative;
  top: auto;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 14px;
  padding: 14px;
  overflow: visible;
  border: 1px solid var(--sw-line);
  border-radius: var(--sw-radius);
  background: var(--sw-surface);
  box-shadow: var(--sw-shadow-soft);
}

.free-a-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin: 16px 0 12px;
  padding: 20px 18px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--sw-blue) 0%, #199a71 100%);
  color: #fff;
  box-shadow: var(--sw-shadow);
}

.free-a-hero__copy span {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  opacity: 0.88;
}

.free-a-hero__copy strong {
  display: block;
  font-size: 25px;
  line-height: 1.15;
}

.free-a-hero__copy p {
  margin: 6px 0 0;
  color: rgba(255, 255, 255, 0.88);
  font-size: 14px;
  line-height: 1.45;
}

.free-a-hero__score {
  display: grid;
  place-items: center;
  min-width: 72px;
  color: #fff;
  font-size: 26px;
  font-weight: 900;
}

.free-a-hero__bar {
  grid-column: 1 / -1;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.26);
  overflow: hidden;
}

.free-a-hero__bar i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: #fff;
}

.free-a-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.free-a-stats div {
  min-height: 94px;
  padding: 14px;
  border: 1px solid var(--sw-line);
  border-radius: var(--sw-radius);
  background: var(--sw-surface);
  box-shadow: var(--sw-shadow-soft);
}

.free-a-stats strong {
  display: block;
  color: var(--sw-blue);
  font-size: 30px;
  line-height: 1.1;
}

.free-a-stats span {
  display: block;
  margin-top: 8px;
  color: var(--sw-muted);
  font-size: 13px;
  font-weight: 800;
}

.free-bottom-nav {
  position: fixed;
  right: max(0px, calc((100vw - 430px) / 2));
  bottom: 0;
  left: max(0px, calc((100vw - 430px) / 2));
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  height: 74px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--sw-line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -8px 24px rgba(26, 27, 31, 0.08);
}

.free-bottom-nav a {
  display: grid;
  place-items: center;
  min-height: 52px;
  border-radius: 14px;
  color: var(--sw-muted);
  text-decoration: none;
  font-size: 12px;
  font-weight: 900;
}

.free-bottom-nav a.active {
  background: var(--sw-blue-soft);
  color: var(--sw-blue-dark);
}

.select-field {
  grid-column: 1 / -1;
  display: grid;
  gap: 5px;
}

.select-label {
  color: var(--sw-muted);
  font-size: 12px;
  font-weight: 800;
}

.category-select,
.lesson-select,
.search,
.voice-select {
  min-height: 44px;
  border: 1px solid var(--sw-line);
  border-radius: 10px;
  background: var(--sw-surface);
  color: var(--sw-text);
  box-shadow: none;
}

.tab {
  min-height: 42px;
  border: 0;
  border-radius: 12px;
  background: var(--sw-surface);
  color: var(--sw-muted);
  font-size: 13px;
  box-shadow: var(--sw-shadow-soft);
}

.tab.active {
  background: var(--sw-blue-soft);
  color: var(--sw-blue-dark);
}

.stage {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.lesson-panel {
  position: relative;
  top: auto;
  border: 1px solid var(--sw-line);
  border-radius: var(--sw-radius);
  background: var(--sw-surface);
  box-shadow: var(--sw-shadow);
  overflow: hidden;
}

.cover {
  min-height: 126px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(0, 112, 235, 0.94), rgba(0, 135, 51, 0.84)) !important;
}

.cover h2 {
  font-size: 25px;
  line-height: 1.12;
}

.panel-body {
  padding: 14px 16px 16px;
}

.meter {
  height: 8px;
  border-radius: 999px;
  background: var(--sw-line);
}

.meter span {
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sw-blue), var(--sw-green));
}

.cards {
  gap: 12px;
}

.card {
  border: 1px solid var(--sw-line);
  border-radius: var(--sw-radius);
  background: var(--sw-surface);
  box-shadow: var(--sw-shadow-soft);
}

.card:hover {
  transform: none;
  border-color: var(--sw-line);
}

.card.done {
  border-left: 0;
  box-shadow:
    inset 4px 0 0 var(--sw-green),
    var(--sw-shadow-soft);
}

.speaker {
  color: var(--sw-blue-dark);
}

.thai {
  color: var(--sw-text);
  font-size: clamp(22px, 7vw, 30px);
}

.meaning {
  color: var(--sw-muted);
}

.gloss {
  border-top: 1px solid var(--sw-line);
}

.token b,
.vocab-word {
  color: var(--sw-blue);
}

.play-btn,
.mini-btn.primary {
  border: 0;
  border-radius: 10px;
  background: var(--sw-blue);
  color: #fff;
}

.word-play {
  border: 0;
  border-radius: 8px;
  background: var(--sw-blue-soft);
  color: var(--sw-blue-dark);
}

.word-save {
  border: 0;
  border-radius: 8px;
  background: var(--sw-orange-soft);
  color: #6a3b00;
}

.word-save.saved {
  background: var(--sw-orange);
  color: #fff;
}

.mini-btn {
  min-height: 38px;
  border: 1px solid var(--sw-line);
  border-radius: 10px;
  background: var(--sw-surface-soft);
}

.mini-btn.danger {
  background: #ffdad6;
  color: var(--sw-danger);
}

.review-answer {
  border-top: 1px solid var(--sw-line);
}

.empty {
  border: 1px solid var(--sw-line);
  border-radius: var(--sw-radius);
  background: var(--sw-surface);
  color: var(--sw-muted);
}

@media (min-width: 760px) {
  body {
    background:
      linear-gradient(90deg, #f0f2f8 0, var(--sw-bg) 28%, var(--sw-bg) 72%, #eef2f8 100%) !important;
  }
}

@media (max-width: 380px) {
  .app {
    padding-right: 16px;
    padding-left: 16px;
  }

  .topbar,
  .tabs,
  .free-style-bar {
    margin-right: -16px;
    margin-left: -16px;
    padding-right: 16px;
    padding-left: 16px;
  }

  .progress {
    min-width: 78px;
  }
}
