/* ==========================================================================
   iman — оформление
   Палитра: тёмно-зелёное ночное небо, зелёный акцент, полупрозрачные
   «стеклянные» карточки.
   ========================================================================== */

:root {
  --bg-deep:      #040D07;
  --bg-warm:      #14331B;
  --bg-mid:       #09190C;

  /* Фирменный зелёный. Он очень тёмный (светлота 10%), поэтому работает как
     цвет ПОВЕРХ светло-зелёного — на кнопках, аватаре, активной вкладке
     (контраст 4.5–9.1:1). Для текста и иконок на тёмном фоне он даёт 1.42:1
     и не читается: там идут --accent и --accent-soft того же тона (117°). */
  --brand:        #033500;

  --accent:       #4CBF46;
  --accent-soft:  #93E58D;
  --accent-deep:  #3AA835;

  --text:         #FFFFFF;
  --muted:        rgba(255, 255, 255, 0.58);
  --faint:        rgba(255, 255, 255, 0.34);

  --card:         rgba(255, 255, 255, 0.07);
  --card-strong:  rgba(9, 25, 12, 0.82);
  --line:         rgba(255, 255, 255, 0.11);

  --ok:           #55C57A;
  --err:          #FF6B5E;

  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;

  --shell: 480px;
  --tabbar-h: 68px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

/* Атрибут hidden должен побеждать всегда. Без этого правила любой класс с
   собственным display (.field, .row, .btn-block …) перекрывает браузерное
   [hidden] { display: none }, и скрытый элемент остаётся на экране. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-deep);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

/* ------------------------------------------------------------------ фон */

.sky {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(120% 68% at 50% 104%, #1B4A22 0%, transparent 62%),
    linear-gradient(180deg, #102916 0%, var(--bg-mid) 46%, var(--bg-deep) 100%);
}

/* ------------------------------------------------- фотография на главной

   Снимок мечети показывается только на главном экране — класс has-photo
   ставит app.js при переходе на маршрут «#/».

   Устройство слоёв продумано вокруг читаемости. Снимок прижат к низу: здание
   стоит внизу, а сверху остаётся пустое небо, и обратный отсчёт идёт по нему,
   а не по узорам купола. Верхний край фотографии съеден маской, поэтому она
   не обрывается поперёк экрана, а переходит в зелёный градиент неба. */
.sky-photo {
  position: absolute;
  inset: 0;
  background-image: url("img/mosque.jpg");
  background-size: cover;
  background-position: 50% 100%;
  opacity: 0;
  transition: opacity .55s ease;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 15%, #000 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 15%, #000 100%);
}

/* Затемнение и зелёный подмес.
   Снимок бирюзово-золотой, а палитра зелёная — без подмеса он выглядел бы
   вклеенным из другого приложения. Нижняя часть градиента почти непрозрачна:
   под ней лежат карточка времён и прогресс, и узор здания не должен
   просвечивать сквозь цифры. */
.sky-tint {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity .55s ease;
  pointer-events: none;
  background:
    linear-gradient(180deg,
      rgba(4, 13, 7, .52) 0%,
      rgba(4, 13, 7, .34) 22%,
      rgba(4, 13, 7, .10) 46%,
      rgba(4, 13, 7, .58) 72%,
      rgba(4, 13, 7, .92) 100%),
    linear-gradient(180deg,
      rgba(18, 64, 32, .46) 0%,
      rgba(12, 45, 22, .34) 55%,
      rgba(10, 38, 19, .46) 100%);
}

.sky.has-photo .sky-photo,
.sky.has-photo .sky-tint { opacity: 1; }

/* У снимка своё звёздное небо — наши точки поверх него лишние */
.sky.has-photo .sky-stars { opacity: 0; }

/* Свечение у горизонта подсвечивало бы здание снизу вопреки его
   собственному освещению — приглушаем, но не убираем совсем */
.sky.has-photo .sky-glow { opacity: .35; }

/* На широком экране растягивать снимок 416 px во всю ширину нельзя — он
   расплывётся. Держим его в границах той же колонки, что и «телефон». */
@media (min-width: 720px) {
  .sky-photo,
  .sky-tint {
    left: 50%;
    right: auto;
    width: var(--shell);
    transform: translateX(-50%);
  }
}

/* Зелёное свечение у горизонта */
.sky-glow {
  position: absolute;
  left: 50%;
  bottom: -22%;
  width: 150%;
  height: 62%;
  transform: translateX(-50%);
  background: radial-gradient(50% 50% at 50% 50%,
              rgba(76, 191, 70, 0.22) 0%,
              rgba(76, 191, 70, 0.08) 45%,
              transparent 72%);
  filter: blur(6px);
  pointer-events: none;
}

/* Редкие звёзды сверху — точками через повторяющийся градиент */
.sky-stars {
  position: absolute;
  inset: 0 0 45% 0;
  opacity: 0.5;
  background-image:
    radial-gradient(1.4px 1.4px at 18% 22%, rgba(255,255,255,.8), transparent),
    radial-gradient(1.2px 1.2px at 74% 14%, rgba(255,255,255,.7), transparent),
    radial-gradient(1px 1px   at 42% 34%, rgba(255,255,255,.6), transparent),
    radial-gradient(1.3px 1.3px at 88% 40%, rgba(255,255,255,.55), transparent),
    radial-gradient(1px 1px   at 8%  52%, rgba(255,255,255,.5), transparent),
    radial-gradient(1.1px 1.1px at 60% 58%, rgba(255,255,255,.45), transparent);
  pointer-events: none;
}

/* --------------------------------------------------------------- каркас */

.screen {
  position: relative;
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(14px + var(--safe-top)) 18px
           calc(var(--tabbar-h) + 18px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
}

.screen[hidden] { display: none; }

/* На большом экране «телефон» подсвечиваем мягкой рамкой */
@media (min-width: 720px) {
  .screen {
    min-height: 100dvh;
    border-left: 1px solid rgba(255,255,255,.06);
    border-right: 1px solid rgba(255,255,255,.06);
    background: rgba(255, 255, 255, 0.012);
  }
}

/* ------------------------------------------------------------ типовые */

.btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 14px 20px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  background: var(--card);
  cursor: pointer;
  transition: transform .12s ease, background .18s ease, opacity .18s ease;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .55; cursor: default; }

.btn-primary {
  background: linear-gradient(180deg, var(--accent-soft), var(--accent-deep));
  color: var(--brand);
  box-shadow: 0 8px 24px rgba(58, 168, 53, .30);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.05); }

.btn-ghost {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
}
.btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,.11); }

