@font-face {
    font-family: 'Orbitron';
    /* Keep in sync with `get_fingerprinted_url("static/Orbitron/Orbitron-VariableFont_wght.ttf")` */
    src: url('/static/Orbitron/Orbitron-VariableFont_wght.46eefc70.ttf') format('truetype');
    font-display: swap;
    font-weight: 100 900;
    font-style: normal;
}

:root {
    --neon: #00c0ff;
    --neon-glow: 0 0 6px rgba(0, 192, 255, 0.35), 0 0 12px rgba(0, 192, 255, 0.18);
    --panel: #2a2a2a;
    --panel-2: #333;
    --stroke: #0b0b0b;
    --danger: #ff3b6a;
    --danger-glow: 0 0 8px rgba(255, 59, 106, 0.45), 0 0 16px rgba(255, 59, 106, 0.2);
}

body {
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #1a1a1a;
    color: #e0e0e0;
    font-size: 16px;
}

#header {
    display: flex;
    flex-wrap: wrap;
    gap: 0px 12px;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid #333;
    background-color: var(--panel);
    box-sizing: border-box;
}

#search-form {
    display: flex;
    flex: 1;
    box-sizing: border-box;
    gap: 8px;
}

#search-form input {
    flex: 1;
    padding: 8px;
    border: 1px solid #444;
    border-radius: 4px;
    background-color: var(--panel-2);
    color: #e0e0e0;
    box-sizing: border-box;
    min-width: 0;
    height: 44px;
}

#search-form button {
    height: 44px;
    box-sizing: border-box;
}

.header-icon-btn {
    border: 1px solid rgba(0, 192, 255, 0.35);
    padding: 8px;
    font-size: 20px;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
    box-sizing: border-box;
    color: var(--neon);
    box-shadow: inset 0 0 0 1px rgba(0, 192, 255, 0.08);
}

.header-icon-btn:hover {
    border-color: rgba(0, 192, 255, 0.65);
    text-decoration: none;
    box-shadow: var(--neon-glow);
}

#user-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

#login-form {
    display: flex;
    gap: 5px;
    align-items: center;
    flex-wrap: nowrap;
    margin: 0px;
    position: relative;
}

/* Desktop: the password + submit panel floats below the username input */
.login-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--panel);
    border: 1px solid #444;
    border-radius: 6px;
    padding: 8px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

#login-form:focus-within .login-dropdown,
#login-form:has(input[type="text"]:not(:placeholder-shown)) .login-dropdown {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

a {
    color: var(--neon);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
    color: var(--neon);
    text-shadow: var(--neon-glow);
}

/* Opt-in “site navigation / UI” link styling */
a.nav-link,
.nav-link a {
    font-family: 'Orbitron', system-ui, sans-serif;
    letter-spacing: 0.02em;
}

button {
    cursor: pointer;
    font-family: inherit;
}

button.btn-primary {
    padding: 8px 16px;
    background-color: var(--neon);
    color: #000;
    border: 1px solid rgba(0, 192, 255, 0.85);
    border-radius: 4px;
    font-size: 16px;
    min-height: 44px;
    font-family: 'Orbitron', system-ui, sans-serif;
    letter-spacing: 0.02em;
}

button.btn-primary:hover {
    filter: brightness(1.05);
    box-shadow: var(--neon-glow);
}

button.btn-danger {
    background-color: transparent;
    color: var(--danger);
    border: 1px solid rgba(255, 59, 106, 0.7);
}

button.btn-danger:hover {
    box-shadow: var(--danger-glow);
}

button.btn-secondary,
button.btn-tertiary {
    background-color: transparent;
    color: var(--neon);
    border: 1px solid rgba(0, 192, 255, 0.55);
    border-radius: 4px;
    min-height: 44px;
    box-shadow: inset 0 0 0 1px rgba(0, 192, 255, 0.08);
    font-family: 'Orbitron', system-ui, sans-serif;
    letter-spacing: 0.02em;
}

button.btn-primary:disabled {
    cursor: not-allowed;
    box-shadow: none; /* cancels hover box-shadow */
    filter: brightness(0.5); /* dims, also cancels hover brightness */
}

button.btn-secondary:disabled,
button.btn-tertiary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    border-color: rgba(160, 160, 160, 0.55);
    color: rgba(200, 200, 200, 0.8);
    box-shadow: none;
}

