/* Configurateur V2 — thème app, mobile, sheets */

:root {
    color-scheme: dark;
    --bg: #0a0e14;
    --bg-elevated: #0f141c;
    --panel: #151b24;
    --panel-soft: #0d1218;
    --text: #f0f3f8;
    --muted: #8b95a8;
    /* Marque Forge — ne pas confondre avec les teintes frame (presets Atlantis) */
    --primary: #c22032;
    --primary-dim: rgba(194, 32, 50, 0.22);
    --primary-glow: rgba(194, 32, 50, 0.2);
    --primary-soft: rgba(194, 32, 50, 0.08);
    --primary-hover: #e8485c;
    --surface-on-primary: #2a1216;
    --border: #2a3548;
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    --radius-sm: 7px;
    --radius-md: 11px;
    --radius-lg: 14px;
    --header-h: 56px;
    --mobile-nav-h: 56px;
    --font: "JetBrains Mono", "SF Mono", ui-monospace, monospace;
    --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

body {
    margin: 0;
    font-family: var(--font-ui);
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.app-shell {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 16px;
    min-height: var(--header-h);
    padding: 10px 16px;
    padding-top: max(10px, env(safe-area-inset-top));
    background: linear-gradient(180deg, #121820 0%, rgba(10, 14, 20, 0.96) 100%);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
}

.app-header__lead {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    flex: 1 1 auto;
}

.app-logo-link {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    border-radius: var(--radius-sm);
    outline-offset: 3px;
    transition: opacity 0.15s ease, transform 0.12s ease;
}

.app-logo-link:hover {
    opacity: 0.92;
}

.app-logo-link:active {
    transform: scale(0.98);
}

.app-logo {
    display: block;
    height: 38px;
    width: auto;
    max-width: min(148px, 28vw);
    object-fit: contain;
    object-position: left center;
}

.app-brand {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1 1 auto;
}

.app-brand__title {
    margin: 0;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.app-brand__machine {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 72vw;
}

.app-header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

/* Layout grid */
.app-grid {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(280px, 320px) 1fr minmax(300px, 400px);
    gap: 0;
    min-height: 0;
}

@media (max-width: 1180px) {
    .app-grid {
        grid-template-columns: minmax(260px, 300px) 1fr minmax(260px, 340px);
    }
}

@media (max-width: 899px) {
    .app-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
}

/* Colonne gauche : recherche + couleurs */
.left-rail {
    border-right: 1px solid var(--border);
    background: linear-gradient(180deg, #10161e 0%, var(--bg) 100%);
    padding: 14px 12px 18px;
    overflow-y: auto;
    max-height: calc(100dvh - var(--header-h));
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.left-rail .sheet-handle--left {
    display: none;
}

.machine-search-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.machine-search-label {
    font-size: 10px;
    font-family: var(--font);
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--muted);
}

.machine-search-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.machine-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-dim);
}

.machine-search-input::placeholder {
    color: #5c6575;
}

.machine-search-hint {
    margin: 0;
    font-size: 11px;
    line-height: 1.35;
}

.machine-search-results {
    list-style: none;
    padding: 0;
    margin: 4px 0 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: min(260px, 36vh);
    overflow-y: auto;
    flex-shrink: 0;
    scrollbar-width: thin;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--panel-soft);
    padding: 6px;
}

.machine-search-results[hidden] {
    display: none !important;
}

.machine-search-item {
    margin: 0;
}

.machine-search-item.is-hidden {
    display: none;
}

.machine-search-empty-msg {
    list-style: none;
    margin: 0;
    padding: 12px 8px;
    text-align: center;
    font-size: 12px;
    color: var(--muted);
}

.machine-search-empty-msg[hidden] {
    display: none !important;
}

.machine-search-empty {
    margin: 0;
    font-size: 12px;
}

.left-rail .panel-colors {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

@media (max-width: 899px) {
    .left-rail {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        max-height: min(85vh, calc(100dvh - 100px));
        z-index: 80;
        border-right: none;
        border-top: 1px solid var(--border);
        border-radius: 18px 18px 0 0;
        box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
        transform: translateY(108%);
        transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
        padding-bottom: calc(18px + var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px));
    }

    .left-rail.is-open {
        transform: translateY(0);
    }

    .left-rail .sheet-handle--left {
        display: block;
    }
}

.machine-link {
    display: block;
    text-decoration: none;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 11px;
    background: var(--panel);
    font-size: 13px;
    transition: border-color 0.18s ease, background 0.18s ease, transform 0.12s ease;
}

.machine-link:hover {
    border-color: #3d4f6a;
}

.machine-link:active {
    transform: scale(0.98);
}

.machine-link.active {
    border-color: var(--primary);
    background: var(--primary-dim);
    box-shadow: 0 0 0 1px var(--primary) inset;
}

/* Main column */
.app-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 14px 16px;
    padding-bottom: calc(14px + var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px));
    gap: 12px;
}

