:root {
  --canvas:   var(--tg-theme-bg-color, #ffffff);
  --surface:  var(--tg-theme-secondary-bg-color, #f2f4f7);
  --surface-2: var(--tg-theme-section-bg-color, #ffffff);
  --text:     var(--tg-theme-text-color, #14181f);
  --text-2:   var(--tg-theme-subtitle-text-color, #67707c);
  --line:     var(--tg-theme-section-separator-color, #dfe3e8);
  --link:     var(--tg-theme-link-color, #17608f);
  --danger:   var(--tg-theme-destructive-text-color, #b3261e);
  --ok:       #1f6b45;
  --ok-tint:  #e4f2ea;
  --btn:      #17608f;
  --btn-text: #ffffff;
  --stroke:   #8a929c;
  --now-text: #0f2c1c;
  --now-bg:   #dcede2;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas:   var(--tg-theme-bg-color, #17212b);
    --surface:  var(--tg-theme-secondary-bg-color, #1e2a38);
    --surface-2: var(--tg-theme-section-bg-color, #17212b);
    --text:     var(--tg-theme-text-color, #f2f5f8);
    --text-2:   var(--tg-theme-subtitle-text-color, #93a2b1);
    --line:     var(--tg-theme-section-separator-color, #2c3a4a);
    --link:     var(--tg-theme-link-color, #62bcf9);
    --danger:   var(--tg-theme-destructive-text-color, #ff6b6b);
    --ok:       #7fd6a4;
    --ok-tint:  #16301f;
    --btn:      #7fd6a4;
    --btn-text: #0b2016;
    --stroke:   #6b7f92;
    --now-text: #b9e8cd;
    --now-bg:   #14301f;
  }
}

* {
  box-sizing: border-box;
}

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 24px;
  font-variant-numeric: tabular-nums;
}

.app {
  max-width: 30rem;
  margin-inline: auto;
  padding: calc(12px + var(--tg-content-safe-area-inset-top, 0px)) 16px
    calc(16px + var(--tg-safe-area-inset-bottom, 0px));
}

h1 {
  font-size: 20px;
  line-height: 26px;
  font-weight: 600;
  margin: 4px 0 12px;
}

/* --- Навигация: две вкладки, обе цели не меньше 44px (§5). ------------- */
.nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
}

.tab[aria-selected="true"] {
  background: var(--surface);
  border-color: transparent;
}

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

/* --- Столбик времени: экран «День» -------------------------------------- */
.table {
  border-top: 1px solid var(--line);
}

.row {
  display: grid;
  grid-template-columns: 62px 92px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
}

.row .time {
  font-size: 19px;
  font-weight: 500;
}

.row .time.empty {
  visibility: hidden;
}

.row .name {
  font-size: 19px;
  font-weight: 500;
}

.row .state {
  font-size: 15px;
  line-height: 21px;
  color: var(--text-2);
}

.row.now {
  background: var(--now-bg);
  color: var(--now-text);
  border-radius: 10px;
  padding-left: 8px;
  padding-right: 8px;
}

.row.now .state {
  color: var(--now-text);
}

.row.now .time, .row.now .name {
  font-weight: 600;
}

.ask {
  font-size: 17px;
  line-height: 24px;
  font-weight: 500;
  padding: 20px 4px 12px;
}

.answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* --- Общие кнопки (§8): одна главная на экран. -------------------------- */
.btn {
  min-height: 48px;
  border-radius: 12px;
  border: none;
  font: inherit;
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 100ms cubic-bezier(0.2, 0, 0, 1);
}

.btn:active {
  transform: scale(0.98);
}

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

.btn.primary {
  background: var(--btn);
  color: var(--btn-text);
}

.btn.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--stroke);
}

.btn[disabled] {
  opacity: 0.45;
  cursor: default;
}

.link-row {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  background: transparent;
  border: none;
  padding: 12px 4px;
  font: inherit;
  font-size: 17px;
  color: var(--link);
  text-align: left;
  cursor: pointer;
}

.link-row:focus-visible {
  outline: 2px solid var(--ok);
  outline-offset: -2px;
}

/* --- Экран «Каза»: разбивка по намазам, темп. ---------------------------- */
.lead {
  font-size: 19px;
  line-height: 26px;
  font-weight: 600;
  margin-bottom: 6px;
}

.sub {
  font-size: 15px;
  line-height: 21px;
  color: var(--text-2);
  margin-bottom: 4px;
}

.today-line {
  display: inline-block;
  margin: 10px 0 16px;
  background: var(--ok-tint);
  color: var(--ok);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 15px;
  line-height: 21px;
  font-weight: 500;
}

.hint {
  font-size: 15px;
  line-height: 21px;
  color: var(--text-2);
  margin-bottom: 8px;
}

.trow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  border-left: none;
  border-right: none;
  border-top: none;
  color: var(--text);
  font: inherit;
  font-size: 17px;
  text-align: left;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background-color 150ms cubic-bezier(0.2, 0, 0, 1);
}

.trow:active {
  background: rgba(127, 127, 127, 0.16);
}

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

.trow .name {
  font-weight: 500;
}

.trow .rest {
  font-weight: 600;
}

.trow .act {
  color: var(--text-2);
  font-weight: 400;
  padding-left: 10px;
}

/* --- Строка-линейка (задача `10.6`): «История», «Приглашения» ----------- */
.hrow {
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  line-height: 21px;
}

.pace {
  background: var(--surface);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
}

.pace h2 {
  font-size: 15px;
  line-height: 21px;
  font-weight: 600;
  margin: 0 0 8px;
}

.pace p {
  font-size: 15px;
  line-height: 21px;
  margin: 0 0 6px;
}

.pace .note {
  color: var(--text-2);
  margin: 10px 0 0;
}

.witr {
  font-size: 15px;
  line-height: 21px;
  color: var(--text-2);
  margin-bottom: 16px;
}

.undo {
  margin-top: 4px;
}

.undo .note {
  font-size: 15px;
  line-height: 21px;
  color: var(--text-2);
  margin: 0 0 4px;
}

/* --- Состояния экрана (§9): скелетон, пусто, ошибка. --------------------- */
.skeleton {
  display: block;
  height: 20px;
  margin-bottom: 12px;
  border-radius: 6px;
  background: var(--surface);
  animation: qn-pulse 1200ms ease-in-out infinite;
}

.skeleton.wide {
  width: 70%;
}

.skeleton.row {
  height: 48px;
  border-radius: 10px;
}

@keyframes qn-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.notice {
  font-size: 17px;
  line-height: 24px;
  color: var(--text);
  padding: 8px 0;
}

.notice.error {
  color: var(--text);
}

.notice .cause {
  color: var(--text-2);
  font-size: 15px;
  line-height: 21px;
  margin-top: 4px;
}

/* --- Движение (§10): одна кривая, выключается целиком по запросу. ------- */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