button.btn-secondary:hover,
button.btn-tertiary:hover {
    background-color: rgba(0, 192, 255, 0.06);
    box-shadow: var(--neon-glow);
}

.search-results {
    display: flex;
    flex-wrap: wrap;
    padding: 20px;
    gap: 20px;
}

.search-results>div {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Image size constraints live on .editable-image (the wrapper).
   --max-w/--max-h are referenced by the inline style's min() expression to
   compute the correct width that satisfies both constraints simultaneously.
   The <img> fills the wrapper 100%x100%, so the wrapper IS the image content area. */
.editable-image.search-result-image {
    --max-w: 45vw;
    --max-h: 45vh;
    margin: 0;
    border: 1px solid #444;
    border-radius: 4px;
    background-color: #2a2a2a;
}

.editable-image.main-image,
img.main-image {
    border: 1px solid #444;
    border-radius: 4px;
    margin: 10px 0;
    background-color: #2a2a2a;
}

.editable-image.main-image {
    --max-w: 60vw;
    --max-h: 60vh;
}

img.main-image {
    max-width: 60vw;
    max-height: 60vh;
}

.editable-image.similar-image {
    --max-w: 30vw;
    --max-h: 30vh;
    border: 1px solid #444;
    border-radius: 4px;
    background-color: #2a2a2a;
}

.similar-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 20px 0;
}

.similar-container>div {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.image-metadata {
    text-align: center;
    font-size: 0.9em;
    color: #999;
    margin: 0;
}

.image-controls {
    display: flex;
    flex-direction: row;
    gap: 5px;
    margin-top: 5px;
    align-items: center;
    position: relative;
}

.editable-image {
    position: relative;
    display: inline-block;
    line-height: 0;
    /* CSS custom properties for crop state, updated by JS syncEditorUI.
       Since the wrapper IS the image content area, % positions are correct. */
    --crop-left: 0;
    --crop-top: 0;
    --crop-right: 1;
    --crop-bottom: 1;
}

/* The <img> fills the wrapper exactly — no object-fit needed since the wrapper
   is sized to the image's natural aspect ratio via inline style. */
.editable-image img {
    width: 100%;
    height: 100%;
    display: block;
    transition: transform 120ms ease;
}

.editable-image[data-mirrored="1"] img {
    transform: scaleX(-1);
}

/* Crop boundary: positioned as % of the wrapper (= image content area) */
.image-edit-boundary {
    position: absolute;
    pointer-events: none;
    opacity: 0;
    transition: opacity 120ms ease;
    box-sizing: border-box;
    /* Double-contrast border: white inner, black outer via box-shadow */
    border: 1.5px solid rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.9);
    left: calc(var(--crop-left) * 100%);
    top: calc(var(--crop-top) * 100%);
    width: calc((var(--crop-right) - var(--crop-left)) * 100%);
    height: calc((var(--crop-bottom) - var(--crop-top)) * 100%);
}

.editable-image.is-edited .image-edit-boundary {
    opacity: 1;
}

/* Outside-crop shading: 4 divs cover areas outside the crop rect */
.image-crop-shade {
    position: absolute;
    background: rgba(0, 0, 0, 0.38);
    pointer-events: none;
    opacity: 0;
    transition: opacity 120ms ease;
}

/* top shade */
.image-crop-shade:nth-child(3) {
    left: 0;
    top: 0;
    width: 100%;
    height: calc(var(--crop-top) * 100%);
}

/* bottom shade */
.image-crop-shade:nth-child(4) {
    left: 0;
    top: calc(var(--crop-bottom) * 100%);
    width: 100%;
    height: calc((1 - var(--crop-bottom)) * 100%);
}

/* left shade */
.image-crop-shade:nth-child(5) {
    left: 0;
    top: calc(var(--crop-top) * 100%);
    width: calc(var(--crop-left) * 100%);
    height: calc((var(--crop-bottom) - var(--crop-top)) * 100%);
}

/* right shade */
.image-crop-shade:nth-child(6) {
    left: calc(var(--crop-right) * 100%);
    top: calc(var(--crop-top) * 100%);
    width: calc((1 - var(--crop-right)) * 100%);
    height: calc((var(--crop-bottom) - var(--crop-top)) * 100%);
}

