:root {
  color-scheme: dark;
  --bg: #163b3d;
  --bg-2: #0f2b2d;
  --surface: #f5f6f7;
  --surface-2: #ffffff;
  --text: #0c1a1b;
  --text-muted: rgba(12, 26, 27, 0.62);
  --accent-lime: #b9f12b;
  --accent-lavender: #c9b8ff;
  --accent-mint: #49d38a;
  --accent-soft: rgba(255, 255, 255, 0.08);
  --danger: #cf566f;
  --success: #149968;
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --space-1: 8px;
  --space-2: 12px;
  --space-3: 16px;
  --space-4: 24px;
  --shadow-1: 0 10px 30px rgba(0, 0, 0, 0.18);
  --shadow-2: 0 2px 10px rgba(0, 0, 0, 0.1);
  --timer-size: clamp(52px, 12vw, 108px);
  --bg-mix: var(--bg);
  --text-mix: var(--text);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  color: var(--surface-2);
  background:
    radial-gradient(1100px circle at 8% -20%, color-mix(in srgb, var(--bg-mix) 62%, var(--bg-2)) 0%, transparent 56%),
    radial-gradient(1200px circle at 110% 120%, color-mix(in srgb, var(--bg-2) 70%, #08191b) 0%, transparent 60%),
    linear-gradient(160deg, var(--bg-mix) 0%, var(--bg-2) 72%);
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 12px calc(env(safe-area-inset-bottom, 0px) + 18px);
}

.app-shell {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  max-width: 980px;
  margin: 0 auto;
  display: grid;
  gap: var(--space-3);
}

.app-shell::before,
.app-shell::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
  z-index: -1;
  opacity: 0.88;
}

.app-shell::before {
  width: 280px;
  height: 280px;
  left: -90px;
  top: 70px;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent-lime) 85%, white) 0%, transparent 68%);
  filter: blur(6px);
}

.app-shell::after {
  width: 220px;
  height: 220px;
  right: -80px;
  top: 10px;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent-lavender) 78%, white) 0%, transparent 70%);
  filter: blur(8px);
}

.topbar {
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2);
  background: var(--accent-soft);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
}
.topbar-title { margin: 0; font-size: clamp(26px, 4vw, 38px); letter-spacing: -0.02em; }
.topbar-subtitle { margin: 4px 0 0; color: rgba(255, 255, 255, 0.76); }
.topbar-actions { display: flex; flex-wrap: wrap; gap: var(--space-1); justify-content: flex-end; }
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: min(280px, 80vw);
  max-height: 280px;
  overflow: auto;
  display: none;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  box-shadow: var(--shadow-1);
  padding: 8px;
  z-index: 30;
}
.dropdown-menu.open { display: grid; gap: 4px; }
.dropdown-item { padding: 8px 10px; border-radius: 10px; color: var(--text-mix); }
.dropdown-item.muted { color: var(--text-muted); }

.screen {
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 97%, white);
  box-shadow: var(--shadow-1);
  padding: var(--space-4);
  min-height: 66vh;
  color: var(--text-mix);
}

