/* Раскладка: одна колонка под телефон (до 480px), липкая лента дней, сетка слотов в два столбца, нижние шторки. */
:root {
  --bg: #f7f5f9;
  --surface: #ffffff;
  --text: #1c1822;
  --muted: #827b8e;
  --faint: #b6b0c0;
  --line: #e8e4ee;
  --field: #f4f1f7;

  --accent: #7a3e9d;
  --accent-press: #693389;
  --on-accent: #ffffff;
  --accent-soft: #f2e9f8;
  --accent-soft-text: #6b3090;

  --busy-bg: #fff0e0;
  --busy-text: #a4550f;
  --past-bg: #f0eef3;
  --past-text: #b9b4c2;
  --danger: #c93838;
  --danger-soft: #fdecec;
  --scrim: rgba(22, 14, 30, 0.46);
  --shadow: 0 -8px 40px rgba(40, 20, 60, 0.12);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 14px;
  --gutter: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --kb: 0px; /* высота экранной клавиатуры, выставляется из JS */
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141118;
    --surface: #1f1b25;
    --text: #f2eff6;
    --muted: #9b94a8;
    --faint: #645e70;
    --line: #2f2a38;
    --field: #29242f;
    --accent: #b680d8;
    --accent-press: #a56dca;
    --on-accent: #1b0f24;
    --accent-soft: #30223c;
    --accent-soft-text: #d6b0ef;
    --busy-bg: #35271a;
    --busy-text: #f1b377;
    --past-bg: #1a171f;
    --past-text: #514b5c;
    --danger: #f27878;
    --danger-soft: #3b2020;
    --scrim: rgba(0, 0, 0, 0.6);
    --shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #141118;
  --surface: #1f1b25;
  --text: #f2eff6;
  --muted: #9b94a8;
  --faint: #645e70;
  --line: #2f2a38;
  --field: #29242f;
  --accent: #b680d8;
  --accent-press: #a56dca;
  --on-accent: #1b0f24;
  --accent-soft: #30223c;
  --accent-soft-text: #d6b0ef;
  --busy-bg: #35271a;
  --busy-text: #f1b377;
  --past-bg: #1a171f;
  --past-text: #514b5c;
  --danger: #f27878;
  --danger-soft: #3b2020;
  --scrim: rgba(0, 0, 0, 0.6);
  --shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.35 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  overscroll-behavior-y: none;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

/* <i> — обёртка для SVG-иконок */
i {
  flex: none;
  display: inline-flex;
  align-items: center;
  font-style: normal;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ───────── Экран расписания ───────── */

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 14px var(--gutter) calc(28px + var(--safe-bottom));
}

.app.has-cta {
  padding-bottom: calc(104px + var(--safe-bottom));
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
}

.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  font-size: 26px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.avatar {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-soft-text);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.avatar-btn {
  width: 42px;
  height: 42px;
  font-size: 14px;
}

.avatar-lg {
  width: 64px;
  height: 64px;
  font-size: 22px;
}

.sticky {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0 calc(-1 * var(--gutter));
  padding: 6px var(--gutter) 12px;
  background: var(--bg);
}

.days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 0 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.day-wd {
  font-size: 12px;
  color: var(--muted);
  text-transform: capitalize;
}

.day-num {
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.day.is-today .day-wd {
  color: var(--accent);
  font-weight: 600;
}

/* Точка: в этот день у меня есть встреча. */
.day.has-mine::after {
  content: "";
  position: absolute;
  bottom: 5px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

.day[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.day[aria-selected="true"] .day-wd {
  color: inherit;
  opacity: 0.85;
}

.day[aria-selected="true"]::after {
  background: var(--on-accent);
}

.day-head {
  padding-top: 16px;
}

h2 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.hint {
  margin-top: 2px;
  min-height: 20px;
  font-size: 14px;
  color: var(--muted);
}

.hint.is-active {
  color: var(--accent);
}

.slots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.slot {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
  padding: 11px 14px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s, transform 0.12s;
}

.slot:active:not(:disabled) {
  transform: scale(0.975);
}

.slot-time {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.slot-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  font-size: 13px;
  color: var(--muted);
}

.slot-meta svg {
  flex: none;
}

.slot-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot[data-state="past"] {
  background: var(--past-bg);
  border-color: transparent;
  color: var(--past-text);
  cursor: default;
}

.slot[data-state="past"] .slot-meta {
  color: inherit;
}

.slot[data-state="busy"] {
  background: var(--busy-bg);
  border-color: transparent;
}

.slot[data-state="busy"] .slot-meta {
  color: var(--busy-text);
}

.slot[data-state="mine"] {
  background: var(--accent-soft);
  border-color: transparent;
}

.slot[data-state="mine"] .slot-meta {
  color: var(--accent-soft-text);
}

.slot[data-state="selected"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.slot[data-state="selected"] .slot-meta {
  color: inherit;
  opacity: 0.85;
}

/* ───────── Кнопки ───────── */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 12px 18px;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: background-color 0.15s, opacity 0.15s, transform 0.1s;
}

.btn:active:not(:disabled) {
  transform: scale(0.985);
}

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

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

.btn-primary:active:not(:disabled) {
  background: var(--accent-press);
}

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

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.link-btn {
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
  padding: 6px 0;
}

.link-btn.is-danger {
  color: var(--danger);
}

/* ───────── Нижняя кнопка «Забронировать» ───────── */

.cta {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 28px var(--gutter) calc(14px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 62%, transparent);
  pointer-events: none;
  animation: rise 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.cta-inner {
  max-width: 448px;
  margin: 0 auto;
  pointer-events: auto;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
}

/* ───────── Шторка ───────── */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: var(--kb);
  background: var(--scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  max-height: calc(100% - 20px);
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.backdrop.is-open .sheet {
  transform: none;
}

.sheet-grip {
  flex: none;
  width: 36px;
  height: 4px;
  margin: 8px auto 0;
  border-radius: 2px;
  background: var(--line);
}

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 20px calc(20px + var(--safe-bottom));
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.sheet-head h3 {
  flex: 1;
  min-width: 0;
  font-size: 21px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
  padding-top: 4px;
}

.icon-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--field);
  color: var(--muted);
}

.when {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.when strong {
  font-weight: 600;
}

.when .dot {
  color: var(--faint);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-soft-text);
  font-size: 12px;
  font-weight: 600;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.label small {
  font-weight: 400;
  font-size: 13px;
}

.input {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--field);
  font-size: 16px; /* меньше 16px iOS увеличивает страницу при фокусе */
  outline: none;
  transition: border-color 0.15s, background-color 0.15s;
}

.input::placeholder {
  color: var(--faint);
}

.input:focus {
  border-color: var(--accent);
  background: var(--surface);
}

textarea.input {
  min-height: 76px;
  resize: none;
  line-height: 1.35;
}

.input-code {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.note {
  font-size: 13px;
  color: var(--muted);
}

.note-box {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-soft-text);
  font-size: 13px;
}

.error {
  font-size: 13px;
  color: var(--danger);
}

.error:empty {
  display: none;
}

/* Участники */

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

.chips:empty {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 6px 8px 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-soft-text);
  font-size: 14px;
  font-weight: 500;
}

.chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip svg {
  flex: none;
  opacity: 0.7;
}

.people {
  display: flex;
  flex-direction: column;
  max-height: 186px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.people:empty {
  display: none;
}

.person {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 7px 12px;
  text-align: left;
}

.person + .person {
  border-top: 1px solid var(--line);
}

.person-text {
  flex: 1;
  min-width: 0;
}

.person-name,
.person-sub,
.row-title,
.row-sub {
  display: block;
}

.person-name {
  font-size: 15px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-sub {
  font-size: 13px;
  color: var(--muted);
}

.check {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--faint);
  color: transparent;
}

.person[aria-pressed="true"] .check {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.people-static {
  max-height: none;
  border: 0;
}

.people-static .person {
  padding: 5px 0;
  min-height: 46px;
}

.people-static .person + .person {
  border-top: 0;
}

.desc {
  font-size: 15px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Профиль */

.profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-name {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.profile-email {
  font-size: 14px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.list {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  background: var(--field);
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 9px 14px;
  text-align: left;
  width: 100%;
}

.row + .row {
  border-top: 1px solid var(--line);
}

.row-text {
  flex: 1;
  min-width: 0;
}

.row-title {
  font-size: 15px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-sub {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.row > i {
  color: var(--faint);
}

.switch {
  flex: none;
  position: relative;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: var(--faint);
  transition: background-color 0.18s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s;
}

.row[aria-checked="true"] .switch {
  background: var(--accent);
}

.row[aria-checked="true"] .switch::after {
  transform: translateX(18px);
}

/* ───────── Заглушки и уведомления ───────── */

.gate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.gate-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 320px;
  text-align: center;
}

.gate-box h2 {
  font-size: 21px;
}

.gate-box p {
  color: var(--muted);
}

.gate-box .btn {
  margin-top: 10px;
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-bottom) + var(--kb));
  z-index: 60;
  max-width: min(360px, calc(100% - 32px));
  padding: 11px 16px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