.editable-image.is-edited .image-crop-shade {
    opacity: 1;
}

.image-mirror-btn,
.image-crop-handle {
    position: absolute;
    border: 2px solid #111;
    background: rgba(255, 255, 255, 0.96);
    color: #111;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 120ms ease, background-color 120ms ease;
    z-index: 2;
    /* positions set via CSS custom properties as % of the wrapper */
}

/* Hover (JS-managed via mouseenter/mouseleave), touch, or drag: show handles/mirror btn fully */
.editable-image.is-hovered .image-mirror-btn,
.editable-image.is-hovered .image-crop-handle,
.editable-image.is-dragging .image-mirror-btn,
.editable-image.is-dragging .image-crop-handle,
.editable-image.is-touched .image-mirror-btn,
.editable-image.is-touched .image-crop-handle {
    opacity: 1;
    pointer-events: auto;
}

/* Unedited: ghost handles and border so incidental hovers/touches aren't jarring */
.editable-image.is-hovered:not(.is-edited) .image-mirror-btn,
.editable-image.is-hovered:not(.is-edited) .image-crop-handle,
.editable-image.is-dragging:not(.is-edited) .image-mirror-btn,
.editable-image.is-dragging:not(.is-edited) .image-crop-handle,
.editable-image.is-touched:not(.is-edited) .image-mirror-btn,
.editable-image.is-touched:not(.is-edited) .image-crop-handle {
    opacity: 0.35;
}

.editable-image.is-hovered:not(.is-edited) .image-edit-boundary,
.editable-image.is-dragging:not(.is-edited) .image-edit-boundary,
.editable-image.is-touched:not(.is-edited) .image-edit-boundary {
    opacity: 0.35;
}

.image-mirror-btn {
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    font-size: 18px;
    line-height: 1;
}

.editable-image[data-mirrored="1"] .image-mirror-btn {
    background: var(--neon);
}

.image-crop-handle {
    width: 16px;
    height: 16px;
    border-radius: 999px;
    padding: 0;
    /* translate(-50%, -50%) centers the handle on its corner point */
    transform: translate(-50%, -50%);
    display: block;
    touch-action: none;
}

/* Handle positions via CSS custom properties — no JS geometry needed */
.image-crop-handle-nw {
    left: calc(var(--crop-left) * 100%);
    top: calc(var(--crop-top) * 100%);
    cursor: nwse-resize;
}

.image-crop-handle-ne {
    left: calc(var(--crop-right) * 100%);
    top: calc(var(--crop-top) * 100%);
    cursor: nesw-resize;
}

.image-crop-handle-sw {
    left: calc(var(--crop-left) * 100%);
    top: calc(var(--crop-bottom) * 100%);
    cursor: nesw-resize;
}

.image-crop-handle-se {
    left: calc(var(--crop-right) * 100%);
    top: calc(var(--crop-bottom) * 100%);
    cursor: nwse-resize;
}

@media (max-width: 700px) {
    .image-mirror-btn {
        width: 40px;
        height: 40px;
    }

    .image-crop-handle {
        width: 22px;
        height: 22px;
        /* No margin here — transform: translate(-50%, -50%) handles centering */
    }
}

.image-detail-admin {
    margin: 15px 0;
    padding: 15px;
    background-color: #2a2a2a;
    border-radius: 4px;
    display: inline-block;
}

.content-wrapper {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

.upload-filename {
    word-break: break-all;
    overflow-wrap: break-word;
}

th,
td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #333;
}

th {
    background-color: #2a2a2a;
    font-weight: 600;
}

form {
    margin: 10px 0;
}

h1,
h2 {
    margin: 20px 0 10px 0;
    color: #f0f0f0;
}

textarea {
    width: 100%;
    min-height: 80px;
    padding: 8px;
    border: 1px solid #444;
    border-radius: 4px;
    font-family: inherit;
    margin: 10px 0;
    background-color: #333;
    color: #e0e0e0;
}

input[type="text"],
input[type="password"],
input[type="file"],
input[type="search"] {
    padding: 8px;
    border: 1px solid #444;
    border-radius: 4px;
    background-color: #333;
    color: #e0e0e0;
    font-size: 16px;
}

input[type="file"] {
    margin-right: 10px;
}

