:root {
  color-scheme: light;
  --bg: #f7f8fc;
  --surface: #ffffff;
  --surface-soft: #f4f5fa;
  --surface-tint: #f1ecff;
  --text: #171927;
  --muted: #7b8190;
  --line: #e3e6ee;
  --line-strong: #d6dbe8;
  --accent: #6f4bd8;
  --accent-strong: #5f39d3;
  --accent-soft: #eee8ff;
  --blue-soft: #eaf3ff;
  --blue-line: #bad8ff;
  --danger: #ee4f5f;
  --ok: #009e73;
  --shadow: 0 12px 34px rgba(36, 42, 68, 0.08);
  --line-tick: #c4cad8;
  --line-minor: #eef0f6;
  --now: #ee4f5f;
  --weekend-tint: #faf7ff;
  --dot-color: rgba(112, 75, 216, 0.06);
  --shell-bg: rgba(255, 255, 255, 0.92);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

html,
body {
  /* Kill rubber-band/bounce and stop scroll chaining to the Telegram webview —
     the bounce reads as "everything twitches". */
  overscroll-behavior: none;
  /* Pin text scaling so mobile WebKit/Blink never auto-inflate our fixed sizes. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: var(--tg-vh, 100dvh);
  /* manipulation = no double-tap zoom and no 300ms tap delay (pinch is blocked in JS). */
  touch-action: manipulation;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 50% -12%, rgba(112, 75, 216, 0.16), transparent 34%),
    radial-gradient(var(--dot-color) 1px, transparent 1px),
    linear-gradient(#f9fafc, #f4f6fb);
  background-size: auto, 22px 22px, auto;
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

i[data-lucide],
svg.lucide {
  display: inline-block;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  stroke: currentColor;
}

svg.lucide {
  pointer-events: none;
}

.phone-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(100%, 430px);
  min-height: var(--tg-vh, 100dvh);
  margin: 0 auto;
  background: linear-gradient(180deg, var(--surface), var(--surface-tint));
}

.link-button {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  justify-self: start;
  background: transparent;
  color: #4b34c7;
  font-size: 14px;
  font-weight: 650;
}

.status-strip {
  margin: 12px 18px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}

.status-strip[data-tone="ok"] {
  color: var(--ok);
}

.status-strip[data-tone="danger"] {
  color: var(--danger);
}

.view {
  flex: 1;
  display: grid;
  align-content: start;
  gap: 14px;
  padding: calc(22px + var(--tg-top-inset, 0px)) 18px
    calc(72px + max(env(safe-area-inset-bottom, 0px), var(--tg-bottom-inset, 0px)));
}

/* The create wizard hides the bottom nav and pins its own fixed footer,
   so it manages its own bottom spacing — don't reserve nav height here. */
.view:has(> .create-screen) {
  padding-bottom: 0;
}

.screen-head {
  display: grid;
  gap: 6px;
}

.screen-head h1,
.screen-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 21px;
  line-height: 1.18;
  font-weight: 850;
}

.screen-head p,
.muted {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.home-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(111, 75, 216, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(238, 232, 255, 0.92), rgba(255, 255, 255, 0.96) 54%),
    var(--surface);
  box-shadow: var(--shadow);
}

.hero-copy {
  display: grid;
  gap: 7px;
}

.hero-copy h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
  font-weight: 880;
}

.hero-copy p {
  margin: 0;
  color: #565d6d;
  font-size: 14px;
  line-height: 1.42;
}

.hero-meter {
  display: grid;
  width: 72px;
  min-height: 72px;
  place-items: center;
  border: 1px solid rgba(95, 57, 211, 0.14);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-strong);
  padding: 8px;
  text-align: center;
}

.hero-meter strong {
  font-size: 26px;
  line-height: 1;
}

.hero-meter span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.insight-item {
  display: grid;
  min-height: 82px;
  align-content: start;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  box-shadow: 0 8px 24px rgba(36, 42, 68, 0.05);
}

