/* =====================================================================
   Vehicle Gallery - clean modern theme
   ===================================================================== */
@font-face{font-family:"Schibsted Grotesk";font-weight:400;font-style:normal;font-display:swap;src:url("fonts/schibsted-grotesk-latin-400-normal.woff2") format("woff2")}
@font-face{font-family:"Schibsted Grotesk";font-weight:500;font-style:normal;font-display:swap;src:url("fonts/schibsted-grotesk-latin-500-normal.woff2") format("woff2")}
@font-face{font-family:"Schibsted Grotesk";font-weight:600;font-style:normal;font-display:swap;src:url("fonts/schibsted-grotesk-latin-600-normal.woff2") format("woff2")}
@font-face{font-family:"Schibsted Grotesk";font-weight:700;font-style:normal;font-display:swap;src:url("fonts/schibsted-grotesk-latin-700-normal.woff2") format("woff2")}

:root{
    --paper:#fbfbfa; --card-bg:#ffffff; --ink:#16181d; --text:#16181d;
    --muted:#5d6370; --line:#e4e5e8; --border:#e4e5e8;
    --accent:#2347f5; --accent-dark:#1a37c4; --tile:#eceef2; --danger:#c53030;
}
*{box-sizing:border-box}
html{scroll-padding-top:80px}
body{margin:0;background:var(--paper);color:var(--ink);font-family:"Schibsted Grotesk",system-ui,-apple-system,"Segoe UI",sans-serif;line-height:1.55;-webkit-font-smoothing:antialiased}
a{color:var(--accent)}
:focus-visible{outline:3px solid var(--accent);outline-offset:3px;border-radius:4px}
[hidden]{display:none !important}
h1{margin:0 0 8px;font-size:clamp(1.9rem,4vw,2.8rem);line-height:1.08;letter-spacing:-.03em;font-weight:700}
h2{margin:36px 0 14px;font-size:1.25rem;letter-spacing:-.015em;font-weight:600}