.btn-danger { background: rgba(255, 107, 94, .16); color: #FF8F84; }
.btn-danger:hover { background: rgba(255, 107, 94, .24); }

.btn-block { display: block; width: 100%; }
.btn-sm { padding: 11px 16px; font-size: 14px; }

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  flex: 0 0 auto;
}
.icon-btn:hover { background: rgba(255,255,255,.14); }
.icon-btn-ghost { background: transparent; pointer-events: none; }

.text-btn {
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 4px;
}

.field { display: block; margin-bottom: 14px; }

.field-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 7px;
}

.field input,
.field textarea {
  width: 100%;
  padding: 13px 15px;
  font: inherit;
  font-size: 16px; /* 16px — иначе iOS зумит страницу при фокусе */
  color: var(--text);
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  transition: border-color .18s ease, background .18s ease;
}
.field input::placeholder,
.field textarea::placeholder { color: var(--faint); }

.field input:focus,
.field textarea:focus {
  border-color: rgba(76, 191, 70, .65);
  background: rgba(255,255,255,.09);
}

.field textarea { resize: vertical; min-height: 110px; line-height: 1.5; }

.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Пояснение под полем ввода */
.field-hint {
  display: block;
  margin-top: 7px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--faint);
}

.form-msg {
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 14px;
  margin-bottom: 14px;
  line-height: 1.45;
}
.form-msg.is-err { background: rgba(255,107,94,.14); color: #FF9086; }
.form-msg.is-ok  { background: rgba(85,197,122,.14); color: #7FD79B; }
.form-msg[hidden] { display: none; }

/* ----------------------------------------------------------- вход */

.screen-auth { justify-content: center; padding-bottom: calc(24px + var(--safe-bottom)); }

.auth-wrap { width: 100%; margin: auto 0; }

.auth-logo { text-align: center; margin-bottom: 26px; }
.auth-logo img { display: block; margin: 0 auto 12px; }
.auth-logo h1 {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: .01em;
}
.auth-sub { margin: 6px 0 0; color: var(--muted); font-size: 15px; }

.auth-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 18px;
  background: rgba(0,0,0,.28);
  border-radius: 14px;
}
.seg-btn {
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 10px;
  border-radius: 11px;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.seg-btn.is-active { background: var(--card); color: var(--text); }

.auth-divider {
  position: relative;
  text-align: center;
  margin: 18px 0 14px;
  color: var(--faint);
  font-size: 13px;
}
.auth-divider::before {
  content: "";
  position: absolute;
  inset: 50% 0 auto;
  height: 1px;
  background: var(--line);
}
.auth-divider span { position: relative; background: #0E2412; padding: 0 12px; }

.auth-note {
  margin: 14px 2px 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--faint);
  text-align: center;
}

/* ------------------------------------------------------ главный экран */

.home-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 7px 7px;
  border: 0;
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  max-width: 60%;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.chip span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip-avatar {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--accent-soft), var(--accent-deep));
  color: var(--brand);
  flex: 0 0 auto;
}