/* Style the search input clear button for dark theme */
input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
    height: 16px;
    width: 16px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23e0e0e0"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>');
    background-size: 16px 16px;
    cursor: pointer;
}

input[type="search"]::-webkit-search-cancel-button:hover {
    opacity: 0.7;
}

input[type="file"]::file-selector-button {
    background-color: rgba(0, 0, 0, 0.25);
    color: var(--neon);
    border: 1px solid rgba(0, 192, 255, 0.55);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 10px;
    font-family: 'Orbitron', system-ui, sans-serif;
}

input[type="file"]::file-selector-button:hover {
    background-color: rgba(0, 192, 255, 0.06);
    box-shadow: var(--neon-glow);
}

.icon {
    width: 25px;
    height: 25px;
    display: inline-block;
    background-color: currentColor;
    -webkit-mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-size: contain;
    mask-repeat: no-repeat;
    mask-position: center;
}

/* Default (wide): show text label, hide icon */
.search-btn-icon {
    display: none;
}

.icon-home {
    -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="black" fill-rule="evenodd" d="M4 22V12H1L12 3L23 12H20V22H4ZM17 4H20V8H17V4ZM7 22V14H10V22H7ZM14 14H18V18H14V14Z"/></svg>');
    mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="black" fill-rule="evenodd" d="M4 22V12H1L12 3L23 12H20V22H4ZM17 4H20V8H17V4ZM7 22V14H10V22H7ZM14 14H18V18H14V14Z"/></svg>');
}

.icon-search {
    /* Slightly longer handle for better legibility at 20px */
    -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="black" d="M10 2a8 8 0 105.3 14l5.2 5.2 1.4-1.4-5.2-5.2A8 8 0 0010 2zm0 2a6 6 0 110 12 6 6 0 010-12z"/></svg>');
    mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="black" d="M10 2a8 8 0 105.3 14l5.2 5.2 1.4-1.4-5.2-5.2A8 8 0 0010 2zm0 2a6 6 0 110 12 6 6 0 010-12z"/></svg>');
}

.icon-dice {
    mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2l9 4.5-9 4.5-9-4.5L12 2zM12 5a1.2 1.2 0 100 2.4 1.2 1.2 0 000-2.4z" fill-rule="evenodd"/><path d="M3 8.5l8 4v9.5l-8-4V8.5zM6 12a1 1 0 100 2 1 1 0 000-2zM9 16a1 1 0 100 2 1 1 0 000-2z" fill-rule="evenodd"/><path d="M13 12.5l8-4v9.5l-8 4v-9.5zM15.5 12a1 1 0 100 2 1 1 0 000-2zM17 14.5a1 1 0 100 2 1 1 0 000-2zM18.5 17a1 1 0 100 2 1 1 0 000-2z" fill-rule="evenodd"/></svg>');
    -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2l9 4.5-9 4.5-9-4.5L12 2zM12 5a1.2 1.2 0 100 2.4 1.2 1.2 0 000-2.4z" fill-rule="evenodd"/><path d="M3 8.5l8 4v9.5l-8-4V8.5zM6 12a1 1 0 100 2 1 1 0 000-2zM9 16a1 1 0 100 2 1 1 0 000-2z" fill-rule="evenodd"/><path d="M13 12.5l8-4v9.5l-8 4v-9.5zM15.5 12a1 1 0 100 2 1 1 0 000-2zM17 14.5a1 1 0 100 2 1 1 0 000-2zM18.5 17a1 1 0 100 2 1 1 0 000-2z" fill-rule="evenodd"/></svg>');
}

pre {
    background-color: #2a2a2a;
    color: #e0e0e0;
}

.mod-description-input {
    width: 300px;
    margin-right: 10px;
}

.welcome-image {
    max-width: 400px;
    width: 100%;
    height: auto;
    object-fit: contain;
    border: 1px solid #444;
    border-radius: 4px;
    margin: 20px 0 10px 0;
    background-color: #2a2a2a;
}

.welcome-quote {
    font-style: italic;
    text-align: center;
    margin: 10px 0;
    color: #e0e0e0;
}