.btn, .icon-btn, .chip {
  border: none;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-mix);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  box-shadow: var(--shadow-2);
  transition: transform .16s ease, filter .16s ease, opacity .16s ease;
}
.btn { padding: 11px 18px; }
.btn.primary {
  color: #0e1b1c;
  background: linear-gradient(135deg, var(--accent-lime), color-mix(in srgb, var(--accent-mint) 72%, #fff));
}
.btn.ghost {
  background: color-mix(in srgb, var(--surface) 65%, #dde4e5);
}
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
}
.btn:hover, .icon-btn:hover, .chip:hover { transform: translateY(-1px); filter: brightness(1.02); }
.btn:active, .icon-btn:active, .chip:active { transform: translateY(0); opacity: .88; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
button:focus-visible, textarea:focus-visible, .chip:focus-visible, .timer-tile:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent-mint) 65%, #fff);
  outline-offset: 2px;
}

.controls-row {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.search-input, textarea {
  width: 100%;
  border-radius: var(--radius-md);
  border: none;
  padding: 14px;
  font: inherit;
  color: var(--text-mix);
  background: color-mix(in srgb, var(--surface-2) 87%, #eef2f3);
  box-shadow: inset 0 0 0 1px rgba(12, 26, 27, 0.08);
}
textarea { min-height: 106px; resize: vertical; }

.search-input:disabled,
.disabled-input {
  background: color-mix(in srgb, #b6bec2 62%, #e3e7e9);
  color: rgba(12, 26, 27, 0.45);
  cursor: not-allowed;
}
.segmented {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-2) 80%, #ecf0f1);
}
.segmented button {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  background: transparent;
  color: var(--text-muted);
}
.segmented button.active {
  background: color-mix(in srgb, var(--accent-lavender) 38%, var(--surface-2));
  color: #2a2444;
}

.list-layout {
  display: grid;
  gap: var(--space-3);
}

.timer-list { display: grid; gap: var(--space-2); }
.timer-tile {
  text-align: left;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: none;
  background: var(--surface-2);
  box-shadow: var(--shadow-2);
  display: grid;
  gap: 8px;
}
.timer-head { display: flex; justify-content: space-between; gap: var(--space-2); align-items: flex-start; }
.timer-label { margin: 0; font-size: 20px; letter-spacing: -0.01em; }
.meta { color: var(--text-muted); }
.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
}
.status-active { color: #304117; background: color-mix(in srgb, var(--accent-lime) 56%, var(--surface-2)); }
.status-fired { color: #14553f; background: color-mix(in srgb, var(--accent-mint) 38%, var(--surface-2)); }
.status-canceled { color: #6f3240; background: color-mix(in srgb, var(--danger) 25%, var(--surface-2)); }


.invite-tile { cursor: default; }
.invite-tile[data-open-invite] { cursor: pointer; }
.invite-accepted { background: #e9f8ef; }
.invite-declined { background: #fff2e7; }
.invite-expired { background: #eceff1; }
.invite-pill-pending { color: #284b67; background: #e7f2ff; }
.invite-pill-accepted { color: #1f5e3b; background: #d6f2e3; }
.invite-pill-declined { color: #8b5826; background: #ffe6cf; }
.invite-pill-expired { color: #556066; background: #dce1e4; }

.timer-hero {
  position: relative;
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, var(--surface-2), #edf1f2);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.timer-hero::before,
.timer-hero::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
  z-index: 0;
}
.timer-hero::before {
  width: 180px;
  height: 180px;
  top: -100px;
  right: -40px;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent-mint) 70%, white), transparent 70%);
  filter: blur(2px);
}
.timer-hero::after {
  width: 220px;
  height: 220px;
  left: -100px;
  bottom: -130px;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent-lavender) 62%, white), transparent 72%);
  filter: blur(5px);
}
.timer-hero > * { position: relative; z-index: 1; }
.timer-hero h2 { margin: 0; font-size: clamp(26px, 5vw, 40px); letter-spacing: -0.02em; }
.big-timer {
  font-size: var(--timer-size);
  font-weight: 800;
  line-height: .94;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  display: flex;
  gap: .08em;
  flex-wrap: wrap;
}
.big-timer .digit {
  display: inline-block;
  min-width: .62em;
  text-align: center;
  transition: transform .2s ease, opacity .2s ease;
}
.big-timer .digit.bump { transform: translateY(-3px); opacity: .82; }
.hero-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 15px;
}
.hero-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 20, 21, 0.48);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.create-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
  width: min(680px, 100%);
  max-height: min(88vh, 820px);
  overflow: auto;
  padding: var(--space-3);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: color-mix(in srgb, var(--surface) 95%, #fff);
  box-shadow: var(--shadow-1);
  transform: translateY(104%);
  transition: transform .24s ease;
  z-index: 10;
}
.create-sheet.open { transform: translateY(0); }
.overlay.open { opacity: 1; pointer-events: auto; }
.sheet-handle {
  width: 52px;
  height: 5px;
  border-radius: 999px;
  margin: 4px auto 12px;
  background: rgba(12, 26, 27, 0.22);
}
.create-head { display: flex; justify-content: space-between; align-items: center; }
.create-head h2 { margin: 0; }
.hint { color: var(--text-muted); margin: 8px 0 2px; }
.preset-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 12px; background: color-mix(in srgb, var(--accent-lavender) 28%, var(--surface-2)); }
.chip:nth-child(3n+1) { background: color-mix(in srgb, var(--accent-lime) 30%, var(--surface-2)); }
.chip:nth-child(3n+2) { background: color-mix(in srgb, var(--accent-mint) 24%, var(--surface-2)); }
.preview-box {
  min-height: 64px;
  border-radius: var(--radius-sm);
  padding: 10px;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--surface-2) 75%, #ecf0f2);
}
.preview-box.good { color: var(--text-mix); }
.inline-error { min-height: 18px; color: var(--danger); }
.create-actions { display: flex; justify-content: flex-end; gap: var(--space-1); }

.toast-stack { position: fixed; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; z-index: 40; }
.toast { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow-2); color: var(--text-mix); }

.empty { text-align: center; color: var(--text-muted); padding: 48px 0; }



.settings-sheet {
  position: fixed;
  right: 12px;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  width: min(420px, calc(100% - 24px));
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 95%, #fff);
  box-shadow: var(--shadow-1);
  transform: translateY(-8px);
  opacity: 0;
  pointer-events: none;
  z-index: 20;
  transition: transform .2s ease, opacity .2s ease;
}
.settings-sheet.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
.settings-actions { justify-content: flex-start; }

@media (min-width: 900px) {
  body { padding-left: 18px; padding-right: 18px; }
  .screen { min-height: 60vh; }
  .create-sheet {
    left: 50%;
    right: auto;
    top: 50%;
    bottom: auto;
    transform: translate(-50%, -40%) scale(.98);
    opacity: 0;
    pointer-events: none;
    border-radius: var(--radius-lg);
  }
  .create-sheet.open {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    pointer-events: auto;
  }
  .sheet-handle { display: none; }
}
