/*
 * Calm by design: soft colours, large readable type, clear focus states,
 * predictable layouts and no motion. Viewers may be anxious or sensitive
 * to sensory input, so nothing flashes, slides or plays on its own.
 */

:root {
    --bg: #f6f4ef;
    --surface: #ffffff;
    --surface-2: #efece5;
    --text: #1d2a2f;
    --muted: #55636a;
    --border: #ddd8cd;
    --accent: #2d6a6e;
    --accent-strong: #1f5155;
    --accent-soft: #dcebea;
    --on-accent: #ffffff;
    --success: #2d6b45;
    --success-soft: #e0efe4;
    --warning: #7a5a00;
    --warning-soft: #f7edcf;
    --danger: #a23a2f;
    --danger-soft: #f6e1dd;
    --focus: #e3a21a;
    --shadow: 0 1px 2px rgba(29, 42, 47, .06), 0 4px 16px rgba(29, 42, 47, .05);
    --radius: 14px;
    --radius-small: 10px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #141a1c;
        --surface: #1b2326;
        --surface-2: #222c30;
        --text: #e6ecec;
        --muted: #a3b0b3;
        --border: #313d41;
        --accent: #7fc1c3;
        --accent-strong: #a6d6d7;
        --accent-soft: #23393b;
        --on-accent: #0f1a1c;
        --success: #8fcfa3;
        --success-soft: #1f3327;
        --warning: #e7c46a;
        --warning-soft: #352c14;
        --danger: #f0a196;
        --danger-soft: #3a211e;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3);
        color-scheme: dark;
    }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 17px/1.6 var(--font);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main { flex: 1; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.75rem, 1.4rem + 1.5vw, 2.4rem); }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-underline-offset: 3px; }
@media (hover: hover) { a:hover { color: var(--accent-strong); } }

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
    border-radius: 4px;
}

img, video { max-width: 100%; display: block; }

.container {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 16px;
}

@media (min-width: 720px) {
    .container { padding: 0 32px; }
}

.narrow { max-width: 720px; }

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

.skip-link {
    position: absolute;
    left: 16px;
    top: -60px;
    background: var(--surface);
    padding: 8px 14px;
    border-radius: var(--radius-small);
    z-index: 10;
}
.skip-link:focus { top: 12px; }

.muted { color: var(--muted); }
.small { font-size: .9rem; }
.stack > * + * { margin-top: 16px; }
.stack-large > * + * { margin-top: 28px; }
[hidden] { display: none !important; }

/* ---------- Header and footer ---------- */

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.site-header .container {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 68px;
    flex-wrap: wrap;
    padding-top: 8px;
    padding-bottom: 8px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
    text-decoration: none;
    margin-right: auto;
}
.brand svg { width: 34px; height: 34px; flex: none; color: var(--accent); }
.brand-org { font-weight: 500; color: var(--muted); }

.nav {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    align-items: center;
}

.nav a, .nav button.link {
    padding: 8px 12px;
    border-radius: var(--radius-small);
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
}
@media (hover: hover) { .nav a:hover, .nav button.link:hover { background: var(--surface-2); } }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); }
.nav a.btn-primary, .nav a.btn-primary:hover { background: var(--accent); color: var(--on-accent); padding: 6px 16px; border-radius: 999px; font-weight: 600; }
.nav form { margin: 0; }

button.link {
    background: none;
    border: 0;
    font: inherit;
    cursor: pointer;
    color: var(--accent);
    padding: 0;
}

.site-footer {
    padding: 32px 0 40px;
    color: var(--muted);
    font-size: .9rem;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 10px 20px;
    border-radius: 999px;
    border: 2px solid transparent;
    font: 600 1rem/1.2 var(--font);
    text-decoration: none;
    cursor: pointer;
    background: var(--surface-2);
    color: var(--text);
}
@media (hover: hover) { .btn:hover { filter: brightness(.97); color: inherit; } }
.btn svg { width: 20px; height: 20px; flex: none; }

