@font-face {
    font-family: "Serotiva";
    src: url("fonts/serotiva-regular-webfont.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Serotiva";
    src: url("fonts/serotiva-semibold-webfont.woff2") format("woff2");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Serotiva";
    src: url("fonts/serotiva-bold-webfont.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg: #F6F5F3;
    --card: #FFFFFF;
    --text: #25282A;
    --muted: #52575C;
    --accent: #E4002B;
    --accent-press: #C00024;
    --accent-text: #FFFFFF;
    --border: #E8E3DC;
    --error-bg: #FFE4E6;
    --error-text: #BE123C;
    --focus: #E4002B;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1A1A1A;
        --card: #2A2A2A;
        --text: #F5F5F5;
        --muted: #BFBFBF;
        --accent: #FF3354;
        --accent-press: #E4002B;
        --accent-text: #1A1A1A;
        --border: #3D3D3D;
        --error-bg: #4C0519;
        --error-text: #FB7185;
        --focus: #FF3354;
        color-scheme: dark;
    }
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Serotiva", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 17px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    text-rendering: optimizeLegibility;
}

main {
    max-width: 28rem;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    padding: max(1.5rem, env(safe-area-inset-top)) 1.25rem max(1.5rem, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding-top: 1rem;
}

.brand h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -.01em;
}

section {
    display: flex;
    flex-direction: column;
    gap: .875rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem 1.25rem;
}

section[hidden],
[hidden] {
    display: none !important;
}

.lead {
    margin: 0;
    font-size: 1.125rem;
}

.lead:focus {
    outline: none;
}

code {
    font-size: .95em;
}

button {
    font: inherit;
    cursor: pointer;
    border-radius: 8px;
    min-height: 3.25rem;
    padding: .75rem 1rem;
    border: 1px solid transparent;
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.primary {
    background: var(--accent);
    color: var(--accent-text);
    font-weight: 600;
}

.primary:active {
    background: var(--accent-press);
}

.primary.big {
    min-height: 9rem;
    font-size: 1.375rem;
}

.secondary {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}

.link {
    background: transparent;
    color: var(--accent);
    min-height: 2.75rem;
    padding: .5rem;
    font-weight: 600;
}

.receipts {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .5rem;
}

.receipts li {
    position: relative;
    aspect-ratio: 3 / 4;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg);
}

.receipts.single {
    grid-template-columns: 1fr;
}

.receipts.single li {
    aspect-ratio: auto;
}

.receipts img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.receipts.single img {
    height: auto;
    max-height: 22rem;
    object-fit: contain;
}

.file-name {
    margin: 0;
    padding: 2.75rem .75rem 1rem;
    font-size: .85rem;
    word-break: break-all;
}

.receipts .remove {
    position: absolute;
    top: .35rem;
    right: .35rem;
    min-height: 0;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, .6);
    color: #FFFFFF;
    font-size: 1.25rem;
    line-height: 1;
}

.add-more {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.add-more[hidden] {
    display: none;
}

.history {
    margin-top: .5rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.history h2 {
    margin: 0 0 .5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--muted);
}

.history ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.history li {
    display: flex;
    gap: .75rem;
    font-size: .95rem;
}

.history .when {
    flex: none;
    width: 6.5rem;
    color: var(--muted);
}

.history .what {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.field-label {
    font-weight: 600;
}

.field-label span {
    color: var(--muted);
    font-weight: 400;
}

input[type="text"] {
    font: inherit;
    width: 100%;
    min-height: 3.25rem;
    padding: .75rem .875rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
}

.error {
    margin: 0;
    padding: .875rem 1rem;
    border-radius: 8px;
    background: var(--error-bg);
    color: var(--error-text);
}

footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    color: var(--muted);
    font-size: .9rem;
}

footer span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.spinner {
    width: 2.5rem;
    height: 2.5rem;
    margin: .5rem auto 0;
    border-radius: 50%;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation-duration: 3s;
    }
}
