:root {
  --tg-theme-bg-color: #f4f5f7;
  --tg-theme-text-color: #1c1c1e;
  --tg-theme-hint-color: #8e8e93;
  --tg-theme-link-color: #2481cc;
  --tg-theme-button-color: #2481cc;
  --tg-theme-button-text-color: #ffffff;
  --tg-theme-secondary-bg-color: #ffffff;
  --radius: 14px;
  --nav-h: 56px;
  --shadow: 0 8px 24px rgba(16, 24, 40, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--tg-theme-bg-color);
  color: var(--tg-theme-text-color);
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
}

.topbar {
  padding: 16px 20px 8px;
}

.topbar-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar-sub {
  margin-top: 4px;
  font-size: 13px;
  color: var(--tg-theme-hint-color);
}

.screen {
  flex: 1;
  padding: 8px 16px calc(var(--nav-h) + 20px);
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  background: var(--tg-theme-secondary-bg-color);
  border-top: 1px solid color-mix(in srgb, var(--tg-theme-hint-color) 22%, transparent);
  max-width: 560px;
  margin: 0 auto;
}

.tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--tg-theme-hint-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  cursor: pointer;
}

.tab.active {
  color: var(--tg-theme-button-color);
  font-weight: 600;
}

.tab-ico {
  font-size: 18px;
  line-height: 1;
}

.card {
  background: var(--tg-theme-secondary-bg-color);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.card.clickable {
  cursor: pointer;
}

.card.locked {
  opacity: 0.62;
}

.card h3 {
  font-size: 16px;
  margin-bottom: 6px;
}

.muted {
  color: var(--tg-theme-hint-color);
  font-size: 13px;
  line-height: 1.45;
}

.progress {
  margin-top: 10px;
  height: 6px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--tg-theme-hint-color) 20%, transparent);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--tg-theme-button-color);
  border-radius: 99px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  background: var(--tg-theme-button-color);
  color: var(--tg-theme-button-text-color, #fff);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  text-decoration: none;
}

.billing {
  margin-bottom: 12px;
}

.plan-card {
  margin-top: 10px;
}

.btn.ghost {
  background: transparent;
  color: var(--tg-theme-link-color);
  box-shadow: none;
  width: auto;
  padding: 8px 0;
}

.btn.option {
  background: var(--tg-theme-bg-color);
  color: var(--tg-theme-text-color);
  text-align: left;
  font-weight: 500;
  margin-bottom: 8px;
}

.btn.option.ok {
  background: #d1fae5;
}

.btn.option.bad {
  background: #fee2e2;
}

.hint-btn {
  width: 100%;
  margin: 0 0 12px;
  border: 1px dashed color-mix(in srgb, var(--tg-theme-link-color) 45%, transparent);
  border-radius: 12px;
  padding: 10px 12px;
}

.hint-box {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--tg-theme-button-color) 10%, transparent);
  color: var(--tg-theme-text-color);
  line-height: 1.45;
}

.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--tg-theme-hint-color);
}

.lesson-body {
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 40vh;
  padding-bottom: 12px;
}

.bubble {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.bubble.user {
  align-self: flex-end;
  background: var(--tg-theme-button-color);
  color: var(--tg-theme-button-text-color, #fff);
}

.bubble.assistant {
  align-self: flex-start;
  background: var(--tg-theme-secondary-bg-color);
  box-shadow: var(--shadow);
}

.chat-form {
  display: flex;
  gap: 8px;
  position: sticky;
  bottom: calc(var(--nav-h) + 8px);
}

.chat-form input,
select {
  flex: 1;
  border: 0;
  border-radius: 12px;
  padding: 12px;
  background: var(--tg-theme-secondary-bg-color);
  color: var(--tg-theme-text-color);
  font-size: 15px;
  outline: none;
  box-shadow: var(--shadow);
}

.chat-form button {
  width: auto;
  padding: 12px 16px;
}

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.badge {
  font-size: 12px;
  color: var(--tg-theme-button-color);
  background: color-mix(in srgb, var(--tg-theme-button-color) 12%, transparent);
  border-radius: 999px;
  padding: 4px 8px;
}

.result {
  text-align: center;
  padding: 24px 8px;
}

.result .score {
  font-size: 42px;
  font-weight: 800;
  color: var(--tg-theme-button-color);
}