@media (min-width: 900px) {
    .app-main {
        padding-bottom: 14px;
        max-height: calc(100dvh - var(--header-h));
        overflow-y: auto;
    }
}

.studio-wrap {
    position: relative;
}

.studio-wrap::before {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: var(--radius-lg);
    pointer-events: none;
    opacity: 0.45;
    background: radial-gradient(ellipse 80% 60% at 50% 0%, var(--primary-soft), transparent);
}

@media (prefers-reduced-motion: reduce) {
    .studio-wrap::before {
        display: none;
    }
}

.tool-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.toggle-btn {
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.toggle-btn:hover {
    border-color: #455472;
}

.toggle-btn:active {
    transform: scale(0.98);
}

.toggle-btn.active {
    border-color: var(--primary);
    background: var(--primary-dim);
}

.toggle-btn--primary {
    border-color: var(--primary);
    background: var(--surface-on-primary);
}

a.toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-sizing: border-box;
}

.hub-entry-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--primary);
    background: var(--surface-on-primary);
    color: var(--text);
    font-size: 11px;
    font-family: var(--font);
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    text-decoration: none;
    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        transform 0.1s ease;
}

.hub-entry-btn:hover {
    border-color: var(--primary-hover);
    background: rgba(194, 32, 50, 0.28);
}

.hub-entry-btn:active {
    transform: scale(0.98);
}

.lang-switch {
    display: inline-flex;
    gap: 4px;
}

.lang-switch a {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    font-size: 12px;
    background: var(--panel-soft);
}

.lang-switch a.active {
    border-color: var(--primary);
    background: var(--primary-dim);
}

.skew-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.skew-bar input[type="text"] {
    min-width: 100px;
    flex: 1 140px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--panel-soft);
    color: var(--text);
    font-size: 13px;
}

.muted {
    color: var(--muted);
    font-size: 12px;
}

.mono {
    font-family: var(--font);
    font-size: 12px;
}

.hint-inline {
    font-size: 11px;
    line-height: 1.35;
}

/* Viewer */
.viewer {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: #ffffff;
    min-height: clamp(300px, 52vh, 720px);
    position: relative;
    overflow: visible;
    display: grid;
    place-items: center;
    padding: 18px 18px 22px;
    box-shadow: var(--shadow);
}

.viewer.transparent {
    background-image:
        linear-gradient(45deg, #1d1d1d 25%, transparent 25%),
        linear-gradient(-45deg, #1d1d1d 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #1d1d1d 75%),
        linear-gradient(-45deg, transparent 75%, #1d1d1d 75%);
    background-size: 24px 24px;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

.stage {
    position: relative;
    width: min(100%, 1300px);
    max-height: calc(100dvh - 220px);
    aspect-ratio: 16 / 10;
    isolation: isolate;
    /* Ombre très légère suivant la silhouette du composite (calques) */
    filter: drop-shadow(0 18px 32px rgba(10, 14, 22, 0.09)) drop-shadow(0 6px 14px rgba(10, 14, 22, 0.05));
}

@media (max-width: 899px) {
    .viewer {
        min-height: 42vh;
        padding: 14px 12px 18px;
    }

    .stage {
        max-height: 52vh;
    }
}

.layer {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.2s ease;
    image-rendering: auto;
}

.layer.base.dimmed {
    opacity: 0.28;
}

.layer.hidden {
    opacity: 0;
}

/* Sidebar panels (desktop + mobile sheet) */
.sidebar-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 16px;
    padding-bottom: calc(14px + var(--mobile-nav-h));
    overflow-y: auto;
    border-left: 1px solid var(--border);
    background: var(--bg-elevated);
    max-height: calc(100dvh - var(--header-h));
}

@media (min-width: 900px) {
    .sidebar-column {
        padding-bottom: 20px;
    }
}

@media (max-width: 899px) {
    .sidebar-column {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        max-height: min(78vh, calc(100dvh - 120px));
        z-index: 80;
        border-left: none;
        border-top: 1px solid var(--border);
        border-radius: 18px 18px 0 0;
        box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
        transform: translateY(108%);
        transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
        padding-bottom: calc(18px + var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px));
    }

    .sidebar-column.is-open {
        transform: translateY(0);
    }

    .sidebar-column[data-active-tab="layers"] .panel-fiche {
        display: none;
    }

    .sidebar-column[data-active-tab="fiche"] .panel-layers {
        display: none;
    }
}

.sheet-handle {
    display: none;
    width: 36px;
    height: 4px;
    margin: 8px auto 12px;
    border-radius: 4px;
    background: #3d4a5c;
}

@media (max-width: 899px) {
    .sheet-handle {
        display: block;
    }
}

.sheet-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.52);
    z-index: 70;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.sheet-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 899px) {
    .sheet-backdrop {
        display: block;
    }
}