.insight-item svg.lucide {
  width: 17px;
  height: 17px;
  color: var(--accent-strong);
}

.insight-item strong {
  font-size: 14px;
  line-height: 1.15;
}

.insight-item span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.next-event-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  box-shadow: var(--shadow);
}

.next-event-card.empty {
  border-style: dashed;
  border-color: rgba(111, 75, 216, 0.22);
  background: linear-gradient(180deg, #fff, var(--surface-tint));
}

.next-event-card > div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.next-event-card strong {
  overflow: hidden;
  font-size: 15px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.next-event-card span:not(.eyebrow, .next-event-icon) {
  color: var(--muted);
  font-size: 12px;
}

.next-event-icon,
.mini-icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.mini-icon-button {
  border: 1px solid rgba(111, 75, 216, 0.16);
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 2px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.section-title-row h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 860;
}

.section-title-row span {
  color: var(--muted);
  font-size: 12px;
}

.mini-action {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-strong);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 800;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-pad {
  padding: 14px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-header h2,
.panel-header h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
  font-weight: 850;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.link-card {
  display: grid;
  gap: 8px;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-button,
.slot-button,
.step-next {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: 8px;
  padding: 10px 14px;
  text-decoration: none;
  text-align: center;
  font-size: 14px;
  font-weight: 800;
  transition:
    transform 160ms ease,
    opacity 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease;
}

.primary-button,
.step-next {
  background: linear-gradient(180deg, #7d5cf0 0%, var(--accent-strong) 100%);
  color: #fff;
  box-shadow: 0 10px 24px rgba(95, 57, 211, 0.28);
}

.secondary-button,
.ghost-button,
.slot-button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
}

.danger-button {
  border: 1px solid rgba(238, 79, 95, 0.24);
  background: #fff;
  color: var(--danger);
}

.primary-button:active,
.secondary-button:active,
.danger-button:active,
.ghost-button:active,
.slot-button:active,
.step-next:active {
  transform: scale(0.985);
}

.home-event-list,
.event-list,
.user-list {
  display: grid;
  gap: 12px;
}

.home-card {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.event-time {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ok);
  font-size: 13px;
  font-weight: 850;
}

.event-time svg.lucide {
  width: 15px;
  height: 15px;
}

.event-time small {
  border-radius: 999px;
  background: rgba(0, 158, 115, 0.1);
  color: #04785b;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 850;
}

.event-title {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
  font-weight: 850;
}

.event-subline,
.event-members {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.event-subline svg.lucide {
  width: 15px;
  height: 15px;
}

.event-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.event-meta-row span {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: #596070;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
}

.event-meta-row svg.lucide {
  width: 13px;
  height: 13px;
}

.avatar-stack {
  display: flex;
  align-items: center;
  min-height: 28px;
}

.avatar {
  display: grid;
  width: 28px;
  height: 28px;
  margin-left: -6px;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  background: linear-gradient(145deg, #3b455e, #c68b64);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}

.avatar:first-child {
  margin-left: 0;
}

.avatar.extra {
  background: #eef0f6;
  color: #626a7a;
}

.home-card .primary-button {
  min-height: 42px;
  margin-top: 2px;
}

.week-top {
  display: grid;
  gap: 16px;
}

.week-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.week-title-row h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 850;
}

.week-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  box-shadow: var(--shadow);
}

.week-summary-main {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.week-summary-main strong {
  font-size: 16px;
}

.week-summary-main span:last-child {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.week-summary-stat {
  display: grid;
  min-width: 64px;
  min-height: 56px;
  place-items: center;
  border-radius: 8px;
  background: #f4fbf8;
  color: var(--ok);
  padding: 8px;
  font-size: 12px;
  font-weight: 850;
}

.week-arrow {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: transparent;
  color: #303549;
}

.week-arrow svg.lucide {
  width: 21px;
  height: 21px;
}

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

.day-cell {
  position: relative;
  display: grid;
  min-height: 70px;
  gap: 5px;
  justify-items: center;
  border-radius: 8px;
  background: transparent;
  color: #222638;
  font-size: 12px;
  padding: 2px 0;
}

.day-cell:not(:nth-child(7n)) {
  border-right: 1px solid var(--line);
}

.day-cell:nth-child(6),
.day-cell:nth-child(7) {
  background: var(--weekend-tint);
}

.day-cell:nth-child(6) span:first-child,
.day-cell:nth-child(7) span:first-child {
  color: var(--accent);
}

.day-cell span:first-child {
  color: var(--muted);
  font-size: 11px;
}

.day-cell strong {
  display: grid;
  width: 36px;
  height: 42px;
  place-items: center;
  border-radius: 10px;
}

.day-cell.today:not(.active) strong {
  border: 1px solid rgba(111, 75, 216, 0.3);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.day-cell.active strong {
  display: grid;
  width: 36px;
  height: 42px;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(180deg, #7d5cf0, #6845d8);
  color: #fff;
  box-shadow: 0 8px 18px rgba(95, 57, 211, 0.25);
}

.day-cell small {
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border-radius: 50%;
  color: transparent;
  font-size: 9px;
  font-weight: 850;
}

.day-cell.has-events small {
  background: rgba(0, 158, 115, 0.12);
  color: var(--ok);
}

.timeline-shell {
  display: grid;
  gap: 10px;
}

.timeline-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
}

.timeline-title-row strong {
  font-size: 15px;
}

.timeline-title-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.timeline {
  position: relative;
  display: grid;
  grid-template-columns: 44px 1fr;
  min-height: calc(var(--timeline-hours, 14) * 58px);
  border-top: 1px solid var(--line);
}

.time-labels {
  display: grid;
  grid-template-rows: repeat(var(--timeline-hours, 14), 58px);
  color: #596070;
  font-size: 12px;
}

.time-labels span {
  position: relative;
  transform: translateY(-8px);
}

.time-labels span::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 0;
  width: 6px;
  height: 1px;
  background: var(--line-tick);
}

.time-grid {
  position: relative;
  min-height: calc(var(--timeline-hours, 14) * 58px);
  background:
    repeating-linear-gradient(
      to bottom,
      var(--line-tick) 0,
      var(--line-tick) 1px,
      transparent 1px,
      transparent 58px
    ),
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 29px,
      var(--line-minor) 29px,
      var(--line-minor) 30px,
      transparent 30px,
      transparent 58px
    );
  border-left: 1px solid var(--line-tick);
}

.timeline-empty {
  position: absolute;
  top: 128px;
  right: 18px;
  left: 18px;
  display: grid;
  justify-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 18px;
  text-align: center;
  font-size: 13px;
  font-weight: 750;
}

.timeline-empty strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.week-block {
  position: absolute;
  right: auto;
  left: calc((100% / var(--lanes, 1)) * var(--lane, 0) + 4px);
  width: calc((100% / var(--lanes, 1)) - 8px);
  display: grid;
  align-content: start;
  gap: 2px;
  min-height: 44px;
  padding: 9px 10px;
  border: 1px solid #b9a8ff;
  border-radius: 8px;
  background: linear-gradient(180deg, #eee9ff, #e6dfff);
  color: #4a2fbb;
  overflow: hidden;
  text-align: left;
  font-size: 12px;
  font-weight: 750;
}

.week-block.blue {
  border-color: var(--blue-line);
  background: linear-gradient(180deg, #eff7ff, var(--blue-soft));
  color: #285aa6;
}

.week-block small {
  justify-self: start;
  color: inherit;
  font-weight: 650;
  opacity: 0.78;
}

.week-block strong {
  justify-self: start;
}

.now-line {
  position: absolute;
  right: 0;
  left: 0;
  height: 0;
  border-top: 2px solid var(--now);
  pointer-events: none;
  z-index: 3;
}

.now-line .now-dot {
  position: absolute;
  top: -5px;
  left: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--now);
  box-shadow: 0 0 0 3px rgba(238, 79, 95, 0.18);
}

.stepper {
  display: grid;
  grid-template-columns: repeat(7, minmax(26px, 1fr));
  align-items: center;
  gap: 0;
  margin-bottom: 24px;
  width: 100%;
}

.step-dot {
  position: relative;
  display: grid;
  justify-items: center;
  min-width: 0;
  color: #9aa1b1;
  font-size: 11px;
}

.step-dot::before {
  position: absolute;
  top: 13px;
  right: 50%;
  left: -50%;
  height: 1px;
  background: var(--line-strong);
  content: "";
  transition: background-color 180ms ease;
}

.step-dot:first-child::before {
  display: none;
}

.step-dot span {
  z-index: 1;
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: #fff;
  font-weight: 800;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background-color 180ms ease,
    box-shadow 180ms ease,
    color 180ms ease;
}

.step-dot svg.lucide {
  width: 14px;
  height: 14px;
}

.step-dot.active span {
  border-color: var(--accent);
  background: linear-gradient(180deg, #7d5cf0, #6845d8);
  color: #fff;
  animation: step-pop 260ms cubic-bezier(0.22, 1, 0.36, 1) both;
  box-shadow: 0 8px 18px rgba(95, 57, 211, 0.28);
}

.step-dot.done span {
  border-color: var(--line-strong);
  color: var(--accent);
}

.step-dot.done::before,
.step-dot.active::before {
  background: rgba(111, 75, 216, 0.42);
}

.create-screen {
  display: grid;
  min-height: calc(var(--tg-vh, 100dvh) - 180px);
  gap: 16px;
  align-content: start;
  /* Clear the fixed footer (up to two stacked CTA buttons on the final step,
     with slack for a wrapped label) so the last content can always scroll above it. */
  padding-bottom: calc(150px + max(env(safe-area-inset-bottom, 0px), var(--tg-bottom-inset, 0px)));
}

.create-screen .screen-head,
.create-screen label.field-label,
.create-screen .create-detail-note,
.create-screen .calendar-card,
.create-screen .time-grid-options,
.create-screen .search-box,
.create-screen .option-list,
.create-screen .zoom-list,
.create-screen .recur-box,
.create-screen .confirm-card,
.create-screen .ghost-button {
  animation: create-panel-in 260ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.create-screen .create-detail-note,
.create-screen .calendar-card,
.create-screen .search-box,
.create-screen .option-list,
.create-screen .zoom-list,
.create-screen .recur-box,
.create-screen .confirm-card {
  animation-delay: 45ms;
}

.create-topbar {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.create-topbar > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.create-back-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 7px 10px 7px 7px;
  box-shadow: 0 8px 24px rgba(36, 42, 68, 0.05);
}

.create-back-button svg.lucide {
  width: 17px;
  height: 17px;
}

.create-body {
  display: grid;
  gap: 12px;
}

.create-detail-note {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 10px;
  border: 1px solid rgba(111, 75, 216, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 10px 12px;
}

.create-detail-note > span {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.create-detail-note div {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.create-detail-note strong {
  font-size: 13px;
  line-height: 1.2;
}

.create-detail-note p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.create-footer {
  position: fixed;
  right: 0;
  /* The Telegram webview already pins fixed elements to the visible (visual)
     viewport, so bottom:0 sits just above the on-screen keyboard — no manual
     lift (a manual lift double-counts and throws the bar to the top). */
  bottom: 0;
  left: 0;
  z-index: 20;
  display: grid;
  gap: 10px;
  width: min(100%, 430px);
  margin: 0 auto;
  padding: 18px 18px calc(14px + max(env(safe-area-inset-bottom, 0px), var(--tg-bottom-inset, 0px)));
  background: linear-gradient(transparent, var(--surface) 44%);
  animation: create-footer-in 220ms ease both;
}

label.field-label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 13px 14px;
  outline: none;
  /* >=16px so iOS Safari/WKWebView never auto-zooms the page on focus. */
  font-size: 16px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #9a82ef;
  box-shadow: 0 0 0 3px rgba(111, 75, 216, 0.12);
}

.counter {
  justify-self: end;
  color: var(--muted);
  font-size: 12px;
}

.calendar-card {
  display: grid;
  gap: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  box-shadow: var(--shadow);
}

.month-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 850;
}

.month-row button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: transparent;
  color: #202437;
}

.month-row button svg.lucide {
  width: 21px;
  height: 21px;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px 5px;
  text-align: center;
}

.month-grid span {
  display: grid;
  min-height: 30px;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.date-button {
  position: relative;
  display: grid;
  width: 36px;
  height: 36px;
  min-height: 36px;
  place-items: center;
  justify-self: center;
  border-radius: 50%;
  background: transparent;
  color: #161b2d;
  font-weight: 700;
}

.date-button.muted {
  color: #a9afbf;
}

.date-button.selected {
  background: linear-gradient(180deg, #7d5cf0, #6845d8);
  color: #fff;
  animation: option-selected-pop 180ms ease both;
  box-shadow: 0 10px 22px rgba(95, 57, 211, 0.24);
}

.date-button.weekend:not(.muted):not(.today):not(.selected) {
  color: var(--accent);
}

.date-button.today:not(.selected) {
  border: 1px solid rgba(111, 75, 216, 0.3);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
}

.date-button.has-events::after {
  content: "";
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ok);
}

.date-button.selected.has-events::after {
  background: #fff;
}

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

.slot-button {
  flex-direction: column;
  gap: 2px;
  min-height: 50px;
}

.slot-button.selected,
.option-row.selected,
.zoom-choice.selected {
  border-color: #8d74ea;
  background: var(--accent-soft);
  color: #2a1d78;
  animation: option-selected-pop 180ms ease both;
}

.slot-button.busy,
.slot-button:disabled {
  border-color: #d9dde8;
  background: #f1f3f8;
  color: #8d94a3;
  cursor: not-allowed;
  opacity: 1;
  box-shadow: none;
}

.slot-button.busy small {
  color: var(--danger);
  font-size: 10px;
  font-weight: 850;
  line-height: 1;
}

.option-list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.option-row,
.participant-row,
.zoom-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  text-align: left;
}

.option-row:last-child,
.participant-row:last-child,
.zoom-choice:last-child {
  border-bottom: 0;
}

.radio-mark,
.check-mark {
  display: grid;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #c9ceda;
  border-radius: 50%;
  color: transparent;
  font-size: 12px;
  font-weight: 900;
}

.radio-mark svg.lucide,
.check-mark svg.lucide {
  width: 14px;
  height: 14px;
}

.check-mark {
  border-radius: 5px;
}

.selected .radio-mark,
.selected .check-mark {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.participant-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.choice-main {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.choice-icon {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.participant-copy {
  display: grid;
  gap: 2px;
}

.participant-copy strong {
  font-size: 14px;
}

.participant-copy span {
  color: var(--muted);
  font-size: 12px;
}

.search-box {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 0 12px;
}

.search-box:focus-within {
  border-color: #9a82ef;
  box-shadow: 0 0 0 3px rgba(111, 75, 216, 0.12);
}

.search-box .search-field {
  min-height: 44px;
  border: 0;
  background: transparent;
  padding: 0;
  box-shadow: none;
}

.search-field {
  min-height: 44px;
  border-color: transparent;
  background: var(--surface-soft);
}

.zoom-choice {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.zoom-list {
  display: grid;
  gap: 12px;
}

.confirm-card {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.summary-list {
  display: grid;
  gap: 14px;
}

.summary-item {
  display: grid;
  gap: 4px;
}

.summary-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-item strong {
  font-size: 14px;
}

.detail-title {
  display: grid;
  gap: 8px;
}

.detail-title h1 {
  margin: 0;
  font-size: 23px;
  line-height: 1.1;
}

.tag {
  display: inline-flex;
  width: fit-content;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 800;
  gap: 5px;
}

.tag.ok {
  background: rgba(0, 158, 115, 0.12);
  color: var(--ok);
}

.tag.warn {
  background: rgba(229, 165, 49, 0.14);
  color: #a06000;
}

.tag.danger {
  background: rgba(238, 79, 95, 0.12);
  color: var(--danger);
}

.tag.accepted {
  background: rgba(0, 158, 115, 0.12);
  color: var(--ok);
}

.tag.invited {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.tag.declined {
  background: rgba(238, 79, 95, 0.12);
  color: var(--danger);
}

.tag.cancelled {
  background: var(--surface-soft);
  color: var(--muted);
}

.tag svg.lucide {
  width: 13px;
  height: 13px;
}

.detail-lines {
  display: grid;
  gap: 12px;
  color: #3f4554;
  font-size: 15px;
}

.detail-line {
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.35;
}

.detail-line svg.lucide {
  width: 18px;
  height: 18px;
  color: var(--accent-strong);
}

.detail-hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.zoom-link-card {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.zoom-link-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.zoom-link-row code {
  min-width: 0;
  overflow: hidden;
  color: #4b34c7;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center;
  width: min(100%, 430px);
  margin: 0 auto;
  padding: 7px 12px calc(8px + max(env(safe-area-inset-bottom, 0px), var(--tg-bottom-inset, 0px)));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
}

.bottom-nav[hidden] {
  display: none;
}

.tab-button {
  display: grid;
  min-height: 50px;
  place-items: center;
  gap: 2px;
  border-radius: 8px;
  background: transparent;
  color: #5d6474;
  font-size: 10px;
  font-weight: 750;
}

.tab-button .nav-icon {
  width: 20px;
  height: 20px;
}

.tab-button[aria-current="page"] {
  color: var(--accent-strong);
}

.tab-add-button {
  display: grid;
  min-height: 50px;
  place-items: center;
  gap: 2px;
  border-radius: 8px;
  background: transparent;
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 750;
  transition:
    transform 120ms ease,
    opacity 120ms ease;
}

.tab-add-button:active {
  transform: scale(0.97);
}

.nav-add-dot {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 999px;
  background: linear-gradient(180deg, #7d5cf0 0%, var(--accent-strong) 100%);
  color: #fff;
  box-shadow: 0 9px 22px rgba(95, 57, 211, 0.28);
}

.tab-add-button .nav-add-icon {
  width: 20px;
  height: 20px;
}

.empty-state {
  display: grid;
  min-height: 96px;
  gap: 6px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 22px 18px;
  text-align: center;
}

.empty-state strong {
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
}

.empty-state-text {
  font-size: 13px;
  line-height: 1.4;
}

.empty-state-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  margin-bottom: 2px;
}

.empty-state-icon svg.lucide {
  width: 20px;
  height: 20px;
}

.empty-state .mini-action {
  margin-top: 8px;
}

.loading-state svg.lucide {
  animation: spin 900ms linear infinite;
  color: var(--accent-strong);
}

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

@media (min-width: 700px) {
  body {
    background: #0a0f12;
  }

  .phone-shell {
    min-height: calc(100vh - 48px);
    margin-top: 24px;
    margin-bottom: 24px;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 24px 90px rgba(0, 0, 0, 0.36);
  }
}

@keyframes view-enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes create-panel-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes create-footer-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes step-pop {
  0% {
    transform: scale(0.82);
  }
  70% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes option-selected-pop {
  0% {
    transform: scale(0.985);
  }
  100% {
    transform: scale(1);
  }
}

.view.is-entering {
  animation: view-enter 220ms ease both;
}

.panel.home-card {
  transition:
    transform 160ms ease,
    box-shadow 160ms ease;
}

@media (hover: hover) {
  .primary-button:hover,
  .step-next:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(95, 57, 211, 0.34);
  }

  .secondary-button:hover,
  .ghost-button:hover,
  .slot-button:not(.busy):not(:disabled):hover {
    transform: translateY(-1px);
    border-color: var(--line-strong);
    background: var(--surface-soft);
  }

  .mini-action:hover,
  .panel.home-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 28px rgba(36, 42, 68, 0.1);
  }

  .tab-button:hover {
    color: var(--accent-strong);
  }

  .day-cell:hover:not(.active) strong {
    background: var(--accent-soft);
  }
}

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

  .loading-state svg.lucide {
    animation: spin 900ms linear infinite !important;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-soft: #222633;
    --surface-tint: #241f38;
    --text: #eef0f6;
    --muted: #9aa1b5;
    --line: #2b3040;
    --line-strong: #3a4053;
    --line-tick: #3f465a;
    --line-minor: #20242f;
    --accent: #8b6bf0;
    --accent-strong: #a285f5;
    --accent-soft: #2a2350;
    --blue-soft: #1c2a40;
    --blue-line: #2f4a6b;
    --danger: #ff6b78;
    --now: #ff6b78;
    --ok: #2fd39e;
    --weekend-tint: #1d2030;
    --dot-color: rgba(160, 133, 245, 0.07);
    --shell-bg: rgba(26, 29, 39, 0.92);
    --shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
  }

  body {
    background-color: var(--bg);
    background-image:
      radial-gradient(circle at 50% -12%, rgba(120, 90, 230, 0.18), transparent 34%),
      radial-gradient(var(--dot-color) 1px, transparent 1px),
      linear-gradient(#13151d, #0f1117);
  }

  .insight-item,
  .next-event-card,
  .week-summary,
  .hero-meter,
  input,
  select,
  textarea,
  .secondary-button,
  .ghost-button,
  .slot-button,
  .danger-button,
  .create-back-button,
  .mini-action,
  .option-list,
  .option-row,
  .participant-row,
  .zoom-choice,
  .create-detail-note {
    background: var(--surface);
    color: var(--text);
  }

  .bottom-nav {
    background: rgba(26, 29, 39, 0.97);
  }

  .create-footer {
    background: linear-gradient(transparent, var(--surface) 44%);
  }

  .next-event-card.empty {
    background: linear-gradient(180deg, var(--surface), var(--surface-tint));
  }

  .link-button,
  .zoom-link-row code {
    color: var(--accent-strong);
  }

  .hero-copy p {
    color: var(--muted);
  }

  .day-cell,
  .month-row button,
  .date-button {
    color: var(--text);
  }

  .week-arrow {
    color: var(--text);
  }

  .tab-button {
    color: var(--muted);
  }

  .time-labels,
  .event-meta-row span {
    color: var(--muted);
  }

  .week-summary-stat {
    background: rgba(47, 211, 158, 0.12);
  }

  .slot-button.busy,
  .slot-button:disabled {
    background: var(--surface-soft);
    color: var(--muted);
    border-color: var(--line);
  }

  .home-hero {
    background: linear-gradient(135deg, var(--accent-soft), var(--surface) 60%);
    border-color: var(--line-strong);
  }

  .week-block {
    background: linear-gradient(180deg, #2c2550, #241f44);
    border-color: #4a3f8a;
    color: #cfc4ff;
  }

  .week-block.blue {
    background: linear-gradient(180deg, #1c2a40, #18283c);
    border-color: var(--blue-line);
    color: #aaccf5;
  }

  .event-time small {
    background: rgba(47, 211, 158, 0.16);
    color: var(--ok);
  }

  .detail-lines {
    color: var(--text);
  }

  .summary-item strong,
  .participant-copy strong,
  .choice-main strong,
  .zoom-link-card strong {
    color: var(--text);
  }

  .slot-button.selected,
  .option-row.selected,
  .zoom-choice.selected {
    color: var(--accent-strong);
  }

  .tag.warn {
    color: #f0b056;
  }

  .avatar.extra {
    background: var(--surface-soft);
    color: var(--muted);
  }

  .step-dot {
    color: var(--muted);
  }

  .date-button.muted {
    color: #6b7286;
  }
}

@keyframes backdrop-drift {
  0% {
    background-position: 0% 0%, 100% 0%, 50% 100%, center;
  }

  100% {
    background-position: 26% 18%, 74% 32%, 42% 82%, center;
  }
}

/* Desktop backdrop behind the phone shell: soft drifting aurora, kept subtle. */
@media (min-width: 700px) {
  body {
    background-color: #0b0d14;
    background-image:
      radial-gradient(38% 48% at 18% 20%, rgba(125, 92, 240, 0.24), transparent 70%),
      radial-gradient(42% 52% at 82% 28%, rgba(72, 110, 214, 0.2), transparent 72%),
      radial-gradient(48% 56% at 50% 90%, rgba(168, 85, 247, 0.16), transparent 74%),
      linear-gradient(160deg, #0e1119, #0a0c12);
    background-size: 200% 200%, 220% 220%, 210% 210%, auto;
    background-position: 0% 0%, 100% 0%, 50% 100%, center;
    background-attachment: fixed;
    animation: backdrop-drift 30s ease-in-out infinite alternate;
  }
}

/* Animated aurora behind the in-app content — the background visible in Telegram. */
.phone-shell > .status-strip,
.phone-shell > .view {
  position: relative;
  z-index: 1;
}

.bg-aurora {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-aurora .blob {
  position: absolute;
  /* Sized in vw (width-relative) so the on-screen keyboard, which only
     changes height, never resizes/repaints these expensive blurred layers.
     Capped so they aren't oversized on tablet/desktop. */
  width: min(128vw, 620px);
  height: min(128vw, 620px);
  border-radius: 50%;
  filter: blur(44px);
  opacity: 0.45;
  will-change: transform;
}

.bg-aurora .blob-1 {
  top: -20%;
  left: -24%;
  background: radial-gradient(circle, rgba(125, 92, 240, 0.6), transparent 62%);
  animation: aurora-1 19s ease-in-out infinite alternate;
}

.bg-aurora .blob-2 {
  right: -22%;
  bottom: -24%;
  background: radial-gradient(circle, rgba(96, 122, 224, 0.55), transparent 62%);
  animation: aurora-2 23s ease-in-out infinite alternate;
}

.bg-aurora .blob-3 {
  top: 38%;
  left: 32%;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.42), transparent 62%);
  animation: aurora-3 27s ease-in-out infinite alternate;
}

/* Translate-only drift: compositor moves a cached blur layer instead of
   re-rasterizing it every frame (scale animations forced a per-frame reblur). */
@keyframes aurora-1 {
  to {
    transform: translate3d(16%, 12%, 0);
  }
}

@keyframes aurora-2 {
  to {
    transform: translate3d(-16%, -11%, 0);
  }
}

@keyframes aurora-3 {
  to {
    transform: translate3d(-12%, 11%, 0);
  }
}

/* Recurrence selector + detail action buttons */
.detail-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.recur-card,
.recur-edit-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.recur-edit-card {
  margin-top: 12px;
  padding: 16px;
}

.recur-head {
  margin-bottom: 2px;
}

.recur-selector {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.recur-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recur-chip {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 15px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.recur-chip.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.recur-summary {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.recur-edit-actions {
  display: flex;
  gap: 10px;
}
