:root {
    --bg: #0e0820;
    --bg-elev: #1a1238;
    --bg-elev-2: #251a4a;
    --text: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.65);
    --text-faint: rgba(255, 255, 255, 0.45);
    --accent: #b794f4;
    --accent-strong: #9f7aea;
    --border: rgba(255, 255, 255, 0.08);
    --danger: #f87171;
    --success: #4ade80;
    --env-tint: var(--accent);
}

/* Dev environment — swap accents to amber and tint the chrome so the
   marketing team can never mistake dev for prod. */
body.env-dev {
    --bg: #1a1305;
    --bg-elev: #2a200a;
    --bg-elev-2: #3a2c0e;
    --accent: #fbbf24;
    --accent-strong: #f59e0b;
    --env-tint: #fbbf24;
}

.env-banner {
    background: linear-gradient(90deg, #f59e0b, #fbbf24, #f59e0b);
    color: #1a1305;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 6px 12px;
    text-transform: uppercase;
}

.brand-env {
    display: inline-block;
    padding: 1px 8px;
    margin: 0 4px;
    background: var(--env-tint);
    color: #1a1305;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI",
                 Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elev);
}
.topbar .brand {
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
    text-decoration: none;
    letter-spacing: 0.2px;
}
.topbar .brand span {
    color: var(--text-muted);
    font-weight: 500;
    margin-left: 6px;
}
.topbar nav { display: flex; gap: 18px; align-items: center; }
.topbar nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
}
.topbar nav a:hover { color: var(--text); }

/* Logout reads as a tertiary action — visually distinct from product
   nav links so the marketing team doesn't mis-click. Padded so it's a
   reliable target on touch. */
.topbar nav a.logout {
    margin-left: 8px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12px;
    color: var(--text-faint);
}
.topbar nav a.logout:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

main {
    flex: 1;
    max-width: 920px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

h1 { font-size: 26px; margin: 0 0 4px; }

/* Page-head: title left, action button right. Generous bottom margin so
   the tabs row sits on its own visual band. */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 12px;
}
.page-head h1 { margin: 0; }
.new-post-btn {
    font-size: 13px;
    padding: 8px 16px;
    border-radius: 999px;
    flex: 0 0 auto;
    white-space: nowrap;
}

/* Tabs sit in their own padded segmented-control container so the active
   tab reads as obviously selected — solid pill background + accent text
   + a soft glow. Margin-top decouples the row from the action button
   above so they never visually touch. */
.tabs {
    display: inline-flex;
    gap: 4px;
    margin: 28px 0 20px;
    padding: 4px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.tab {
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.tab:hover { color: var(--text); background: var(--bg-elev-2); }
.tab.active {
    color: #1a1305;
    background: var(--accent);
    box-shadow: 0 2px 8px rgba(251, 191, 36, 0.35);
}
.tab.active:hover {
    color: #1a1305;
    background: var(--accent);
}

.extracted-meta {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
}
.extracted-meta .tag { margin-bottom: 4px; }

.polaroid-preview {
    position: relative;
    margin-top: 10px;
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    display: flex;
    justify-content: center;
    overflow: hidden;
}
.polaroid-preview canvas {
    display: block;
    width: auto;
    /* Hard caps on both axes so the preview never grows past the
       surrounding brown card frame. Width also constrained because at
       portrait ratio (~1080×1292), an unconstrained width would still
       blow past the card on wide screens. */
    max-width: min(100%, 420px);
    max-height: 500px;
    height: auto;
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    background: #fff;
}
/* Empty-state placeholder collapses tightly so the publish buttons sit
   right under the "What gets uploaded…" description until a photo is
   actually picked. */
.polaroid-empty {
    color: var(--text-faint);
    font-size: 13px;
    padding: 14px 12px;
    text-align: center;
}

/* Language toggle for TMDB search — tiny segmented pill mirroring the
   shape of the main Basic/Advanced tabs so the patterns rhyme. */
.lang-toggle {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 999px;
}
.lang-pill {
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
    cursor: pointer;
}
.lang-pill:hover { color: var(--text); }
.lang-pill.active {
    color: #1a1305;
    background: var(--accent);
}
.lang-pill.active:hover { color: #1a1305; background: var(--accent); }
h2 { font-size: 18px; margin: 24px 0 8px; }
p.subtitle { color: var(--text-muted); margin: 0 0 24px; }

.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 16px;
}

label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; }
input[type="text"], input[type="search"], textarea, select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font: inherit;
}
textarea { min-height: 110px; resize: vertical; }

button {
    background: var(--accent);
    color: #1a1238;
    border: none;
    border-radius: 10px;
    padding: 10px 18px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
}
button:hover { background: var(--accent-strong); color: white; }
button[disabled] { opacity: 0.4; cursor: not-allowed; }
button.secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.row { display: flex; gap: 12px; align-items: center; }
.row > * { flex: 1; }

.preview {
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-top: 12px;
}
.preview .poster {
    width: 100%;
    aspect-ratio: 2 / 3;
    background: var(--bg);
    border-radius: 8px;
    object-fit: cover;
    margin-bottom: 12px;
}

footer {
    padding: 16px 24px;
    color: var(--text-faint);
    font-size: 12px;
    text-align: center;
    border-top: 1px solid var(--border);
}
footer .build-stamp code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    color: var(--text-muted);
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(183, 148, 244, 0.15);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    margin-right: 4px;
}

.status-ok { color: var(--success); }
.status-err { color: var(--danger); }

.success-banner {
    background: linear-gradient(135deg, rgba(74, 222, 128, 0.12), rgba(74, 222, 128, 0.04));
    border: 1px solid rgba(74, 222, 128, 0.35);
    border-radius: 12px;
    padding: 14px 16px;
    margin-top: 10px;
}
.success-banner.mocked {
    background: linear-gradient(135deg, rgba(183, 148, 244, 0.12), rgba(183, 148, 244, 0.04));
    border-color: rgba(183, 148, 244, 0.35);
}
.success-banner.draft {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.12), rgba(251, 191, 36, 0.04));
    border-color: rgba(251, 191, 36, 0.35);
}
.success-banner.draft .success-title { color: #fbbf24; }
.success-banner .success-title {
    font-weight: 700;
    font-size: 15px;
    color: var(--success);
    margin-bottom: 4px;
}
.success-banner.mocked .success-title { color: var(--accent); }
.success-banner .success-sub {
    color: var(--text);
    font-size: 14px;
}
.success-banner .success-sub a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
    margin-left: 8px;
}
.success-banner .success-sub a:hover { text-decoration: underline; }
.success-banner .success-id {
    color: var(--text-faint);
    font-size: 11px;
    margin-top: 6px;
}
.success-banner code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
}

.search-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-top: 10px;
}
.search-results .result {
    background: var(--bg-elev-2);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
}
.search-results .result.selected { border-color: var(--accent); }
.search-results .result img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; display: block; }
.search-results .result .title { padding: 6px 8px; font-size: 12px; line-height: 1.3; }