@media (min-width: 900px) {
    .sheet-backdrop {
        display: none !important;
    }
}

/* Mobile bottom nav */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 90;
    padding: 6px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, rgba(15, 20, 28, 0.92), #0a0e14);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(12px);
}

@media (max-width: 899px) {
    .mobile-nav {
        display: flex;
        gap: 6px;
        justify-content: stretch;
    }
}

.mobile-nav__btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 6px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    font-size: 10px;
    font-family: var(--font);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}

.mobile-nav__btn span.icon {
    font-size: 18px;
    line-height: 1;
    opacity: 0.85;
}

.mobile-nav__btn.is-active {
    color: var(--primary);
    background: var(--primary-dim);
}

.panel-block {
    min-width: 0;
}

.panel-colors .atlantis-panel,
.panel-layers .layer-hint,
.panel-fiche .product-sheet {
    margin-top: 0;
}

/* Atlantis + frame */
.frame-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    background: var(--panel);
    flex-wrap: wrap;
}

.frame-controls input[type="checkbox"] {
    margin: 0;
}

.frame-controls input[type="color"] {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
}

.frame-controls input[type="range"] {
    width: 90px;
}

.debug-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--panel);
    padding: 10px;
    display: grid;
    gap: 8px;
    box-shadow: var(--shadow);
}

.debug-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
}

.debug-item {
    display: grid;
    gap: 4px;
    font-size: 12px;
}

.debug-item input[type="range"] {
    width: 100%;
}

#debugOutput {
    margin: 0;
    font-size: 11px;
    line-height: 1.35;
    color: #d1d5db;
    background: #0a0a0a;
    border: 1px solid #2a2a2a;
    border-radius: var(--radius-sm);
    padding: 8px;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--font);
}

.atlantis-panel {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--panel);
    padding: 11px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    box-shadow: var(--shadow);
}

.atlantis-panel .atlantis-intro {
    font-size: 11px;
    margin: 0;
}

.atlantis-tier {
    display: grid;
    grid-template-columns: minmax(68px, auto) 1fr;
    gap: 8px 10px;
    align-items: stretch;
    min-width: 0;
}

.atlantis-tier--column {
    grid-template-columns: 1fr;
    gap: 8px;
}

.atlantis-tier > strong {
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    line-height: 1.2;
    display: flex;
    align-items: center;
    font-family: var(--font);
}

.atlantis-swatches {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 6px;
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    padding-bottom: 4px;
    scrollbar-width: thin;
}

.atlantis-swatches--column {
    flex-direction: column;
    flex-wrap: nowrap;
    overflow-x: visible;
    overflow-y: visible;
    padding-bottom: 0;
    gap: 7px;
}

.atlantis-swatches::-webkit-scrollbar {
    height: 5px;
}

.atlantis-swatches::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}

.atlantis-preset {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 4px 8px;
    background: var(--panel-soft);
    cursor: pointer;
    flex: 1 1 0;
    min-width: 52px;
    max-width: 140px;
    transition:
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        transform 0.14s ease;
}

.atlantis-preset--row {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    width: 100%;
    max-width: none;
    min-width: 0;
    flex: none;
    padding: 8px 10px;
    text-align: left;
}

@media (prefers-reduced-motion: reduce) {
    .atlantis-preset {
        transition: border-color 0.1s ease, box-shadow 0.1s ease;
    }
}

.atlantis-preset:hover {
    border-color: #4a5c78;
}

.atlantis-preset:active {
    transform: scale(0.99);
}

.atlantis-preset.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary) inset, 0 4px 14px var(--primary-glow);
    transform: none;
}

