﻿  /* ── Lightbox + photo markup ── */
  #photoLightbox {
    --font-mono: 'DM Mono', monospace;
    --font-sans: 'DM Sans', sans-serif;
    --font-display: 'Bebas Neue', sans-serif;
    --text-caption: 10px;
    --text-body: 13px;
    --text-secondary: 11px;
    --radius-sm: 4px;
    --tap-min: 40px;
    --red: #E92A2C;
    --green: #22c55e;
    --amber: #f59e0b;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.93);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    padding: 0;
    cursor: zoom-out;
  }
  .lb-close-fixed {
    position: fixed;
    top: max(10px, env(safe-area-inset-top, 0px));
    right: max(12px, env(safe-area-inset-right, 0px));
    z-index: 10005;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #202020;
    border: 2px solid rgba(255, 255, 255, 0.55);
    color: #fff;
    font-size: 1.625rem;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
    -webkit-tap-highlight-color: transparent;
  }
  .lb-close-fixed:active { background: #404040; }
  .lb-topbar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: max(12px, env(safe-area-inset-top, 0px)) 56px 8px 14px;
    flex-shrink: 0;
    z-index: 10004;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.55) 70%, transparent 100%);
    pointer-events: none;
  }
  .lb-topbar-title {
    font-family: var(--font-mono);
    font-size: var(--text-caption);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255,255,255,.72);
    pointer-events: auto;
  }
  .lightbox-close {
    display: none;
  }
  .lb-header,
  .lb-close-header,
  .lb-photo-meta,
  .lb-nav-badge,
  .lb-rail-footer,
  .lb-edit-section-head,
  .lb-ai-title,
  .lb-ai-sub,
  .lb-ai-confidence,
  .lb-tags-hint,
  .lb-mobile-header,
  .lb-mobile-badge-row { display: none; }
  .lb-dialog {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
  }
  .lb-workspace {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }
  .lb-rail {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
    max-height: min(42vh, 360px);
    overflow-y: auto;
    background: rgba(7, 17, 31, 0.92);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 10px;
  }
  .lb-main-footer { display: none; }
  .lb-stage {
    position: relative;
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 12px 6px;
    cursor: default;
    touch-action: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .lb-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 4;
    width: 40px;
    height: 56px;
    border: none;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.45);
    color: rgba(255, 255, 255, 0.9);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
  }
  .lb-nav-btn.visible { display: flex; }
  .lb-nav-btn:hover:not(:disabled) { background: rgba(0, 0, 0, 0.65); }
  .lb-nav-btn:disabled { opacity: 0.35; cursor: default; }
  .lb-nav-prev { left: 4px; }
  .lb-nav-next { right: 4px; }
  .lb-nav-counter {
    font-weight: 400;
    opacity: 0.85;
    margin-left: 0.35em;
  }
  .lb-photo-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    min-height: 0;
  }
  .lb-img-wrap {
    position: relative;
    flex: 0 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    min-height: 0;
    will-change: transform;
    transition: transform .12s ease-out;
  }
  .lb-stage.lb-zoomed .lb-img-wrap { cursor: grab; }
  .lb-stage.lb-zoomed .lb-img-wrap.lb-panning { cursor: grabbing; transition: none; }
  #lightboxImg {
    max-width: 100%;
    max-height: min(52vh, calc(100dvh - 240px));
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 8px 40px rgba(0,0,0,.6);
    display: block;
    user-select: none;
    -webkit-user-drag: none;
  }
  #lightboxAnnotCanvas {
    position: absolute;
    pointer-events: auto;
    touch-action: none;
    border-radius: 6px;
  }
  .lb-zoom-controls {
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.58);
    border: 1px solid rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(2px);
  }
  .lb-zoom-btn {
    min-width: 32px;
    height: 30px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 999px;
    background: rgba(255,255,255,.08);
    color: rgba(255,255,255,.92);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: .04em;
    text-transform: uppercase;
    cursor: pointer;
    padding: 0 10px;
  }
  .lb-zoom-pct {
    min-width: 44px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 10px;
    color: rgba(255,255,255,.84);
    letter-spacing: .04em;
  }
  .lb-text-popover {
    position: absolute;
    z-index: 3;
    display: none;
    flex-direction: column;
    gap: 6px;
    min-width: 180px;
    max-width: min(260px, 72vw);
    padding: 8px;
    background: rgba(12,24,38,.96);
    border: 1px solid rgba(255,255,255,.2);
    border-radius: var(--radius);
    box-shadow: 0 8px 28px rgba(0,0,0,.45);
  }
  .lb-text-popover input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 11px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--steel);
    color: var(--off-white);
    font-family: var(--font-sans);
    font-size: var(--text-body);
  }
  .lb-text-popover button {
    padding: 9px 12px;
    border-radius: 4px;
    border: none;
    background: var(--red-gradient);
    color: #fff;
    font-family: var(--font-mono);
    font-size: var(--text-caption);
    letter-spacing: .06em;
    text-transform: uppercase;
    cursor: pointer;
    min-height: var(--tap-min);
  }
  .lb-toolbar-wrap {
    flex-shrink: 0;
    max-height: min(46vh, 420px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: rgba(7,17,31,.92);
    border-top: 1px solid rgba(255,255,255,.1);
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .lb-toolbar {
    display: flex;
    align-items: stretch;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
  }
  .lb-toolbar-row .lb-tool {
    flex: 1 1 calc(20% - 6px);
    min-width: 56px;
    max-width: none;
  }
  .lb-ai-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 2px 4px;
    border-top: 1px solid rgba(255,255,255,.08);
  }
  .lb-ai-bar.visible { display: flex; }
  .lb-ai-classify {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .lb-ai-label {
    font-family: var(--font-mono);
    font-size: 8px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255,255,255,.45);
  }
  #lbAiClassifyText {
    font-family: var(--font-sans);
    font-size: 11px;
    color: rgba(255,255,255,.88);
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .lb-ai-rescan-btn {
    flex-shrink: 0;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(74,158,255,.45);
    background: rgba(74,158,255,.18);
    color: #93c5fd;
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    cursor: pointer;
    min-height: 36px;
  }
  .lb-ai-rescan-btn:active { opacity: .85; }
  .lb-ai-rescan-btn:disabled {
    opacity: .45;
    pointer-events: none;
  }
  .lb-rescan-status {
    display: none;
    padding: 0 2px 4px;
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--amber);
    text-align: center;
  }
  .lb-rescan-status.visible { display: block; }
  .lb-rescan-status.ok { color: var(--green); }
  .lb-rescan-status.err { color: var(--red); }
  .lb-suppress-row {
    display: none;
    justify-content: center;
    padding: 2px 2px 0;
  }
  .lb-suppress-row.visible { display: flex; }
  .lb-suppress-btn {
    border: none;
    background: transparent;
    color: rgba(255, 140, 140, .92);
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
    padding: 6px 8px;
    min-height: var(--tap-min);
  }
  .lb-suppress-btn:active { opacity: .8; }
  .lb-suppress-btn:disabled { opacity: .45; pointer-events: none; }
  .lb-suppress-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 12050;
    background: rgba(0, 0, 0, .72);
    align-items: center;
    justify-content: center;
    padding: 20px;
  }
  .lb-suppress-overlay.open { display: flex; }
  .lb-suppress-card {
    width: min(100%, 360px);
    /* Fixed dark card — do not use var(--charcoal); mockup light shell sets --charcoal to white */
    background: #1c1c1c;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: var(--radius);
    padding: 18px 16px 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .45);
  }
  .lb-suppress-card h3 {
    margin: 0 0 10px;
    font-family: var(--font-display);
    font-size: 22px;
    letter-spacing: .04em;
    color: #fff;
  }
  .lb-suppress-card p {
    margin: 0 0 16px;
    font-family: var(--font-sans);
    font-size: 13px;
    line-height: 1.45;
    color: rgba(255, 255, 255, .82);
  }
  .lb-suppress-card strong { color: #ffb4b4; font-weight: 700; }
  .lb-suppress-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
  }
  .lb-suppress-actions button {
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, .18);
    background: rgba(255, 255, 255, .06);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    padding: 10px 12px;
    min-height: 40px;
    cursor: pointer;
  }
  .lb-suppress-actions button.danger {
    border-color: rgba(233, 42, 44, .55);
    background: rgba(233, 42, 44, .22);
    color: #ffc9c9;
  }
  .lb-suppress-error {
    display: none;
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: rgba(233, 42, 44, 0.15);
    border: 1px solid rgba(233, 42, 44, 0.35);
    color: #ffb4b4;
    font-size: 12px;
    line-height: 1.45;
  }
  .lb-tags-bar {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 2px;
    border-top: 1px solid rgba(255,255,255,.08);
  }
  .lb-tags-label {
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255,255,255,.5);
  }
  .lb-tags-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .lb-tag-chip {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,.18);
    background: rgba(255,255,255,.06);
    color: rgba(255,255,255,.78);
    font-family: var(--font-sans);
    font-size: 10px;
    line-height: 1.2;
    cursor: pointer;
    min-height: 30px;
  }
  .lb-tag-chip.on {
    border-color: var(--red);
    background: rgba(233,42,44,.22);
    color: #fff;
  }
  .lb-tag-chip.safety.on {
    border-color: var(--amber);
    background: rgba(255,176,32,.2);
  }
  .lb-tag-chip--new {
    border-style: dashed;
    border-color: rgba(233,42,44,.6);
    color: #fff;
  }
  .pg-tag-pill {
    display: inline-block;
    margin-right: 4px;
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(233,42,44,.15);
    color: var(--red);
    font-family: var(--font-mono);
    font-size: 8px;
    letter-spacing: .03em;
    text-transform: uppercase;
    vertical-align: middle;
  }
  .pg-tag-pill.safety {
    background: rgba(255,176,32,.15);
    color: var(--amber);
  }
  .lb-tool {
    flex: 0 0 auto;
    min-width: 56px;
    max-width: 72px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 4px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,.14);
    background: rgba(255,255,255,.06);
    color: rgba(255,255,255,.82);
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: .05em;
    text-transform: uppercase;
    cursor: pointer;
    min-height: var(--tap-min);
  }
  .lb-tool svg { flex-shrink: 0; opacity: .9; width: 18px; height: 18px; }
  .lb-tool.on {
    border-color: var(--red);
    background: rgba(233,42,44,.22);
    color: #fff;
  }
  .lb-tool:active { opacity: .85; }
  .lb-tool.lb-tool-action { max-width: none; flex: 0 0 auto; min-width: 72px; }
  .lightbox-caption {
    width: 100%;
    margin-top: 8px;
    padding: 0 8px 2px;
    font-family: var(--font-sans);
    font-size: var(--text-secondary);
    color: rgba(255,255,255,.72);
    text-align: center;
    line-height: 1.45;
    word-break: break-word;
    flex-shrink: 0;
  }
  .lightbox-caption.lb-save-ok { color: var(--green); font-weight: 600; }
  .lightbox-caption.lb-save-err { color: var(--red); }
  .lb-tool.lb-saving { opacity: 0.55; pointer-events: none; }
  .lb-edit-panel {
    display: none;
    flex-direction: column;
    gap: 10px;
    padding: 10px 14px 6px;
    background: rgba(7,17,31,.94);
    border-top: 1px solid rgba(255,255,255,.1);
    flex-shrink: 0;
  }
  .lb-edit-panel.open { display: flex; }
  .lb-edit-hint {
    font-family: var(--font-mono);
    font-size: var(--text-caption);
    color: rgba(255,255,255,.55);
    letter-spacing: .04em;
  }
  .lb-edit-slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .lb-edit-slider-row label {
    flex: 0 0 72px;
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: rgba(255,255,255,.7);
  }
  .lb-edit-slider-row input[type="range"] {
    flex: 1;
    min-width: 0;
    accent-color: var(--red);
  }
  .lb-edit-slider-row span {
    flex: 0 0 36px;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 9px;
    color: rgba(255,255,255,.65);
  }
  .lb-edit-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }
  .lb-edit-actions button {
    flex: 1;
    min-width: 100px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,.18);
    background: rgba(255,255,255,.08);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: .05em;
    text-transform: uppercase;
    cursor: pointer;
    min-height: 36px;
  }
  .lb-edit-actions button.primary {
    border-color: rgba(233,42,44,.55);
    background: rgba(233,42,44,.22);
  }
  .lb-share-sheet {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    z-index: 12;
    display: none;
    flex-direction: column;
    gap: 10px;
    padding: 14px 14px calc(12px + env(safe-area-inset-bottom, 0px));
    background: rgba(7,17,31,.98);
    border-top: 1px solid rgba(255,255,255,.14);
    box-shadow: 0 -12px 40px rgba(0,0,0,.45);
    max-height: min(58vh, 420px);
    overflow-y: auto;
  }
  .lb-share-sheet.open { display: flex; }
  .lb-share-tabs {
    display: flex;
    gap: 6px;
  }
  .lb-share-tab {
    flex: 1;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,.16);
    background: rgba(255,255,255,.06);
    color: rgba(255,255,255,.75);
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: .07em;
    text-transform: uppercase;
    cursor: pointer;
    min-height: 36px;
  }
  .lb-share-tab.on {
    border-color: var(--red);
    background: rgba(233,42,44,.22);
    color: #fff;
  }
  .lb-showcase-preview {
    font-family: var(--font-sans);
    font-size: var(--text-caption);
    color: rgba(255,255,255,.72);
    line-height: 1.45;
    padding: 10px 11px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,.12);
    background: rgba(255,255,255,.04);
    max-height: 120px;
    overflow-y: auto;
    white-space: pre-wrap;
  }
  .lb-share-btn.showcase {
    grid-column: 1 / -1;
    flex-direction: row;
    gap: 8px;
    min-height: 44px;
    border-color: rgba(233,42,44,.55);
    background: rgba(233,42,44,.22);
    color: #fff;
    font-size: 10px;
  }
  .lb-share-link {
    display: block;
    margin-top: 6px;
    color: var(--blue);
    font-family: var(--font-mono);
    font-size: var(--text-caption);
    word-break: break-all;
  }
  .lb-share-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  .lb-share-head span {
    font-family: var(--font-mono);
    font-size: var(--text-caption);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255,255,255,.7);
  }
  .lb-share-close {
    width: 34px; height: 34px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,.12);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
  }
  .lb-share-recipients {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .lb-share-chip {
    padding: 7px 11px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,.18);
    background: rgba(255,255,255,.06);
    color: rgba(255,255,255,.82);
    font-family: var(--font-sans);
    font-size: var(--text-caption);
    cursor: pointer;
    min-height: 32px;
  }
  .lb-share-chip.on {
    border-color: var(--red);
    background: rgba(233,42,44,.22);
    color: #fff;
  }
  .lb-share-chip:disabled { opacity: .45; cursor: default; }
  .lb-share-note {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 11px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,.16);
    background: rgba(255,255,255,.06);
    color: #fff;
    font-family: var(--font-sans);
    font-size: var(--text-body);
    resize: vertical;
    min-height: 56px;
  }
  .lb-share-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .lb-share-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,.14);
    background: rgba(255,255,255,.07);
    color: rgba(255,255,255,.88);
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: .05em;
    text-transform: uppercase;
    cursor: pointer;
    min-height: var(--tap-min);
  }
  .lb-share-btn:active { opacity: .8; }
  .lb-share-btn.pm {
    border-color: rgba(233,42,44,.55);
    background: rgba(233,42,44,.18);
    color: #fff;
  }
  .lb-share-btn.busy { opacity: .5; pointer-events: none; }
  .lb-share-status {
    font-family: var(--font-sans);
    font-size: var(--text-caption);
    color: rgba(255,255,255,.55);
    text-align: center;
    min-height: 1.2em;
  }
  .lb-share-status.ok { color: var(--green); }
  .lb-share-status.err { color: var(--red); }

