:root { color-scheme: light dark; font-family: system-ui, sans-serif; --muted: #6b7280; --accent: #0f766e; }
body { margin: 0; }
header { position: relative; display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; border-bottom: 1px solid #8884; }
.spacer { flex: 1; }
/* Non-production: a 3px amber line on the top edge, overlaid so it takes no space. Hover shows the label. */
.env-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 100; height: 8px; overflow: hidden; font-size: 0;
  background: linear-gradient(#f59e0b 0 3px, transparent 3px); }
.env-bar:hover { height: auto; font-size: .6875rem; line-height: 1.2rem; text-align: center; text-transform: capitalize; background: #f59e0b; color: #1f2937; }
main { max-width: 60rem; margin: 2rem auto; padding: 0 1rem; }
form { display: grid; gap: .75rem; max-width: 22rem; }
label { display: grid; gap: .25rem; }
input, button { font: inherit; padding: .5rem .75rem; border-radius: .375rem; border: 1px solid #8886; }
button { cursor: pointer; background: var(--accent); color: white; border-color: transparent; }
header button { background: transparent; color: inherit; border-color: #8886; }
.note { color: var(--muted); }
.error { color: #b91c1c; max-width: 60rem; margin: 1rem auto 0; padding: 0 1rem; }
[hidden] { display: none !important; }
.suggestions .meta { color: var(--muted); font-size: .875rem; }

/* Sites: each card is a tiny version of the site (colour band, name in its font, accent button). */
.sites { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); }
.card { display: flex; flex-direction: column; height: 100%; border-radius: .625rem; overflow: hidden; text-decoration: none;
  border: 1px solid #8884; box-shadow: 0 1px 3px #0001; transition: transform .1s, box-shadow .1s; }
.card:hover, .card:focus-visible { transform: translateY(-2px); box-shadow: 0 6px 18px #0002; }
.card-top { flex: 1; min-height: 6rem; display: flex; align-items: flex-end; padding: 1rem; color: #fff; }
.card-name { font-weight: 700; font-size: 1.125rem; line-height: 1.25; overflow-wrap: anywhere; }
.card-bottom { display: flex; align-items: center; justify-content: space-between; padding: .625rem 1rem; background: #fff; color: #1f2937; }
.card-cta { width: 3.5rem; height: .75rem; border-radius: .25rem; }
.small { font-size: .75rem; margin: .375rem 0 0; }
.combo { position: relative; display: grid; gap: .25rem; }
.combo input { width: 100%; box-sizing: border-box; }
.suggestions { position: absolute; top: 100%; left: 0; right: 0; z-index: 10; margin: .25rem 0 0; padding: .25rem; list-style: none;
  max-height: 18rem; overflow-y: auto; background: Canvas; border: 1px solid #8886; border-radius: .5rem; box-shadow: 0 8px 24px #0002; }
.suggestions li { display: grid; gap: .125rem; padding: .5rem .625rem; border-radius: .375rem; cursor: pointer; }
.suggestions li[aria-selected="true"], .suggestions li[role=option]:hover { background: #8882; }
.suggestions .name { font-weight: 600; }
.suggestions .empty { color: var(--muted); cursor: default; }
button.secondary { background: transparent; color: inherit; border-color: #8886; }

/* Site screen: toolbar on top, the site fills the rest of the window. */
body.site-mode { height: 100dvh; display: flex; flex-direction: column; }
body.site-mode main { display: none; }
header button { padding: .375rem .75rem; white-space: nowrap; flex-shrink: 0; }
header #who, .pub { white-space: nowrap; flex-shrink: 0; }
.site-bar { display: flex; align-items: center; gap: .625rem; min-width: 0; flex: 0 1 auto; }
.site-name { min-width: 3rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-view { flex: 1; display: flex; min-height: 0; background: #8881; position: relative; overflow: hidden; }
/* Element selection over the preview (editor.js). Purple = AI. */
.site-view { --ai: #7c3aed; }
.hover-box, .selection { position: absolute; pointer-events: none; box-sizing: border-box; }
/* One focus indicator, drawn just outside the element: white then purple, so at least one ring
   has 3:1 contrast against any site colour (WCAG 2.4.11/2.4.13). The page itself isn't tinted. */
.hover-box { box-shadow: 0 0 0 1px #fff, 0 0 0 2px var(--ai); opacity: .6; }
.selection { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ai); }
/* AI control: just the star at the ring's bottom-left; expands into a prompt pill. */
.ai { position: absolute; z-index: 1; box-sizing: border-box; display: flex; flex-wrap: wrap; align-items: center; max-width: calc(100% - 1rem); }
.ai[hidden] { display: none; }
.ai-toggle { display: inline-flex; align-items: center; justify-content: center; width: 2.25rem; height: 2.25rem; padding: 0; border: 0; background: transparent; flex-shrink: 0; }
.ai-star { width: 1.75rem; height: 1.75rem; fill: var(--ai); stroke: #fff; stroke-width: 1.5; paint-order: stroke; stroke-linejoin: round; filter: drop-shadow(0 1px 2px #0004); transition: transform .15s; }
.ai-toggle:hover .ai-star { transform: scale(1.1); }
.ai-toggle:focus-visible { outline: 2px solid var(--ai); outline-offset: 2px; border-radius: 999px; }
.ai.open { width: min(24rem, calc(100% - 1rem)); padding: .125rem .375rem .125rem .125rem; background: Canvas; color: CanvasText; border: 2px solid var(--ai); border-radius: 1.25rem; box-shadow: 0 4px 16px #0003; }
.ai.open .ai-star { filter: none; }
.ai input { flex: 1; min-width: 0; border: 0; padding: .5rem .25rem; font: inherit; font-size: 1rem; background: transparent; color: inherit; }
.ai input:focus { outline: none; }
.ai.open:focus-within { box-shadow: 0 4px 16px #0003, 0 0 0 3px #c4b5fd; }
.ai-status { flex-basis: 100%; margin: 0 .5rem .375rem; font-size: .875rem; color: var(--muted); }
.ai-status:empty { display: none; }
.ai-status.error { color: #b91c1c; }
/* Working: the star spins (the element itself pulses, from editor.js). */
.ai.busy .ai-star { animation: ai-spin 1s linear infinite; }
@keyframes ai-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ai.busy .ai-star { animation: none; opacity: .6; } }
.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; }
.site-view iframe { flex: 1; border: 0; width: 100%; background: white; }
body.site-mode #who, body.site-mode #sign-out { display: none; }

header #site-save { background: var(--accent); color: white; border-color: transparent; }
header #site-save:disabled { cursor: default; background: #8882; color: var(--muted); }

/* Settings modal (centred on every screen size). */
.settings { box-sizing: border-box; width: min(28rem, calc(100vw - 2rem)); padding: 1.25rem; border: 1px solid #8886; border-radius: .75rem; background: Canvas; color: CanvasText; }
.settings::backdrop { background: #0006; }
.settings form { max-width: none; gap: .5rem; }
.settings h2 { margin: 0 0 .75rem; font-size: 1.25rem; }
.settings .switch { display: flex; align-items: center; gap: .75rem; padding: .75rem; margin-bottom: .75rem; border: 1px solid #8884; border-radius: .5rem; cursor: pointer; }
.settings .switch > span { display: grid; }
.settings .switch .note { font-size: .875rem; }
.settings .switch input { width: 1.25rem; height: 1.25rem; margin: 0; accent-color: var(--accent); }
.address-field { display: flex; align-items: center; gap: .25rem; font-size: .875rem; color: var(--muted); flex-wrap: wrap; }
.address-field input { flex: 1; min-width: 8rem; color: CanvasText; }
.settings .error { margin: 0; padding: 0; }
.settings .actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .75rem; }
@media (max-width: 40rem) { header #who, body.site-mode .site-bar, #site-settings .label, header .pub .label { display: none; } header { gap: .5rem; } }
/* Site name centred in the toolbar; hidden on phones. */
@media (min-width: 40.01rem) {
  body.site-mode .site-name { position: absolute; left: 50%; transform: translateX(-50%); max-width: calc(100% - 22rem); text-align: center; }
}

/* Icons: an SVG sprite (public/icons.svg), stroked in the current text colour. */
.icon { width: 1.125rem; height: 1.125rem; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
header .icon-button { display: inline-flex; align-items: center; justify-content: center; gap: .375rem; min-width: 2.25rem; min-height: 2.25rem; padding: .375rem .625rem; line-height: 1; }

/* Confirm the charity before adding a site. */
.confirm { border: 1px solid #8886; border-radius: .5rem; padding: 1rem; margin-top: 1rem; }
.confirm h2 { margin: 0 0 1rem; font-size: 1.25rem; }
.confirm dl { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1rem; margin: 0 0 1rem; }
.confirm dt { color: var(--muted); }
.confirm dd { margin: 0; overflow-wrap: anywhere; }
.confirm .actions { display: flex; gap: .5rem; justify-content: flex-end; }
@media (max-width: 30rem) { .confirm dl { grid-template-columns: 1fr; gap: .125rem; } .confirm dd { margin-bottom: .5rem; } }
.confirm .source { margin-top: .75rem; }

/* Publish status: filled green dot = live, hollow grey ring = offline. */
.pub { display: inline-flex; align-items: center; gap: .375rem; font-size: .8125rem; color: var(--muted); }
.pub .dot { width: .5rem; height: .5rem; border-radius: 50%; box-sizing: border-box; border: 1.5px solid #9ca3af; flex-shrink: 0; }
.pub.live .dot { background: #16a34a; border-color: #16a34a; box-shadow: 0 0 0 3px #16a34a26; }
header button.pub { background: none; border: 0; padding: .375rem .5rem; min-height: 2.25rem; min-width: 2.25rem; justify-content: center; color: var(--muted); }
header button.pub:hover .label { text-decoration: underline; }
.card .pub { color: #6b7280; }
