/* Ministers Wealth System — Telegram Mini App styles.
   Telegram theme aware: uses var(--tg-theme-*) with safe fallbacks so the
   page also looks right in a plain browser (preview mode). */

:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f4f4f5);
  --text: var(--tg-theme-text-color, #1c1c1e);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --link: var(--tg-theme-link-color, #2481cc);
  --button: var(--tg-theme-button-color, #2481cc);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --destructive: var(--tg-theme-destructive-text-color, #cc0000);
  --section-bg: var(--tg-theme-section-bg-color, var(--secondary-bg));
  --section-separator: var(--tg-theme-section-separator-color, #e5e5ea);
  --radius: 14px;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  font-size: 16px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  padding-bottom: env(safe-area-inset-bottom);
}

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

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--section-separator);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--button);
  color: var(--button-text);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.5px;
  flex: none;
}

.back-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 12px;
  border: 1px solid var(--section-separator);
  border-radius: 10px;
  background: var(--secondary-bg);
  color: var(--link);
  font-size: 16px;
  cursor: pointer;
}

.preview-banner {
  background: #fff3cd;
  color: #664d03;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  border-bottom: 1px solid #ffe69c;
}

.loading { padding: 48px 16px; text-align: center; color: var(--hint); font-size: 17px; }

#view { flex: 1; padding: 16px 16px 24px; }

h1 { font-size: 26px; line-height: 1.25; margin: 4px 0 12px; }
h2 { font-size: 21px; line-height: 1.3; margin: 28px 0 10px; }
h3 { font-size: 18px; margin: 20px 0 8px; }
p { margin: 0 0 14px; }

.lede { font-size: 17px; color: var(--text); }
.muted { color: var(--hint); font-size: 15px; }
.small { font-size: 15px; }

.card {
  background: var(--section-bg);
  border: 1px solid var(--section-separator);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 14px;
}

.card h2, .card h3 { margin-top: 0; }

.quote {
  border-left: 3px solid var(--button);
  padding-left: 14px;
  font-style: italic;
  margin: 16px 0;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 13px;
  font-weight: 700;
  color: var(--hint);
  margin-bottom: 6px;
}

.author { font-size: 16px; font-weight: 600; margin-bottom: 4px; }

/* Progress */
.progress-wrap { display: flex; align-items: center; gap: 16px; }
.progress-ring { flex: none; }
.progress-ring .ring-bg { stroke: var(--section-separator); }
.progress-ring .ring-fg { stroke: var(--button); stroke-linecap: round; transform: rotate(-90deg); transform-origin: center; transition: stroke-dashoffset 0.4s ease; }
.progress-ring .ring-label { font-size: 15px; font-weight: 700; fill: var(--text); }
.progress-bar { height: 10px; border-radius: 5px; background: var(--section-separator); overflow: hidden; margin: 10px 0 6px; }
.progress-bar > span { display: block; height: 100%; background: var(--button); border-radius: 5px; transition: width 0.4s ease; }

/* Buttons and lists */
.btn {
  display: inline-block;
  width: 100%;
  min-height: 52px;
  padding: 14px 18px;
  border: none;
  border-radius: 12px;
  background: var(--button);
  color: var(--button-text);
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
}
.btn:active { opacity: 0.85; }
.btn.secondary {
  background: var(--secondary-bg);
  color: var(--link);
  border: 1px solid var(--section-separator);
}
.btn.done { background: #2e7d32; color: #ffffff; }
.btn:disabled { opacity: 0.55; cursor: default; }

.module-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.module-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  width: 100%;
  min-height: 64px;
  padding: 14px 16px;
  text-align: left;
  background: var(--section-bg);
  border: 1px solid var(--section-separator);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
}
.module-item .num {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--button);
  color: var(--button-text);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px;
}
.module-item.completed .num { background: #2e7d32; }
.module-item .mod-title { font-weight: 700; display: block; }
.module-item .mod-sub { color: var(--hint); font-size: 15px; display: block; margin-top: 2px; }
.module-item .check { margin-left: auto; font-size: 20px; color: #2e7d32; flex: none; }

.lesson-list { list-style: none; margin: 0 0 14px; padding: 0; counter-reset: lesson; }
.lesson-list li {
  counter-increment: lesson;
  padding: 12px 0 12px 44px;
  position: relative;
  border-bottom: 1px solid var(--section-separator);
  font-size: 16px;
}
.lesson-list li:last-child { border-bottom: none; }
.lesson-list li::before {
  content: counter(lesson);
  position: absolute; left: 0; top: 12px;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--secondary-bg);
  border: 1px solid var(--section-separator);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700;
}

.template-list, .stage-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.template-list li, .stage-list li {
  background: var(--section-bg);
  border: 1px solid var(--section-separator);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 16px;
}
.template-list .t-num, .stage-list .s-num { font-weight: 800; color: var(--link); margin-right: 6px; }

.flywheel-steps { list-style: none; margin: 0 0 14px; padding: 0; counter-reset: step; }
.flywheel-steps li {
  counter-increment: step;
  padding: 12px 0 12px 48px;
  position: relative;
  border-bottom: 1px solid var(--section-separator);
  font-size: 16px;
}
.flywheel-steps li:last-child { border-bottom: none; }
.flywheel-steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 12px;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--button); color: var(--button-text);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800;
}
.flywheel-steps .step-name { font-weight: 700; display: block; }

.detail-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--section-separator); font-size: 16px; }
.detail-row:last-child { border-bottom: none; }
.detail-row .k { color: var(--hint); flex: none; }
.detail-row .v { text-align: right; font-weight: 600; }

.notice {
  background: var(--section-bg);
  border: 1px solid var(--section-separator);
  border-left: 4px solid var(--destructive);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.notice h2 { margin-top: 0; }

.error { color: var(--destructive); font-size: 16px; padding: 16px 0; }

/* Bottom tab bar */
.tabbar {
  position: sticky;
  bottom: 0;
  display: flex;
  background: var(--bg);
  border-top: 1px solid var(--section-separator);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  min-height: 52px;
  padding: 8px 2px;
  border: none;
  background: none;
  color: var(--hint);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.tab.active { color: var(--link); }

.app-footer { padding: 12px 16px 20px; color: var(--hint); font-size: 13px; line-height: 1.5; }
.app-footer p { margin: 0; }

.noscript { padding: 24px 16px; font-size: 17px; }

@media (prefers-color-scheme: dark) {
  .preview-banner { background: #332a00; color: #ffe08a; border-bottom-color: #554400; }
}