.atlantis-preset__text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.atlantis-preset .swatch {
    width: 100%;
    max-width: 40px;
    aspect-ratio: 1;
    height: auto;
    border-radius: 8px;
    border: 1px solid #333;
    flex-shrink: 0;
    background: #2a2a2a;
    background-image:
        linear-gradient(45deg, #333 25%, transparent 25%),
        linear-gradient(-45deg, #333 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #333 75%),
        linear-gradient(-45deg, transparent 75%, #333 75%);
    background-size: 8px 8px;
    background-position: 0 0, 0 4px, 4px -4px, -4px 0;
}

.atlantis-preset--row .swatch {
    width: 36px;
    height: 36px;
    max-width: 36px;
    border-radius: 9px;
}

.atlantis-preset .swatch.has-color {
    background-image: none;
}

.atlantis-preset .code {
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    font-family: var(--font);
}

.atlantis-preset--row .code {
    font-size: 12px;
}

.atlantis-preset .label {
    font-size: 9px;
    color: var(--muted);
    text-align: center;
    width: 100%;
    line-height: 1.15;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    hyphens: auto;
}

.atlantis-preset--row .label {
    text-align: left;
    font-size: 11px;
    -webkit-line-clamp: 3;
}

.manual-frame-section {
    display: none;
    width: 100%;
    margin-top: 4px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    flex-direction: column;
    gap: 10px;
}

.manual-frame-section.visible {
    display: flex;
}

.manual-frame-section h2 {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
}

.manual-frame-section .frame-controls {
    flex-wrap: wrap;
}

/* Layer grid — stagger */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
    gap: 10px;
}

@media (min-width: 900px) {
    .grid .card {
        animation: cardIn 0.45s ease both;
    }

    .grid .card:nth-child(1) {
        animation-delay: 0.03s;
    }

    .grid .card:nth-child(2) {
        animation-delay: 0.06s;
    }

    .grid .card:nth-child(3) {
        animation-delay: 0.09s;
    }

    .grid .card:nth-child(4) {
        animation-delay: 0.12s;
    }

    .grid .card:nth-child(5) {
        animation-delay: 0.15s;
    }

    .grid .card:nth-child(n + 6) {
        animation-delay: 0.18s;
    }
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--panel);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.card button {
    width: 100%;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    text-align: left;
    padding: 0;
}

.thumb {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: contain;
    display: block;
    background: #ffffff;
    box-sizing: border-box;
    padding: 6px;
}

.name {
    padding: 8px 10px;
    font-size: 12px;
    border-top: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary) inset;
}

/* Paddings groupés : aperçus superposés (même cadrage) ; séparés : cartes + chargement différé des vignettes */
.card--padding-bundle .thumb-pair {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    box-sizing: border-box;
    padding: 6px;
    background: #ffffff;
    overflow: hidden;
}

.card--padding-bundle .thumb.thumb--bundle {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% - 12px);
    height: calc(100% - 12px);
    max-width: calc(100% - 12px);
    max-height: calc(100% - 12px);
    object-fit: contain;
    object-position: center;
    padding: 0;
    margin: 0;
    display: block;
    pointer-events: none;
}

.card--padding-bundle .name--bundle {
    font-size: 11px;
    line-height: 1.35;
    white-space: normal;
    text-wrap: balance;
}

.empty {
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 18px;
    color: var(--muted);
    text-align: center;
    font-size: 13px;
}

.product-sheet {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--panel);
    padding: 16px;
    box-shadow: var(--shadow);
    display: grid;
    gap: 12px;
    min-width: 0;
}

.product-sheet h2 {
    margin: 0;
    font-size: 15px;
}

.product-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.product-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.product-meta {
    font-size: 11px;
    color: var(--muted);
}

.product-desc {
    font-size: 13px;
    line-height: 1.55;
    color: #d1d5db;
    white-space: pre-wrap;
}

.product-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.product-actions a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--primary);
    background: var(--surface-on-primary);
    color: var(--text);
    text-decoration: none;
    font-size: 12px;
}

.product-actions a:hover {
    border-color: var(--primary-hover);
}

.product-error {
    color: #fca5a5;
    font-size: 13px;
}

.spec-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px 12px;
}

.spec-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    background: var(--panel-soft);
}