.btn-primary { background: var(--accent); color: var(--on-accent); }
@media (hover: hover) { .btn-primary:hover { background: var(--accent-strong); color: var(--on-accent); } }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
@media (hover: hover) { .btn-secondary:hover { border-color: var(--muted); } }
.btn-danger { background: var(--danger); color: #fff; }
@media (hover: hover) { .btn-danger:hover { color: #fff; } }
.btn-small { min-height: 38px; padding: 6px 14px; font-size: .92rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .55; cursor: not-allowed; }

.button-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* ---------- Forms ---------- */

.field { margin-bottom: 22px; }
.field label, .label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}
.hint { display: block; color: var(--muted); font-size: .92rem; margin: -2px 0 8px; font-weight: 400; }

input[type="text"], input[type="email"], input[type="password"], input[type="url"], textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-small);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
input:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

.has-error input, .has-error textarea { border-color: var(--danger); }
.error-text { color: var(--danger); font-weight: 600; font-size: .95rem; margin-top: 6px; }

.input-prefix {
    display: flex;
    align-items: stretch;
    border: 2px solid var(--border);
    border-radius: var(--radius-small);
    background: var(--surface);
    overflow: hidden;
}
.input-prefix span {
    display: flex;
    align-items: center;
    padding: 0 4px 0 14px;
    color: var(--muted);
    white-space: nowrap;
}
.input-prefix input { border: 0; padding-left: 2px; min-width: 0; }
.input-prefix input:focus { box-shadow: none; }
.input-prefix:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Cards, notices, pills ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}
.card h2 { font-size: 1.2rem; }
.card + .card { margin-top: 20px; }

.notice {
    padding: 14px 18px;
    border-radius: var(--radius-small);
    margin-bottom: 20px;
    border: 1px solid transparent;
}
.notice-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.notice-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.notice-warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.notice-info { background: var(--accent-soft); color: var(--accent-strong); }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 12px;
    border-radius: 999px;
    font-size: .85rem;
    font-weight: 600;
    white-space: nowrap;
    background: var(--surface-2);
    color: var(--muted);
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill-live { background: var(--success-soft); color: var(--success); }
.pill-processing { background: var(--accent-soft); color: var(--accent-strong); }
.pill-failed { background: var(--danger-soft); color: var(--danger); }
.pill-plain::before { display: none; }

/* ---------- Page structure ---------- */

.page { padding: 32px 0 48px; }

.page-head {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; }

.back-link {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    margin-bottom: 12px;
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
}
.back-link svg { width: 20px; height: 20px; flex: none; }

/* ---------- Dashboard: story list ---------- */

.story-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }

.story-row {
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 16px;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
}

.thumb {
    aspect-ratio: 16 / 10;
    width: 100%;
    border-radius: var(--radius-small);
    background: var(--surface-2);
    object-fit: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    overflow: hidden;
}
.thumb svg { width: 32px; height: 32px; opacity: .7; }

.story-row h2 { font-size: 1.1rem; margin: 0 0 6px; }
.story-row h2 a { color: var(--text); text-decoration: none; }
@media (hover: hover) { .story-row h2 a:hover { text-decoration: underline; } }
.story-meta { display: flex; gap: 8px 14px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: .92rem; }

.story-actions { display: flex; gap: 8px; flex-wrap: wrap; grid-column: 1 / -1; }
.story-actions form { margin: 0; }

.story-row .thumb { aspect-ratio: 9 / 16; }

@media (min-width: 760px) {
    .story-row { grid-template-columns: 84px 1fr auto; }
    .story-actions { grid-column: auto; justify-content: flex-end; }
}

.order-buttons { display: inline-flex; gap: 4px; }
.icon-button {
    width: 38px; height: 38px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}
@media (hover: hover) { .icon-button:hover { background: var(--surface-2); } }
.icon-button svg { width: 18px; height: 18px; }
.icon-button[disabled] { opacity: .35; cursor: default; }

.empty-state {
    text-align: center;
    padding: 48px 24px;
}
.empty-state svg { width: 64px; height: 64px; color: var(--accent); margin: 0 auto 16px; }
.empty-state p { max-width: 520px; margin-left: auto; margin-right: auto; }

