:root {
  --ink: #10242c;
  --ink-soft: #3a5560;
  --paper: #f7f1e8;
  --paper-2: #efe6d8;
  --teal: #1a4a5c;
  --teal-deep: #0d2b36;
  --amber: #e08a3c;
  --amber-soft: #f0a05a;
  --coral: #c45c4a;
  --success: #2f6b4f;
  --line: rgba(16, 36, 44, 0.12);
  --shadow: 0 18px 50px rgba(13, 43, 54, 0.18);
  --radius: 18px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", system-ui, sans-serif;
}

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

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--teal-deep);
}

body {
  min-height: 100dvh;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(240, 160, 90, 0.35), transparent 55%),
    radial-gradient(ellipse 70% 45% at 90% 10%, rgba(90, 160, 170, 0.28), transparent 50%),
    linear-gradient(165deg, #163f4f 0%, #0d2b36 48%, #1a3a2a 100%);
  animation: drift 18s ease-in-out infinite alternate;
}

body:has(#login-screen:not(.hidden)) .atmosphere {
  display: none;
}

@keyframes drift {
  from { filter: hue-rotate(0deg) saturate(1); }
  to { filter: hue-rotate(8deg) saturate(1.08); }
}

.hidden { display: none !important; }

.screen {
  min-height: 100dvh;
}

.brand {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 10vw, 4.5rem);
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.03em;
  color: var(--paper);
  line-height: 0.95;
  animation: rise 0.7s ease both;
}

.brand.compact {
  font-size: 1.55rem;
  color: var(--teal-deep);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* Login — glass panel over scenic background */
.login-screen {
  position: relative;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
  overflow: hidden;
  isolation: isolate;
}

.login-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(12, 28, 48, 0.25) 0%, rgba(8, 20, 36, 0.45) 100%),
    url("/static/login-bg.jpg") center / cover no-repeat,
    linear-gradient(165deg, #4a6fa5 0%, #c47a5a 42%, #7a8fa8 70%, #dfe7ef 100%);
}

.login-panel.glass {
  width: min(100%, 360px);
  margin: 0 auto;
  padding: 2.1rem 1.55rem 1.7rem;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.14);
  box-shadow: 0 20px 50px rgba(8, 20, 36, 0.28);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  color: #fff;
  text-align: center;
  animation: rise 0.8s ease both;
}

.login-title {
  margin: 0;
  font-family: var(--font-body);
  font-size: clamp(2.4rem, 9vw, 3.1rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.25);
}

.login-subtitle {
  margin: 0.55rem 0 1.55rem;
  font-size: 0.95rem;
  font-weight: 400;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.88);
}

.login-form {
  display: grid;
  gap: 0.95rem;
}

.glass-field {
  position: relative;
  display: block;
  margin: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.glass-field input {
  width: 100%;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  padding: 0.9rem 3rem 0.9rem 1.15rem;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 0.98rem;
}

.glass-field input::placeholder {
  color: rgba(255, 255, 255, 0.72);
}

.glass-field input:focus {
  outline: none;
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.18);
}

.field-icon {
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  padding: 0;
}

.field-icon svg {
  width: 1.2rem;
  height: 1.2rem;
}

