:root {
  color-scheme: light dark;
  --bg: #f9f9f9;
  --card: #fff;
  --text: #0f0f0f;
  --muted: #606060;
  --line: #e5e5e5;
  --accent: #e62117;
  --accent-text: #fff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f0f;
    --card: #181818;
    --text: #f1f1f1;
    --muted: #aaa;
    --line: #303030;
    --accent: #ff4538;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}

main {
  width: 100%;
  max-width: 30rem;
  padding: 2rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.16);
}

h1 { margin: 0 0 0.25rem; font-size: 1.75rem; line-height: 1.2; }
.lede { margin: 0 0 1.5rem; color: var(--muted); }
.note { margin: 0.9rem 0 0; color: var(--muted); font-size: 0.875rem; }

label.field { display: block; margin-bottom: 0.4rem; font-size: 0.9rem; font-weight: 600; }
label.field small { color: var(--muted); font-weight: 400; }
code { padding: 0.1em 0.35em; border-radius: 0.3em; background: var(--line); font-size: 0.85em; }

textarea,
input[type="search"] {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: inherit;
  font: inherit;
}
textarea { resize: vertical; font: 0.85rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }

.button {
  display: inline-block;
  padding: 0.8rem 1.4rem;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { filter: brightness(1.1); }
.button[aria-disabled="true"] { opacity: 0.4; pointer-events: none; }
.secondary { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.25rem; }
.actions .button { flex: 1; min-width: 10rem; }

.button:focus-visible,
a:focus-visible,
textarea:focus-visible,
input:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

a { color: var(--accent); }

.divider { display: flex; align-items: center; gap: 1rem; margin: 1.75rem 0; color: var(--muted); font-size: 0.85rem; }
.divider::before,
.divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }


main.wide { max-width: 46rem; }
main.wide .savebar { margin: 1.5rem -2rem -2rem; }

.toolbar { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.toolbar input { flex: 1; min-width: 10rem; }
.chips { display: flex; gap: 0.4rem; }
.chip { padding: 0.5rem 0.9rem; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); font: inherit; font-size: 0.85rem; cursor: pointer; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }

h2.zone { margin: 1.75rem 0 0.6rem; color: var(--muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
#chosen-zone[hidden] { display: none; }

.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; }
@media (max-width: 32rem) { .grid { grid-template-columns: repeat(3, 1fr); } }

.tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; padding: 0.9rem 0.4rem 0.7rem; border: 2px solid transparent; border-radius: 16px; background: transparent; color: inherit; font: inherit; font-size: 0.8rem; line-height: 1.25; text-align: center; cursor: pointer; }
.tile:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.tile[hidden] { display: none; }
.tile img,
.tile .initial { width: 64px; height: 64px; border-radius: 50%; background: var(--line); object-fit: cover; }
.tile .initial { display: grid; place-items: center; color: var(--muted); font-size: 1.4rem; font-weight: 600; }
.tile .name { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; word-break: break-word; }
.tile[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.tile[aria-pressed="true"]::after { content: "✓"; position: absolute; top: 0.45rem; right: 0.45rem; display: grid; place-items: center; width: 1.3rem; height: 1.3rem; border-radius: 50%; background: var(--accent); color: var(--accent-text); font-size: 0.75rem; }

.savebar { position: sticky; bottom: 0; display: flex; align-items: center; gap: 1rem; padding: 1rem 2rem; border-top: 1px solid var(--line); border-radius: 0 0 20px 20px; background: var(--card); }
.savebar .note { flex: 1; margin: 0; }

details { margin-top: 1.5rem; color: var(--muted); font-size: 0.9rem; }
details summary { cursor: pointer; }
details .field { margin-top: 1rem; }

.coffee { margin: 2rem 0 0; color: var(--muted); font-size: 0.875rem; text-align: center; }
.coffee a { display: inline-block; margin-bottom: 0.3rem; color: var(--text); font-weight: 600; text-decoration: none; }
.coffee a:hover { color: var(--accent); }
.coffee span { display: block; }
.kofi { width: 1.2em; height: 1.2em; fill: #ff5e5b; vertical-align: -0.25em; }

.masthead { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
.masthead h1 { margin: 0; }
.masthead .lede { margin: 0.2rem 0 0; font-size: 0.9rem; }
.logo { display: block; width: 64px; height: 64px; border-radius: 16px; }
.legal { margin-top: 1rem; font-size: 0.8rem; }
.legal a { color: var(--muted); text-decoration: underline; }
a.tile { color: inherit; text-decoration: none; }