/* Mobile / narrow responsive styles */
@media (max-width: 768px) {
    * {
        box-sizing: border-box;
    }

    body {
        font-size: 18px;
        overflow-x: hidden;
    }

    #header {
        flex-direction: column;
        padding: 15px;
        gap: 0px;
        align-items: stretch;
        width: 100%;
        max-width: 100vw;
    }

    #header>a {
        text-align: center;
        padding: 8px;
    }

    #search-form {
        display: flex;
        width: 100%;
        flex-direction: row;
        margin: 5px 0px;
        gap: 8px;
    }

    #search-form input {
        flex: 1;
        min-width: 0;
        padding: 12px;
        font-size: 16px;
        height: 50px;
    }

    #search-form button {
        flex-shrink: 0;
        width: auto;
        padding: 12px 20px;
        height: 50px;
    }

    .header-icon-btn {
        padding: 10px;
        width: 50px;
        height: 50px;
        font-size: 22px;
    }

    .search-btn-text {
        display: none;
    }

    .search-btn-icon {
        display: inline-block;
    }

    #search-form button {
        width: 50px;
        height: 50px;
        padding: 12px;
        flex-shrink: 0;
        font-size: 22px;
    }

    #user-controls {
        flex-direction: column;
        width: 100%;
        gap: 8px;
        align-items: stretch;
        margin-left: 0px;
    }

    #user-controls>a,
    #user-controls>form {
        width: 100%;
    }

    /* Login form: full-width on mobile; dropdown still floats out-of-flow */
    #login-form {
        width: 100%;
    }

    #login-form input[type="text"] {
        width: 100%;
    }

    button.btn-primary,
    button.btn-secondary,
    button.btn-tertiary {
        width: 100%;
        padding: 12px 16px;
        font-size: 16px;
        min-height: 44px;
    }

    .search-results {
        flex-direction: column;
        align-items: center;
        padding: 15px;
        gap: 20px;
    }

    .search-results>div {
        width: 100%;
    }

    .editable-image.search-result-image {
        --max-w: 90vw;
        --max-h: 60vh;
    }

    .editable-image.main-image {
        --max-w: 95vw;
        --max-h: 70vh;
    }

    img.main-image {
        max-width: 95vw;
        max-height: 70vh;
    }

    .similar-container {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }

    .similar-container>div {
        width: 100%;
    }

    .editable-image.similar-image {
        --max-w: 90vw;
        --max-h: 50vh;
    }

    .image-metadata {
        font-size: 1em;
    }

    .details-content {
        position: static;
        min-width: auto;
        max-width: 100%;
        width: 100%;
    }

    .content-wrapper {
        padding: 15px;
    }

    h1 {
        font-size: 1.75em;
    }

    h2 {
        font-size: 1.5em;
    }

    table {
        font-size: 14px;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    th,
    td {
        padding: 8px 6px;
    }

    textarea {
        font-size: 16px;
        padding: 12px;
    }

    input[type="text"],
    input[type="password"],
    input[type="file"],
    input[type="search"] {
        padding: 12px;
        font-size: 16px;
        min-height: 44px;
        margin-bottom: 10px;
        width: 100%;
        box-sizing: border-box;
    }

    .mod-description-input {
        width: 100%;
        margin-right: 0;
        margin-bottom: 10px;
    }

    form {
        width: 100%;
    }

    a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .welcome-image {
        max-width: 90vw;
    }
}

/* Extra small devices (phones in portrait) */
@media (max-width: 480px) {
    body {
        font-size: 16px;
    }

    #header {
        padding: 12px;
    }

    .content-wrapper {
        padding: 12px;
    }

    h1 {
        font-size: 1.5em;
    }

    h2 {
        font-size: 1.3em;
    }

    table {
        font-size: 12px;
    }

    th,
    td {
        padding: 6px 4px;
    }
}

/* Image action buttons (copy, download) */
.image-action-btn {
    background-color: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 32px;
    transition: background-color 0.2s, border-color 0.2s;
}

.image-action-btn:hover {
    background-color: #3a3a3a;
    border-color: #555;
}

.image-action-btn.copied {
    color: #28a745;
    border-color: #28a745;
}

/* Photopea "More actions" dropdown */
.photopea-menu {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.photopea-menu-dropdown {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    background: #2a2a2a;
    border: 1px solid #555;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    z-index: 500;
    overflow: hidden;
}

.photopea-menu.is-open .photopea-menu-dropdown {
    display: block;
}

.photopea-menu-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 12px;
    color: #e0e0e0;
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
    min-height: auto;
    transition: background-color 0.15s;
}