/* ---------- Header ---------- */
.site-header{position:sticky;top:0;z-index:10;background:rgba(251,251,250,.92);-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border-bottom:1px solid var(--line)}
.bar{max-width:1160px;margin:0 auto;padding:0 28px;display:flex;align-items:center;justify-content:space-between;min-height:68px;gap:20px}
.brand{display:flex;align-items:center;gap:11px;text-decoration:none;color:var(--ink);font-weight:700;font-size:1.05rem;letter-spacing:-.01em}
.brand svg{width:30px;height:30px;color:var(--accent);flex:none}
.site-header nav{display:flex;align-items:center;flex-wrap:wrap;gap:4px}
.site-header nav a{text-decoration:none;font-weight:500;font-size:.95rem;color:var(--muted);padding:9px 14px;border-radius:999px}
.site-header nav a:hover{color:var(--ink);background:var(--tile)}
.site-header nav a[aria-current]{color:var(--ink);font-weight:600}
.site-header nav a.nav-button{background:var(--ink);color:var(--paper);font-weight:600;margin-left:8px;padding:9px 20px}
.site-header nav a.nav-button:hover{background:var(--accent);color:#fff}

/* ---------- Page layout ---------- */
.container{max-width:1160px;margin:0 auto;padding:36px 28px 80px}
.site-footer{border-top:1px solid var(--line);padding:28px 0 40px;color:var(--muted);font-size:.9rem}
.site-footer .footer-inner{max-width:1160px;margin:0 auto;padding:0 28px;display:flex;justify-content:space-between;gap:16px;flex-wrap:wrap}
.flash-messages{margin-bottom:20px}
.flash{background:#fff8e1;border:1px solid #f0d98c;padding:12px 16px;border-radius:10px;margin-bottom:8px}
.back-link,.container > p > a{color:var(--muted);text-decoration:none;font-weight:500;font-size:.95rem}
.back-link a:hover,.container > p > a:hover{color:var(--accent)}
.back-link{margin:0 0 14px}
.result-count{color:var(--muted);margin:0 0 24px;font-size:.95rem}

/* ---------- Homepage ---------- */
.intro{padding:56px 0 52px;display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr);gap:48px;align-items:end}
.intro h1{font-size:clamp(2.4rem,5.4vw,4.2rem);line-height:1.02;letter-spacing:-.035em;max-width:14ch;margin:0}
.intro p{margin:0;color:var(--muted);font-size:1.08rem;max-width:42ch}
.intro p strong{color:var(--ink);font-weight:600}
.section-head{display:flex;justify-content:space-between;align-items:baseline;border-top:1px solid var(--ink);padding-top:14px;margin-bottom:24px}
.section-head h2{margin:0;font-size:1rem;font-weight:600;letter-spacing:0}
.section-head span{color:var(--muted);font-size:.9rem}
.tile-grid{display:grid;grid-template-columns:repeat(12,1fr);gap:26px 18px}
.tile{grid-column:span 3;text-decoration:none;color:var(--ink);display:block}
.tile.lead{grid-column:span 6}
.tile .photo{aspect-ratio:4/3;background:var(--tile);border-radius:10px;overflow:hidden;position:relative}
.tile.lead .photo{aspect-ratio:16/10}
.tile .photo img{width:100%;height:100%;object-fit:cover;display:block;transition:transform .5s ease}
.tile:hover .photo img{transform:scale(1.03)}
.tile-placeholder,.card-placeholder{position:absolute;inset:0;background:repeating-linear-gradient(135deg,#e6e8ed 0 14px,#eceef2 14px 28px)}
.tile-meta{display:flex;justify-content:space-between;align-items:baseline;gap:12px;padding:14px 2px 0}
.tile-label{font-size:1.2rem;letter-spacing:-.015em;font-weight:600}
.tile-count{color:var(--muted);font-size:.92rem;white-space:nowrap}
.tile:hover .tile-label{color:var(--accent)}
.latest-head{margin-top:72px}

/* ---------- Search bar + chips ---------- */
.search-bar{display:flex;gap:10px;margin:18px 0 14px;flex-wrap:wrap}
.search-bar input[type="text"]{flex:1;min-width:220px;padding:13px 16px;border:1px solid #c9ccd3;border-radius:10px;font-size:1rem;font-family:inherit;background:#fff;color:var(--ink)}
.search-bar input[type="text"]:focus{outline:3px solid rgba(35,71,245,.25);border-color:var(--accent)}
.clear-link{align-self:center;color:var(--muted);text-decoration:none;font-size:.95rem;padding:0 6px}
.clear-link:hover{color:var(--accent)}
.chip-row{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:22px}
.chip{background:transparent;color:var(--ink);padding:6px 14px;border-radius:999px;font-size:.88rem;text-decoration:none;border:1px solid var(--line)}
.chip:hover{border-color:var(--ink)}
.chip-active{background:var(--ink);color:var(--paper);border-color:var(--ink)}

/* ---------- Shared buttons ---------- */
.search-bar button,.inline-form button,.comment-form button,.upload-form button,.button-link,button.danger{
    display:inline-block;padding:12px 22px;background:var(--ink);color:#fff;border:none;border-radius:10px;
    font-family:inherit;font-size:1rem;font-weight:600;cursor:pointer;text-decoration:none;line-height:1.3}
.search-bar button:hover,.inline-form button:hover,.comment-form button:hover,.upload-form button:hover,.button-link:hover{background:var(--accent)}
button.danger,.upload-form button.danger{background:var(--danger)}
button.danger:hover,.upload-form button.danger:hover{background:#922626}

/* ---------- Photo grid + cards ---------- */
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(250px,1fr));gap:28px 20px}
.card{display:block;text-decoration:none;color:var(--ink);position:relative}
.card img,.card .card-placeholder{width:100%;aspect-ratio:4/3;object-fit:cover;display:block;background:var(--tile);border-radius:10px;transition:filter .2s ease}
.card .card-placeholder{position:relative;inset:auto}
.card:hover img{filter:brightness(.93)}
.card-body{padding:12px 2px 0}
.card-title{font-weight:600;font-size:1.05rem;letter-spacing:-.01em;margin-bottom:6px}
.card:hover .card-title{color:var(--accent)}
.tags{display:flex;flex-wrap:wrap;gap:6px}
.tag{background:var(--tile);color:var(--muted);padding:3px 10px;border-radius:999px;font-size:.8rem;text-decoration:none}
a.tag:hover{background:var(--ink);color:#fff}
.album-badge{display:block;color:var(--muted);font-size:.85rem;margin-bottom:6px}
.album-count{color:var(--muted);font-size:.9rem}

.pagination{display:flex;justify-content:center;align-items:center;gap:22px;margin-top:44px;color:var(--muted);flex-wrap:wrap}
.pagination a{color:var(--ink);text-decoration:none;font-weight:600;padding:10px 20px;border:1px solid var(--ink);border-radius:999px}
.pagination a:hover{background:var(--ink);color:#fff}
.empty-state{text-align:center;color:var(--muted);padding:72px 20px;border:1px dashed #c9ccd3;border-radius:12px}

/* ---------- Forms (login/edit/albums) ---------- */
.upload-form{display:flex;flex-direction:column;max-width:480px;gap:6px}
.upload-form label,.comment-form label{font-weight:600;margin-top:14px}
.upload-form input[type="text"],.upload-form input[type="password"],.upload-form input[type="file"],.upload-form select,.upload-form textarea,
.comment-form input[type="text"],.comment-form textarea,.inline-form input[type="text"]{
    padding:12px 14px;border:1px solid #c9ccd3;border-radius:10px;font-size:1rem;font-family:inherit;background:#fff;color:var(--ink)}
.upload-form .hint{color:var(--muted);font-size:.88rem;margin:4px 0 0}
.upload-form button,.comment-form button{margin-top:20px;align-self:flex-start}
.current-photo{margin-bottom:10px}
.current-photo img{width:220px;max-width:100%;border-radius:10px;display:block}
.inline-form{display:flex;gap:10px;margin-bottom:24px;flex-wrap:wrap}
.inline-form input[type="text"]{flex:1;min-width:220px}
.album-manage{display:flex;gap:20px;align-items:flex-start;margin-bottom:24px;flex-wrap:wrap}
.album-manage form{margin:0}
.album-manage .inline-form{margin-bottom:0}

/* ---------- Photo page ---------- */
.detail{display:flex;gap:40px;flex-wrap:wrap;align-items:flex-start}
.detail-media{flex:2;min-width:280px}
.detail-img{display:block;width:100%;max-height:80vh;object-fit:contain;background:#16181d;border-radius:10px;cursor:zoom-in}
.detail-nav{display:flex;justify-content:space-between;align-items:center;margin-top:14px}
.detail-nav a{color:var(--ink);text-decoration:none;font-weight:600;padding:10px 20px;border:1px solid var(--ink);border-radius:999px}
.detail-nav a:hover{background:var(--ink);color:#fff}
.detail-nav .nav-disabled{color:#b4b8c0;font-weight:600;padding:10px 20px;border:1px solid var(--line);border-radius:999px}
.detail-nav .nav-position{color:var(--muted);font-size:.95rem}
.detail-info{flex:1;min-width:250px}
.detail-info .caption{margin:6px 0 16px;line-height:1.55;font-size:1.05rem}
.detail-info .meta{color:var(--muted);font-size:.95rem;margin-top:18px}
.album-link{margin:4px 0 14px;color:var(--muted)}
.album-link a{color:var(--accent);font-weight:600;text-decoration:none}
.album-link a:hover{text-decoration:underline}
.download-box{margin-top:22px;padding:18px;background:var(--tile);border-radius:12px}
.download-box .button-link{background:var(--accent);padding:14px 24px}
.download-box .button-link:hover{background:var(--accent-dark)}
.download-box .hint{margin:12px 0 0;font-size:.85rem;color:var(--muted)}
.detail-actions{display:flex;align-items:center;gap:12px;margin-top:18px;flex-wrap:wrap}
.detail-actions form{margin:0}

.lightbox{display:none;position:fixed;inset:0;background:rgba(10,10,12,.94);z-index:1000;align-items:center;justify-content:center;padding:24px;cursor:zoom-out;overflow:hidden}
.lightbox.active{display:flex}
.lightbox img{max-width:95vw;max-height:95vh;object-fit:contain;box-shadow:0 10px 50px rgba(0,0,0,.6);border-radius:4px;cursor:zoom-in;transition:transform .2s ease;will-change:transform;touch-action:none;-webkit-user-drag:none;user-select:none}
/* 2nd click: 2x zoom. transform-origin is moved by JS so the photo follows the cursor. */
.lightbox img.zoomed{transform:scale(2);cursor:zoom-out}
.lightbox-close{position:absolute;top:18px;right:26px;z-index:2;color:#fff;font-size:2.4rem;line-height:1;cursor:pointer;user-select:none;font-weight:300}

/* ---------- Comments ---------- */
.comments-section{margin-top:56px;border-top:1px solid var(--ink);padding-top:8px;max-width:680px}
.comments-section h2{margin-top:20px}
.comment{padding:14px 0;border-bottom:1px solid var(--line)}
.comment-name{font-weight:600}
.comment-text{margin:4px 0;white-space:pre-wrap}
.comment-date{color:var(--muted);font-size:.85rem}
.comment form{margin-top:8px}
.comment-form{display:flex;flex-direction:column;max-width:480px;gap:6px;margin-top:28px}
.hint{color:var(--muted)}
.honeypot{position:absolute;left:-9999px;width:1px;height:1px;opacity:0}

/* ---------- Stats (admin) ---------- */
.stats-summary{display:flex;gap:16px;flex-wrap:wrap;margin-bottom:30px}
.stat-box{background:var(--tile);border-radius:12px;padding:18px 26px}
.stat-number{font-size:2rem;font-weight:700;letter-spacing:-.02em}
.stat-label{color:var(--muted);font-size:.9rem;margin-top:2px}
.stats-table{width:100%;border-collapse:collapse;margin-bottom:30px}
.stats-table th,.stats-table td{text-align:left;padding:12px 14px;border-bottom:1px solid var(--line);font-size:.95rem}
.stats-table th{color:var(--muted);font-weight:600;border-bottom:1px solid var(--ink)}
.stats-table a{color:var(--accent);text-decoration:none}
.stats-table a:hover{text-decoration:underline}
code{background:var(--tile);padding:1px 6px;border-radius:4px}

/* ---------- Responsive ---------- */
@media (max-width:820px){
    .intro{grid-template-columns:1fr;gap:20px;padding:36px 0 40px}
    .tile,.tile.lead{grid-column:span 6}
    .tile.lead .photo{aspect-ratio:4/3}
}
@media (max-width:600px){
    .bar{padding:10px 18px;flex-direction:column;align-items:flex-start;gap:4px}
    .site-header nav{margin-left:-14px}
    .container{padding:24px 18px 60px}
    .site-footer .footer-inner{padding:0 18px}
    .tile,.tile.lead{grid-column:1/-1}
    .latest-grid{grid-template-columns:repeat(2,1fr);gap:22px 12px}
    .latest-grid .card-title{font-size:.95rem}
    .detail{flex-direction:column;gap:24px}
    .detail-img{max-height:60vh}
    .stats-summary{flex-direction:column}
}
@media (prefers-reduced-motion:reduce){.tile .photo img,.card img{transition:none}.tile:hover .photo img{transform:none}}

/* =====================================================================
   Bulk upload organizer (Flickr-style)
   ===================================================================== */
[hidden] { display: none !important; }

.container-wide {
    max-width: none;
    margin: 0;
    padding: 0;
}

.organizer {
    --o-bg: #232323;
    --o-panel: #1b1b1b;
    --o-line: #333;
    --o-text: #e6e6e6;
    --o-muted: #8d8d8d;
    --o-pink: #ff0084;
    --o-blue: #0063dc;
    background: var(--o-bg);
    color: var(--o-text);
    min-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
}

.o-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: #f2f2f2;
    border-bottom: 1px solid #ddd;
    flex-wrap: wrap;
}
.o-tool {
    background: transparent;
    border: none;
    color: #333;
    font-size: 0.95rem;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px;
}
.o-tool:hover { background: #e2e2e2; }
.o-toolbar-info { color: #777; font-size: 0.85rem; margin-left: 10px; }
.o-upload {
    margin-left: auto;
    background: var(--o-blue);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 10px 18px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}
.o-upload:hover:not(:disabled) { background: #004fb3; }
.o-upload:disabled { background: #9db9e0; cursor: not-allowed; }

.o-banner {
    padding: 12px 18px;
    font-size: 0.92rem;
    line-height: 1.5;
}
.o-banner a { color: inherit; font-weight: 700; }
.o-banner-ok { background: #1f4d2c; color: #d4f5dc; }
.o-banner-warn { background: #5a4a14; color: #fbefc2; }
.o-banner-error { background: #6b1f1f; color: #ffd9d9; }
.o-link-btn {
    background: transparent;
    border: 1px solid currentColor;
    color: inherit;
    border-radius: 6px;
    padding: 2px 10px;
    cursor: pointer;
    font-size: 0.82rem;
}

.o-body { display: flex; flex: 1; min-height: 0; }

.o-sidebar {
    width: 290px;
    flex-shrink: 0;
    background: var(--o-panel);
    border-right: 1px solid var(--o-line);
    padding: 6px 0 20px;
}
.o-side-head {
    padding: 18px 20px;
    font-size: 1.15rem;
    color: #aaa;
    border-bottom: 1px solid var(--o-line);
}
.o-side-section {
    padding: 14px 20px;
    border-bottom: 1px solid var(--o-line);
}
.o-side-section label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: var(--o-text);
}
.o-req { color: var(--o-pink); font-size: 0.72rem; margin-left: 6px; }
.o-sidebar select,
.o-sidebar textarea,
.o-sidebar input[type="text"] {
    width: 100%;
    background: #2b2b2b;
    color: var(--o-text);
    border: 1px solid #444;
    border-radius: 6px;
    padding: 9px 10px;
    font-size: 0.92rem;
    font-family: inherit;
}
.o-sidebar textarea { resize: vertical; }
.o-sidebar :disabled { opacity: 0.45; cursor: not-allowed; }
.o-tag-add { display: flex; gap: 6px; }
.o-tag-add button {
    background: #3a3a3a;
    color: var(--o-text);
    border: 1px solid #555;
    border-radius: 6px;
    padding: 0 14px;
    cursor: pointer;
}
.o-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.o-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #3a3a3a;
    border-radius: 999px;
    padding: 3px 4px 3px 11px;
    font-size: 0.82rem;
}
.o-chip-partial { opacity: 0.55; font-style: italic; }
.o-chip button {
    background: #555;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    line-height: 16px;
    padding: 0;
    cursor: pointer;
    font-size: 0.85rem;
}
.o-chip button:hover { background: var(--o-pink); }
.o-side-note { color: var(--o-muted); font-size: 0.8rem; padding: 14px 20px 0; line-height: 1.5; margin: 0; }

.o-main {
    flex: 1;
    padding: 22px;
    min-width: 0;
    position: relative;
}
.o-main.dragging { outline: 3px dashed var(--o-pink); outline-offset: -10px; }

.o-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--o-muted);
    min-height: 320px;
    gap: 6px;
}
.o-empty-icon { font-size: 3rem; }
.o-empty p { margin: 4px 0; }
.o-empty .o-upload { margin: 10px 0; }
.o-empty-hint { font-size: 0.82rem; }

.o-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 22px 18px;
    align-content: start;
}
.o-tile { cursor: pointer; min-width: 0; user-select: none; }
.o-thumb {
    position: relative;
    aspect-ratio: 4 / 3;
    background: #111;
    border: 4px solid #333;
    border-radius: 3px;
    overflow: hidden;
}
.o-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.o-tile:hover .o-thumb { border-color: #555; }
.o-tile.selected .o-thumb { border-color: var(--o-pink); }
.o-tile.flagged .o-thumb { border-color: #e03131; box-shadow: 0 0 0 2px rgba(224,49,49,0.4); }
.o-tile.failed .o-thumb { border-color: #e03131; }
.o-tile.done .o-thumb { border-color: #2f9e44; }
.o-tile.done img { opacity: 0.55; }
.o-tile.done, .o-tile.uploading { cursor: default; }

.o-check {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    border: 2px solid #fff;
    color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.1s;
}
.o-tile:hover .o-check, .o-tile.selected .o-check { opacity: 1; }
.o-tile.selected .o-check { background: var(--o-pink); border-color: var(--o-pink); color: #fff; }
.o-tile.done .o-check, .o-tile.uploading .o-check { display: none; }
@media (hover: none) { .o-check { opacity: 1; } }

.o-overlay {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    padding: 6px 8px;
    background: rgba(0,0,0,0.72);
    font-size: 0.78rem;
    display: none;
}
.o-tile.uploading .o-overlay,
.o-tile.done .o-overlay,
.o-tile.failed .o-overlay { display: block; }
.o-bar { height: 4px; background: #444; border-radius: 2px; overflow: hidden; margin-bottom: 4px; }
.o-bar span { display: block; height: 100%; width: 0; background: var(--o-blue); transition: width 0.15s; }
.o-tile.done .o-bar span { background: #2f9e44; }
.o-tile.failed .o-bar { display: none; }
.o-tile.failed .o-msg { color: #ff9b9b; }
.o-tile.done .o-msg { color: #8be0a0; }

.o-title {
    margin-top: 10px;
    font-weight: 700;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 2px 0;
}
.o-title:hover { text-decoration: underline; text-decoration-style: dotted; }
.o-title-input {
    width: 100%;
    margin-top: 8px;
    background: #fff;
    color: #111;
    border: 2px solid var(--o-blue);
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 0.92rem;
    font-weight: 700;
}
.o-sub { color: var(--o-muted); font-size: 0.8rem; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.o-sub-warn { color: #ffa94d; }

@media (max-width: 800px) {
    .o-body { flex-direction: column; }
    .o-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--o-line); }
    .o-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px 12px; }
    .o-upload { margin-left: 0; }
}

/* description line under the title (click to edit, like the title) */
.o-desc {
    color: #cfcfcf;
    font-size: 0.85rem;
    padding: 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.o-desc:hover { text-decoration: underline; text-decoration-style: dotted; }
.o-desc-empty { color: var(--o-muted); }
.o-desc-input {
    width: 100%;
    background: #fff;
    color: #111;
    border: 2px solid var(--o-blue);
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 0.85rem;
}

/* Album picker on the edit page (a photo can be in several albums) */
.album-picker{max-height:240px;overflow:auto;border:1px solid var(--line);border-radius:8px;padding:8px 12px;margin:6px 0 4px}
.album-option{display:flex;align-items:center;gap:8px;padding:3px 0;font-weight:400;cursor:pointer}
.album-option input{width:auto;margin:0}
