/* ============ Tokens ============ */
:root {
    --bg:           #f5f7f9;
    --surface:      #ffffff;
    --border:       #e4e7ec;
    --text:         #0f172a;
    --muted:        #64748b;
    --accent:       #0f766e;
    --accent-2:     #14b8a6;
    --accent-soft:  #e6f7f4;
    --danger:       #dc2626;
    --radius:       14px;
    --radius-lg:    20px;
    --shadow-sm:    0 1px 2px rgba(15,23,42,.05), 0 1px 3px rgba(15,23,42,.06);
    --shadow-md:    0 10px 28px rgba(15,23,42,.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }

.container {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

main.container { flex: 1; padding-top: 1.5rem; padding-bottom: 3rem; }

/* ============ Header ============ */
.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255,255,255,.85);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
}
.site-header .nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}
.brand {
    font-family: 'Playfair Display', 'Inter', serif;
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.01em;
}
.brand span { color: var(--accent); }
.nav-actions { display: flex; gap: .4rem; }

/* ============ Buttons ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .65rem 1.1rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform .08s, background .15s, box-shadow .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--accent-soft); border-color: var(--accent-2); color: var(--accent); }
.btn:active { transform: translateY(1px); }

.btn-small  { padding: .45rem .9rem; font-size: .82rem; border-radius: 999px; }
.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 6px 14px rgba(15,118,110,.25);
}
.btn-primary:hover { background: #0b5f58; border-color: #0b5f58; color: #fff; }
.btn-ghost  { background: #fff; }
.btn-danger { color: var(--danger); border-color: #f1c0c0; }
.btn-danger:hover { background: #fef2f2; border-color: #f1c0c0; color: var(--danger); }
.btn-icon   { font-weight: 700; margin-right: .1rem; }

/* ============ Alerts ============ */
.alerts { display: flex; flex-direction: column; gap: .5rem; margin: .75rem 0 1.25rem; }
.alert {
    padding: .7rem .95rem;
    border-radius: 10px;
    font-size: .88rem;
    border: 1px solid transparent;
    animation: slideDown .25s ease-out;
}
.alert.success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert.error,
.alert.danger  { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert.info    { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert.warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============ Hero ============ */
.hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.25rem 0 2rem;
    flex-wrap: wrap;
}
.hero .eyebrow {
    font-size: .7rem;
    letter-spacing: .18em;
    font-weight: 700;
    color: var(--accent);
    margin: 0 0 .35rem;
}
.hero h1 {
    font-family: 'Playfair Display', 'Inter', serif;
    font-size: clamp(1.5rem, 2.4vw + 1rem, 2.25rem);
    margin: 0 0 .35rem;
    letter-spacing: -.02em;
}
.hero .muted { max-width: 48ch; margin: 0; }
.hero-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ============ Section heading ============ */
.section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 1.5rem 0 1rem;
}
.section-heading h2 { margin: 0; font-size: 1.1rem; }
.badge {
    background: var(--accent-soft);
    color: var(--accent);
    font-size: .75rem;
    font-weight: 600;
    padding: .3rem .7rem;
    border-radius: 999px;
}

/* ============ Cards / grid ============ */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}
.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform .15s, box-shadow .2s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card-link { display: block; }
.card img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    background: #eef1f6;
    transition: transform .35s ease;
}
.card:hover img { transform: scale(1.03); }
.card-body { padding: .75rem .9rem; }
.card-body h3 {
    margin: 0 0 .2rem;
    font-size: .95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.card-body .muted { font-size: .78rem; margin: 0; }

/* ============ Empty state ============ */
.empty {
    text-align: center;
    padding: 3rem 1rem;
    border: 1px dashed var(--border);
    border-radius: 16px;
    background: #fff;
    color: var(--muted);
}
.empty-icon { font-size: 2rem; margin-bottom: .35rem; }
.empty-actions { display: flex; justify-content: center; gap: .5rem; margin-top: .85rem; }

/* ============ Cards on standalone pages ============ */
.card.upload-page { max-width: 560px; margin: 0 auto; padding: 1.5rem; }

/* ============ Upload form ============ */
.upload-form { display: flex; flex-direction: column; gap: .9rem; }
.upload-form > label {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    font-size: .8rem;
    font-weight: 600;
}
.upload-form input[type=text],
.upload-form textarea {
    padding: .65rem .8rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
    font-size: .88rem;
    outline: none;
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    resize: vertical;
}
.upload-form input[type=text]:focus,
.upload-form textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15,118,110,.15);
}
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: .6rem;
    margin-top: 1rem;
}

