/* Commune Image Server — Styles */

@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:ital,wght@0,300;0,400;0,600;0,700;1,400&family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&display=swap');

/* ── Brand Tokens ───────────────────────────────────────────────────────── */
:root {
    --sidebar-width:   260px;
    --linen:           #f4f0e3;
    --linen-light:     #faf8f2;
    --linen-dark:      #e8e2d0;
    --sage:            #9aa583;
    --sage-light:      #b5bdaa;
    --sage-dark:       #7d8c6e;
    --desert:          #c8856a;
    --stone:           #6b7d8a;
    --forest:          #3d5b47;
    --forest-light:    #4f7259;
    --forest-dark:     #2c3e33;
    --bg-page:         var(--linen);
    --bg-card:         #ffffff;
    --bg-sidebar:      var(--forest-dark);
    --text-primary:    #2c3530;
    --text-secondary:  #5e6b62;
    --text-muted:      #8a9189;
    --border:          var(--linen-dark);
    --accent:          var(--forest);
    --font-heading:    'Libre Baskerville', Georgia, serif;
    --font-body:       'Nunito Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--bg-page);
    color: var(--text-primary);
    overflow-x: hidden;
    font-size: 14px;
    line-height: 1.5;
}

/* ── Auth Screen ──────────────────────────────────────────────────────────── */
.auth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    padding: 2rem;
    background: linear-gradient(160deg, var(--linen) 0%, var(--linen-dark) 100%);
}

.auth-logo { width: 180px; margin-bottom: 2rem; }

.auth-container h2 {
    font-family: var(--font-heading);
    color: var(--forest);
    margin-bottom: 0.5rem;
    font-size: 1.8rem;
}

.btn-google {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 28px;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-body);
    color: var(--text-primary);
    background: white;
    border: 2px solid var(--linen-dark);
    border-radius: 8px;
    margin-top: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-google:hover {
    border-color: var(--sage);
    box-shadow: 0 2px 12px rgba(61,91,71,0.12);
    transform: translateY(-1px);
}

.auth-note {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.btn-external {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    background: #f0f0f0;
    color: #444;
    border: 1px solid #ccc;
    transition: all 0.2s;
    margin-top: 0.75rem;
    width: 100%;
}

.btn-external:hover { background: #e0e0e0; border-color: #bbb; transform: translateY(-1px); }

.auth-back-btn {
    padding: 0;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--sage, #5a7a5a);
    text-decoration: none;
}

#auth-external { max-width: 320px; }
#auth-external .form-label {
    font-size: 0.9rem;
    color: var(--forest, #3d5b47);
    font-weight: 500;
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
#app { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    left: 0; top: 56px; bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: rgba(244,240,227,0.75);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow: hidden;
}

/* Drag handle pinned to the sidebar's right edge */
.sidebar-resizer {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 6px;
    cursor: col-resize;
    z-index: 110;
    background: transparent;
    transition: background 0.15s ease;
}
.sidebar-resizer:hover,
body.sidebar-resizing .sidebar-resizer {
    background: rgba(154,165,131,0.55);
}
/* While dragging, kill text selection and pointer interference everywhere */
body.sidebar-resizing {
    cursor: col-resize;
    user-select: none;
}
body.sidebar-resizing .main-content { pointer-events: none; }

.sidebar-header { display: none !important; }
.sidebar-header-DISABLED {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.sidebar-logo { width: 32px; height: auto; }

.sidebar-title {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--linen);
    letter-spacing: 0.3px;
}

.sidebar-body {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
    scrollbar-gutter: stable;
    scrollbar-color: rgba(255,255,255,0.15) #2c3e33;
    scrollbar-width: thin;
}
.sidebar-body::-webkit-scrollbar {
    width: 6px;
}
.sidebar-body::-webkit-scrollbar-track {
    background: #2c3e33;
}
.sidebar-body::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}
.sidebar-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
}

.sidebar-search {
    padding: 0 16px 12px;
}

.sidebar-search .form-control {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--linen);
    font-size: 0.85rem;
}