.spec-item dt {
    margin: 0;
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.spec-item dd {
    margin: 4px 0 0;
    font-size: 12px;
}

@media (max-width: 520px) {
    .atlantis-tier {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .controls {
        width: 100%;
    }

    .toggle-btn {
        flex: 1 1 auto;
        min-width: 112px;
    }

    .app-logo {
        height: 32px;
        max-width: min(120px, 34vw);
    }

    .app-header__lead {
        gap: 10px;
    }
}

/* Toast */
.toast {
    position: fixed;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    z-index: 100;
    padding: 12px 18px;
    border-radius: var(--radius-md);
    background: #1e2936;
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 13px;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition:
        transform 0.35s cubic-bezier(0.32, 0.72, 0, 1),
        opacity 0.25s ease;
    max-width: min(92vw, 380px);
    text-align: center;
}

@media (min-width: 900px) {
    .toast {
        bottom: 24px;
    }
}

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

.toast--error {
    border-color: #b45353;
    background: #2a1818;
}

/* --- Intro / splash (première visite par session) --- */
body.splash-lock {
    overflow: hidden;
}

.splash-screen {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse 120% 80% at 50% 40%, #141a24 0%, #070a0e 55%, #040508 100%);
    transition:
        opacity 0.65s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.65s cubic-bezier(0.4, 0, 0.2, 1),
        filter 0.5s ease;
}

.splash-screen--out {
    opacity: 0;
    pointer-events: none;
    transform: scale(1.06);
    filter: blur(12px);
}

.splash-screen__noise {
    position: absolute;
    inset: -20%;
    opacity: 0.07;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    animation: splash-noise-drift 0.4s steps(3) infinite;
}

.splash-screen__scanlines {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.13) 2px,
        rgba(0, 0, 0, 0.13) 3px
    );
    opacity: 0.35;
    mix-blend-mode: multiply;
}

.splash-screen__inner {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    padding: 2rem;
}

.splash-glitch {
    position: relative;
    width: min(280px, 78vw);
    min-height: 72px;
}

.splash-glitch__img {
    display: block;
    position: absolute;
    left: 50%;
    top: 50%;
    width: 100%;
    max-width: 280px;
    height: auto;
    transform: translate(-50%, -50%);
    object-fit: contain;
}

.splash-glitch__img--base {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    margin: 0 auto;
    z-index: 3;
    animation: splash-logo-breathe 2.8s ease-in-out infinite;
    filter: drop-shadow(0 0 24px rgba(194, 32, 50, 0.25));
}

.splash-glitch__img--r,
.splash-glitch__img--c {
    z-index: 2;
    mix-blend-mode: lighten;
    pointer-events: none;
    opacity: 0;
}

.splash-glitch__img--r {
    animation: splash-glitch-r 2.75s step-end infinite;
}

.splash-glitch__img--c {
    animation: splash-glitch-c 2.75s step-end infinite;
}

.splash-screen__tag {
    margin: 0;
    font-family: var(--font);
    font-size: 11px;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--muted);
    animation: splash-tag-flicker 3.2s step-end infinite;
}

@keyframes splash-noise-drift {
    0% {
        transform: translate(0, 0);
    }
    33% {
        transform: translate(-1%, 1%);
    }
    66% {
        transform: translate(1%, -0.5%);
    }
    100% {
        transform: translate(0, 0);
    }
}

@keyframes splash-logo-breathe {
    0%,
    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 24px rgba(194, 32, 50, 0.25));
    }
    50% {
        transform: scale(1.03);
        filter: drop-shadow(0 0 32px rgba(194, 32, 50, 0.4));
    }
}

@keyframes splash-glitch-r {
    0%,
    86%,
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) translate(0, 0);
        clip-path: inset(0 0 0 0);
    }
    87% {
        opacity: 0.85;
        transform: translate(-50%, -50%) translate(-6px, 2px);
        clip-path: inset(8% 0 55% 0);
        filter: drop-shadow(3px 0 0 #c22032);
    }
    88% {
        opacity: 0.55;
        transform: translate(-50%, -50%) translate(5px, -3px);
        clip-path: inset(45% 0 12% 0);
    }
    89% {
        opacity: 0;
        transform: translate(-50%, -50%) translate(0, 0);
        clip-path: inset(0 0 0 0);
    }
    92% {
        opacity: 0.7;
        transform: translate(-50%, -50%) translate(-4px, 1px);
        clip-path: inset(20% 0 40% 0);
    }
    93% {
        opacity: 0;
    }
}

