:root {
  --top: #1e2a44;
  --bottom: #3d5a6c;
  --text: #f2e8d8;
  --red: #c9303a;
  --muted: rgba(242, 232, 216, 0.6);
  --line: rgba(242, 232, 216, 0.2);
  --fade: 700ms;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--top);
  color: var(--text);
}

body {
  min-height: 100dvh;
  background: linear-gradient(to bottom, var(--top), var(--bottom));
  overscroll-behavior: none;
  font-family: -apple-system, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* ---- Main screen ---- */

#stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    calc(env(safe-area-inset-top) + 48px)
    calc(env(safe-area-inset-right) + 32px)
    calc(env(safe-area-inset-bottom) + 48px)
    calc(env(safe-area-inset-left) + 32px);
  -webkit-user-select: none;
  user-select: none;
}

#prompt {
  margin: 0;
  max-width: 22ch;
  font-family: ui-serif, "New York", Georgia, serif;
  font-weight: 400;
  font-size: clamp(1.6rem, 7vw, 2.6rem);
  line-height: 1.35;
  text-align: center;
  text-wrap: balance;
  opacity: 0;
  transition: opacity var(--fade) ease;
}

#prompt.shown { opacity: 1; }

/* After the closing line the screen fades to near-black; music continues. */
#dim {
  position: fixed;
  inset: 0;
  background: #05070c;
  opacity: 0;
  pointer-events: none;
  transition: opacity 3s ease;
}

body.dim #dim { opacity: 0.85; }
body.dim #prompt.shown { opacity: 0.4; transition-duration: 3s; }

/* After the visit: a heart and "it's okay to do nothing" */
#stage { z-index: 1; }

#rest {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: fadeIn 1.2s ease both;
}

#rest[hidden] { display: none; }

.heart {
  width: 56px;
  height: 56px;
  fill: var(--red);
}

/* A slow, calm heartbeat: lub-dub, then a long rest. */
.heart { animation: heartbeat 2.2s ease-in-out infinite; }

@keyframes heartbeat {
  0%, 45%, 100% { transform: scale(1); }
  10%           { transform: scale(1.12); }
  20%           { transform: scale(1.02); }
  30%           { transform: scale(1.08); }
}

.rest-text {
  margin: 0;
  font-family: ui-serif, "New York", Georgia, serif;
  font-size: clamp(1.3rem, 5.5vw, 1.8rem);
  color: var(--muted);
  text-align: center;
}

.lists-open {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  z-index: 2;
  transform: translateX(-50%);
  padding: 8px 14px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  opacity: 0.6;
  animation: fadeIn 1.2s ease 0.8s both;
}

.lists-open[hidden] { display: none; }

.head-buttons {
  display: flex;
  gap: 8px;
}

.head-buttons[hidden] { display: none; }

.head-buttons .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.head-buttons svg { width: 15px; height: 15px; }

.list-title {
  flex: 1;
  min-width: 0;
  padding: 6px 2px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: 600 16px -apple-system, system-ui, sans-serif;
}

.list-title:focus { outline: none; border-color: var(--muted); }
.list-title::placeholder { color: var(--muted); font-weight: 400; }

.sync-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.sync-input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  font: 16px -apple-system, system-ui, sans-serif; /* 16px stops iOS zoom-on-focus */
}

.sync-input:focus { outline: none; border-color: var(--muted); }

#sync-off[hidden], #sync-on[hidden] { display: none; }

.time-section a { color: var(--text); }

.list-card {
  margin: 0 0 8px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
  font-size: 16px;
  line-height: 1.45;
}

#edit-open,
#music-toggle {
  position: fixed;
  z-index: 1;
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  opacity: 0.35;
}

#edit-open { right: calc(env(safe-area-inset-right) + 12px); }
#music-toggle { left: calc(env(safe-area-inset-left) + 12px); }

#edit-open svg,
#music-toggle svg { width: 20px; height: 20px; }

#music-toggle[aria-pressed="true"] { opacity: 0.6; }
#music-toggle[aria-pressed="true"] .mute-slash { display: none; }

/* ---- Splash (once per launch) ---- */