.sidebar-search .form-control::placeholder { color: rgba(244,240,227,0.4); }
.sidebar-search .form-control:focus {
    background: rgba(255,255,255,0.12);
    border-color: var(--sage);
    box-shadow: 0 0 0 2px rgba(154,165,131,0.25);
    color: var(--linen);
}

.sidebar-section-label {
    padding: 8px 20px 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(244,240,227,0.35);
}

/* ── Collapsible sidebar sections ───────────────────────────────────────── */
.sidebar-section { margin-bottom: 4px; }
.sidebar-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    padding: 8px 20px 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(244,240,227,0.35);
    transition: color 0.15s;
}
.sidebar-section-header:hover { color: rgba(244,240,227,0.65); }
.section-chevron {
    font-size: 0.7rem;
    transition: transform 0.18s ease;
}
.sidebar-section.collapsed .section-chevron { transform: rotate(-90deg); }
.sidebar-section.collapsed .sidebar-section-content { display: none; }
.sidebar-scroll-list {
    max-height: 38vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.sidebar-scroll-list::-webkit-scrollbar { width: 5px; }
.sidebar-scroll-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}
#section-tags .sidebar-scroll-list { max-height: 30vh; }

.sidebar-nav { list-style: none; padding: 0; margin: 0; }

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.15s;
    border-left: 3px solid transparent;
    color: rgba(244,240,227,0.65);
    border-radius: 0;
}

.sidebar-nav .nav-item:hover {
    background: rgba(154,165,131,0.12);
    color: var(--linen);
}

.sidebar-nav .nav-item.active {
    background: rgba(154,165,131,0.18);
    color: var(--sage-light);
    border-left-color: var(--sage);
    font-weight: 600;
}

.sidebar-nav .nav-item .album-count {
    margin-left: auto;
    font-size: 0.72rem;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 1px 7px;
    color: rgba(244,240,227,0.5);
}

.sidebar-footer {
    padding: 12px 10px 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

/* ── Album list item controls ───────────────────────────────────────────── */
.sidebar-nav .nav-item .album-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-nav .nav-item .album-actions {
    display: none;
    margin-left: auto;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.sidebar-nav .nav-item:hover .album-actions { display: inline-flex; }
.sidebar-nav .nav-item:hover .album-count    { display: none; }

/* "Unassigned" pseudo-album: pinned to the top, set off with a divider. */
.sidebar-nav .nav-item.album-unassigned {
    border-bottom: 1px solid rgba(255,255,255,0.08);
    font-style: italic;
    color: rgba(244,240,227,0.7);
}
/* No actions on Unassigned — keep its count visible on hover. */
.sidebar-nav .nav-item.album-unassigned:hover .album-count { display: inline-block; }

.album-action-btn {
    background: transparent;
    border: none;
    padding: 2px 5px;
    border-radius: 4px;
    color: rgba(244,240,227,0.6);
    cursor: pointer;
    font-size: 0.8rem;
    line-height: 1;
    transition: all 0.12s;
}

.album-action-btn:hover {
    background: rgba(255,255,255,0.12);
    color: var(--linen);
}

.album-action-btn.danger:hover { color: var(--desert); }

.album-rename-input {
    flex: 1;
    min-width: 0;
    background: rgba(255,255,255,0.12);
    border: 1px solid var(--sage);
    border-radius: 4px;
    color: var(--linen);
    font-size: 0.85rem;
    padding: 2px 6px;
}

.album-rename-input:focus { outline: none; box-shadow: 0 0 0 2px rgba(154,165,131,0.25); }

.new-album-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    width: calc(100% - 32px);
    margin: 6px 16px 0;
    padding: 6px 10px;
    background: transparent;
    border: 1px dashed rgba(255,255,255,0.18);
    border-radius: 6px;
    color: rgba(244,240,227,0.5);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
}

.new-album-btn:hover {
    border-color: var(--sage);
    color: var(--linen);
    background: rgba(154,165,131,0.12);
}

/* ── Main Content ─────────────────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Stats Bar ────────────────────────────────────────────────────────────── */
.stats-bar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 14px 28px;
    background: white;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    font-family: var(--font-heading);
    color: var(--forest);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stats-bar .ms-auto { margin-left: auto; }

/* ── Toolbar ──────────────────────────────────────────────────────────────── */
.toolbar {
    display: flex;
    flex-wrap: wrap;            /* wrap to a second row rather than squeeze labels onto two lines */
    align-items: center;
    gap: 12px;
    row-gap: 8px;
    padding: 12px 28px;
    background: var(--linen-light);
    border-bottom: 1px solid var(--border);
}

.result-count {
    font-size: 0.82rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.result-count strong {
    color: var(--forest);
    font-weight: 700;
}

.sort-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-right: 4px;
}

/* ── Image Grid ───────────────────────────────────────────────────────────── */
.image-grid-wrapper {
    padding: 20px 24px;
    flex: 1;
}

/* External file drag from the OS hovering over the grid */
.image-grid-wrapper.file-dragover {
    outline: 2px dashed var(--sage);
    outline-offset: -8px;
    border-radius: 12px;
    background: rgba(154,165,131,0.08);
}

/* Floating status pill for grid drag-drop uploads */
.grid-drop-status {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--forest, #2f3e2e);
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 0.9rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    z-index: 2000;
    transition: opacity 0.8s;
}
.grid-drop-status.fade-out { opacity: 0; }

.image-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    align-content: start;
}