.btn.login-btn {
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 0.95rem 1.2rem;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  color: #fff;
  background: linear-gradient(90deg, #5ec8e8 0%, #2a8fa8 48%, #176f7f 100%);
  box-shadow: 0 10px 24px rgba(23, 111, 127, 0.35);
}

.btn.login-btn:hover {
  filter: brightness(1.05);
}

.login-error {
  margin: 0;
  color: #ffd0c8;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.lede, .hint {
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.45;
  margin: 0 0 1.2rem;
}

label {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(224, 138, 60, 0.45);
  border-color: var(--amber);
}

.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 0.8rem 1.2rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

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

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

.btn.ghost {
  background: transparent;
  color: var(--teal);
  border: 1px solid var(--line);
}

.btn.danger {
  color: var(--coral);
  border-color: rgba(196, 92, 74, 0.35);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0.8rem 0 1rem;
}

.error { color: var(--coral); font-size: 0.9rem; margin: 0.5rem 0 0; }
.success { color: var(--success); font-size: 0.9rem; }

/* App shell */
.app-screen {
  background: linear-gradient(180deg, rgba(247, 241, 232, 0.97), #f3ebe0 40%, #efe6d8);
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 1rem 1rem 0.75rem;
  padding-top: max(1rem, env(safe-area-inset-top));
  background: rgba(247, 241, 232, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.today-line {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

main {
  padding: 1rem 1rem 7.5rem;
  max-width: 720px;
  margin: 0 auto;
}

/* Full-bleed bottom nav — flush left, right, and bottom */
.bottom-nav {
  pointer-events: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  z-index: 40;
}

.bottom-nav-shell {
  pointer-events: auto;
  position: relative;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0.85rem 0 0;
}

.bottom-nav-bar {
  position: relative;
  width: 100%;
  margin: 0;
  border-radius: 0;
  background: var(--teal);
  /* Extend teal through the iPhone home-indicator safe area */
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -6px 18px rgba(13, 43, 54, 0.14);
}

.bottom-nav-shape {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 78px;
  width: 100%;
  filter: none;
  pointer-events: none;
}

.bottom-nav-dot {
  pointer-events: none;
  position: absolute;
  top: -0.35rem;
  z-index: 20;
  width: 0.875rem;
  height: 0.875rem;
  border-radius: 999px;
  background: var(--teal);
  box-shadow: 0 2px 8px rgba(13, 43, 54, 0.35);
  box-sizing: content-box;
  border: 3px solid var(--paper);
  transition: left 0.3s ease;
}

.bottom-nav-items {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0;
  padding: 0.55rem 0.25rem 0.35rem;
  list-style: none;
}

.bottom-nav-item {
  position: relative;
  display: flex;
  min-height: 3.6rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  width: 100%;
  padding: 0 0.25rem;
  border: none;
  background: transparent;
  color: rgba(247, 241, 232, 0.9);
  font: inherit;
  cursor: pointer;
}

.bottom-nav-item:active {
  opacity: 0.8;
}

.bottom-nav-item.active {
  color: #fff;
}

.bottom-nav-icon {
  display: flex;
  width: 1.75rem;
  height: 1.75rem;
  align-items: center;
  justify-content: center;
  opacity: 0.95;
}

.bottom-nav-icon svg {
  width: 1.5rem;
  height: 1.5rem;
}

.bottom-nav-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.section-block {
  margin-bottom: 1.6rem;
  animation: rise 0.55s ease both;
}

.section-block h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 0.7rem;
}

.person-list {
  display: grid;
  gap: 0.7rem;
}

.person-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 0.75rem;
  padding: 0.95rem 1rem;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  width: 100%;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.person-item:active { transform: scale(0.995); }

.person-item:hover {
  border-color: rgba(224, 138, 60, 0.45);
}

.person-item .name {
  font-weight: 700;
  font-size: 1.05rem;
}

.person-item .meta {
  grid-column: 1 / -1;
  color: var(--ink-soft);
  font-size: 0.85rem;
  line-height: 1.4;
}

.person-item .badge {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--teal);
  background: rgba(26, 74, 92, 0.1);
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  align-self: start;
}

.person-item.highlight {
  background: linear-gradient(135deg, rgba(240, 160, 90, 0.22), rgba(255, 255, 255, 0.8));
  border-color: rgba(224, 138, 60, 0.4);
}

.empty {
  color: var(--ink-soft);
  font-size: 0.95rem;
  padding: 0.4rem 0.1rem 0.8rem;
}

.toolbar {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.toolbar input[type="search"] {
  flex: 1;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  background: rgba(26, 74, 92, 0.1);
  color: var(--teal);
  margin: 0;
}

.status-pill[data-state="granted"] { background: rgba(47, 107, 79, 0.15); color: var(--success); }
.status-pill[data-state="denied"] { background: rgba(196, 92, 74, 0.15); color: var(--coral); }
.status-pill[data-state="unsupported"] { background: rgba(58, 85, 96, 0.12); color: var(--ink-soft); }

.setup-steps {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.5;
}

.setup-steps li { margin-bottom: 0.45rem; }

.settings-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.7rem;
  align-items: end;
}

.settings-form label { margin: 0; }

.form-page h2 {
  margin-bottom: 1rem;
}

.person-page-form {
  max-width: 420px;
}

.date-row {
  display: grid;
  grid-template-columns: 0.8fr 1.4fr 1fr;
  gap: 0.55rem;
}

.other-calendar {
  margin: -0.2rem 0 1rem;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  background: rgba(26, 74, 92, 0.08);
  color: var(--teal);
  font-size: 0.9rem;
  font-weight: 600;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
  color: var(--ink);
}

.checkbox input {
  width: auto;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.55rem;
  margin-top: 0.6rem;
  padding-bottom: 1rem;
}

.form-actions .btn.primary {
  min-width: 6.5rem;
}

@media (max-width: 520px) {
  .settings-form {
    grid-template-columns: 1fr 1fr;
  }
  .settings-form .btn {
    grid-column: 1 / -1;
  }

  .form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .form-actions .btn.primary {
    grid-column: 1 / -1;
  }

  .form-actions .btn.danger:not([hidden]) {
    grid-column: 1 / -1;
  }
}
