/* ReelStash — hand-written CSS, no build step. Light/dark via prefers-color-scheme. */

:root {
    --bg: #f6f4f0;
    --surface: #ffffff;
    --surface-2: #efece6;
    --border: #e4e0d8;
    --text: #1c1b19;
    --text-muted: #6f6a62;
    --accent: #e4572e;
    --accent-2: #db2777;
    --accent-text: #ffffff;
    --accent-soft: #fde8df;
    --danger: #c62828;
    --success: #2e7d32;
    --warning: #b26a00;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgb(0 0 0 / 4%), 0 6px 24px -12px rgb(0 0 0 / 14%);
    --shadow-hover: 0 2px 4px rgb(0 0 0 / 5%), 0 14px 36px -14px rgb(0 0 0 / 24%);
    --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --gradient: linear-gradient(135deg, #f97316 0%, #e4572e 45%, #db2777 100%);
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1115;
        --surface: #171a20;
        --surface-2: #1f232b;
        --border: #2a2f39;
        --text: #ecebe8;
        --text-muted: #9a978f;
        --accent: #ff7a50;
        --accent-soft: #3a2119;
        --danger: #ef5350;
        --success: #66bb6a;
        --warning: #ffb74d;
        --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px -12px rgb(0 0 0 / 60%);
        --shadow-hover: 0 2px 4px rgb(0 0 0 / 35%), 0 16px 40px -14px rgb(0 0 0 / 70%);
    }
}

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

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

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; }

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

code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }

.muted { color: var(--text-muted); }
.small { font-size: .85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Top bar ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
    padding-top: env(safe-area-inset-top);
}

.topbar__inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: .7rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar__nav { display: flex; gap: .25rem; margin-left: auto; }

.logo { display: flex; align-items: center; gap: .55rem; color: var(--text); font-weight: 700; font-size: 1.05rem; }
.logo:hover { text-decoration: none; }

.logo__mark {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: var(--gradient);
    color: #fff;
    flex: none;
}
.logo__mark--lg { width: 56px; height: 56px; border-radius: 16px; }

