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

:root {
  --bg: var(--bale-bg_color, var(--tg-theme-bg-color, #f8faf9));
  --text: var(--bale-text_color, var(--tg-theme-text-color, #1a2e1f));
  --hint: var(--bale-hint_color, var(--tg-theme-hint-color, #5c6b5f));
  --btn: var(--bale-button_color, var(--tg-theme-button-color, #2d6a4f));
  --btn-text: var(--bale-button_text_color, var(--tg-theme-button-text-color, #fff));
  --secondary: var(--bale-secondary_bg_color, var(--tg-theme-secondary-bg-color, #e8f0eb));
  --border: rgba(45, 106, 79, 0.15);
}

html {
  font-size: 16px;
}

body {
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
  line-height: 1.6;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem 1rem 5rem;
}

.screen {
  display: none;
  animation: fade 0.25s ease;
}

.screen.active {
  display: block;
}

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

.logo {
  text-align: center;
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

h1 {
  font-size: 1.25rem;
  text-align: center;
  margin-bottom: 0.5rem;
  font-weight: 700;
}

.subtitle {
  text-align: center;
  color: var(--hint);
  font-size: 0.92rem;
  margin-bottom: 1.15rem;
}

.welcome-course {
  text-align: center;
  color: var(--btn-dark);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.85rem;
}

.welcome-steps {
  margin: 0 0 0.95rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--secondary);
}

.welcome-steps-title {
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--btn-dark);
  margin-bottom: 0.55rem;
  text-align: center;
}

.welcome-steps-list {
  list-style: none;
  counter-reset: welcome-step;
  display: grid;
  gap: 0.45rem;
}

.welcome-steps-list li {
  counter-increment: welcome-step;
  position: relative;
  padding-right: 1.65rem;
  font-size: 0.84rem;
  color: var(--text);
  line-height: 1.7;
}

.welcome-steps-list li::before {
  content: counter(welcome-step);
  position: absolute;
  right: 0;
  top: 0.1rem;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  background: var(--btn);
  color: var(--btn-text);
  font-size: 0.72rem;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.welcome-notice {
  margin: 0 0 1.15rem;
  padding: 0.95rem 1rem;
  border: 1px solid var(--border-strong);
  border-right: 4px solid var(--accent);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--accent-soft), #fffaf6);
}

.welcome-notice-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 0.55rem;
  text-align: center;
}

.welcome-notice-lead {
  font-size: 0.92rem;
  color: var(--text);
  font-weight: 600;
  line-height: 1.85;
  margin-bottom: 0.65rem;
  text-align: center;
}

.welcome-notice-list {
  list-style: none;
  display: grid;
  gap: 0.55rem;
}

.welcome-notice-list li {
  position: relative;
  padding-right: 1rem;
  font-size: 0.86rem;
  color: var(--text);
  line-height: 1.75;
}

.welcome-notice-list li::before {
  content: '•';
  position: absolute;
  right: 0;
  color: var(--accent);
  font-weight: 800;
}

.welcome-underline {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  text-decoration-color: rgba(214, 90, 49, 0.55);
  font-weight: 700;
}

.btn-welcome-start {
  font-size: 0.95rem;
  line-height: 1.5;
  min-height: 54px;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.progress-wrap {
  margin-bottom: 1rem;
}

.progress-label {
  font-size: 0.8rem;
  color: var(--hint);
  margin-bottom: 0.35rem;
}

.progress-bar {
  height: 6px;
  background: var(--secondary);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--btn);
  border-radius: 3px;
  transition: width 0.3s ease;
  width: 0%;
}

.card {
  background: var(--secondary);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.question-text {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
  line-height: 1.7;
  min-height: 1.5em;
  white-space: pre-line;
}

.quiz-error {
  color: #b42318;
  text-align: center;
  font-size: 0.9rem;
  margin: 0.75rem 0 1rem;
  padding: 0.75rem;
  background: rgba(180, 35, 24, 0.08);
  border-radius: 10px;
}

.quiz-loading {
  text-align: center;
  color: var(--hint);
  font-size: 0.9rem;
  padding: 2rem 1rem;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.option-btn {
  width: 100%;
  text-align: right;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  color: #1a2e1f;
  font-family: inherit;
  font-size: 1.05rem;
  line-height: 1.6;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.option-btn:hover,
.option-btn.selected,
.option-btn:focus-visible {
  border-color: var(--btn);
  background: rgba(45, 106, 79, 0.08);
}

.option-btn:focus-visible {
  outline: 2px solid var(--btn);
  outline-offset: 2px;
}

.screen-form {
  margin: 0;
}

input[type="tel"],
input[type="text"] {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 0.75rem;
}

input:focus {
  outline: none;
  border-color: var(--btn);
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 0.9rem;
  background: var(--btn);
  color: var(--btn-text);
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.5rem;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

a.btn-link {
  text-decoration: none;
  box-sizing: border-box;
}

a.btn-link:hover,
a.btn-link:focus-visible {
  opacity: 0.92;
}

.btn-secondary {
  display: block;
  width: 100%;
  padding: 0.75rem;
  background: transparent;
  color: var(--btn);
  border: 1px solid var(--btn);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  margin-top: 0.5rem;
  text-align: center;
  text-decoration: none;
}

#screen-otp .otp-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

#screen-otp .btn-resend-otp {
  margin-top: 0;
  font-variant-numeric: tabular-nums;
  direction: rtl;
}

#screen-otp .btn-resend-otp:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

#screen-otp .btn-resend-otp.is-expired {
  border-color: #c0392b;
  color: #c0392b;
}

#screen-otp .btn-text-link {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--btn);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.5rem;
  text-align: center;
  text-decoration: underline;
}

#screen-otp .btn-text-link:hover {
  opacity: 0.85;
}

.error-msg {
  color: #c0392b;
  font-size: 0.85rem;
  margin-top: 0.5rem;
  text-align: center;
}

.result-box {
  text-align: center;
  padding: 1.5rem 1rem;
}

.result-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--btn);
  margin-bottom: 1rem;
  white-space: pre-wrap;
}

.result-detail {
  color: var(--text);
  font-size: 1rem;
  line-height: 1.9;
  white-space: pre-line;
  text-align: right;
  margin-bottom: 1rem;
}

.eitaa-join-box {
  text-align: right;
  background: linear-gradient(180deg, #f0faf3 0%, #fff 100%);
  border: 2px solid #c8e6c9;
  border-radius: 14px;
  padding: 1rem 1.1rem;
  margin-top: 0.5rem;
}

.eitaa-join-box.join-box-simple {
  padding: 1.1rem 1rem 0.85rem;
  margin-top: 0.25rem;
  text-align: center;
}

.eitaa-join-box.join-box-simple .join-cta {
  width: 100%;
  font-size: 1.05rem;
  padding: 0.95rem 1rem;
  margin-bottom: 0.35rem;
}

.eitaa-join-box.join-box-simple .join-footnote {
  text-align: center;
  font-size: 0.88rem;
  color: var(--hint);
  margin: 0;
}

.join-stats {
  font-size: 0.95rem;
  color: #1a5c2e;
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  line-height: 1.75;
  margin-bottom: 0.65rem;
}

.join-stats strong {
  color: #0d3d1c;
  font-weight: 800;
}

.join-motivation {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.75;
  margin-bottom: 0.65rem;
}

.join-required {
  font-size: 0.9rem;
  color: #b45309;
  background: #fff8eb;
  border: 1px solid #fcd34d;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  line-height: 1.7;
  margin-bottom: 0.85rem;
}

.join-footnote {
  font-size: 0.82rem;
  color: var(--hint);
  line-height: 1.65;
  margin-top: 0.65rem;
  margin-bottom: 0;
}

.eitaa-join-box .btn-primary.join-cta {
  width: 100%;
  margin-top: 0;
  font-size: 1.05rem;
  padding: 1rem;
}

.standalone-support {
  margin-top: 1.25rem;
  text-align: right;
}

.support-intro {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 0.75rem;
}

.support-channels {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.support-channel-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: right;
}

.support-channel-btn:active {
  background: var(--secondary);
}

.support-channel-btn .channel-meta {
  color: var(--hint);
  font-size: 0.8rem;
  direction: ltr;
  unicode-bidi: plaintext;
}

.mode-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.mode-card {
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  text-align: center;
}

.mode-card strong {
  display: block;
  margin-bottom: 0.25rem;
}

.hidden {
  display: none !important;
}

.app-credit {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  max-width: 480px;
  margin: 0 auto;
  padding: 0.65rem 1rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
  text-align: center;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--hint);
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  pointer-events: none;
}

.app-credit a {
  pointer-events: auto;
  color: var(--btn);
  text-decoration: none;
  font-weight: 600;
}

.app-credit a:hover,
.app-credit a:focus-visible {
  text-decoration: underline;
}

/* ویس — سبک تلگرام */
.voice-bubble {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #2b5278;
  border-radius: 18px 18px 18px 4px;
  padding: 0.85rem 1rem;
  margin: 1rem 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  min-height: 56px;
}

.voice-play-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: #3d8fd1;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: transform 0.15s, opacity 0.15s;
}

.voice-play-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.voice-play-btn:not(:disabled):active {
  transform: scale(0.94);
}

.voice-wave-wrap {
  flex: 1;
  min-width: 0;
}

.voice-wave {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 28px;
  margin-bottom: 0.25rem;
}

.voice-wave .bar {
  flex: 1;
  max-width: 4px;
  min-height: 4px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 2px;
  transition: background 0.1s;
}

.voice-wave .bar.active {
  background: #7ec8ff;
}

.voice-wave.recording .bar {
  animation: voicePulse 0.6s ease-in-out infinite alternate;
}

@keyframes voicePulse {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

.voice-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.75);
}

.voice-status {
  text-align: center;
  color: var(--hint);
  font-size: 0.9rem;
  margin: 0.5rem 0;
}

.voice-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
}

.voice-record-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, #3d8fd1, #2b6cb0);
  color: #fff;
  font-size: 1.75rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(61, 143, 209, 0.45);
  transition: transform 0.15s, box-shadow 0.15s;
}

.voice-record-btn.recording {
  background: linear-gradient(145deg, #e74c3c, #c0392b);
  box-shadow: 0 4px 16px rgba(231, 76, 60, 0.45);
  animation: recordPulse 1.2s ease-in-out infinite;
}

@keyframes recordPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.voice-record-btn:active {
  transform: scale(0.95);
}

#btn-voice-skip {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  border: 2px solid #c8e6c9;
  border-radius: 12px;
  background: #f4fbf6;
  color: #2d6a4f;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}

#btn-voice-skip:hover:not(:disabled) {
  background: #e8f5e9;
  border-color: #95d5b2;
}

#btn-voice-skip:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

#btn-voice-continue:not(:disabled) {
  opacity: 1;
}


.brand-mark {
  width: 96px;
  height: 96px;
  margin: 0 auto 1rem;
  border-radius: 12px;
  display: block;
  overflow: hidden;
  background: transparent;
  box-shadow: 0 10px 24px rgba(34, 35, 38, 0.12);
}

.brand-logo {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  border-radius: 8px;
}

.brand-mark.is-small {
  width: 72px;
  height: 72px;
  margin-bottom: 0.65rem;
  border-radius: 10px;
}


.result-detail {
  color: var(--text);
  font-size: 0.98rem;
  line-height: 1.95;
  white-space: pre-line;
  text-align: right;
  margin-bottom: 1rem;
  padding: 0.95rem;
  background: #fbfaf7;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.result-join-box {
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
}

.result-join-box .btn-primary.join-cta {
  width: 100%;
}

.join-steps {
  display: grid;
  gap: 0.55rem;
  margin: 0.35rem 0 0.9rem;
  text-align: right;
}

.join-steps > div {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.join-steps > div > span {
  flex-shrink: 0;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  background: var(--btn);
  color: var(--btn-text);
  font-size: 0.75rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  margin-top: 0.1rem;
}

.join-steps > div > p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text);
}

.join-copy {
  margin-top: 0.45rem;
}

.join-status {
  margin-top: 0.55rem;
  font-size: 0.86rem;
  text-align: center;
  color: var(--hint);
}

.join-status.is-success {
  color: #1a5c2e;
}

.join-status.is-warning {
  color: #b45309;
}

#btn-join-skip {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--hint);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.5rem;
  text-align: center;
  text-decoration: underline;
}

.join-schedule-box {
  margin: 0 0 1rem;
  padding: 0.95rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfaf7;
  text-align: right;
}

.join-schedule-greeting {
  font-size: 1rem;
  font-weight: 700;
  color: var(--btn);
  margin: 0 0 0.45rem;
  text-align: center;
}

.join-schedule-course {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.75;
  margin: 0 0 0.65rem;
  text-align: center;
}

.join-schedule-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--btn-dark);
  margin: 0 0 0.45rem;
}

.join-schedule-list {
  display: grid;
  gap: 0.35rem;
}

.join-schedule-line {
  font-size: 0.86rem;
  line-height: 1.75;
  color: var(--text);
  margin: 0;
  white-space: pre-wrap;
}

.join-schedule-gap {
  height: 0.45rem;
  margin: 0;
  line-height: 0;
  font-size: 0;
}