/* Desktop PM detail — full-viewport three-column editor */
@media (min-width: 960px) {
  #photoLightbox {
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
    background: #353535;
    cursor: default;
  }
  .lb-dialog {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    background: #353535;
    border-radius: 0;
    overflow: hidden;
    box-shadow: none;
    cursor: default;
  }
  .lb-close-fixed,
  .lb-topbar,
  .lb-sidebar-mobile-actions,
  .lb-ai-mobile-only { display: none; }
  .lb-edit-section-head,
  .lb-ai-title,
  .lb-ai-sub,
  .lb-ai-confidence,
  .lb-tags-hint { display: block; }
  .lb-photo-meta { display: block; }
  .lb-nav-badge { display: inline-flex; }
  .lb-rail-footer { display: flex; }
  .lb-main-footer { display: block; }
  .lb-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    background: #2a2a2a;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
  }
  .lb-header-logo { height: 22px; width: auto; flex-shrink: 0; }
  .lb-header-title {
    flex: 1;
    font-family: var(--font-display);
    font-size: 22px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #fff;
  }
  .lb-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
  }
  .lb-header-filename {
    display: block;
    font-family: var(--font-mono);
    font-size: 11px;
    color: rgba(255, 255, 255, 0.55);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
  }
  .lb-close-header {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: rgba(255, 255, 255, 0.75);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
  }
  .lb-close-header:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
  .lb-workspace {
    display: grid;
    grid-template-columns: 168px minmax(0, 1fr) 300px;
    grid-template-rows: minmax(0, 1fr);
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }
  .lb-sidebar,
  .lb-main,
  .lb-rail {
    min-height: 0;
    height: 100%;
    align-self: stretch;
  }
  .lb-sidebar {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px 12px;
    background: #303030;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    overflow-y: auto;
  }
  .lb-sidebar-label {
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
    margin-bottom: 8px;
  }
  .lb-sidebar-tools {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .lb-sidebar .lb-tool {
    width: 100%;
    max-width: none;
    min-width: 0;
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    padding: 10px 12px;
    min-height: 42px;
    font-size: 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
  }
  .lb-sidebar .lb-tool svg { width: 16px; height: 16px; }
  .lb-sidebar .lb-tool.on {
    border-color: var(--red);
    background: var(--red);
    color: #fff;
  }
  .lb-sidebar-undo { margin-top: auto; }
  .lb-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: #2f2f2f;
  }
  .lb-stage {
    flex: 1;
    min-height: 0;
    padding: 16px 48px 8px;
    overflow: hidden;
  }
  .lb-zoom-controls {
    top: 14px;
    right: 16px;
  }
  .lb-photo-stack {
    flex: 1;
    min-height: 0;
    max-height: 100%;
    justify-content: center;
  }
  .lb-img-wrap {
    flex: 1;
    min-height: 0;
    max-height: 100%;
    width: 100%;
  }
  #lightboxImg {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
  }
  .lb-nav-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-family: var(--font-mono);
    font-size: 10px;
    color: rgba(255, 255, 255, 0.85);
  }
  .lb-nav-badge::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--red);
  }
  .lb-main-footer {
    flex-shrink: 0;
    padding: 0 18px 16px;
    text-align: left;
  }
  .lightbox-caption {
    text-align: left;
    padding: 0 0 0 12px;
    margin: 0 0 8px;
    font-size: 13px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.82);
    border-left: 3px solid var(--red);
  }
  .lb-photo-meta {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.45);
    line-height: 1.5;
  }
  .lb-rail {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 14px 16px;
    background: #383838;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    max-height: none;
    overflow: hidden;
  }
  .lb-edit-panel {
    display: none;
    background: transparent;
    border-top: none;
    padding: 0;
    flex-shrink: 0;
  }
  .lb-edit-panel.open {
    display: flex;
    max-height: 42%;
    overflow-y: auto;
  }
  .lb-edit-section-head { margin-bottom: 4px; }
  .lb-edit-section-title {
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
    margin-bottom: 4px;
  }
  .lb-edit-section-hint {
    font-family: var(--font-sans);
    font-size: 11px;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.45);
  }
  .lb-edit-slider-row label { flex: 0 0 78px; }
  .lb-edit-slider-row span {
    flex: 0 0 34px;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 11px;
    color: rgba(255, 255, 255, 0.75);
  }
  .lb-edit-slider-row span.has-offset { color: var(--red); font-weight: 700; }
  .lb-ai-bar {
    display: none;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.08);
    flex: 1 1 auto;
    min-height: 0;
  }
  .lb-ai-bar.visible { display: flex; }
  .lb-ai-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
  }
  .lb-ai-body {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
  }
  .lb-ai-classify {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
  }
  .lb-ai-title {
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    line-height: 1.45;
    white-space: normal;
    overflow: visible;
  }
  .lb-ai-sub {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.55);
    line-height: 1.45;
    margin-top: 6px;
    white-space: normal;
    overflow: visible;
  }
  .lb-ai-confidence {
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 700;
    color: var(--green);
  }
  .lb-tags-bar {
    border-top: none;
    padding-top: 0;
    flex-shrink: 0;
  }
  .lb-tags-label {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.55);
  }
  .lb-tags-hint { font-weight: 400; text-transform: none; letter-spacing: 0; }
  .lb-rail-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: auto;
    padding-top: 8px;
    flex-shrink: 0;
  }
  #lbRescanStatus.lb-rescan-status,
  .lb-rail .lb-rescan-status {
    flex-shrink: 0;
  }
  .lb-rail .lb-suppress-row.visible {
    flex-shrink: 0;
  }
  .lb-rail-share-btn {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  .lb-save-primary {
    flex: 1;
    min-height: 44px;
    border: none;
    border-radius: 8px;
    background: var(--red);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
  }
  .lb-save-primary.lb-saving { opacity: 0.55; pointer-events: none; }
  .lb-share-sheet {
    left: auto;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(380px, 32vw);
    max-height: none;
    border-radius: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.12);
  }
}