/* ============ File drop zone ============ */
.file-drop {
    display: block;
    border: 2px dashed #cfd5e4;
    border-radius: 14px;
    background: #fbfcfe;
    padding: 1.5rem 1rem;
    cursor: pointer;
    transition: border-color .2s, background .2s;
}
.file-drop:hover { border-color: var(--accent-2); background: #f8fbfb; }
.file-drop.is-drag { border-color: var(--accent); background: var(--accent-soft); }
.file-drop-inner { text-align: center; }
.file-drop-icon { font-size: 1.4rem; color: var(--accent); margin-bottom: .25rem; }
.file-drop-title { font-weight: 600; margin: 0; font-size: .92rem; }
.file-drop-sub { margin: .15rem 0 0; color: var(--muted); font-size: .82rem; }
.file-drop .link { color: var(--accent); font-weight: 600; }

/* ============ Preview ============ */
.preview {
    display: flex;
    align-items: center;
    gap: .8rem;
    margin-top: .85rem;
    padding: .6rem .7rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
}
.preview img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    background: #eef1f6;
}
.preview-meta {
    font-size: .8rem;
    color: var(--muted);
    word-break: break-all;
}

/* ============ Modal ============ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal.is-open { display: flex; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(4px);
    animation: fadeIn .18s ease-out;
}

.modal-dialog {
    position: relative;
    background: #fff;
    border-radius: 20px;
    width: 100%;
    max-width: 480px;
    padding: 1.5rem;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .25);
    animation: slideUp .22s ease-out;
    max-height: 92vh;
    overflow-y: auto;
}
.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}
.modal-header h2 {
    margin: 0 0 .15rem;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -.01em;
}
.modal-header .muted { font-size: .82rem; margin: 0; }
.modal-close {
    background: none;
    border: 0;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    padding: .25rem .5rem;
    border-radius: 8px;
    transition: background .15s, color .15s;
}
.modal-close:hover { background: #f1f5f9; color: var(--text); }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: .6rem;
    margin-top: 1.25rem;
}

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ============ Photo detail ============ */
.photo-page .back {
    display: inline-block;
    margin-bottom: 1rem;
    color: var(--muted);
    font-size: .85rem;
}
.photo-page .back:hover { color: var(--accent); }

.photo-layout {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 1.5rem;
}
@media (max-width: 860px) {
    .photo-layout { grid-template-columns: 1fr; }
}

.photo-frame {
    background: #0f172a;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 260px;
}
.photo-frame img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
}

.details .eyebrow {
    font-size: .7rem;
    letter-spacing: .18em;
    font-weight: 700;
    color: var(--accent);
    margin: 0 0 .2rem;
}
.details h1 {
    margin: .2rem 0 .5rem;
    font-size: 1.35rem;
    letter-spacing: -.01em;
    word-break: break-word;
}
.details .description {
    color: var(--muted);
    font-size: .9rem;
    margin: 0 0 1rem;
}
.details dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .4rem 1rem;
    margin: 1rem 0;
    padding: .9rem 1rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: .84rem;
}
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 600; word-break: break-word; text-align: right; }
.details code { font-size: .8rem; }

.share-label {
    display: block;
    font-size: .75rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: .35rem;
}
.share-box {
    display: flex;
    gap: .5rem;
    margin: 0 0 1rem;
}
.share-box input {
    flex: 1;
    padding: .55rem .75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
    font-size: .82rem;
    background: #fff;
    outline: none;
    min-width: 0;
}
.share-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15,118,110,.15); }

.detail-actions {
    display: flex;
    gap: .6rem;
    flex-wrap: wrap;
}
.detail-actions form { display: inline; }

/* ============ Footer ============ */
.footer {
    border-top: 1px solid var(--border);
    background: #fff;
    padding: 1.25rem 0;
    text-align: center;
    font-size: .8rem;
    color: var(--muted);
}

/* ---------- Layout helpers ---------- */
.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;
}

/* ---------- Hero ---------- */
.hero {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 2.5rem 0 2rem;
    border-bottom: 1px solid var(--border, #e5e7eb);
    margin-bottom: 2rem;
}

.hero h1 {
    margin: 0.35rem 0 0;
    font-size: clamp(1.75rem, 3vw, 2.25rem);
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--text, #0f172a);
}

.hero-sub {
    margin-top: 0.5rem;
    max-width: 42ch;
    color: var(--muted, #64748b);
    font-size: 0.95rem;
    line-height: 1.55;
}

.eyebrow {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent, #2563eb);
}

/* ---------- Card ---------- */
.card {
    background: #ffffff;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04),
                0 8px 24px -8px rgba(15, 23, 42, 0.10);
}

/* ---------- Login page ---------- */
.login-page {
    max-width: 440px;
    margin: 0 auto;
    padding: 2rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.field label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text, #0f172a);
}

.field input {
    width: 100%;
    height: 46px;
    padding: 0 0.9rem;
    font-size: 0.95rem;
    color: var(--text, #0f172a);
    background: #ffffff;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 10px;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.field input::placeholder {
    color: #94a3b8;
}

.field input:hover {
    border-color: #cbd5e1;
}

.field input:focus {
    outline: none;
    border-color: var(--accent, #2563eb);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border, #e5e7eb);
    margin-top: 0.25rem;
}

.form-actions .btn {
    min-width: 120px;
    justify-content: center;
}

.login-hint {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border, #e5e7eb);
    font-size: 0.85rem;
    color: var(--muted, #64748b);
    text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
    .hero {
        padding-top: 1.75rem;
        align-items: flex-start;
    }

    .login-page {
        padding: 1.5rem;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .btn {
        width: 100%;
    }
}