:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --border: #dfe3e8;
    --text: #16181d;
    --muted: #6b7280;
    --accent: #2f6fed;
    --accent-text: #ffffff;
    --danger: #c0362c;
    --radius: 12px;
    --shadow: 0 1px 3px rgb(16 18 29 / 8%), 0 4px 16px rgb(16 18 29 / 4%);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14161a;
        --surface: #1d2026;
        --border: #2e333c;
        --text: #eceef2;
        --muted: #9aa1ad;
        --accent: #5b8dff;
        --accent-text: #0d1017;
        --danger: #ef7c72;
        --shadow: none;
    }
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    /* Keep the capture button clear of the iOS home indicator. */
    padding-bottom: env(safe-area-inset-bottom);
}

.app-shell { min-height: 100dvh; display: flex; flex-direction: column; }

.app-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top));
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand { font-weight: 600; text-decoration: none; color: var(--text); }

.app-bar-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }

.who {
    font-size: 13px;
    color: var(--muted);
    max-width: 40vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-body { flex: 1; width: 100%; max-width: 900px; margin: 0 auto; padding: 16px; }

h1 { font-size: 22px; margin: 0 0 16px; }

.muted { color: var(--muted); }
.center { text-align: center; }
.empty { padding: 40px 0; }

.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;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}

.narrow { max-width: 380px; margin-inline: auto; }

.stack { display: flex; flex-direction: column; gap: 14px; text-align: left; }

.field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.field > span { font-size: 13px; font-weight: 500; color: var(--muted); }

.field input {
    /* 16px keeps iOS Safari from zooming the viewport on focus. */
    font-size: 16px;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    width: 100%;
}

.field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn, .btn-ghost, .btn-link {
    font: inherit;
    cursor: pointer;
    border-radius: 8px;
    /* Apple's minimum comfortable tap target. */
    min-height: 44px;
    padding: 10px 16px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.big { width: 100%; min-height: 56px; font-size: 17px; }

.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); font-size: 14px; padding: 8px 10px; }
.btn-ghost.danger { color: var(--danger); }

.btn-link { border: 0; background: none; color: var(--accent); text-decoration: underline; padding: 8px 0; }

.btn:disabled, .btn-ghost:disabled, .btn-link:disabled { opacity: .55; cursor: not-allowed; }

.row { display: flex; gap: 10px; }
.row > .btn { flex: 1; }
.row.tight { gap: 4px; justify-content: flex-end; }

.capture { margin-bottom: 20px; }

.preview img {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 14px;
    display: block;
}

.alert { border-radius: 8px; padding: 10px 12px; font-size: 14px; margin: 0; }
.alert.error { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.alert.info { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.tile {
    margin: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.tile img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--bg); }

.tile-broken {
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 13px;
    background: var(--bg);
}

.tile figcaption { padding: 8px 10px 0; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.tile .cap { font-size: 14px; overflow-wrap: anywhere; }
.tile time { font-size: 12px; color: var(--muted); }
.tile > .btn-ghost, .tile > .row { align-self: flex-end; }

.validation-message { color: var(--danger); font-size: 13px; }

#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 0 0 0;
    z-index: 1000;
    padding: 12px 16px;
    background: #f3d34a;
    color: #16181d;
}

#blazor-error-ui .dismiss { cursor: pointer; float: right; }

.loading-progress-text { text-align: center; padding-top: 30vh; color: var(--muted); }