.place {
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: right;
  cursor: pointer;
  padding: 6px 0;
}
.place-city {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  font-size: 15px;
  font-weight: 600;
}
.place-date { display: block; font-size: 12.5px; color: var(--muted); margin-top: 3px; }

.home-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 22px 0;
}

.next-line {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}
.next-label { color: var(--text); }
.next-icon { display: inline-flex; }
.next-icon svg { display: block; }
.next-dot { color: var(--faint); }
.next-time { color: var(--text); }

.countdown {
  font-size: clamp(46px, 15vw, 66px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 4px 30px rgba(0,0,0,.45);
}

.clock-now {
  margin-top: 8px;
  font-size: 15px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.home-bottom { display: flex; flex-direction: column; gap: 12px; }

/* Строка шести времён */
.times-card {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  padding: 14px 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.time-cell {
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  padding: 6px 2px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transition: background .18s ease;
}
.time-cell:hover { background: rgba(255,255,255,.07); }

/* Иконка. Неактивная — серая (цвет идёт в currentColor), активная
   заливается своим градиентом прямо в SVG. */
.time-cell .t-icon {
  height: 26px;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, .42);
}
.time-cell .t-icon svg { display: block; }

/* Индикатор под иконкой: у неактивных точка, у активного полоска,
   которая заполняется от начала времени до начала следующего. */
.time-cell .t-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .28);
}

.time-cell .t-bar {
  width: 78%;
  max-width: 34px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .22);
  overflow: hidden;
}
.time-cell .t-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width .9s linear;
}

.time-cell .t-value {
  font-size: clamp(12px, 3.6vw, 15px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, .82);
}
.time-cell .t-name {
  font-size: clamp(9.5px, 2.9vw, 11.5px);
  color: var(--muted);
}

/* Идёт сейчас: время и название подсвечены */
.time-cell.is-active .t-value { color: var(--text); }
.time-cell.is-active .t-name { color: var(--accent); }

.time-cell.is-edited .t-value::after {
  content: "•";
  color: var(--accent);
  margin-left: 2px;
}

/* Прогресс намазов */
.progress-card {
  padding: 15px 16px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.progress-title { font-size: 14px; font-weight: 600; }
.progress-count { font-size: 13px; color: var(--accent); font-weight: 700; }

.progress-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,.10);
  overflow: hidden;
  margin-bottom: 13px;
}
.progress-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-soft), var(--accent-deep));
  transition: width .35s ease;
}

.progress-marks { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }

.mark {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  padding: 9px 2px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transition: all .18s ease;
}
.mark .mark-box {
  width: 19px; height: 19px;
  border-radius: 50%;
  border: 1.6px solid var(--faint);
  display: grid; place-items: center;
}
.mark.is-done {
  background: rgba(76,191,70,.16);
  border-color: rgba(76,191,70,.45);
  color: var(--accent);
}
.mark.is-done .mark-box {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--brand);
}
.mark:disabled { opacity: .5; cursor: default; }

.progress-praise {
  margin-top: 12px;
  font-size: 13px;
  color: var(--accent-soft);
  text-align: center;
  min-height: 18px;
}

