:root {
  color-scheme: light dark;
  --bg: #f6f5f8;
  --card: #ffffff;
  --field: #f6f5f8;
  --text: #17161c;
  --muted: #676474;
  --line: #e2e0e8;
  --accent: #d93a62;
  --accent-ink: #ffffff;
  --accent-soft: #fce9ee;
  --error: #a8201a;
  --error-soft: #fdecea;
  --shadow: 0 1px 2px rgba(20, 16, 30, 0.05), 0 6px 20px rgba(20, 16, 30, 0.05);
  --radius: 18px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0e13;
    --card: #1a1920;
    --field: #121117;
    --text: #f1eff6;
    --muted: #a19db0;
    --line: #2d2b36;
    --accent: #ff6b8e;
    --accent-ink: #22070f;
    --accent-soft: #3a1823;
    --error: #ffb4ab;
    --error-soft: #3b1614;
    --shadow: none;
  }
}

/* On computers, sky.js draws a night sky behind the page and adds .night-sky, so the page switches to
   dark, slightly see-through panels whatever the system theme. */
:root.night-sky {
  color-scheme: dark;
  --bg: #05060f;
  --card: rgba(17, 19, 36, 0.8);
  --field: rgba(5, 7, 18, 0.55);
  --text: #f1eff6;
  --muted: #a9a8c4;
  --line: rgba(190, 200, 255, 0.14);
  --accent: #ff6b8e;
  --accent-ink: #22070f;
  --accent-soft: rgba(255, 107, 142, 0.16);
  --error: #ffb4ab;
  --error-soft: rgba(110, 28, 28, 0.55);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
#sky { display: none; }
.night-sky #sky {
  display: block;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
}
.night-sky .card, .night-sky .reply, .night-sky .ghost {
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

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

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px calc(40px + env(safe-area-inset-bottom));
}

.top { position: relative; margin: 8px 0 20px; }
.admin-link {
  position: absolute;
  top: 0;
  right: 0;
  padding: 8px 0 8px 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.admin-link:hover { color: var(--text); }
.admin-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.logo { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.logo span { color: var(--accent); }
.tag { margin: 4px 0 0; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
h2 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.drop {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 22px 12px;
  border: 1.5px dashed var(--line);
  border-radius: 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.drop-icon { color: var(--accent); margin-bottom: 4px; }
.drop small { color: var(--muted); font-size: 14px; }

.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.thumbs:empty { display: none; }
.thumb {
  position: relative;
  width: 72px; height: 112px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--field);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.thumb button {
  position: absolute; top: 4px; right: 4px;
  width: 28px; height: 28px;
  border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, 0.66); color: #fff;
  font-size: 18px; line-height: 28px; padding: 0;
}

textarea, input[type="text"], input[type="password"] {
  width: 100%;
  font: inherit;
  font-size: 16px; /* 16px stops iOS zooming in on focus */
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}
textarea { display: block; margin-top: 12px; min-height: 104px; resize: vertical; }
textarea::placeholder, input::placeholder { color: var(--muted); opacity: 0.85; }
textarea:focus, input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  min-height: 40px;
  padding: 7px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-size: 15px;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.chip:focus-visible, .ghost:focus-visible, .copy:focus-visible, .go:focus-visible, .thumb button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.go {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 56px;
  padding: 14px;
  border: 0; border-radius: 16px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 17px; font-weight: 750;
}
.go:disabled { opacity: 0.75; cursor: progress; }
.spinner {
  width: 18px; height: 18px;
  border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

.error, .notice { margin: 14px 0 0; padding: 12px 14px; border-radius: 12px; }
.error { background: var(--error-soft); color: var(--error); }
.notice { margin: 0 0 14px; background: var(--accent-soft); color: var(--text); }

.results { margin-top: 26px; }
.read { margin: 0 0 14px; padding: 0 2px; color: var(--muted); }
.reply {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px 12px;
  margin-bottom: 10px;
}
.reply-label { font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--accent); }
.bubble {
  margin: 8px 0 12px;
  font-size: 17px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  -webkit-user-select: text; user-select: text;
}
.copy {
  min-height: 40px;
  padding: 7px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  font-size: 15px; font-weight: 650;
}
.copy.done { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.empty { color: var(--muted); }

.saved { margin: 4px 2px 12px; font-size: 14px; color: var(--muted); }

/* Who it's with */
.people { margin: 12px 0 0; }
.people:empty { display: none; }
.person { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.person-summary { margin: 0; color: var(--muted); font-size: 15px; }
.person-actions { display: flex; gap: 18px; margin-top: 4px; }
.link {
  min-height: 40px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 15px;
  font-weight: 650;
}
.link.danger { color: var(--muted); }
.link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.history { margin-top: 6px; font-size: 15px; }
.history h3 { margin: 12px 0 6px; font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.history ul { margin: 0; padding-left: 20px; }
.history li { margin: 2px 0; }
.chat-entry { padding: 10px 0; border-top: 1px solid var(--line); }
.chat-entry:first-of-type { border-top: 0; }
.chat-when { font-size: 13px; color: var(--muted); }
.chat-sent { margin: 4px 0 0; }
.chat-sent strong { font-weight: 650; }
.chat-entry details { margin-top: 4px; }
.chat-entry summary { cursor: pointer; color: var(--muted); font-size: 14px; padding: 6px 0; }
.transcript {
  margin: 6px 0 0;
  padding: 10px 12px;
  max-height: 260px;
  overflow: auto;
  background: var(--field);
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.actions { display: flex; gap: 10px; margin-top: 8px; }
.ghost {
  flex: 1;
  min-height: 50px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  font-weight: 650;
}

/* Admin login page */
.login { max-width: 400px; padding-top: max(12vh, 24px); }
.login h2 label { cursor: pointer; }
.login .go { margin-top: 12px; }
.back { margin: 16px 2px 0; font-size: 14px; }
.back a { color: var(--muted); }
.back a:hover { color: var(--text); }
