/* ---------- Base (mobile) styles first ---------- */
:root {
    --bg: #f6f5f3;
    --surface: #ffffff;
    --text: #1f1c1a;
    --muted: #7a7570;
    --accent: #1e7dd1;
    --accent-dark: #1e57d1;
    --border: #e6e2dd;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-dark); text-decoration: none; }

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 16px;
}

.brand {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
}

.app-main {
    padding: 16px;
    max-width: 720px;
    margin: 0 auto;
}

h1 { font-size: 1.4rem; margin: 8px 0 16px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }

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

.item-list { display: flex; flex-direction: column; gap: 12px; list-style: none; padding: 0; margin: 0; }

.item-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow);
}

.item-thumb {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    object-fit: cover;
    background: var(--border);
    flex-shrink: 0;
}

.item-thumb.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: var(--muted);
}

.item-info { flex: 1; min-width: 0; }
.item-name { font-weight: 600; display: block; }
.item-meta { font-size: 0.85rem; color: var(--muted); }

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

/* Buttons and inputs — sized for touch */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 12px 18px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    text-align: center;
}

.btn:hover { background: var(--accent-dark); }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--bg); }

.btn-danger { background: #b3261e; }
.btn-danger:hover { background: #8f1e18; }

.btn-fab {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    font-size: 1.6rem;
    padding: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.form-group { margin-bottom: 16px; }

label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.95rem;
}

input[type="text"],
input[type="file"] {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    background: var(--surface);
    color: var(--text);
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

.field-error { color: #b3261e; font-size: 0.85rem; margin-top: 4px; }

.back-link { display: inline-block; margin-bottom: 12px; color: var(--muted); }

.photo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 12px;
}

.photo-grid figure {
    margin: 0;
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    overflow: hidden;
    background: var(--border);
}

.photo-grid img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    cursor: zoom-in;
}

/* ---------- Lightbox ---------- */
.lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.lightbox-overlay.open { display: flex; }

.lightbox-overlay img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.lightbox-close:hover { background: rgba(255,255,255,0.3); }

.action-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.photo-grid figcaption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.65), rgba(0,0,0,0));
    color: #fff;
    font-size: 0.68rem;
    padding: 12px 6px 4px;
    text-align: left;
    pointer-events: none;
}

.photo-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
}

.preview-thumb {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 8px;
    margin: 4px 4px 0 0;
    border: 1px solid var(--border);
}

#photoPreview { display: flex; flex-wrap: wrap; }

.upload-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ---------- Larger screens ---------- */
@media (min-width: 600px) {
    .app-main { padding: 24px; }

    .btn { width: auto; }

    .upload-row {
        flex-direction: row;
        align-items: flex-end;
    }

    .upload-row input[type="file"] { flex: 1; }

    .action-stack { flex-direction: row; }

    .photo-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 900px) {
    .photo-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}