.photopea-menu-item:hover {
    background-color: #3a3a3a;
    color: #fff;
}

.photopea-favicon {
    margin-right: 4px;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: bottom;
}



/* Toast notification */
.image-action-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #333;
    color: #e0e0e0;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.image-action-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Linked image preview in comments */
.linked-image-preview-container {
    float: right;
    width: 15vw;
    height: 15vh;
    overflow: hidden;
    margin: 0 0 8px 12px;
    border-radius: 4px;
    border: 1px solid #444;
}

/* /chat */
.chat-container {
    margin-top: 16px;
}

.chat-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 2px 0;
}

.chat-line {
    display: block;
}

.chat-reactions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-height: 20px;
}

.chat-reaction-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.chat-reaction {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.25);
    color: #e0e0e0;
    font-size: 13px;
    line-height: 18px;
}

.chat-reaction:hover {
    border-color: rgba(0, 192, 255, 0.65);
    box-shadow: var(--neon-glow);
}

.chat-reaction--mine {
    border-color: rgba(0, 192, 255, 0.75);
    background: rgba(0, 192, 255, 0.12);
}

.chat-reaction-picker {
    position: fixed;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 6px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: #242424;
    z-index: 20;
    min-width: 180px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
}

.chat-reaction-picker-item {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.15);
    font-size: 18px;
    line-height: 30px;
}

.chat-reaction-picker-item:hover {
    border-color: rgba(0, 192, 255, 0.65);
    box-shadow: var(--neon-glow);
}

.chat-tooltip {
    position: fixed;
    transform: translate(-50%, -100%);
    max-width: min(420px, calc(100vw - 16px));
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: #242424;
    color: #e0e0e0;
    font-size: 12px;
    line-height: 1.3;
    z-index: 10000;
    pointer-events: none;
    display: none;
}

.chat-username-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.chat-username-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-warning {
    opacity: 0.8;
    margin-top: 12px;
}

.chat-status-row {
    margin-top: 8px;
}

.chat-log {
    margin-top: 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 8px;
    height: 320px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 13px;
    line-height: 1.35;
}

.chat-system {
    color: #9aa0a6;
}

.chat-message-pending {
    opacity: 0.65;
}

.chat-send-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.chat-send-row input {
    flex: 1;
}

@media (max-width: 768px) {
    .chat-send-row {
        flex-direction: column;
    }

    .chat-send-row button {
        width: 100%;
    }
}

.linked-image-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* Comment with preview - for image detail page */
.comment-with-preview {
    padding: 8px 0;
    border-bottom: 1px solid #333;
    overflow: hidden;
}

/* Comment content with preview wrapper - for front page */
.comment-content-with-preview {
    white-space: pre-wrap;
    word-break: break-word;
    overflow: hidden;
}

/* Responsive styles for linked image preview */
@media (max-width: 768px) {
    .linked-image-preview-container {
        width: 25vw;
        height: 12vh;
    }
}

/* ── Error page ─────────────────────────────────────────────── */
.error-page {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 60px;
}

.error-card {
    text-align: center;
    max-width: 480px;
    width: 100%;
    padding: 40px 32px;
    background: var(--panel);
    border: 1px solid #3a3a3a;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Large numeric code — light rose pink */
.error-code {
    font-family: 'Orbitron', system-ui, sans-serif;
    font-size: clamp(3.5rem, 10vw, 6rem);
    font-weight: 800;
    letter-spacing: 0.04em;
    color: #f9a8c4;
    margin: 0 0 4px 0;
    line-height: 1;
    text-shadow: 0 0 24px rgba(249, 168, 196, 0.35);
}

.error-label {
    font-family: 'Orbitron', system-ui, sans-serif;
    font-size: 1.1rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    color: #c0c0c0;
    margin: 0 0 20px 0;
    text-transform: uppercase;
}

.error-message {
    color: #b0b0b0;
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 0 0 28px 0;
}

.error-back-link {
    display: inline-block;
    font-size: 0.9rem;
    color: var(--neon);
    min-height: auto;
}

.error-back-link:hover {
    text-shadow: var(--neon-glow);
}
