/* ==========================================================================
   Мини-апп «Задать вопрос»
   Цвета берутся из темы Telegram, поэтому работает и в светлой, и в тёмной.
   ========================================================================== */

:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg-secondary: var(--tg-theme-secondary-bg-color, #f2f3f7);
  --text: var(--tg-theme-text-color, #16181d);
  --hint: var(--tg-theme-hint-color, #8b8f9a);
  --link: var(--tg-theme-link-color, #2f7ce0);
  --button: var(--tg-theme-button-color, #2f7ce0);
  --button-text: var(--tg-theme-button-text-color, #ffffff);

  --warn: #e8912d;
  --warn-soft: rgba(232, 145, 45, .12);
  --stop: #e5484d;
  --stop-soft: rgba(229, 72, 77, .11);
  --ok: #2f9e44;
  --ok-soft: rgba(47, 158, 68, .12);

  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 10px 30px rgba(0, 0, 0, .07);
}

@media (prefers-color-scheme: dark) {
  :root {
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg-secondary);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------------------------------------------------------------- Шапка -- */

.hero {
  text-align: center;
  padding: 8px 4px 2px;
}

.hero__icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--button-text);
  background: linear-gradient(135deg, var(--button), color-mix(in srgb, var(--button) 65%, #7b5cff));
  box-shadow: 0 8px 20px color-mix(in srgb, var(--button) 35%, transparent);
}

.hero__icon svg { width: 26px; height: 26px; }

.hero__title {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.hero__subtitle {
  margin: 0;
  color: var(--hint);
  font-size: 14px;
}

/* Кнопка перехода в админку — видна только администраторам */
.adminlink {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--button-text);
  background: var(--button);
  border-radius: 999px;
  text-decoration: none;
}

.adminlink:active { opacity: .85; }

/* hidden должен побеждать display: inline-block */
.adminlink[hidden] { display: none; }

/* ------------------------------------------------------------ Аккордеон -- */

.accordion {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1.5px solid color-mix(in srgb, var(--warn) 28%, transparent);
}

.accordion__toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 16px;
  font: inherit;
  color: inherit;
  text-align: left;
  /* Ровная заливка без градиента: диагональный переход давал резкую
     границу справа и выглядел как артефакт. */
  background: var(--bg);
  border: 0;
  cursor: pointer;
  transition: background .15s ease;
}

.accordion__toggle:active { background: var(--bg-secondary); }

.accordion__badge {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--warn);
  background: var(--warn-soft);
}

.accordion__badge svg { width: 19px; height: 19px; }

.accordion__text {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.accordion__title {
  font-weight: 600;
  font-size: 15px;
}

.accordion__hint {
  color: var(--hint);
  font-size: 12.5px;
}

.accordion__chevron {
  flex: 0 0 auto;
  color: var(--hint);
  display: grid;
  place-items: center;
  transition: transform .25s ease;
}

.accordion__chevron svg { width: 20px; height: 20px; }

.accordion__toggle[aria-expanded="true"] .accordion__chevron {
  transform: rotate(180deg);
}

/* Плавное раскрытие через grid-template-rows */
.accordion__panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .3s ease;
}

.accordion__panel.is-open { grid-template-rows: 1fr; }

.accordion__inner {
  overflow: hidden;
  min-height: 0;
}

.accordion__panel.is-open .accordion__inner {
  padding: 0 16px 16px;
}

/* ------------------------------------------------------------ Заметки --- */

.note {
  display: flex;
  gap: 11px;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
}

.note:first-child { margin-top: 4px; }

.note__icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.note__icon svg { width: 100%; height: 100%; }

.note strong {
  display: block;
  font-size: 14.5px;
  margin-bottom: 3px;
}

.note p {
  margin: 0;
  font-size: 13.5px;
  color: var(--hint);
}

.note p + p,
.note .chips + p,
.note p + .chips { margin-top: 8px; }

/* Пояснение между двумя группами чипов.
   Намеренно без яркого текста: белые вставки на цветном фоне выглядели
   инородно, поэтому выделяем полужирным, а не цветом. */
.note__sub {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--hint);
}

.note__sub b {
  font-weight: 600;
  color: inherit;
  opacity: .95;
}

.note__foot {
  font-size: 12.5px !important;
  font-style: italic;
}

.note--warn { background: var(--warn-soft); }
.note--warn .note__icon { color: var(--warn); }
.note--warn strong { color: var(--warn); }

.note--stop { background: var(--stop-soft); }
.note--stop .note__icon { color: var(--stop); }
.note--stop strong { color: var(--stop); }

.note--ok { background: var(--ok-soft); }
.note--ok .note__icon { color: var(--ok); }
.note--ok strong { color: var(--ok); }

/* ------------------------------------------------------------- Чипы ----- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--stop);
  background: color-mix(in srgb, var(--stop) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--stop) 30%, transparent);
}

.chip--ok {
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 15%, transparent);
  border-color: color-mix(in srgb, var(--ok) 30%, transparent);
}

/* ------------------------------------------------------------ Шаги ------ */

.steps {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--bg-secondary);
}

.steps__title {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
}

.steps__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.steps__list li {
  display: flex;
  gap: 10px;
  font-size: 13.5px;
  color: var(--hint);
}

.steps__list li b { color: var(--text); }

.steps__num {
  flex: 0 0 auto;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--button-text);
  background: var(--button);
  margin-top: 1px;
}

code {
  padding: 1px 6px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  color: var(--text);
  background: var(--bg-secondary);
}

.example {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 12.5px;
  font-style: italic;
  color: var(--text);
  background: var(--bg-secondary);
}

.steps__done {
  margin: 12px 0 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ok);
}

/* ------------------------------------------------------------ Форма ----- */

.composer {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.composer__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.composer__label {
  font-weight: 600;
  font-size: 14.5px;
}

.composer__counter {
  font-size: 12.5px;
  color: var(--hint);
  font-variant-numeric: tabular-nums;
}

.composer__counter.near-limit {
  color: var(--stop);
  font-weight: 600;
}

textarea {
  width: 100%;
  padding: 13px 14px;
  font: inherit;
  font-size: 14.5px;
  color: var(--text);
  background: var(--bg-secondary);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  resize: vertical;
  min-height: 150px;
  outline: none;
  transition: border-color .15s ease, background .15s ease;
}

textarea::placeholder { color: var(--hint); }
textarea:focus { border-color: var(--button); }

.btn {
  width: 100%;
  margin-top: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font: inherit;
  font-size: 15.5px;
  font-weight: 600;
  color: var(--button-text);
  background: var(--button);
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity .15s ease, transform .1s ease;
}

.btn__icon { display: grid; place-items: center; }
.btn__icon svg { width: 17px; height: 17px; }

.btn:disabled { opacity: .55; cursor: default; }
.btn:not(:disabled):active { transform: scale(.985); opacity: .9; }

/* ----------------------------------------------------------- Статус ----- */

.status {
  margin: 0;
  padding: 0 4px;
  font-size: 13.5px;
  text-align: center;
  min-height: 0;
}

.status:empty { display: none; }

.status.error,
.status.success {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
}

.status.error {
  color: var(--stop);
  background: var(--stop-soft);
}

.status.success {
  color: var(--ok);
  background: var(--ok-soft);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Уважаем настройку «меньше движения» */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