@media (max-width: 1400px) { .image-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px)  { .image-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px)  { .image-grid { grid-template-columns: 1fr; } }

.img-card {
    margin-bottom: 16px;
    border-radius: 8px;
    overflow: hidden;
    background: white;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    position: relative;
}

.img-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.13);
}

.img-card img {
    display: block;
    width: 100%;
    height: auto;
    background: var(--linen-dark);
}

/* Original-aspect mode — cards are packed masonry-style: grid-auto-rows sets a
   fine row unit and JS (applyMasonry) gives each card a row span matching its
   image's aspect ratio, so columns stay tight with no ragged gaps. */
.image-grid.aspect-original { grid-auto-rows: 10px; }
.image-grid.aspect-original .img-card { margin-bottom: 0; }
.image-grid.aspect-original .img-card img { height: 100%; object-fit: cover; }

.img-card-overlay {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: linear-gradient(0deg, rgba(44,62,51,0.85) 0%, transparent 100%);
    padding: 24px 10px 10px;
    opacity: 0;
    transition: opacity 0.15s;
}

.img-card:hover .img-card-overlay { opacity: 1; }

.img-card-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.img-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tag-pill {
    font-size: 0.68rem;
    background: rgba(154,165,131,0.45);
    color: white;
    border-radius: 10px;
    padding: 1px 7px;
    white-space: nowrap;
}

/* ── Load More ───────────────────────────────────────────────────────────── */
.load-more-wrap {
    text-align: center;
    padding: 20px 0 40px;
}

/* ── Empty / Loading States ─────────────────────────────────────────────── */
.grid-status {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.grid-status .bi { font-size: 3rem; margin-bottom: 1rem; display: block; }

/* ── Image Detail Modal ─────────────────────────────────────────────────── */
#detail-modal .modal-dialog { max-width: 1100px; }

#detail-modal .modal-body-DISABLED {
    display: grid;
    grid-template-columns: 58% 42%;
    gap: 0;
    padding: 0;
    min-height: 560px;
}

.detail-image-col {
    background: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px 0 0 8px;
    overflow: hidden;
}

.detail-image-col img {
    width: 100%;
    height: 100%;
    min-height: 500px;
    max-height: 85vh;
    object-fit: contain;
    display: block;
}

.detail-meta-col {
    padding: 20px;
    overflow-y: auto;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.detail-title-input {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 4px 6px;
    width: 100%;
    transition: border-color 0.15s;
    background: transparent;
    color: var(--text-primary);
}

.detail-title-input:hover { border-color: var(--linen-dark); }
.detail-title-input:focus { border-color: var(--sage); outline: none; background: white; }

.detail-description-input {
    font-size: 0.85rem;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 4px 6px;
    width: 100%;
    resize: vertical;
    min-height: 60px;
    transition: border-color 0.15s;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-body);
}