/* ---------- Dashboard: story editor ---------- */

.editor-grid { display: grid; gap: 24px; }
@media (min-width: 960px) {
    .editor-grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
    .editor-side { position: sticky; top: 20px; }
}

.status-line { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }

.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 28px 20px;
    text-align: center;
    background: var(--surface-2);
}
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone > svg { width: 40px; height: 40px; color: var(--accent); margin: 0 auto 8px; }
.dropzone p { margin-bottom: 12px; }

.progress {
    height: 12px;
    border-radius: 999px;
    background: var(--surface-2);
    overflow: hidden;
    margin: 12px 0 8px;
}
.progress-bar {
    height: 100%;
    width: 0;
    background: var(--accent);
    border-radius: 999px;
}

.qr-box {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 16px;
    align-items: center;
}
.qr {
    background: #fff;
    border-radius: var(--radius-small);
    padding: 8px;
    aspect-ratio: 1;
    border: 1px solid var(--border);
}
.qr svg { width: 100%; height: 100%; display: block; }

.share-link { margin: 20px 0 0; }
.copy-field { display: flex; gap: 8px; }
.copy-field input { flex: 1; min-width: 0; font-size: .92rem; padding: 8px 12px; }

.stats { display: flex; gap: 24px; }
.stat strong { display: block; font-size: 1.6rem; line-height: 1.2; }
.stat span { color: var(--muted); font-size: .9rem; }

.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }

/* ---------- Billing ---------- */

.lead { font-size: 1.1rem; color: var(--muted); margin-top: -4px; }
.notice > p { margin: 0; }
.notice > p + p { margin-top: 10px; }
.billing-badge { margin: 0 0 8px; }
.billing-status h2 { margin-top: 0; }
.billing-status .button-row { margin-top: 18px; }
.billing-status .button-row form { margin: 0; }
.billing-status .btn svg, .billing-banner .btn svg { width: 18px; height: 18px; }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; }
.checklist svg { width: 20px; height: 20px; flex: none; margin-top: 2px; color: var(--success); }
.qa { margin: 0; }
.qa dt { font-weight: 600; margin-top: 16px; }
.qa dt:first-child { margin-top: 0; }
.qa dd { margin: 4px 0 0; color: var(--muted); }
.billing-banner { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.billing-banner p { margin: 0; flex: 1 1 260px; }
.billing-banner form { margin: 0; }
.account-plan { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.account-plan p { margin: 0; }

details.help { margin-top: 8px; }
details.help summary { cursor: pointer; color: var(--accent); font-weight: 600; }
details.help ul { margin: 10px 0 0; padding-left: 20px; color: var(--muted); }

/* ---------- Video player (shared) ---------- */

.player {
    position: relative;
    background: #0d1214;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 16 / 9;
}
.player.is-portrait { aspect-ratio: 9 / 16; max-height: 78vh; margin: 0 auto; }
.player video { width: 100%; height: 100%; object-fit: contain; background: #0d1214; }

.player-error {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
    color: #e6ecec;
    background: rgba(13, 18, 20, .88);
}

.player-controls { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0 10px; }

.toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }

.no-video {
    aspect-ratio: 16 / 9;
    border-radius: var(--radius);
    background: var(--surface-2);
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--muted);
    padding: 24px;
}
.no-video svg { width: 40px; height: 40px; }

/* ---------- Shared story content (steps, good to know) ---------- */

.section-title {
    font-size: 1.15rem;
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 24px;
}
.section-title svg { width: 24px; height: 24px; color: var(--accent); flex: none; }

.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; display: grid; gap: 10px; }
.steps li {
    counter-increment: step;
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 14px;
    align-items: start;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    font-size: 1.08rem;
    line-height: 1.5;
}
.steps li::before {
    content: counter(step);
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}

.good-to-know {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 6px solid var(--accent);
    border-radius: var(--radius);
    padding: 4px 18px 18px;
    margin-top: 24px;
}

/* ---------- Consumer app shell: top bar, column, bottom tabs ---------- */

.app-column { width: 100%; max-width: 560px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }

.consumer { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }

.app-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding-top: env(safe-area-inset-top);
}
.app-bar-inner { display: flex; align-items: center; gap: 8px; min-height: 56px; }
.app-bar .brand { font-size: 1.05rem; }
.app-bar .brand svg { width: 30px; height: 30px; color: var(--accent); }
.app-bar-back { display: inline-flex; width: 40px; height: 40px; align-items: center; justify-content: center; margin-left: -8px; color: var(--text); border-radius: 50%; }
.app-bar-back svg { width: 26px; height: 26px; }
.install-button {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    border-radius: 999px; padding: 6px 14px; font: 600 .9rem var(--font); cursor: pointer;
}
.install-button svg { width: 18px; height: 18px; }

.app-main { padding-top: 20px; padding-bottom: 24px; }

.tab-bar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 20;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
}
.tab-bar-inner { display: flex; }
.tab-bar a {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 60px;
    color: var(--muted);
    text-decoration: none;
    font-size: .8rem;
    font-weight: 600;
}
.tab-bar a svg { width: 26px; height: 26px; }
.tab-bar a[aria-current="page"] { color: var(--accent); }

.page-title { font-size: 1.6rem; margin-bottom: 6px; }
.section-heading { font-size: 1.1rem; margin: 28px 0 12px; }

/* ---------- Home and search ---------- */

.home-hero h1 { font-size: 1.85rem; margin-bottom: 8px; }
.home-hero > p { font-size: 1.05rem; margin-bottom: 20px; }
.home-hero .btn-block { margin-top: 12px; }

.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 999px;
    padding: 0 18px;
    min-height: 54px;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box svg { width: 22px; height: 22px; color: var(--muted); flex: none; }
.search-box input { border: 0; background: none; padding: 12px 0; font-size: 1.05rem; box-shadow: none; }
.search-box input:focus { box-shadow: none; }
.search-page .search-box { margin-bottom: 16px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    padding: 8px 16px; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--border);
    color: var(--text); text-decoration: none; font-weight: 600; font-size: .95rem;
}

.home-section { margin-top: 8px; }
.business-card { margin-top: 36px; padding: 20px; background: var(--surface-2); border-radius: var(--radius); }
.business-card h2 { font-size: 1.1rem; margin-bottom: 4px; }
.install-hint { margin-top: 24px; }
.install-hint svg { width: 18px; height: 18px; vertical-align: -3px; }