.streak-badge {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

/* ------------------------------------------------ календарь прогресса

   Завершённый день закрашен акцентом, под числом — сколько намазов закрыто.
   Сегодняшний день только обведён: он ещё идёт и закрасится, когда
   закончится. Цифры на закрашенном дне идут фирменным --brand: на светло
   -зелёном он даёт 5.9:1, тогда как белый — всего 2.4:1. */

.calendar-card {
  padding: 15px 16px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.cal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 13px;
}
.cal-month { font-size: 15.5px; font-weight: 700; }

.cal-nav {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .05);
  color: var(--text);
  cursor: pointer;
  flex: 0 0 auto;
  transition: background .18s ease, opacity .18s ease;
}
.cal-nav:hover:not(:disabled) { background: rgba(255, 255, 255, .12); }
.cal-nav:disabled { opacity: .28; cursor: default; }

.cal-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 14px; }

.cal-tile {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, .04);
  text-align: center;
}
.cal-tile-icon { display: block; color: var(--accent); margin-bottom: 5px; }
.cal-tile-icon svg { display: inline-block; vertical-align: middle; }
.cal-tile-value {
  display: block;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.cal-tile-label { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }

.cal-week,
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }

.cal-week { margin-bottom: 6px; }
.cal-week span { text-align: center; font-size: 10.5px; color: var(--faint); }

.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}
.cal-num { font-size: 12.5px; font-weight: 600; color: rgba(255, 255, 255, .80); }
.cal-count { font-size: 9px; font-weight: 700; color: var(--muted); line-height: 1; }

.cal-day.is-done { background: var(--accent); border-color: var(--accent); }
.cal-day.is-done .cal-num,
.cal-day.is-done .cal-count { color: var(--brand); }

/* Сегодня — обводка вместо заливки */
.cal-day.is-today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-day.is-today .cal-num { color: var(--accent); }
.cal-day.is-today .cal-count { color: var(--accent-soft); }

/* Дни до регистрации: у человека их ещё не было */
.cal-day.is-before { opacity: .26; }

.guest-hint {
  padding: 14px 16px;
  background: rgba(76,191,70,.10);
  border: 1px solid rgba(76,191,70,.24);
  border-radius: var(--r-md);
}
.guest-hint p { margin: 0 0 11px; font-size: 13px; line-height: 1.5; color: var(--accent-soft); }

/* ------------------------------------------------------ листы-экраны */

.screen-sheet { padding-top: calc(8px + var(--safe-top)); }

.sheet-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0 16px;
}
.sheet-top h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  flex: 1;
}

.sheet-body { flex: 1; }

.sheet-note {
  margin: 16px 2px 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--faint);
  text-align: center;
}
.sheet-note-top { margin: 0 2px 18px; text-align: left; }

/* Барабаны времени — как в будильнике */
.wheel {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 210px;
  margin: 6px 0 22px;
  overflow: hidden;
  /* края барабана растворяются — эффект цилиндра */
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 26%, #000 74%, transparent);
  mask-image: linear-gradient(180deg, transparent, #000 26%, #000 74%, transparent);
}

.wheel-highlight {
  position: absolute;
  left: 8px; right: 8px;
  top: 50%;
  height: 54px;
  transform: translateY(-50%);
  border-radius: 14px;
  background: rgba(255,255,255,.07);
  pointer-events: none;
}

.wheel-col {
  height: 100%;
  width: 92px;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  outline: none;
  /* сверху и снизу — пустое место, чтобы первый и последний пункт
     могли встать по центру */
  padding: 78px 0;
}
.wheel-col::-webkit-scrollbar { display: none; }

.wheel-item {
  height: 54px;
  scroll-snap-align: center;
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--faint);
  transition: color .18s ease, transform .18s ease;
}
.wheel-item.is-current { color: var(--text); transform: scale(1.06); }

.wheel-sep {
  font-size: 30px;
  font-weight: 600;
  color: var(--text);
  padding-bottom: 3px;
}