.search { position: relative; flex: 1; max-width: 560px; }
.search__icon { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search input {
    width: 100%;
    padding: .6rem .9rem .6rem 2.4rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }

/* ---------- Layout ---------- */

.container { max-width: 1320px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

.layout { display: grid; grid-template-columns: 260px 1fr; gap: 2rem; align-items: start; }

.sidebar { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 1.5rem; }

.content__header { margin-bottom: 1.25rem; }
.content__header p { margin: 0; }
.content__title { font-size: 1.6rem; font-weight: 750; }

.narrow { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; }

/* ---------- Components ---------- */

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .62rem 1.1rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    color: var(--text);
    background: var(--surface-2);
    transition: transform .08s, background .15s, box-shadow .15s, opacity .15s;
    text-decoration: none !important;
    white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn--primary { background: var(--gradient); color: var(--accent-text); box-shadow: 0 6px 18px -8px var(--accent-2); }
.btn--primary:hover { opacity: .93; }
.btn--ghost { background: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn--danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn--sm { padding: .42rem .85rem; font-size: .88rem; }
.btn--block { width: 100%; }

.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .9rem; }
.field__label { font-size: .82rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.field input, .field textarea {
    width: 100%;
    padding: .62rem .8rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font: inherit;
    resize: vertical;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .32rem .7rem;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: .86rem;
    text-decoration: none !important;
    transition: border-color .15s, background .15s;
}
.chip span { color: var(--text-muted); font-size: .78rem; }
.chip:hover { border-color: var(--accent); }
.chip.is-active { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.is-active span { color: color-mix(in srgb, var(--bg) 70%, transparent); }
.chip--sm { padding: .12rem .5rem; font-size: .75rem; background: var(--surface-2); border-color: transparent; }

.filter-group__title { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: .6rem; }

.badge {
    display: inline-flex;
    align-items: center;
    padding: .18rem .55rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 650;
    background: var(--surface-2);
    color: var(--text);
}
.badge--overlay { position: absolute; top: .6rem; left: .6rem; background: rgb(0 0 0 / 55%); color: #fff; backdrop-filter: blur(6px); }
.badge--right { left: auto; right: .6rem; }
.badge--pending { background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--warning); }
.badge--failed { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }

.status-dot { position: absolute; bottom: .65rem; right: .65rem; width: 10px; height: 10px; border-radius: 50%; border: 2px solid #fff; }
.status-dot--inline { position: static; border: 0; width: 8px; height: 8px; display: inline-block; }
.status-dot--pending { background: var(--warning); }
.status-dot--failed { background: var(--danger); }

.flash { padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid var(--border); background: var(--surface); }
.flash--success { border-color: color-mix(in srgb, var(--success) 40%, transparent); background: color-mix(in srgb, var(--success) 10%, var(--surface)); }
.flash--error { border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.flash--info { border-color: color-mix(in srgb, var(--accent) 35%, transparent); background: var(--accent-soft); }

/* ---------- Grid of items ---------- */

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

.item-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform .18s ease, box-shadow .18s ease;
}
.item-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }

.item-card__media { position: relative; aspect-ratio: 4 / 5; background: var(--surface-2); overflow: hidden; }
.item-card__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.item-card:hover .item-card__media img { transform: scale(1.03); }

.item-card__body { padding: .85rem .95rem 1rem; display: flex; flex-direction: column; gap: .3rem; flex: 1; }
.item-card__title { font-size: .95rem; font-weight: 650; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-card__title a { color: var(--text); }
.item-card__author { margin: 0; font-size: .82rem; color: var(--accent); font-weight: 550; }
.item-card__excerpt { margin: 0; font-size: .85rem; color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.item-card__excerpt--note { font-style: italic; }
.item-card__footer { margin-top: auto; padding-top: .45rem; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; font-size: .76rem; color: var(--text-muted); }
.item-card__footer time { margin-right: .2rem; }

.placeholder {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    color: rgb(255 255 255 / 85%);
    background: var(--gradient);
}
.placeholder--post { background: linear-gradient(135deg, #6366f1, #a855f7 60%, #ec4899); }
.placeholder--tall { aspect-ratio: 4 / 5; border-radius: var(--radius); }

.empty { text-align: center; padding: 3rem 1.5rem; }
.empty p { max-width: 440px; margin: .5rem auto 0; color: var(--text-muted); }

.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 2rem; }

/* ---------- Detail ---------- */

.back-link { display: inline-block; margin-bottom: 1rem; color: var(--text-muted); font-weight: 550; }

.detail { display: grid; grid-template-columns: minmax(260px, 380px) 1fr; gap: 2.25rem; align-items: start; }
.detail__media-inner { position: sticky; top: 84px; display: flex; flex-direction: column; gap: .9rem; }
.detail__media img { border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; aspect-ratio: 4 / 5; object-fit: cover; background: var(--surface-2); }

.detail__main { display: flex; flex-direction: column; gap: 1.1rem; min-width: 0; }
.detail__header { display: flex; flex-direction: column; gap: .6rem; }
.detail__header p { margin: 0; }
.detail__meta { display: flex; gap: .4rem; flex-wrap: wrap; }

.detail__author { display: inline-flex; align-items: center; gap: .7rem; color: var(--text); }
.detail__author:hover { text-decoration: none; }
.detail__author > span:last-child { display: flex; flex-direction: column; line-height: 1.3; }
.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--gradient); color: #fff; font-weight: 700; flex: none; }

.caption { padding: 1.4rem 1.5rem; }
.caption__text { font-size: 1.04rem; line-height: 1.72; max-width: 70ch; overflow-wrap: anywhere; }
.caption__text a.hashtag { color: var(--accent-2); }

.empty-caption p { margin: 0; color: var(--text-muted); }
.error-details { margin-top: .75rem; }
.error-details summary { cursor: pointer; color: var(--text-muted); font-size: .85rem; }
.error-details pre { white-space: pre-wrap; background: var(--surface-2); padding: .75rem; border-radius: var(--radius-sm); max-height: 240px; overflow: auto; }

.edit-form .btn { align-self: flex-start; }
.edit-form { display: flex; flex-direction: column; }

.detail__actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.detail__actions form { margin: 0; }

/* ---------- Login ---------- */

.page-login .container { min-height: 100vh; display: grid; place-items: center; }
.login { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 1.5rem; }
.login__brand { text-align: center; display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.login__brand h1 { font-size: 1.8rem; margin: .4rem 0 0; }
.login__brand p { margin: 0; }
.login__form { padding: 1.5rem; }

/* ---------- Import ---------- */

.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .3rem;
    padding: 2rem 1rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    text-align: center;
    cursor: pointer;
    margin-bottom: 1rem;
    transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { max-width: 100%; margin-bottom: .5rem; }
.dropzone__title { font-weight: 650; }

.checkbox { display: flex; gap: .6rem; align-items: flex-start; margin-bottom: 1rem; cursor: pointer; }
.checkbox input { margin-top: .25rem; accent-color: var(--accent); width: 1.05rem; height: 1.05rem; flex: none; }

.help ol { padding-left: 1.2rem; margin: .5rem 0; }
.help li { margin-bottom: .4rem; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin: 1rem 0; }
.stats div { background: var(--surface-2); border-radius: var(--radius-sm); padding: .75rem; text-align: center; }
.stats dt { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.stats dd { margin: 0; font-size: 1.6rem; font-weight: 750; }
.report .btn { margin-top: .5rem; }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; gap: 1.25rem; }
    .sidebar { position: static; gap: 1rem; }
    .sidebar .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .25rem; scrollbar-width: none; }
    .sidebar .chips::-webkit-scrollbar { display: none; }
    .chip { flex: none; }
    .add-form { display: none; }

    .detail { grid-template-columns: 1fr; gap: 1.25rem; }
    .detail__media-inner { position: static; max-width: 420px; margin: 0 auto; width: 100%; }
}

@media (max-width: 600px) {
    body { font-size: 15px; }
    .container { padding: 1rem .85rem 3rem; }
    .topbar__inner { padding: .6rem .85rem; gap: .6rem; flex-wrap: wrap; }
    .logo__text { display: none; }
    .search { order: 3; flex-basis: 100%; max-width: none; }
    .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
    .item-card__body { padding: .65rem .7rem .75rem; }
    .item-card__excerpt { -webkit-line-clamp: 2; }
    .content__title { font-size: 1.3rem; }
    .caption { padding: 1.1rem; }
    .caption__text { font-size: 1rem; }
}

/* ---------- 2FA ---------- */

.otp-input { font-size: 1.6rem !important; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; }
.login__cancel { text-align: center; margin: 1rem 0 0; }