/* Avatars and "story rings" */
.avatar {
    width: 48px; height: 48px;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.05rem; letter-spacing: .02em;
    color: #fff;
    object-fit: cover;
    flex: none;
}
.avatar-sm { width: 34px; height: 34px; font-size: .8rem; }
.avatar-lg { width: 84px; height: 84px; font-size: 1.7rem; }
.avatar-c0 { background: #2d6a6e; }
.avatar-c1 { background: #5b6f9c; }
.avatar-c2 { background: #7a6a4f; }
.avatar-c3 { background: #4f7a5c; }
.avatar-c4 { background: #8a5a6e; }
.avatar-c5 { background: #4f6f7a; }

.ring {
    display: inline-flex;
    padding: 3px;
    border-radius: 50%;
    border: 2.5px solid var(--accent);
    background: var(--bg);
    flex: none;
}
.ring .avatar { display: flex; }
.ring-lg { padding: 4px; border-width: 3px; }

.ring-row { list-style: none; margin: 0 -16px; padding: 0 16px 4px; display: flex; gap: 14px; overflow-x: auto; scrollbar-width: none; }
.ring-row::-webkit-scrollbar { display: none; }
.ring-row a { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 76px; text-decoration: none; color: var(--text); }
.ring-row .avatar { width: 64px; height: 64px; }
.ring-label { font-size: .8rem; text-align: center; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.place-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.place-row {
    display: flex; align-items: center; gap: 14px;
    padding: 10px 4px;
    color: var(--text); text-decoration: none;
    border-radius: var(--radius-small);
}
.place-row > svg { width: 20px; height: 20px; color: var(--muted); flex: none; margin-left: auto; }
.place-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.place-text strong { font-size: 1.05rem; }
.place-meta { color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Scanner ---------- */

.scanner {
    position: relative;
    aspect-ratio: 3 / 4;
    max-height: 60vh;
    width: 100%;
    margin: 16px auto 0;
    border-radius: 22px;
    overflow: hidden;
    background: #11181a;
}
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner-frame {
    position: absolute;
    inset: 18% 14%;
    border-radius: 18px;
    box-shadow: 0 0 0 999px rgba(0, 0, 0, .35);
    border: 3px solid rgba(255, 255, 255, .9);
    display: none;
}
.scanner.is-scanning .scanner-frame { display: block; }
.scanner-idle {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
    text-align: center; padding: 24px; color: #e6ecec;
}
.scanner-idle > svg { width: 48px; height: 48px; }
.scan-status { min-height: 1.6em; margin: 12px 0 0; font-weight: 600; }
.code-form { margin-top: 24px; }
.code-form label { font-weight: 600; display: block; }

/* ---------- Place profile ---------- */

.profile-head { display: flex; align-items: center; gap: 18px; margin-bottom: 16px; }
.profile-head h1 { font-size: 1.5rem; margin: 0 0 2px; }
.profile-head p { margin: 0; }
.profile-about { margin-bottom: 12px; }
.profile-links { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 6px; color: var(--muted); }
.profile-links li { display: flex; gap: 8px; align-items: flex-start; }
.profile-links svg { width: 20px; height: 20px; flex: none; margin-top: 3px; }

.tile-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 480px) { .tile-grid { grid-template-columns: repeat(3, 1fr); } }
.tile {
    position: relative;
    display: block;
    aspect-ratio: 9 / 16;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface-2);
    color: #fff;
    text-decoration: none;
}
.tile img { width: 100%; height: 100%; object-fit: cover; }
.tile-placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.tile-placeholder svg { width: 36px; height: 36px; }
.tile-text {
    position: absolute; left: 0; right: 0; bottom: 0;
    padding: 36px 10px 10px;
    background: linear-gradient(transparent, rgba(0, 0, 0, .72));
    display: flex; flex-direction: column; gap: 2px;
}
.tile-title { font-weight: 700; line-height: 1.25; }
.tile-meta { font-size: .8rem; display: flex; align-items: center; gap: 4px; opacity: .9; }
.tile-meta svg { width: 12px; height: 12px; }

/* ---------- Full-screen story viewer ---------- */

.viewer-page, .viewer-body { background: #000; height: 100%; overflow: hidden; }
.viewer-body { display: block; min-height: 0; overscroll-behavior: none; }

.viewer {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    background: #000;
    color: #fff;
    -webkit-user-select: none;
    user-select: none;
}
.viewer-stage {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
}
/* Wider screens: a phone-shaped 9:16 stage in the middle, like Instagram on the web. */
@media (min-aspect-ratio: 10 / 16) {
    .viewer-stage { width: calc(100vh * 9 / 16); width: calc(100dvh * 9 / 16); }
}

.viewer-backdrop {
    position: absolute;
    inset: -40px;
    background-size: cover;
    background-position: center;
    filter: blur(28px) brightness(.5);
    display: none;
}
.viewer.is-landscape .viewer-backdrop { display: block; }

.viewer-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: transparent;
}
.viewer.is-landscape .viewer-video { object-fit: contain; }

.viewer-text {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 96px 28px;
    text-align: center;
    background: linear-gradient(160deg, #2d6a6e, #1f3f42);
}
.viewer-text h2 { font-size: 1.6rem; }

.viewer-top {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 3;
    padding: calc(env(safe-area-inset-top) + 10px) 12px 28px;
    background: linear-gradient(rgba(0, 0, 0, .55), transparent);
}
.viewer-progress { display: flex; gap: 4px; }
.viewer-progress span { flex: 1; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .35); overflow: hidden; }
.viewer-progress i { display: block; height: 100%; width: 0; background: #fff; }

.viewer-head { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.viewer-org { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; color: #fff; text-decoration: none; text-shadow: 0 1px 3px rgba(0, 0, 0, .5); }
.viewer-org > span:last-child { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.viewer-org strong { font-size: .95rem; }
.viewer-org [data-story-title] { font-size: .85rem; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.viewer-icon {
    width: 44px; height: 44px;
    flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    border: 0; border-radius: 50%;
    background: transparent; color: #fff;
    font: 700 .85rem var(--font);
    cursor: pointer;
}
.viewer-icon svg { width: 24px; height: 24px; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .5)); }
.viewer-icon[aria-pressed="true"] { background: #fff; color: #000; }

.viewer-preview { background: var(--warning-soft); color: var(--warning); font-size: .85rem; padding: 6px 10px; border-radius: 8px; margin-bottom: 8px; text-shadow: none; }
.viewer-preview a { color: inherit; }

.viewer-tap {
    position: absolute;
    top: 0; bottom: 0;
    z-index: 2;
    border: 0;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.viewer-tap-prev { left: 0; width: 30%; }
.viewer-tap-next { right: 0; width: 70%; }
.viewer-tap:focus-visible { outline-offset: -6px; }

.viewer-bottom {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 32px 12px calc(env(safe-area-inset-bottom) + 14px);
    background: linear-gradient(transparent, rgba(0, 0, 0, .6));
}
.viewer-steps-button {
    display: inline-flex; align-items: center; gap: 6px;
    min-height: 44px;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .35);
    background: rgba(255, 255, 255, .16);
    color: #fff;
    font: 600 .95rem var(--font);
    cursor: pointer;
}
.viewer-steps-button svg { width: 18px; height: 18px; }
.viewer-controls { display: flex; gap: 2px; }

/* While a finger is held down, get the controls out of the way. */
.viewer.is-held .viewer-top, .viewer.is-held .viewer-bottom { opacity: 0; }

.viewer-start, .viewer-end {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 24px 28px;
    text-align: center;
}
.viewer-start { background: radial-gradient(circle, rgba(0, 0, 0, .15), rgba(0, 0, 0, .55)); cursor: pointer; }
.viewer-play {
    width: 92px; height: 92px;
    border-radius: 50%;
    border: 0;
    background: #fff;
    color: var(--accent-strong);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
    cursor: pointer;
}
.viewer-play svg { width: 40px; height: 40px; margin-left: 6px; color: #2d6a6e; }
.viewer-start-title { font-size: 1.5rem; font-weight: 700; text-shadow: 0 2px 8px rgba(0, 0, 0, .6); margin: 8px 0 0; }
.viewer-start-meta { display: flex; align-items: center; gap: 6px; opacity: .95; text-shadow: 0 1px 4px rgba(0, 0, 0, .6); }
.viewer-start-meta svg { width: 20px; height: 20px; }

.viewer-end { background: rgba(10, 14, 16, .82); }
.viewer-end .btn { max-width: 340px; }
.viewer-end-title { font-size: 1.25rem; font-weight: 700; margin-bottom: 8px; }
.btn-light { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .28); }

.sheet-scrim { position: fixed; inset: 0; z-index: 8; background: rgba(0, 0, 0, .5); }
.viewer-sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 9;
    max-width: 560px;
    max-height: 86vh;
    max-height: 86dvh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    border-radius: 22px 22px 0 0;
    -webkit-user-select: text;
    user-select: text;
}
.viewer-sheet[hidden] { display: none; }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 10px auto 2px; flex: none; }
.sheet-scroll { overflow-y: auto; padding: 10px 20px 20px; overscroll-behavior: contain; }
.sheet-scroll h2 { font-size: 1.4rem; }
.sheet-scroll h2:focus { outline: none; }
.sheet-address { display: flex; gap: 8px; color: var(--muted); margin-top: 20px; }
.sheet-address svg { width: 20px; height: 20px; flex: none; margin-top: 3px; }
.sheet-actions { padding: 12px 20px calc(env(safe-area-inset-bottom) + 12px); border-top: 1px solid var(--border); flex: none; }

/* ---------- Auth ---------- */

.auth { padding: 40px 0 64px; }
.auth .card { max-width: 480px; margin: 0 auto; padding: 32px; }
.auth h1 { font-size: 1.8rem; }
.auth-switch { text-align: center; margin-top: 20px; }

/* ---------- For organisations ---------- */

.how { display: grid; gap: 14px; margin: 0 0 32px; padding: 0; list-style: none; }
.how li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.how .step-number {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent-strong);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; margin-bottom: 12px;
}
.how h3 { margin-bottom: 6px; }
.how p { color: var(--muted); }

/* ---------- Printable poster ---------- */

.print-toolbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
}
.print-toolbar .container { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.print-toolbar .back-link { margin: 0 auto 0 0; }

.poster-notice { margin: 24px 0 0; }
.poster-wrap { padding: 32px 16px 48px; display: flex; justify-content: center; }

.poster {
    background: #fff;
    color: #1d2a2f;
    width: 100%;
    max-width: 794px;
    aspect-ratio: 210 / 297;
    padding: 7% 8%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: var(--shadow);
    border-radius: 6px;
}
.poster-org { font-size: clamp(1rem, 2.6vw, 1.5rem); font-weight: 600; color: #55636a; margin-bottom: .4em; }
.poster h1 { font-size: clamp(1.6rem, 5.4vw, 3rem); margin-bottom: .3em; color: #1d2a2f; }
.poster-lead { font-size: clamp(1rem, 2.8vw, 1.5rem); color: #1d2a2f; max-width: 22em; }
.poster .qr { width: 64%; margin: 4% auto; border: 0; padding: 0; }
.poster-steps { display: flex; gap: 6%; justify-content: center; font-size: clamp(.8rem, 2vw, 1.1rem); color: #55636a; margin-bottom: 1em; }
.poster-url { font-size: clamp(.85rem, 2.2vw, 1.15rem); font-weight: 600; color: #2d6a6e; margin-top: auto; word-break: break-all; }
.poster-brand { display: flex; align-items: center; gap: 8px; margin-top: .6em; font-size: clamp(.75rem, 1.8vw, .95rem); font-weight: 700; color: #55636a; }
.poster-brand svg { width: 1.6em; height: 1.6em; color: #2d6a6e; }

@page { size: A4; margin: 0; }

@media print {
    body { background: #fff; display: block; }
    .print-toolbar, .site-footer, .no-print { display: none !important; }
    .poster-wrap { padding: 0; }
    .poster { box-shadow: none; border-radius: 0; max-width: none; width: 210mm; height: 297mm; aspect-ratio: auto; padding: 18mm 16mm; }
    .poster .qr { width: 120mm; }
}

/* ---------- Dashboard on phones: bottom tabs instead of the top menu ---------- */

.dash-tabs { display: none; }
@media (max-width: 760px) {
    .has-dash-tabs .desktop-only { display: none; }
    .has-dash-tabs .dash-tabs { display: block; }
    .has-dash-tabs { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
    .has-dash-tabs .site-footer { display: none; }
    .site-header { padding-top: env(safe-area-inset-top); }
}

/* ---------- Small phones ---------- */

@media (max-width: 560px) {
    .nav a.btn-primary { padding: 6px 14px; }
    .page-head .button-row > * { flex: 1 1 auto; }
    .page-head .button-row form .btn { width: 100%; }
    .qr-box { grid-template-columns: 1fr; justify-items: center; }
    .qr-box .qr { width: 168px; }
    .qr-box .stack { width: 100%; display: flex; flex-wrap: wrap; gap: 10px; }
    .qr-box .stack > * { flex: 1 1 auto; }
    .qr-box .stack > * + * { margin-top: 0; }
    .copy-field { flex-wrap: wrap; }
    .copy-field input { flex-basis: 100%; }
}

/* ---------- Error page ---------- */

.error-page { text-align: center; padding: 72px 0; }
.error-page svg { width: 64px; height: 64px; color: var(--accent); margin: 0 auto 16px; }

@media (prefers-reduced-motion: no-preference) {
    .progress-bar { transition: width .4s ease; }
}