.edit-rows {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  margin-bottom: 16px;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row-label { font-size: 14.5px; }
.row-value { font-size: 14.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row-switch { cursor: pointer; }

/* Переключатель */
.switch {
  appearance: none;
  width: 46px; height: 28px;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
  position: relative;
  cursor: pointer;
  transition: background .22s ease;
  flex: 0 0 auto;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform .22s ease;
}
.switch:checked { background: var(--accent-deep); }
.switch:checked::after { transform: translateX(18px); }

.or-line {
  position: relative;
  text-align: center;
  margin: 22px 0 16px;
  font-size: 12.5px;
  color: var(--faint);
}
.or-line::before {
  content: "";
  position: absolute;
  inset: 50% 0 auto;
  height: 1px;
  background: var(--line);
}
.or-line span { position: relative; background: #0A1A0D; padding: 0 12px; }

/* ---------------------------------------------------------- компас */

.screen-qibla .qibla-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 4px;
}

/* ------------------------------------------------------------- компас

   Устройство повторяет приложение-образец:
   - круг с михрабом в центре стоит неподвижно;
   - метка Каабы едет по кольцу и показывает, куда поворачиваться;
   - в ту же сторону от центра бьёт луч света;
   - когда метка доходит до верха, всё загорается оранжевым.

   Углом управляет переменная --aim: её выставляет JavaScript. */

.compass {
  --aim: 0deg;
  position: relative;
  width: min(74vw, 52vh, 280px);
  aspect-ratio: 1;
  margin-bottom: 26px;
  /* Луч выходит далеко за круг, обрезать его нельзя */
  overflow: visible;
}

/* Луч света от центра в сторону Каабы */
.compass-beam {
  position: absolute;
  inset: 0;
  transform: rotate(var(--aim));
  transition: transform .45s cubic-bezier(.22,.61,.36,1);
  pointer-events: none;
  z-index: 0;
}

.compass-beam::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 50%;
  width: 190%;
  height: 165%;
  transform: translateX(-50%);
  /* Треугольник с вершиной в центре круга, расширяется наружу */
  clip-path: polygon(50% 100%, 20% 0, 80% 0);
  background: linear-gradient(to top,
              rgba(255, 255, 255, .26) 0%,
              rgba(255, 255, 255, .10) 38%,
              rgba(255, 255, 255, 0) 76%);
  filter: blur(10px);
  opacity: .85;
  transition: background .4s ease, opacity .4s ease;
}

.compass-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .34);
  background: radial-gradient(circle at 50% 38%,
              rgba(255, 255, 255, .06), rgba(0, 0, 0, .55));
  box-shadow: inset 0 0 40px rgba(0, 0, 0, .55);
  display: grid;
  place-items: center;
  z-index: 1;
  transition: border-color .4s ease, box-shadow .4s ease;
}

/* Михраб в центре — он не вращается, это «вы» */
.compass-mihrab {
  width: 34%;
  color: rgba(255, 255, 255, .62);
  transition: color .4s ease;
}
.compass-mihrab svg { display: block; }

/* Обойма поворачивается на угол до Каабы */
.compass-orbit {
  position: absolute;
  inset: 0;
  transform: rotate(var(--aim));
  transition: transform .45s cubic-bezier(.22,.61,.36,1);
  z-index: 2;
  pointer-events: none;
}

/* Метка сидит на кольце сверху обоймы и повёрнута обратно,
   чтобы значок Каабы не оказался вверх ногами */
.compass-kaaba {
  position: absolute;
  top: -19px;
  left: 50%;
  width: 38px;
  height: 38px;
  margin-left: -19px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #2A2A2A;
  color: rgba(255, 255, 255, .55);
  border: 2px solid rgba(255, 255, 255, .22);
  transform: rotate(calc(-1 * var(--aim)));
  transition: transform .45s cubic-bezier(.22,.61,.36,1),
              background .4s ease, color .4s ease, border-color .4s ease;
}

/* --- повернулись на Каабу: всё загорается --- */

.compass.is-aimed .compass-ring {
  border-color: var(--accent);
  box-shadow: 0 0 46px rgba(76, 191, 70, .30), inset 0 0 40px rgba(0, 0, 0, .5);
}
.compass.is-aimed .compass-mihrab { color: var(--accent); }
.compass.is-aimed .compass-kaaba {
  background: #06210D;
  color: var(--accent);
  border-color: var(--accent);
}
.compass.is-aimed .compass-beam::before {
  background: linear-gradient(to top,
              rgba(76, 191, 70, .55) 0%,
              rgba(76, 191, 70, .24) 40%,
              rgba(76, 191, 70, 0) 78%);
  opacity: 1;
}

/* Пока датчик не включён, луч не показываем: направление «от севера»
   без компаса телефона ни на что в комнате не указывает. */
.compass.no-sensor .compass-beam { opacity: 0; }