@keyframes splash-glitch-c {
    0%,
    86%,
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) translate(0, 0);
        clip-path: inset(0 0 0 0);
    }
    87% {
        opacity: 0.75;
        transform: translate(-50%, -50%) translate(7px, -1px);
        clip-path: inset(30% 0 35% 0);
        filter: drop-shadow(-3px 0 0 #5ee0ff);
    }
    88% {
        opacity: 0.5;
        transform: translate(-50%, -50%) translate(-5px, 3px);
        clip-path: inset(60% 0 5% 0);
    }
    89% {
        opacity: 0;
        transform: translate(-50%, -50%) translate(0, 0);
        clip-path: inset(0 0 0 0);
    }
    91% {
        opacity: 0.65;
        transform: translate(-50%, -50%) translate(4px, 2px);
        clip-path: inset(0 15% 70% 0);
    }
    92% {
        opacity: 0;
    }
}

@keyframes splash-tag-flicker {
    0%,
    94%,
    100% {
        opacity: 0.85;
    }
    95% {
        opacity: 0.35;
    }
    96% {
        opacity: 0.9;
    }
}

@media (prefers-reduced-motion: reduce) {
    .splash-screen__noise {
        animation: none;
    }

    .splash-glitch__img--base {
        animation: none;
    }

    .splash-glitch__img--r,
    .splash-glitch__img--c {
        animation: none !important;
        opacity: 0 !important;
    }

    .splash-screen__tag {
        animation: none;
    }

    .splash-screen--out {
        filter: none;
    }
}

/* --- HUB machines --- */
.hub-shell {
    min-height: 100dvh;
}

.hub-header__subtitle {
    white-space: normal;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    line-height: 1.38;
    max-width: min(520px, 90vw);
}

.hub-main {
    flex: 1;
    padding: 22px 16px 40px;
    max-width: 1420px;
    margin: 0 auto;
    width: 100%;
}

.hub-banner {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    margin-bottom: 22px;
    font-size: 14px;
    line-height: 1.45;
}

.hub-banner--error {
    background: #2a1818;
    border-color: #b45353;
    color: #f3d4d4;
}

.hub-banner--warn {
    background: rgba(232, 160, 69, 0.1);
    border-color: rgba(232, 160, 69, 0.35);
    color: var(--text);
}

.hub-banner__detail {
    display: block;
    margin-top: 8px;
    font-family: var(--font);
    font-size: 11px;
    color: var(--muted);
}

.hub-empty {
    text-align: center;
    padding: 56px 16px;
    font-size: 14px;
}

.hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
    gap: 22px;
    align-items: stretch;
}

.hub-card {
    display: flex;
    flex-direction: column;
    background: linear-gradient(165deg, #161c26 0%, var(--panel) 48%, #121820 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition:
        border-color 0.22s ease,
        transform 0.22s ease,
        box-shadow 0.22s ease;
}

.hub-card:hover {
    border-color: rgba(194, 32, 50, 0.42);
    transform: translateY(-3px);
    box-shadow:
        0 16px 48px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(194, 32, 50, 0.12);
}

.hub-card__media {
    aspect-ratio: 16 / 10;
    background: radial-gradient(ellipse 80% 70% at 50% 40%, #1a222e 0%, #0d1118 100%);
    border-bottom: 1px solid var(--border);
}

.hub-card__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
    padding: 14px;
}

.hub-card__placeholder {
    width: 100%;
    height: 100%;
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.hub-card__placeholder-text {
    font-size: 12px;
    color: var(--muted);
    font-family: var(--font);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.hub-card__body {
    padding: 18px 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.hub-card__title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.28;
}

.hub-card__folder {
    margin: -4px 0 0;
}

.hub-card__desc {
    margin: 0;
    font-size: 13px;
    color: #c8ced9;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hub-card__warn {
    margin: 0;
    font-size: 12px;
    color: #e8a045;
    line-height: 1.4;
}

.hub-card__specs {
    margin: 6px 0 0;
    padding: 0;
}

.hub-card__spec {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 14px;
    align-items: baseline;
    font-size: 12px;
    padding: 10px 0;
    border-top: 1px solid rgba(42, 53, 72, 0.65);
}

.hub-card__spec:first-child {
    border-top: 0;
    padding-top: 2px;
}

.hub-card__spec dt {
    margin: 0;
    color: var(--muted);
    font-weight: 500;
}

.hub-card__spec dd {
    margin: 0;
    font-family: var(--font);
    text-align: right;
    color: var(--text);
}

.hub-card__actions {
    margin-top: auto;
    padding-top: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.hub-card__btn {
    flex: 1 1 auto;
    min-width: 112px;
}

@media (prefers-reduced-motion: reduce) {
    .hub-card:hover {
        transform: none;
    }
}
