:root {
    --bg-dark: #0b0f17;
    --bg-surface: #121824;
    --bg-surface-elevated: #182030;
    --text-primary: #f3f4f6;
    --text-secondary: #94a3b8;
    --accent: #eab308;
    --glass-bg: rgba(18, 24, 36, 0.85);
    --glass-border: rgba(148, 163, 184, 0.18);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
}

.archive-intro-line {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.archive-intro-line strong {
    font-size: 0.86rem;
    color: #f5efe4;
}

.archive-intro-line span {
    font-size: 0.77rem;
    color: var(--text-secondary);
}

.controls {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
    align-items: center;
}

input, select {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}

input:focus, select:focus {
    border-color: var(--accent);
}

/* Grid Layout */
.gallery-container {
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
}

/* Cards */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
    border-color: var(--accent);
}

.card-img-wrap {
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: #000;
}

.card-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.5s ease;
}

.card:hover .card-img-wrap img {
    transform: scale(1.05);
}

.card-content {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.card-type {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--accent);
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    line-height: 1.4;
}

.card-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    flex-grow: 1;
}

.card-footer {
    font-size: 0.75rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--glass-border);
    padding-top: 0.75rem;
    display: flex;
    justify-content: space-between;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.show {
    opacity: 1;
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 1200px;
    margin: 2rem auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.close-modal {
    position: absolute;
    top: -2.5rem;
    right: 0;
    color: #fff;
    font-size: 2.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}
.close-modal:hover { color: var(--accent); }

.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    font-size: 3rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.3s;
    z-index: 10;
}
.nav-btn:hover {
    background: var(--accent);
}
.left-btn { left: -4rem; }
.right-btn { right: -4rem; }

@media (max-width: 900px) {
    .left-btn { left: 0; }
    .right-btn { right: 0; }
}

#modalImage {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

.modal-caption {
    margin-top: 1rem;
    color: #fff;
    text-align: center;
    max-width: 800px;
}

/* --- Editor Styles --- */

.action-btn {
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s;
}

.action-btn:hover {
    background-color: #357abd;
}

.modal-header-tools {
    position: absolute;
    top: -2rem;
    left: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: white;
    font-weight: 600;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255,255,255,0.2);
    transition: .4s;
    border-radius: 24px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px; width: 18px;
    left: 3px; bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: var(--accent);
}
input:checked + .slider:before {
    transform: translateX(24px);
}

/* Toolbar */
.editor-toolbar {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    padding: 0.5rem;
    border-radius: 8px;
    display: flex;
    gap: 0.5rem;
    z-index: 20;
}

.tool-btn {
    background: transparent;
    color: white;
    border: 1px solid transparent;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.tool-btn:hover {
    background: rgba(255,255,255,0.1);
}

.tool-btn.active {
    background: rgba(74, 144, 226, 0.2);
    border-color: var(--accent);
    color: var(--accent);
}

/* Canvas container */
.canvas-container {
    position: relative;
    display: inline-block; /* strictly fits the image inside */
}

.annotations-layer, .drawing-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none; /* Let events pass to the overlay */
}

.drawing-overlay {
    pointer-events: auto; /* Active when editing */
    cursor: crosshair;
}

/* Drawn Elements */
.bounding-box {
    position: absolute;
    border: 2px solid var(--accent);
    background: rgba(74, 144, 226, 0.1);
    box-sizing: border-box;
    pointer-events: auto;
}

.bounding-box:hover {
    background: rgba(74, 144, 226, 0.2);
}

.box-label {
    position: absolute;
    top: -24px;
    left: -2px;
    background: var(--accent);
    color: white;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px 4px 0 0;
    white-space: nowrap;
}

.ref-point {
    position: absolute;
    width: 20px;
    height: 20px;
    transform: translate(-50%, -50%);
    pointer-events: auto;
}
.ref-point::before, .ref-point::after {
    content: '';
    position: absolute;
    background: #ff4757;
}
.ref-point::before {
    top: 9px; left: 0; width: 20px; height: 2px;
}
.ref-point::after {
    left: 9px; top: 0; width: 2px; height: 20px;
}


/* --- Constructive Vector Overlay & 3D Viewer Additions --- */

.viewer-3d-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: linear-gradient(135deg, #d97706, #b45309);
    color: #fff;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid rgba(251, 191, 36, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.viewer-3d-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(217, 119, 6, 0.45);
}

.making-of-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(216, 179, 132, 0.14);
    color: #fef3c7;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid rgba(251, 191, 36, 0.42);
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.making-of-btn:hover {
    transform: translateY(-1px);
    background: rgba(216, 179, 132, 0.26);
    box-shadow: 0 4px 14px rgba(234, 179, 8, 0.25);
}

.calibrated-filter-btn {
    background: rgba(0, 229, 255, 0.08);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.35);
    padding: 0.5rem 0.9rem;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.calibrated-filter-btn:hover,
.calibrated-filter-btn.active {
    background: rgba(0, 229, 255, 0.22);
    color: #e0f2fe;
    border-color: #00e5ff;
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.25);
}

.card-img-wrap {
    position: relative;
}

.card.is-calibrated {
    border-color: rgba(56, 189, 248, 0.35);
}

.calibrated-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(11, 15, 25, 0.88);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.55);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    padding: 3px 8px;
    border-radius: 999px;
    backdrop-filter: blur(6px);
    z-index: 2;
}

.vector-control-bar {
    width: 100%;
    background: rgba(13, 19, 32, 0.92);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 10px;
    padding: 0.55rem 0.9rem;
    margin-bottom: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
    z-index: 25;
}

.vec-master-toggle,
.vec-dark-toggle,
.vec-opacity-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #e2e8f0;
    cursor: pointer;
    user-select: none;
}

.vec-opacity-wrap input[type="range"] {
    width: 88px;
    padding: 0;
    accent-color: #38bdf8;
    cursor: pointer;
}

.vec-divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.14);
}

.vec-layer-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.vec-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(255, 255, 255, 0.06);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    padding: 0.22rem 0.65rem;
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.vec-pill .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.vec-pill.active {
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.42);
}

.vec-pill:not(.active) {
    opacity: 0.42;
}

.canvas-container {
    background: #0b101d;
    border-radius: 8px;
    overflow: hidden;
}

#modalImage {
    display: block;
    transition: filter 0.2s ease, opacity 0.15s ease;
}

#modalImage.dark-blueprint {
    filter: invert(1) hue-rotate(195deg) saturate(1.25) contrast(1.18) brightness(0.88);
}

.vector-svg-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 4;
}

.vector-svg-layer svg {
    width: 100%;
    height: 100%;
    display: block;
}