/* С датчиком метка должна следовать за телефоном без заметной задержки */
.compass.is-live .compass-beam,
.compass.is-live .compass-orbit,
.compass.is-live .compass-kaaba {
  transition-duration: .12s;
  transition-timing-function: linear;
}

.qibla-facing {
  margin-top: 4px;
  font-size: 13px;
  color: var(--accent-soft);
  font-variant-numeric: tabular-nums;
}

/* Когда человек повернулся точно на Каабу — подсказка загорается зелёным */
.qibla-pill.is-on-target {
  background: rgba(85, 197, 122, .16);
  border-color: rgba(85, 197, 122, .45);
  color: #8FDCA6;
}

.qibla-name { margin: 0; font-size: 27px; font-weight: 700; }
.qibla-angle { font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; }

.qibla-pill {
  margin-top: 14px;
  display: inline-block;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--text);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.qibla-meta { margin-top: 10px; font-size: 12.5px; color: var(--faint); }

/* --------------------------------------------------------- письмо */

.letter-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-top: 18px;
}
.letter-title { margin: 0; font-size: 30px; font-weight: 700; text-align: center; }
.letter-sub {
  margin: 7px 0 26px;
  font-size: 15px;
  color: var(--muted);
  text-align: center;
}

.radio-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }

.radio {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.04);
  font-size: 14px;
  cursor: pointer;
  transition: all .18s ease;
}
.radio input { position: absolute; opacity: 0; pointer-events: none; }
.radio-dot {
  width: 19px; height: 19px;
  border-radius: 50%;
  border: 1.8px solid var(--faint);
  position: relative;
  flex: 0 0 auto;
  transition: border-color .18s ease;
}
.radio-dot::after {
  content: "";
  position: absolute;
  inset: 3.4px;
  border-radius: 50%;
  background: var(--accent);
  transform: scale(0);
  transition: transform .18s ease;
}
.radio:has(input:checked) {
  border-color: rgba(76,191,70,.5);
  background: rgba(76,191,70,.11);
}
.radio:has(input:checked) .radio-dot { border-color: var(--accent); }
.radio:has(input:checked) .radio-dot::after { transform: scale(1); }

/* ---------------------------------------------------- нижние вкладки */

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--shell);
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(6, 18, 9, .82);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  z-index: 40;
}
.tabbar[hidden] { display: none; }

.tab {
  border: 0;
  background: none;
  color: var(--faint);
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: color .18s ease;
}
.tab.is-active { color: var(--accent); }
.tab:active { transform: scale(.95); }

/* ------------------------------------------------------------ прочее */

.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 22px + var(--safe-bottom));
  transform: translateX(-50%);
  width: min(92vw, 420px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
  pointer-events: none;
}

.toast {
  padding: 13px 17px;
  border-radius: 15px;
  background: rgba(12, 32, 17, .95);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  box-shadow: 0 12px 34px rgba(0,0,0,.45);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  animation: toast-in .26s cubic-bezier(.2,.8,.3,1);
}
.toast.is-ok  { border-color: rgba(85,197,122,.4); }
.toast.is-err { border-color: rgba(255,107,94,.45); }
.toast.is-out { animation: toast-out .26s ease forwards; }

@keyframes toast-in  { from { opacity: 0; transform: translateY(14px); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(10px); } }

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: end center;
}
.modal[hidden] { display: none; }

.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); }

.modal-card {
  position: relative;
  width: 100%;
  max-width: var(--shell);
  padding: 20px 18px calc(24px + var(--safe-bottom));
  background: #0D2312;
  border: 1px solid var(--line);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: sheet-up .28s cubic-bezier(.2,.8,.3,1);
}
@keyframes sheet-up { from { transform: translateY(100%); } }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 6px;
}
.modal-head strong { font-size: 18px; }

.badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(76,191,70,.16);
  color: var(--accent);
}