@media (max-width: 959px) {
  .lb-header,
  .lb-close-header,
  .lb-header-filename,
  .lb-rail-footer,
  .lb-edit-section-head,
  .lb-ai-title,
  .lb-ai-sub,
  .lb-ai-confidence,
  .lb-tags-hint,
  .lb-sidebar-label,
  .lb-sidebar-brand,
  .lb-sidebar-undo,
  .lb-sidebar-mobile-actions { display: none !important; }
  .lb-mobile-header { display: flex !important; }
  .lb-close-fixed,
  .lb-topbar { display: none !important; }
  #photoLightbox {
    background: #0a0a0a;
    cursor: default;
  }
  .lb-dialog {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    background: #0a0a0a;
  }
  .lb-mobile-header {
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: max(10px, env(safe-area-inset-top, 0px)) 12px 10px;
    background: #0a0a0a;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
  }
  .lb-mobile-close {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .lb-mobile-header-center {
    flex: 1;
    min-width: 0;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .lb-mobile-header-label {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
  }
  .lb-mobile-header-counter {
    font-family: var(--font-display);
    font-size: 26px;
    letter-spacing: 0.04em;
    color: #fff;
    line-height: 1;
  }
  .lb-mobile-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
  }
  .lb-mobile-tags-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .lb-mobile-tags-btn.on {
    color: var(--red);
    background: rgba(233, 42, 44, 0.15);
  }
  .lb-mobile-save-btn {
    min-height: 36px;
    padding: 0 14px;
    border: none;
    border-radius: 8px;
    background: var(--red);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
  }
  .lb-mobile-save-btn.lb-saving { opacity: 0.55; pointer-events: none; }
  .lb-workspace {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }
  .lb-main {
    order: 1;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .lb-mobile-badge-row {
    flex-shrink: 0;
    padding: 8px 14px 0;
  }
  .lb-nav-badge {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-family: var(--font-mono);
    font-size: 10px;
    color: rgba(255, 255, 255, 0.75);
    position: static;
  }
  .lb-nav-badge::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--red);
  }
  .lb-stage {
    flex: 1;
    min-height: 0;
    padding: 8px 8px 4px;
  }
  .lb-zoom-controls {
    top: 6px;
    right: 8px;
    gap: 3px;
    padding: 3px;
  }
  .lb-zoom-btn {
    min-width: 28px;
    height: 27px;
    padding: 0 8px;
    font-size: 10px;
  }
  .lb-zoom-pct {
    min-width: 38px;
    font-size: 9px;
  }
  #lightboxImg {
    max-height: min(42vh, calc(100dvh - 340px));
    border-radius: 4px;
  }
  .lb-nav-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    font-size: 1.5rem;
  }
  .lb-nav-prev { left: 8px; }
  .lb-nav-next { right: 8px; }
  .lb-main-footer {
    display: block !important;
    flex-shrink: 0;
    padding: 10px 14px 12px;
    text-align: left;
  }
  .lightbox-caption {
    text-align: left;
    padding: 0 0 0 10px;
    margin: 0 0 8px;
    border-left: 3px solid var(--red);
    font-size: 13px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.82);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .lb-photo-meta {
    display: block !important;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.4);
    line-height: 1.4;
  }
  .lb-rail {
    order: 2;
    display: none;
    flex-shrink: 0;
    max-height: min(36vh, 280px);
    overflow-y: auto;
    background: #141414;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 10px 14px;
    gap: 10px;
  }
  .lb-rail.lb-panel-open { display: flex; flex-direction: column; }
  .lb-rail.lb-tags-open .lb-edit-panel,
  .lb-rail.lb-tags-open .lb-ai-bar,
  .lb-rail.lb-tags-open .lb-rescan-status,
  .lb-rail.lb-tags-open .lb-suppress-row { display: none !important; }
  .lb-rail:not(.lb-tags-open) .lb-tags-bar { display: none; }
  .lb-rail.lb-tags-open .lb-tags-bar { display: flex; }
  .lb-rail:not(.lb-panel-open) .lb-edit-panel { display: none !important; }
  .lb-ai-bar.visible { display: none !important; }
  .lb-suppress-row { display: none !important; }
  .lb-sidebar {
    order: 3;
    flex-shrink: 0;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 4px;
    padding: 10px 8px calc(10px + env(safe-area-inset-bottom, 0px));
    background: #0a0a0a;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .lb-sidebar-group { display: contents; }
  .lb-sidebar-tools { display: contents; }
  .lb-sidebar .lb-tool {
    flex: 1 1 0;
    min-width: 52px;
    max-width: none;
    min-height: 56px;
    flex-direction: column;
    gap: 4px;
    padding: 8px 4px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    font-size: 8px;
    letter-spacing: 0.06em;
  }
  .lb-sidebar .lb-tool svg { width: 20px; height: 20px; opacity: 1; }
  .lb-sidebar .lb-tool.on {
    border-color: transparent;
    background: var(--red);
    color: #fff;
  }
  .lb-sidebar .lb-tool.lb-tool-action:not([data-lb-tool]) {
    flex: 1 1 0;
    min-width: 52px;
  }
}