#splash {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: linear-gradient(to bottom, var(--top), var(--bottom));
  transition: opacity 700ms ease;
}

#splash.gone {
  opacity: 0;
  pointer-events: none;
}

.splash-logo {
  width: 168px;
  height: 168px;
  animation: splashIn 700ms ease both;
}

.splash-name {
  margin: 0;
  font-family: ui-serif, "New York", Georgia, serif;
  font-size: 1.4rem;
  letter-spacing: 0.02em;
  animation: fadeIn 900ms ease 2.9s both;
}

/* After the story, the logo fades away and a large music button takes
   its place, waiting for the tap that starts the music. */
.splash-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  animation: fadeOut 700ms ease 4.4s both;
}

.splash-music {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 168px;
  height: 168px;
  margin: -84px 0 0 -84px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  background: rgba(242, 232, 216, 0.08);
  animation:
    popIn 800ms ease 5s both,
    breathe 3.2s ease-in-out 5.8s infinite;
}

.splash-music svg { width: 64px; height: 64px; }

@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(242, 232, 216, 0); border-color: var(--line); transform: none; }
  50%      { box-shadow: 0 0 36px 4px rgba(242, 232, 216, 0.16); border-color: var(--muted); transform: scale(1.04); }
}

/* Splash: the umbrella slowly opens (drawn per frame in app.js). */

@keyframes splashIn { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .splash-logo, .splash-name, .splash-music { animation: none; }
  .splash-brand { display: none; }
  .heart, #rest, .lists-open { animation: none; }
}

/* ---- Editor ---- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding:
    calc(env(safe-area-inset-top) + 20px)
    calc(env(safe-area-inset-right) + 20px)
    calc(env(safe-area-inset-bottom) + 20px)
    calc(env(safe-area-inset-left) + 20px);
  background: linear-gradient(to bottom, var(--top), var(--bottom));
}

.sheet[hidden] { display: none; }

.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.editor-head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.editor-head .hint { margin-top: 2px; }

.editor-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  margin: 0 -4px;
  padding: 4px;
}

.prompt-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prompt-item {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  padding: 4px 4px 4px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
  transition: border-color 200ms ease;
}

.prompt-item:focus-within { border-color: var(--muted); }

.prompt-input {
  flex: 1;
  min-width: 0;
  padding: 9px 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: 16px/1.45 -apple-system, system-ui, sans-serif; /* 16px stops iOS zoom-on-focus */
  resize: none;
  overflow: hidden;
}

.prompt-input:focus { outline: none; }
.prompt-input::placeholder { color: var(--muted); }

.prompt-remove {
  flex: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  opacity: 0.45;
}

.prompt-remove svg { width: 16px; height: 16px; }

.add-prompt {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-size: 0.95rem;
}

.tip {
  margin: 10px 2px 4px;
  font-size: 0.8rem;
}

.set + .set { margin-top: 22px; }

.set h3,
.time-section h3 {
  margin: 0 0 10px 2px;
  font-size: 1rem;
  font-weight: 600;
}

.set h3 span {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.85rem;
}

.time-section {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}


.time-section .hint { margin: 4px 0 0; font-size: 0.85rem; }

.advanced { margin-top: 22px; }

.advanced summary {
  display: inline-block;
  padding: 6px 2px;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  list-style: none;
}

.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::after { content: " ›"; }
.advanced[open] summary::after { content: " ⌄"; }

.window-group {
  margin-top: 16px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.08);
}

.window-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.hour-select {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  font: 16px -apple-system, system-ui, sans-serif; /* 16px stops iOS zoom-on-focus */
  -webkit-appearance: none;
  appearance: none;
}

.window-now {
  flex: 1;
  color: var(--text);
  font-size: 0.8rem;
}

.window-now:not(:empty)::before { content: "· "; }

.add-prompt.small {
  padding: 9px;
  font-size: 0.9rem;
}

.editor-actions {
  display: flex;
  gap: 8px;
}

.btn {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-size: 0.95rem;
}

.btn.primary {
  border-color: transparent;
  background: var(--text);
  color: var(--top);
  font-weight: 600;
}

.spacer { flex: 1; }

.credits {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
}
