:root {
  --control-bg: rgba(21, 29, 25, .9);
  --control-shadow: 0 10px 30px rgba(0, 0, 0, .22);
  --sticky-bg: var(--apricot);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f3ed;
  --surface: #ece9e1;
  --text: #17201c;
  --body: #4d5a52;
  --muted: #69756d;
  --line: #cdd3ca;
  --sage: #426b4c;
  --apricot: #98512d;
  --button: #251b16;
  --control-bg: rgba(246, 243, 237, .92);
  --control-shadow: 0 10px 30px rgba(53, 61, 55, .14);
  --sticky-bg: #d98c5d;
}

body,
input,
.timing-card {
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease;
}

html[data-theme="light"] .button {
  background: var(--sticky-bg);
}

.hero {
  position: relative;
}

.theme-toggle {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--control-bg);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  padding: 7px 11px;
  transition: color 160ms ease, border-color 160ms ease, background-color 180ms ease;
}

.theme-toggle::before {
  width: 9px;
  height: 9px;
  border: 1px solid var(--apricot);
  border-radius: 50%;
  background: transparent;
  content: '';
}

html[data-theme="light"] .theme-toggle::before {
  background: var(--apricot);
}

.theme-toggle:hover {
  border-color: var(--apricot);
  color: var(--text);
}

.theme-toggle:focus-visible,
.sticky-invite:focus-visible {
  outline: 2px solid var(--sage);
  outline-offset: 4px;
}

.theme-toggle--home {
  position: absolute;
  z-index: 3;
  top: clamp(28px, 4vw, 48px);
  right: clamp(22px, 7vw, 82px);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sticky-invite {
  position: fixed;
  z-index: 50;
  right: max(24px, calc((100vw - 1100px) / 2 + 24px));
  bottom: max(24px, calc(env(safe-area-inset-bottom) + 18px));
  border-radius: 999px;
  background: var(--sticky-bg);
  box-shadow: var(--control-shadow);
  color: var(--button);
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  padding: 14px 20px;
  pointer-events: none;
  text-decoration: none;
  transform: translateY(16px);
  transition: opacity 180ms ease, transform 180ms ease, background-color 180ms ease;
}

.sticky-invite.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

@media (max-width: 700px) {
  .theme-toggle--home {
    top: 24px;
    right: 22px;
  }

  .sticky-invite {
    right: auto;
    left: 50%;
    bottom: max(18px, calc(env(safe-area-inset-bottom) + 12px));
    width: min(calc(100% - 44px), 360px);
    min-height: 52px;
    padding: 15px 22px;
    text-align: center;
    transform: translate(-50%, 16px);
  }

  .sticky-invite.is-visible {
    transform: translate(-50%, 0);
  }
}

@media (max-width: 420px) {
  .page-actions {
    gap: 10px;
  }

  .theme-toggle {
    gap: 6px;
    padding-inline: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body,
  input,
  .timing-card,
  .sticky-invite {
    transition: none;
  }
}