.detail-description-input:hover { border-color: var(--linen-dark); }
.detail-description-input:focus { border-color: var(--sage); outline: none; background: white; }

.detail-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.ai-source-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: none;
    color: #6d4aff;
    background: rgba(109, 74, 255, 0.10);
    border: 1px solid rgba(109, 74, 255, 0.25);
    vertical-align: middle;
    cursor: help;
}

.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.detail-tag {
    font-size: 0.72rem;
    padding: 2px 9px;
    border-radius: 10px;
    background: var(--linen-dark);
    color: var(--text-secondary);
}

.detail-tag.ai { background: rgba(200,133,106,0.15); color: var(--desert); }

.detail-tag.editable { display: inline-flex; align-items: center; gap: 3px; padding-right: 4px; }
.detail-tag-x {
    border: none; background: none; cursor: pointer; padding: 0 1px;
    font-size: 0.95rem; line-height: 1; color: inherit; opacity: 0.55;
}
.detail-tag-x:hover { opacity: 1; color: #c0392b; }

/* Album membership chips (many-to-many). Sage-tinted to distinguish from tags. */
.detail-album-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 6px;
}
.detail-album-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.72rem;
    padding: 2px 5px 2px 9px;
    border-radius: 10px;
    background: rgba(154,165,131,0.18);
    color: var(--sage-dark);
    border: 1px solid rgba(154,165,131,0.35);
}
.detail-album-chip-label { line-height: 1.2; }
.detail-album-chip-x {
    border: none; background: none; cursor: pointer; padding: 0 1px;
    font-size: 0.95rem; line-height: 1; color: inherit; opacity: 0.55;
}
.detail-album-chip-x:hover { opacity: 1; color: #c0392b; }
.detail-album-empty {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-style: italic;
}

.detail-tag-add {
    font-size: 0.72rem; padding: 2px 9px; border-radius: 10px;
    border: 1px dashed var(--linen-dark); background: transparent;
    color: var(--text-secondary); width: 84px; transition: width 0.12s ease;
}
.detail-tag-add::placeholder { color: var(--text-secondary); opacity: 0.7; }
.detail-tag-add:focus { outline: none; border-color: var(--desert); color: var(--text-primary); width: 130px; }

.detail-tags-empty { font-size: 0.78rem; color: var(--text-secondary); font-style: italic; }

/* Bulk tag-edit modal (multi-select) */
.bulk-tags-intro { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 14px; }
.bulk-tags-summary { font-size: 0.78rem; color: var(--text-secondary); }
.detail-tag.bulk-tag-pending-add {
    background: rgba(46, 160, 67, 0.15); color: #1a7f37;
    box-shadow: inset 0 0 0 1px rgba(46, 160, 67, 0.35);
}
.detail-tag.bulk-tag-pending-remove {
    background: rgba(192, 57, 43, 0.12); color: #c0392b;
    text-decoration: line-through; opacity: 0.8;
}

.detail-meta-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 0.82rem;
}

.detail-meta-row .label { color: var(--text-muted); flex-shrink: 0; }
.detail-meta-row .value { color: var(--text-primary); }

.copy-url-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.btn-copy {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    transition: all 0.15s;
}

/* Per-size download button beside each Copy URL field. */
.btn-download {
    display: flex;
    align-items: center;
    font-size: 0.78rem;
}

.btn-copy.copied {
    background-color: var(--sage) !important;
    border-color: var(--sage-dark) !important;
    color: white !important;
}

.detail-edit-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.detail-footer {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ── Upload Modal ────────────────────────────────────────────────────────── */
#upload-modal .modal-dialog { max-width: 560px; }

.drop-zone {
    border: 2px dashed var(--linen-dark);
    border-radius: 10px;
    padding: 48px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--linen-light);
    color: var(--text-muted);
}

.drop-zone.dragover {
    border-color: var(--sage);
    background: rgba(154,165,131,0.08);
    color: var(--forest);
}