.modal-rows { display: flex; flex-direction: column; gap: 1px; margin-bottom: 6px; }
.modal-rows .row { border-radius: 0; background: var(--card); }
.modal-rows .row:first-child { border-radius: var(--r-sm) var(--r-sm) 0 0; }
.modal-rows .row:last-child  { border-radius: 0 0 var(--r-sm) var(--r-sm); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ==========================================================================
   Адаптация под размеры экранов
   ========================================================================== */

/* Низкие экраны: телефон в альбомной ориентации, маленькие устройства,
   браузер с большой панелью инструментов. Без этого главный экран занимает
   629 px в окне высотой 375 и уезжает под нижнюю панель. Ничего не прячем —
   только ужимаем отступы и шрифты, чтобы всё помещалось целиком. */
@media (max-height: 580px) {
  :root { --tabbar-h: 54px; }

  /* На низком экране светлый купол приходится ровно под обратный отсчёт, и
     белые цифры на нём теряются. Затемняем снимок сильнее и равномернее:
     разглядывать здание тут всё равно некогда, а время читать нужно. */
  .sky.has-photo .sky-tint {
    background:
      linear-gradient(180deg,
        rgba(4, 13, 7, .62) 0%,
        rgba(4, 13, 7, .54) 42%,
        rgba(4, 13, 7, .78) 78%,
        rgba(4, 13, 7, .94) 100%),
      linear-gradient(180deg,
        rgba(14, 52, 26, .50) 0%,
        rgba(10, 38, 19, .50) 100%);
  }

  .screen { padding-top: calc(8px + var(--safe-top)); }

  .home-center { padding: 8px 0; }
  .next-line { font-size: 13px; margin-bottom: 2px; gap: 5px; }
  .countdown { font-size: clamp(32px, 11vh, 46px); }
  .clock-now { font-size: 12.5px; margin-top: 4px; }

  .home-bottom { gap: 8px; }
  .times-card { padding: 9px 4px; }
  .time-cell { gap: 3px; padding: 4px 2px; }
  .time-cell .t-icon { height: 21px; }
  .time-cell .t-icon svg { width: 20px; height: 20px; }

  .progress-card { padding: 10px 12px 11px; }
  .progress-head { margin-bottom: 7px; }
  .progress-bar { height: 5px; margin-bottom: 9px; }
  .mark { padding: 6px 2px; gap: 3px; }
  .mark .mark-box { width: 16px; height: 16px; }
  .progress-praise { margin-top: 8px; font-size: 12px; }

  .compass { margin-bottom: 12px; }
  .qibla-name { font-size: 21px; }
  .qibla-angle { font-size: 13px; }
  .qibla-pill { margin-top: 8px; padding: 7px 14px; font-size: 12.5px; }

  /* Барабаны времени: высоту меняем вместе с отступами, иначе выбранное
     значение перестанет попадать в подсветку. Высота пункта (54 px)
     остаётся прежней — она же зашита в app.js как ITEM_H. */
  .wheel { height: 150px; margin: 2px 0 14px; }
  .wheel-col { padding: 48px 0; }

  .letter-body { padding-top: 6px; }
  .letter-title { font-size: 23px; }
  .letter-sub { margin: 5px 0 14px; }
  .field { margin-bottom: 10px; }
  .field textarea { min-height: 80px; }

  .tab { font-size: 10px; gap: 2px; }
  .tab svg { width: 21px; height: 21px; }
}

/* Совсем узкие телефоны: 320 px и уже. Строка из шести времён там самая
   уязвимая — ужимаем её отдельно. */
@media (max-width: 340px) {
  .screen { padding-left: 12px; padding-right: 12px; }
  .times-card { padding: 12px 2px; gap: 0; }
  .time-cell { padding: 5px 0; }
  .time-cell .t-icon svg { width: 19px; height: 19px; }
  .progress-marks { gap: 4px; }
  .mark { font-size: 10px; }
  .chip { max-width: 54%; font-size: 14px; }
}

/* Планшеты и большие телефоны: колонка остаётся телефонной ширины,
   но воздуха можно дать больше. */
@media (min-width: 600px) and (min-height: 700px) {
  .compass { width: min(62vw, 46vh, 300px); }
  .countdown { font-size: 70px; }
}

/* Телефон в альбомной ориентации: у экрана компаса вся высота уходит на
   круг, поэтому подписи убираем вбок, а не под него. */
@media (max-height: 500px) and (orientation: landscape) {
  .screen-qibla .qibla-body {
    flex-direction: row;
    justify-content: center;
    gap: 22px;
    flex-wrap: wrap;
  }
  .compass { margin-bottom: 0; }
  .screen-qibla .qibla-body > :not(.compass) { max-width: 46%; }
}

/* Устройства без точного указателя (пальцем): цели должны быть крупнее. */
@media (hover: none) and (pointer: coarse) {
  .time-cell { min-height: 62px; }
  .tab { min-height: 48px; }
}