.drop-zone .drop-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    display: block;
    color: var(--sage);
}

.drop-zone p { margin: 6px 0 0; font-size: 0.9rem; }

.upload-file-list {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.upload-file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.83rem;
}

.upload-file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.upload-file-status {
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.upload-file-status.pending  { color: var(--text-muted); }
.upload-file-status.uploading { color: var(--stone); }
.upload-file-status.done     { color: var(--sage-dark); }
.upload-file-status.error    { color: var(--desert); }
.upload-file-status.duplicate { color: var(--stone); }

/* ── Misc ────────────────────────────────────────────────────────────────── */
.badge-count {
    font-size: 0.7rem;
    background: rgba(154,165,131,0.3);
    color: var(--linen);
    border-radius: 10px;
    padding: 2px 8px;
    margin-left: 6px;
}

.spinner-sm {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0,0,0,0.1);
    border-top-color: var(--forest);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }


/* Album search filter */
.album-search-wrap {
    position: relative;
    margin: 6px 0 4px;
}
.album-search-icon {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255,255,255,0.45);
    font-size: 11px;
    pointer-events: none;
}
.album-search-input {
    width: 100%;
    background: rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    color: #e8f5e9;
    font-size: 12px;
    padding: 5px 8px 5px 26px;
    outline: none;
    box-sizing: border-box;
}
.album-search-input::placeholder { color: rgba(255,255,255,0.35); }
.album-search-input:focus { border-color: rgba(255,255,255,0.3); background: rgba(0,0,0,0.35); }
.album-search-input::-webkit-search-cancel-button { cursor: pointer; }


/* Upload-dialog album combobox (searchable) — light theme to match the modal */
.album-combo {
    position: relative;
}
.album-combo-toggle {
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
    cursor: pointer;
    background-color: #fff;
}
.album-combo-toggle #upload-album-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.album-combo-toggle.open {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.2rem rgba(13,110,253,0.18);
}
.album-combo-panel {
    position: absolute;
    z-index: 1080;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ced4da;
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    overflow: hidden;
}
.album-combo-search {
    position: relative;
    padding: 6px;
    border-bottom: 1px solid #eee;
}
.album-combo-search .bi-search {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #adb5bd;
    font-size: 12px;
    pointer-events: none;
}
.album-combo-search input {
    width: 100%;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    font-size: 0.85rem;
    padding: 5px 8px 5px 28px;
    outline: none;
    box-sizing: border-box;
}
.album-combo-search input:focus { border-color: #86b7fe; }
.album-combo-list {
    list-style: none;
    margin: 0;
    padding: 4px;
    max-height: 220px;
    overflow-y: auto;
}
.album-combo-option {
    padding: 6px 10px;
    border-radius: 5px;
    font-size: 0.88rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.album-combo-option:hover { background: #f1f3f5; }
.album-combo-option.selected { background: #e7f1ff; font-weight: 600; }
.album-combo-option.is-new { color: #0d6efd; border-top: 1px solid #eee; margin-top: 2px; }
.album-combo-empty {
    padding: 10px;
    text-align: center;
    color: #adb5bd;
    font-size: 0.85rem;
}

/* Generic combobox label truncation (covers both upload + bulk comboboxes). */
.album-combo-toggle > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Multi-select cards ───────────────────────────────────────────────────── */
.img-card-select {
    position: absolute;
    top: 8px; left: 8px;
    z-index: 3;
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.9);
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
    opacity: 0;
    transition: opacity 0.15s;
    cursor: pointer;
}
.img-card:hover .img-card-select,
.img-card.selected .img-card-select { opacity: 1; }
.img-card-check {
    width: 16px; height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--forest);
}
.img-card.selected {
    outline: 3px solid var(--forest);
    outline-offset: -3px;
}
.img-card.selected img { filter: brightness(0.9); }

/* ── Bulk action bar ──────────────────────────────────────────────────────── */
.bulk-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    padding-left: 14px;
    border-left: 1px solid var(--border);
}
.bulk-bar[hidden] { display: none; }
.bulk-count {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--forest);
    white-space: nowrap;
}
.bulk-album-combo { width: 210px; }

/* ── Bulk download menu (Download button dropdown on the bulk bar) ─────────── */
.bulk-download-combo { width: auto; }
.bulk-download-combo .album-combo-panel {
    right: auto;
    min-width: 170px;
}
.bulk-download-combo .album-combo-option i {
    margin-right: 6px;
    color: var(--text-secondary);
}

/* ── Album drop target (drag images onto a sidebar album) ─────────────────── */
.sidebar-nav .nav-item.drag-over {
    background: var(--forest-light) !important;
    box-shadow: inset 0 0 0 2px var(--sage-light);
}

/* ── Delete confirm overlay ───────────────────────────────────────────────── */
.delete-overlay {
    position: fixed; inset: 0;
    z-index: 2000;
    background: rgba(20,28,23,0.55);
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.delete-overlay[hidden] { display: none; }
.delete-dialog {
    background: #fff;
    border-radius: 10px;
    padding: 22px 24px;
    width: 400px; max-width: 100%;
    box-shadow: 0 16px 50px rgba(0,0,0,0.35);
}
.delete-dialog-title {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 10px;
}
.delete-dialog-title .bi { color: #c0392b; }
.delete-dialog-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0 0 14px;
}
.delete-r2-check {
    display: flex; align-items: flex-start; gap: 8px;
    font-size: 0.82rem; line-height: 1.35;
    color: var(--text-primary);
    background: var(--linen-light);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 10px 12px;
    margin-bottom: 18px;
    cursor: pointer;
}
.delete-r2-check input {
    margin: 2px 0 0;
    accent-color: var(--forest);
    flex-shrink: 0;
}
.delete-dialog-actions {
    display: flex; justify-content: flex-end; gap: 8px;
}

/* ── Replace dialog (shares the delete overlay shell) ──────────────────── */
.replace-dialog .delete-dialog-title .bi { color: var(--forest); }
.replace-help-link {
    margin-right: auto;
    align-self: center;
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-decoration: none;
    white-space: nowrap;
}
.replace-help-link:hover { color: var(--forest); text-decoration: underline; }
.replace-file-info {
    font-size: 0.82rem; line-height: 1.35;
    color: var(--text-primary);
    background: var(--linen-light);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 10px 12px;
    margin-bottom: 14px;
    word-break: break-word;
}
.replace-file-info .hint {
    display: block;
    color: var(--text-secondary);
    margin-top: 4px;
}
.replace-progress {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 12px;
}
.replace-progress[hidden] { display: none; }
.replace-progress-bar {
    height: 100%; width: 0;
    background: var(--forest);
    transition: width 0.15s linear;
}
.replace-status {
    font-size: 0.82rem; line-height: 1.35;
    margin-bottom: 14px;
    color: var(--text-secondary);
}
.replace-status[hidden] { display: none; }
.replace-status.ok    { color: var(--forest); }
.replace-status.warn  { color: #8a6d1a; }
.replace-status.error { color: #c0392b; }

/* Post-replace purge prompt — acknowledged by Close, never auto-dismissed */
.replace-purge-prompt {
    border: 1px solid #d9b95c;
    background: #fdf7e3;
    border-radius: 7px;
    padding: 10px 12px;
    margin-bottom: 14px;
}
.replace-purge-prompt[hidden] { display: none; }
.replace-purge-prompt.ok          { border-color: var(--forest); background: #eef4ef; }
.replace-purge-prompt.unavailable { border-color: #c9c3b5; background: var(--linen-light); }
.replace-purge-title {
    font-weight: 600; font-size: 0.86rem;
    color: var(--text-primary);
    display: flex; align-items: center; gap: 6px;
    margin-bottom: 4px;
}
.replace-purge-prompt.ok .replace-purge-title .bi { color: var(--forest); }
.replace-purge-prompt:not(.ok) .replace-purge-title .bi { color: #8a6d1a; }
.replace-purge-text {
    font-size: 0.82rem; line-height: 1.35;
    color: var(--text-secondary);
    margin: 0 0 8px;
}
.replace-purge-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.replace-purge-result { font-size: 0.8rem; line-height: 1.3; color: var(--text-secondary); }
.replace-purge-result.ok    { color: var(--forest); }
.replace-purge-result.error { color: #c0392b; }
.replace-purge-result.unavailable { color: #8a6d1a; }

/* Manual purge status line under the modal footer buttons */
.detail-purge-status {
    font-size: 0.8rem; line-height: 1.35;
    color: var(--text-secondary);
    padding-top: 8px;
}
.detail-purge-status[hidden] { display: none; }
.detail-purge-status.ok          { color: var(--forest); }
.detail-purge-status.error       { color: #c0392b; }
.detail-purge-status.unavailable { color: #8a6d1a; }

/* ── Tag Manager ────────────────────────────────────────────────────────── */
.tag-mgr-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}
.tag-mgr-toolbar input[type="search"] { flex: 1; min-width: 0; }

.tag-mgr-toast {
    font-size: 0.82rem;
    padding: 7px 11px;
    border-radius: 6px;
    margin-bottom: 10px;
}
.tag-mgr-toast.ok    { background: rgba(61,91,71,0.10);  color: var(--forest);  border: 1px solid rgba(61,91,71,0.25); }
.tag-mgr-toast.error { background: rgba(200,133,106,0.12); color: var(--desert); border: 1px solid rgba(200,133,106,0.35); }

.tag-mgr-summary {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.tag-mgr-status {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 28px 0;
}

.tag-mgr-list {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.tag-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 7px 12px;
    border-bottom: 1px solid var(--border);
}
.tag-row:last-child { border-bottom: none; }
.tag-row:hover { background: var(--linen-light); }

.tag-name {
    flex: 1;
    min-width: 0;
    text-align: left;
    background: transparent;
    border: none;
    padding: 0;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tag-name:hover { color: var(--accent); text-decoration: underline; }

.tag-count {
    flex-shrink: 0;
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}
.tag-count-label { color: var(--text-muted); margin-left: 3px; font-size: 0.72rem; }

.tag-src-hint {
    flex-shrink: 0;
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--linen-dark);
    border-radius: 4px;
    padding: 1px 6px;
}

.tag-row-actions {
    flex-shrink: 0;
    display: inline-flex;
    gap: 2px;
}
.tag-act-btn {
    background: transparent;
    border: none;
    padding: 3px 6px;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    transition: all 0.12s;
}
.tag-act-btn:hover        { background: var(--linen-dark); color: var(--text-primary); }
.tag-act-btn.danger:hover { color: var(--desert); }

.tag-edit-input {
    flex: 1;
    min-width: 0;
    background: #fff;
    border: 1px solid var(--sage);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 2px 6px;
}
.tag-edit-input:focus { outline: none; box-shadow: 0 0 0 2px rgba(154,165,131,0.25); }

.tag-row-editor {
    flex-basis: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
}
.tag-row-editor-label { font-size: 0.82rem; color: var(--text-secondary); }
.tag-row-editor-label.danger { color: var(--desert); font-weight: 600; }
.tag-merge-input { flex: 1; min-width: 140px; max-width: 260px; }

/* ── Resolver Safety Modal ──────────────────────────────────────────────────── */
/* Reuses .ai-tag-intro and .ai-tag-status; only the per-setting block is new. */
.resolver-setting {
    padding: 0.75rem 0;
    border-top: 1px solid var(--border);
}
.resolver-setting .form-check-label { font-size: 0.9rem; cursor: pointer; }
.resolver-setting-help {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0.35rem 0 0 2.5rem;
    line-height: 1.45;
}
.resolver-setting-cost {
    display: block;
    margin-top: 0.25rem;
    color: var(--text-muted);
}
.resolver-setting.saving { opacity: 0.6; }

/* ── AI Tagging Modal ───────────────────────────────────────────────────────── */
.ai-tag-intro {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}
.ai-tag-controls {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 0.75rem;
}
.ai-tag-field { display: flex; flex-direction: column; gap: 0.2rem; }
.ai-tag-field-grow { flex: 1 1 240px; min-width: 200px; }
.ai-tag-field label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.ai-tag-field #ai-tag-limit { width: 90px; }
.ai-tag-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.6rem 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.75rem;
}
.ai-tag-check {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin: 0;
    cursor: pointer;
}
.ai-tag-status {
    font-size: 0.85rem;
    color: var(--forest);
    min-height: 1.2em;
    margin-bottom: 0.5rem;
}
.ai-tag-status.error { color: var(--desert); }
.ai-tag-results { display: flex; flex-direction: column; gap: 0.6rem; }
.ai-result {
    display: flex;
    gap: 0.75rem;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
}
.ai-result.has-error { border-color: rgba(200,133,106,0.4); background: rgba(200,133,106,0.05); }
.ai-result-thumb {
    flex: 0 0 96px;
    width: 96px;
    height: 96px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--linen-dark);
}
.ai-result-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ai-result-body { flex: 1 1 auto; min-width: 0; }
.ai-result-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.4rem; }
.ai-chip {
    font-size: 0.74rem;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    background: rgba(61,91,71,0.10);
    color: var(--forest);
    border: 1px solid rgba(61,91,71,0.22);
}
.ai-result-none { font-size: 0.78rem; color: var(--text-muted); font-style: italic; }
.ai-result-desc { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.45; }
.ai-result-err { font-size: 0.82rem; color: var(--desert); }

/* ── Tag-manager view switch + AI vocabulary editor ─────────────────────── */
.tag-view-switch { margin-bottom: 0.6rem; }
.tag-vocab-intro {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0 0 0.6rem;
}
#tag-vocab-search { margin-bottom: 0.5rem; }
.tag-vocab-summary {
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}
.tag-vocab-cat {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent);
    margin: 0.7rem 0 0.35rem;
    padding-bottom: 0.2rem;
    border-bottom: 1px solid var(--border);
}
.tag-vocab-cat-rule {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-muted);
    font-style: italic;
}
.vocab-row {
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--bg-card);
    margin-bottom: 0.4rem;
}
.vocab-row.ai-off { opacity: 0.62; }
.vocab-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.vocab-tag {
    font-weight: 600;
    font-size: 0.86rem;
    color: var(--text-primary);
}
.vocab-ai-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    margin: 0;
}
.vocab-ai-toggle input { cursor: pointer; }
.vocab-guidance {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.45;
    margin-top: 0.35rem;
    padding: 0.3rem 0.4rem;
    border-radius: 5px;
    cursor: text;
}
.vocab-guidance:hover { background: rgba(61,91,71,0.06); }
.vocab-guidance.empty { font-style: italic; color: var(--text-muted); }
.vocab-guidance-editor { margin-top: 0.35rem; }
.vocab-guidance-editor textarea { font-size: 0.8rem; line-height: 1.45; resize: vertical; }
.vocab-guidance-btns {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.4rem;
}
.vocab-guidance-hint {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-left: auto;
}

/* ── API links (spec quick-link in header, per-album copy buttons) ─────────── */
.commune-header .ch-api-link {
    color: rgba(244, 240, 227, 0.75);
    font-size: 0.78rem;
    text-decoration: none;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.commune-header .ch-api-link:hover { color: #fff; text-decoration: underline; }
.chip-link-btn {
    background: transparent;
    border: 0;
    color: #fff;
    padding: 0 2px;
    line-height: 1;
    font-size: 0.95rem;
    opacity: 0.85;
}
.chip-link-btn:hover, .chip-link-btn.copied { opacity: 1; }
.album-action-btn.copied { color: var(--forest, #2f5d3a); }

/* ── Share this view modal ───────────────────────────────────────────────── */
.toolbar > .btn { white-space: nowrap; }
.share-summary { margin-bottom: 0.5rem; }
.share-facts {
    padding-left: 1.1rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    color: #6c757d;
}
.share-facts li { margin-bottom: 0.15rem; }
.share-result { margin-top: 0.25rem; }
