:root { --primary: #007bff; --bg: #f0f2f5; --danger: #dc3545; --success: #28a745; --accent: #ffc107; --dark: #222; }
* { box-sizing: border-box; }

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg); margin: 0;
    display: flex; flex-direction: column;
    height: 100vh; overflow: hidden;
}

header {
    background: var(--dark); color: white; padding: 8px 16px;
    display: flex; justify-content: flex-start; align-items: center;
    gap: 12px;
    z-index: 100; flex-shrink: 0;
}

.app-mode-toggle {
    display: inline-flex;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 999px;
    padding: 2px;
    gap: 2px;
}

.header-right {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.app-mode-btn {
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.75);
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    line-height: 1.2;
}

.app-mode-btn.active {
    background: #fff;
    color: #111;
}

.app-tools-menu {
    position: relative;
    flex-shrink: 0;
}
body.app-mode-simple .app-tools-menu {
    display: none !important;
}
.app-tools-btn {
    height: 34px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.28);
    background: rgba(255,255,255,0.14);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    padding: 0 12px;
    font-size: 0.75rem;
    font-weight: 700;
}
.app-tools-btn:hover,
.app-tools-btn[aria-expanded="true"] {
    background: rgba(255,255,255,0.24);
    border-color: rgba(255,255,255,0.45);
}
.app-tools-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 240px;
    background: #fff;
    color: #222;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0,0,0,0.22);
    padding: 6px;
    z-index: 200;
}
.app-tools-dropdown[hidden] {
    display: none !important;
}
.app-tools-item {
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #1f2937;
    cursor: pointer;
}
.app-tools-item:hover {
    background: #f3f4f6;
}

body.app-mode-simple {
    background: #000;
}
.header-right,
.app-mode-toggle,
.app-tools-menu,
#studio-view.mode-advanced-view {
    display: none !important;
}
body.app-mode-simple .mode-advanced-view {
    display: none !important;
}
body.app-mode-advanced .mode-simple-view {
    display: none !important;
}

/* La vista avanzata deve occupare tutta l'altezza sotto l'header */
#studio-view.mode-advanced-view {
    flex: 1 1 0;
    min-height: 0;
    height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
body.app-mode-simple header {
    background: #000;
    border-bottom: 1px solid #1a1a1a;
}
body.app-mode-simple .brand-title {
    color: rgba(255,255,255,0.55);
}
body.app-mode-simple .app-mode-toggle {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.12);
}
body.app-mode-simple .app-mode-btn {
    color: rgba(255,255,255,0.55);
}
body.app-mode-simple .app-mode-btn.active {
    background: #fff;
    color: #111;
}

/* Testo più leggibile quando lo sfondo campionato è chiaro */
body.app-mode-simple.simple-bg-light .simple-search-title {
    color: #111;
    text-shadow: 0 1px 0 rgba(255,255,255,0.35);
}
body.app-mode-simple.simple-bg-light .simple-search-subtitle {
    color: rgba(0,0,0,0.45);
}
body.app-mode-simple.simple-bg-light .simple-disclaimer {
    color: rgba(0,0,0,0.55);
}
body.app-mode-simple.simple-bg-light .brand-title {
    color: rgba(0,0,0,0.55);
}
body.app-mode-simple.simple-bg-light .app-mode-btn {
    color: rgba(0,0,0,0.55);
}
body.app-mode-simple.simple-bg-light .app-mode-toggle {
    background: rgba(0,0,0,0.08);
    border-color: rgba(0,0,0,0.18);
}
body.app-mode-simple.simple-bg-light .app-mode-btn.active {
    background: #111;
    color: #fff;
}
body.app-mode-simple.simple-bg-light header {
    border-bottom-color: rgba(0,0,0,0.12);
}

.mode-simple-view {
    flex: 1;
    min-height: 0;
    background: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px 20px;
    position: relative;
    overflow: hidden;
}
.simple-bg-quads {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: 1fr 1fr;
    z-index: 0;
    pointer-events: none;
}
.simple-bg-quad[data-quad="sample"] {
    grid-column: 1 / -1;
}
.simple-bg-quads[hidden] {
    display: none !important;
}
.simple-bg-quads:not([hidden]) {
    animation: simple-bg-reveal 0.95s ease both;
}
.simple-bg-quad {
    position: relative;
    min-height: 0;
    transition: background-color 0.68s ease;
}
.simple-bg-quad-label {
    position: absolute;
    top: 10px;
    left: 10px;
    max-width: calc(100% - 20px);
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.42);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid rgba(255,255,255,0.12);
}
.simple-bg-quad-label.on-light {
    background: rgba(255, 255, 255, 0.72);
    color: #111;
    border-color: rgba(0,0,0,0.08);
}
/* Le quattro etichette dei database sono centrate e allineate. */
.simple-bg-quad[data-quad="classic"] .simple-bg-quad-label,
.simple-bg-quad[data-quad="design"] .simple-bg-quad-label,
.simple-bg-quad[data-quad="pantone"] .simple-bg-quad-label,
.simple-bg-quad[data-quad="ncs"] .simple-bg-quad-label {
    top: 68%;
    left: 50%;
    right: auto;
    bottom: auto;
    transform: translate(-50%, -50%);
    text-align: center;
}
.mode-simple-view.has-quad-bg .simple-search-stage {
    position: relative;
    z-index: 1;
    background: rgba(0, 0, 0, 0.48);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 18px;
    padding: 20px 18px;
    box-shadow: 0 16px 50px rgba(0,0,0,0.35);
}
.mode-simple-view.has-quad-bg .simple-disclaimer {
    position: relative;
    z-index: 1;
    color: rgba(255,255,255,0.7);
    text-shadow: 0 1px 2px rgba(0,0,0,0.45);
}
.simple-search-stage {
    width: min(560px, 100%);
    max-width: 560px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
    margin: auto;
    position: relative;
    z-index: 1;
    transition:
        padding 0.82s cubic-bezier(.18,.72,.2,1),
        background-color 0.68s ease,
        border-color 0.68s ease,
        border-radius 0.68s ease,
        box-shadow 0.82s ease;
}
.simple-search-stage.results-entering {
    animation: simple-stage-reveal 0.94s cubic-bezier(.16,.76,.22,1) both;
}
.simple-search-stage.results-entering .simple-search-row {
    opacity: 0;
    animation: simple-result-reveal 0.62s cubic-bezier(.18,.72,.2,1) forwards;
}
.simple-search-stage.results-entering .simple-search-row:nth-child(1) { animation-delay: 0.16s; }
.simple-search-stage.results-entering .simple-search-row:nth-child(2) { animation-delay: 0.23s; }
.simple-search-stage.results-entering .simple-search-row:nth-child(3) { animation-delay: 0.30s; }
.simple-search-stage.results-entering .simple-search-row:nth-child(4) { animation-delay: 0.37s; }
.simple-search-stage.results-leaving .simple-search-row {
    animation: simple-result-hide 0.58s cubic-bezier(.4,0,.8,.25) forwards;
}
.simple-search-stage.results-leaving .simple-search-row:nth-child(1) { animation-delay: 0.15s; }
.simple-search-stage.results-leaving .simple-search-row:nth-child(2) { animation-delay: 0.10s; }
.simple-search-stage.results-leaving .simple-search-row:nth-child(3) { animation-delay: 0.05s; }
.simple-search-stage.results-leaving .simple-search-row:nth-child(4) { animation-delay: 0s; }
.simple-search-stage.results-leaving .simple-scheme-action {
    transition: opacity 0.45s ease, transform 0.55s ease;
    opacity: 0;
    transform: translateY(-8px);
}
.mode-simple-view.simple-results-closing .simple-bg-quads {
    animation: none;
    opacity: 1;
    transition: opacity 1.2s cubic-bezier(.35,0,.65,1);
}
.mode-simple-view.simple-results-closing.simple-results-fading .simple-bg-quads {
    opacity: 0;
}
@keyframes simple-stage-reveal {
    0% {
        transform: translateY(-7px) scale(0.985);
        opacity: 0.82;
    }
    55% {
        transform: translateY(2px) scale(1.006);
        opacity: 1;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}
@keyframes simple-result-reveal {
    0% {
        transform: translateY(-10px) scale(0.98);
        opacity: 0;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}
@keyframes simple-result-hide {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-8px) scale(0.985);
        opacity: 0;
    }
}
@keyframes simple-bg-reveal {
    from { opacity: 0; }
    to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
    .simple-search-stage,
    .simple-search-stage.results-entering,
    .simple-search-stage.results-entering .simple-search-row,
    .simple-search-stage.results-leaving .simple-search-row {
        transition: none;
        animation: none;
    }
}
.simple-color-wheel-control {
    align-self: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: -6px;
}
.simple-color-wheel-wrap {
    position: relative;
    width: 138px;
    height: 138px;
    align-self: center;
    flex: 0 0 auto;
    border-radius: 50%;
    filter: drop-shadow(0 8px 18px rgba(0,0,0,0.32));
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
.simple-color-wheel {
    display: block;
    width: 138px;
    height: 138px;
    border-radius: 50%;
    cursor: crosshair;
    touch-action: none;
}
.simple-color-wheel-selection {
    position: absolute;
    width: 13px;
    height: 13px;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 1px 5px rgba(0,0,0,0.9), inset 0 0 0 1px rgba(0,0,0,0.3);
    transform: translate(-50%, -50%);
    pointer-events: none;
}
.simple-color-wheel-selection[hidden] {
    display: none;
}
.simple-brightness-control {
    width: 148px;
    display: grid;
    grid-template-columns: 14px 1fr 14px;
    align-items: center;
    gap: 6px;
    color: #777;
    font-size: 0.68rem;
    line-height: 1;
}
.simple-brightness-control input[type="range"] {
    width: 100%;
    height: 3px;
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
    border-radius: 999px;
    background: linear-gradient(90deg, #292929, #f2f2f2);
    outline: none;
}
.simple-brightness-control input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: #777;
    box-shadow: 0 1px 4px rgba(0,0,0,0.7);
    cursor: pointer;
}
.simple-brightness-control input[type="range"]::-moz-range-thumb {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: #777;
    box-shadow: 0 1px 4px rgba(0,0,0,0.7);
    cursor: pointer;
}
.simple-disclaimer {
    margin: 0;
    margin-top: auto;
    width: min(640px, 100%);
    padding: 12px 8px 4px;
    position: relative;
    z-index: 1;
    text-align: center;
    color: #666;
    font-size: 0.68rem;
    line-height: 1.45;
    font-weight: 400;
}
.simple-search-heading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    max-width: min(100%, 34rem);
    margin-inline: auto;
}
.simple-search-title {
    margin: 0;
    text-align: center;
    color: #fff;
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.15;
    overflow-wrap: anywhere;
    min-width: 0;
}
.simple-search-heading .simple-search-badge {
    font-size: 0.72rem;
    padding: 4px 10px;
}
.simple-search-subtitle {
    margin: -8px 0 0 0;
    text-align: center;
    color: #666;
    font-size: 0.62rem;
    font-weight: 500;
    letter-spacing: 0.04em;
}
.simple-search-row-input {
    display: flex;
    align-items: center;
    gap: 10px;
}
.simple-search-field {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
}
.simple-search-input {
    display: block;
    width: 100%;
    height: 52px;
    border: 1px solid #333;
    border-radius: 12px;
    background: #111;
    color: #fff;
    font-size: 1.05rem;
    padding: 0 18px;
    outline: none;
}
.simple-search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}
.simple-search-input::placeholder {
    color: #666;
}
.simple-search-input:focus {
    border-color: #666;
    background: #141414;
}
.simple-search-clear-btn {
    position: absolute;
    top: 50%;
    right: 8px;
    z-index: 2;
    width: 34px;
    height: 34px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid #3a3a3a;
    border-radius: 50%;
    background: #1c1c1c;
    color: #ddd;
    font-size: 0.78rem;
    line-height: 1;
    cursor: pointer;
    transform: translateY(-50%);
}
.simple-search-clear-btn:not([hidden]) {
    display: inline-flex;
}
.simple-search-clear-btn:hover,
.simple-search-clear-btn:active {
    border-color: #777;
    background: #2a2a2a;
    color: #fff;
}
.simple-search-field:has(.simple-search-clear-btn:not([hidden])) .simple-search-input {
    padding-right: 46px;
}
.simple-eyedropper-btn {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    border: 1px solid #333;
    border-radius: 12px;
    background: #111;
    color: #fff;
    font-size: 1.35rem;
    cursor: pointer;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.simple-eyedropper-btn:hover {
    border-color: #666;
    background: #1a1a1a;
}
.simple-eyedropper-btn.active {
    border-color: #fff;
    background: #222;
    box-shadow: 0 0 0 1px #fff inset;
}
.simple-camera-btn {
    display: none;
}
@media (max-width: 768px) {
    body.app-mode-simple .simple-camera-btn {
        display: inline-flex;
    }
    body.app-mode-simple #simple-eyedropper-btn {
        display: none;
    }
    body.app-mode-simple .simple-favorite-add-btn,
    body.app-mode-simple .simple-favorites-palette,
    body.app-mode-simple .simple-color-list-dashboard {
        display: none !important;
    }
}
@media (hover: none) and (pointer: coarse) {
    body.app-mode-simple .simple-favorite-add-btn,
    body.app-mode-simple .simple-favorites-palette,
    body.app-mode-simple .simple-color-list-dashboard {
        display: none !important;
    }
}
#simple-camera-preview-overlay {
    position: fixed;
    inset: 0;
    z-index: 1250;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0,0,0,0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.simple-camera-preview-modal {
    position: relative;
    width: min(520px, 100%);
    max-height: 92vh;
    max-height: 92dvh;
    overflow-y: auto;
    padding: 18px;
    border: 1px solid #292929;
    border-radius: 18px;
    background: #0d0d0d;
    color: #fff;
    box-shadow: 0 24px 70px rgba(0,0,0,0.55);
}
.simple-camera-preview-modal h3 {
    margin: 0 44px 14px 0;
    font-size: 1.05rem;
}
.simple-camera-preview-modal p {
    margin: 10px 0 14px;
    color: #999;
    font-size: 0.75rem;
    line-height: 1.4;
    text-align: center;
}
.simple-camera-preview-frame {
    position: relative;
    width: 100%;
    overflow: hidden;
    border: 1px solid #303030;
    border-radius: 14px;
    background: #000;
}
.simple-camera-preview-frame canvas {
    display: block;
    width: 100%;
    height: auto;
}
.simple-camera-target {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 30px;
    min-height: 30px;
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.65), 0 0 0 9999px rgba(0,0,0,0.18);
}
.simple-camera-target::before,
.simple-camera-target::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    background: #fff;
    box-shadow: 0 0 2px #000;
    transform: translate(-50%, -50%);
}
.simple-camera-target::before {
    width: 12px;
    height: 2px;
}
.simple-camera-target::after {
    width: 2px;
    height: 12px;
}
.simple-search-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}
.simple-search-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #111;
    border: 1px solid #222;
}
.simple-search-row[draggable="true"] {
    cursor: grab;
}
.simple-search-row.is-dragging {
    opacity: 0.42;
    transform: scale(0.985);
}
.simple-search-swatch {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.2);
    flex-shrink: 0;
}
.simple-search-meta {
    min-width: 0;
    flex: 1;
}
.simple-search-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex-wrap: nowrap;
}
.simple-search-code {
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.simple-search-name {
    color: #888;
    font-size: 0.78rem;
    margin-top: 2px;
}
.simple-search-badge {
    flex-shrink: 0;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 999px;
    color: #fff;
}
.simple-search-badge.classic { background: #0056b3; }
.simple-search-badge.design { background: #6f42c1; }
.simple-search-badge.pantone { background: #c2410c; }
.simple-search-badge.ncs { background: #047857; }
.simple-info-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 1px solid #333;
    background: #1a1a1a;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    font-style: italic;
    font-family: Georgia, "Times New Roman", serif;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
}
.simple-info-btn:hover {
    border-color: #888;
    background: #222;
}
.simple-favorite-add-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid #3b3b3b;
    border-radius: 999px;
    background: #171717;
    color: #fff;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.simple-favorite-add-btn:hover {
    transform: scale(1.08);
    border-color: #777;
    background: #242424;
}
.simple-favorite-add-btn.added {
    color: #7ee2a8;
    border-color: #276749;
    background: #102a1d;
}
.simple-list-add-btn {
    width: 34px;
    border-color: #38485c;
    color: #a9c7eb;
    font-size: 0.64rem;
    font-weight: 800;
    letter-spacing: -0.04em;
}
.simple-list-add-btn:hover {
    border-color: #6f91ba;
    background: #172333;
}
.simple-list-add-btn.added {
    color: #9ecbff;
    border-color: #315f8f;
    background: #10243a;
}
.simple-favorites-palette {
    position: fixed;
    top: 108px;
    left: 16px;
    z-index: 40;
    width: 178px;
    box-sizing: border-box;
    max-height: calc(100vh - 126px);
    display: flex;
    flex-direction: column;
    padding: 12px;
    border: 1px solid #262626;
    border-radius: 14px;
    background: rgba(13,13,13,0.9);
    box-shadow: 0 10px 28px rgba(0,0,0,0.22);
    transition: width 0.28s ease, min-height 0.28s ease, padding 0.28s ease, border-radius 0.28s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.simple-favorites-palette.drag-ready {
    border-color: #7ee2a8;
    box-shadow: 0 0 0 3px rgba(126,226,168,0.15), 0 14px 34px rgba(0,0,0,0.3);
    transform: translateY(-2px);
}
.simple-favorites-header {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 8px;
    margin-bottom: 10px;
}
.simple-favorites-title {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}
.simple-palette-name-input {
    width: 100%;
    height: 26px;
    padding: 2px 4px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 800;
    outline: none;
}
.simple-palette-name-input:hover,
.simple-palette-name-input:focus {
    border-color: #3a3a3a;
    background: #171717;
}
.simple-favorites-header > div span {
    color: #666;
    font-size: 0.66rem;
}
.simple-palette-collapse-btn {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid #333;
    border-radius: 50%;
    background: #171717;
    color: #999;
    font-size: 0.62rem;
    cursor: pointer;
}
.simple-palette-collapse-btn:hover {
    border-color: #666;
    background: #222;
    color: #fff;
}
.simple-palette-share-btn {
    grid-column: 1 / -1;
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 10px;
    border: 1px solid #333;
    border-radius: 999px;
    background: #191919;
    color: #ddd;
    font-size: 0.67rem;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
}
.simple-palette-share-btn:hover:not(:disabled) {
    border-color: #666;
    background: #242424;
    color: #fff;
}
.simple-palette-share-btn:disabled {
    opacity: 0.35;
    cursor: default;
}
.simple-favorites-slots {
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #393939 #0b0b0b;
    padding-right: 3px;
}
.simple-favorites-slots::-webkit-scrollbar {
    width: 7px;
}
.simple-favorites-slots::-webkit-scrollbar-track {
    background: #0b0b0b;
    border-radius: 999px;
}
.simple-favorites-slots::-webkit-scrollbar-thumb {
    border: 2px solid #0b0b0b;
    border-radius: 999px;
    background: #3a3a3a;
}
.simple-palette-open-btn {
    display: none;
}
.simple-favorites-palette.is-collapsed {
    width: 48px;
    min-height: 48px;
    padding: 0;
    overflow: visible;
    border-radius: 14px;
}
.simple-favorites-palette.is-collapsed .simple-favorites-header,
.simple-favorites-palette.is-collapsed .simple-favorites-slots {
    display: none;
}
.simple-favorites-palette.is-collapsed .simple-palette-open-btn {
    position: relative;
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 13px;
    background: #111;
    color: #a7f3c4;
    font-size: 0.9rem;
    cursor: pointer;
}
.simple-palette-open-btn small {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid #0b0b0b;
    border-radius: 999px;
    background: #276749;
    color: #fff;
    font-size: 0.58rem;
    line-height: 1;
}
.simple-favorite-slot {
    position: relative;
    min-width: 0;
    height: 104px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px;
    border: 1px dashed #383838;
    border-radius: 11px;
    background: #151515;
    color: #5f5f5f;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}
.simple-favorite-slot[draggable="true"] {
    cursor: grab;
}
.simple-favorite-slot.is-dragging {
    opacity: 0.42;
    transform: scale(0.97);
}
.simple-favorite-slot.drop-ready {
    border-style: solid;
    border-color: #7ee2a8;
    background: #102a1d;
    color: #a7f3c4;
    box-shadow: inset 0 0 0 2px rgba(126,226,168,0.16);
}
.simple-favorite-slot.is-filled {
    border-style: solid;
    border-color: rgba(255,255,255,0.2);
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.75);
}
.simple-favorite-slot.is-filled.on-light {
    color: #111;
    text-shadow: 0 1px 0 rgba(255,255,255,0.45);
}
.simple-favorite-slot.receiving {
    transform: scale(1.04);
    box-shadow: 0 0 0 3px rgba(255,255,255,0.28), 0 10px 24px rgba(0,0,0,0.3);
}
.simple-favorite-slot-index {
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    opacity: 0.72;
}
.simple-favorite-slot-code {
    width: 100%;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.72rem;
    font-weight: 800;
}
.simple-favorite-label-input {
    width: calc(100% - 12px);
    height: 24px;
    min-width: 0;
    padding: 2px 4px;
    border: none;
    border-bottom: 1px solid rgba(255,255,255,0.35);
    border-radius: 0;
    background: rgba(0,0,0,0.12);
    color: inherit;
    text-align: center;
    font-size: 0.68rem;
    font-weight: 700;
    outline: none;
    touch-action: manipulation;
    -webkit-user-select: text;
    user-select: text;
}
.simple-favorite-label-input::placeholder {
    color: currentColor;
    opacity: 0.58;
}
.simple-favorite-label-input:focus {
    border-bottom-color: currentColor;
    background: rgba(0,0,0,0.2);
}
.simple-favorite-slot-hex {
    font-size: 0.65rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.simple-favorite-slot-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 21px;
    height: 21px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 50%;
    background: rgba(0,0,0,0.35);
    color: #fff;
    font-size: 0.66rem;
    cursor: pointer;
}
.simple-drag-handle {
    display: none;
}
@media (any-pointer: coarse) {
    .simple-drag-handle {
        position: absolute;
        top: 5px;
        left: 6px;
        z-index: 2;
        display: inline-block;
        color: currentColor;
        font-size: 0.8rem;
        line-height: 1;
        opacity: 0.62;
        cursor: grab;
        touch-action: none;
        user-select: none;
        -webkit-user-select: none;
    }
}
.simple-touch-dragging {
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    overflow: hidden;
}
.simple-touch-dragging .simple-favorites-palette,
.simple-touch-dragging .simple-color-list-dashboard,
.simple-touch-dragging .simple-favorites-slots,
.simple-touch-dragging .simple-color-list-items {
    touch-action: none;
    overscroll-behavior: none;
}
.simple-touch-drag-ghost {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 4000;
    width: 138px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 7px 10px;
    box-sizing: border-box;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.7);
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.45);
    font-size: 0.68rem;
    font-weight: 800;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0.92;
    pointer-events: none;
}
.simple-favorite-fly {
    position: fixed;
    z-index: 3000;
    border: 2px solid rgba(255,255,255,0.8);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.45);
    pointer-events: none;
}
.simple-color-list-dashboard {
    position: fixed;
    top: 108px;
    right: 16px;
    z-index: 40;
    width: 178px;
    box-sizing: border-box;
    max-height: calc(100vh - 126px);
    display: flex;
    flex-direction: column;
    padding: 12px;
    border: 1px solid #262626;
    border-radius: 14px;
    background: rgba(13,13,13,0.9);
    box-shadow: 0 10px 28px rgba(0,0,0,0.22);
    transition: width 0.28s ease, min-height 0.28s ease, padding 0.28s ease, border-radius 0.28s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.simple-color-list-dashboard.drag-ready {
    border-color: #9ecbff;
    box-shadow: 0 0 0 3px rgba(90,150,220,0.16), 0 14px 34px rgba(0,0,0,0.3);
    transform: translateY(-2px);
}
.simple-color-list-header {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 10px;
}
.simple-color-list-header > div {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}
.simple-color-list-header .simple-color-list-header-actions {
    flex: 0 0 auto;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
}
.simple-color-list-header strong {
    color: #fff;
    font-size: 0.82rem;
}
.simple-color-list-name-input {
    width: 100%;
    height: 25px;
    min-width: 0;
    padding: 2px 4px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 800;
    outline: none;
}
.simple-color-list-name-input:hover,
.simple-color-list-name-input:focus {
    border-color: #3a3a3a;
    background: #171717;
}
.simple-color-list-header span {
    color: #666;
    font-size: 0.66rem;
}
.simple-color-list-clear-btn {
    flex: 0 0 auto;
    padding: 4px 6px;
    border: 1px solid #333;
    border-radius: 7px;
    background: #171717;
    color: #aaa;
    font-size: 0.58rem;
    font-weight: 700;
    cursor: pointer;
}
.simple-color-list-clear-btn:hover:not(:disabled) {
    border-color: #734040;
    background: #291515;
    color: #f1aaaa;
}
.simple-color-list-clear-btn:disabled {
    opacity: 0.35;
    cursor: default;
}
.simple-color-list-toolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 9px;
}
.simple-color-list-share-btn {
    flex: 1 1 auto;
    height: 27px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 7px;
    border: 1px solid #333;
    border-radius: 7px;
    background: #171717;
    color: #c8d9ec;
    font-size: 0.6rem;
    font-weight: 700;
    cursor: pointer;
}
.simple-color-list-share-btn:hover:not(:disabled) {
    border-color: #55779e;
    background: #172333;
    color: #fff;
}
.simple-color-list-share-btn:disabled {
    opacity: 0.35;
    cursor: default;
}
.simple-color-list-collapse-btn {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid #333;
    border-radius: 50%;
    background: #171717;
    color: #999;
    font-size: 0.62rem;
    cursor: pointer;
}
.simple-color-list-collapse-btn:hover {
    border-color: #666;
    background: #222;
    color: #fff;
}
.simple-color-list-open-btn {
    display: none;
}
.simple-color-list-dashboard.is-collapsed {
    width: 48px;
    min-height: 48px;
    padding: 0;
    overflow: visible;
    border-radius: 14px;
}
.simple-color-list-dashboard.is-collapsed .simple-color-list-header,
.simple-color-list-dashboard.is-collapsed .simple-color-list-toolbar,
.simple-color-list-dashboard.is-collapsed .simple-color-list-sort,
.simple-color-list-dashboard.is-collapsed .simple-color-list-items {
    display: none;
}
.simple-color-list-dashboard.is-collapsed .simple-color-list-open-btn {
    position: relative;
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 13px;
    background: #111;
    color: #d5e7fb;
    font-size: 1.35rem;
    font-weight: 800;
    cursor: pointer;
}
.simple-color-list-open-btn small {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid #0b0b0b;
    border-radius: 999px;
    background: #315f8f;
    color: #fff;
    font-size: 0.58rem;
    line-height: 1;
}
.simple-color-list-dashboard.is-collapsed.drag-ready {
    border-color: #9ecbff;
    box-shadow: 0 0 0 4px rgba(90,150,220,0.18), 0 14px 34px rgba(0,0,0,0.3);
}
.simple-color-list-sort {
    flex: 0 0 auto;
    display: grid;
    gap: 4px;
    margin-bottom: 10px;
}
.simple-color-list-sort > span {
    color: #777;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.simple-color-list-sort select {
    width: 100%;
    height: 30px;
    padding: 0 25px 0 8px;
    border: 1px solid #343434;
    border-radius: 8px;
    background: #171717;
    color: #ddd;
    font-size: 0.68rem;
    font-weight: 700;
    outline: none;
    cursor: pointer;
}
.simple-color-list-sort select:focus {
    border-color: #6f91ba;
    box-shadow: 0 0 0 2px rgba(90,150,220,0.12);
}
.simple-color-list-items {
    min-height: 58px;
    display: grid;
    gap: 8px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #393939 #0b0b0b;
    padding-right: 3px;
}
.simple-color-list-items::-webkit-scrollbar {
    width: 7px;
}
.simple-color-list-items::-webkit-scrollbar-track {
    background: #0b0b0b;
    border-radius: 999px;
}
.simple-color-list-items::-webkit-scrollbar-thumb {
    border: 2px solid #0b0b0b;
    border-radius: 999px;
    background: #3a3a3a;
}
.simple-color-list-items::-webkit-scrollbar-thumb:hover {
    background: #555;
}
.simple-color-list-empty {
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border: 1px dashed #383838;
    border-radius: 11px;
    color: #666;
    text-align: center;
    font-size: 0.68rem;
    line-height: 1.35;
}
.simple-color-list-item {
    position: relative;
    min-height: 58px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 5px 28px 5px 7px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 11px;
    color: #fff;
    text-align: center;
    text-shadow: 0 1px 3px rgba(0,0,0,0.75);
    cursor: grab;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    transition: opacity 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.simple-color-list-item.is-dragging {
    opacity: 0.38;
    transform: scale(0.97);
}
.simple-color-list-item.drop-before {
    box-shadow: inset 0 3px 0 #9ecbff;
}
.simple-color-list-item.drop-after {
    box-shadow: inset 0 -3px 0 #9ecbff;
}
.simple-color-list-item.on-light {
    color: #111;
    text-shadow: 0 1px 0 rgba(255,255,255,0.45);
}
.simple-color-list-item-lib {
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    opacity: 0.72;
}
.simple-color-list-item-code {
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.7rem;
    font-weight: 800;
}
.simple-color-list-item.just-added {
    animation: simple-list-item-enter 0.48s cubic-bezier(.18,.72,.2,1) both;
}
.simple-color-list-item-hex {
    font-size: 0.63rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.simple-color-list-item-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 19px;
    height: 19px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 50%;
    background: rgba(0,0,0,0.35);
    color: #fff;
    font-size: 0.66rem;
    cursor: pointer;
}
@keyframes simple-list-item-enter {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
.simple-match-badge {
    flex-shrink: 0;
    font-size: 0.58rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 999px;
    color: #fff;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    line-height: 1.2;
    white-space: nowrap;
}
.simple-match-badge.conf-excellent { background: #1f8f3a; }
.simple-match-badge.conf-good { background: #2ea44f; }
.simple-match-badge.conf-fair { background: #d4a017; color: #111; }
.simple-match-badge.conf-weak { background: #b02a37; }
.simple-search-hint {
    text-align: center;
    color: #444;
    font-size: 0.85rem;
    padding: 8px 0;
}
.simple-scheme-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-top: 14px;
}
.simple-scheme-action[hidden] {
    display: none !important;
}
.simple-scheme-btn {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 1px solid #333;
    background: #141414;
    color: #ddd;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.simple-scheme-btn:hover {
    border-color: #777;
    background: #1c1c1c;
    color: #fff;
}
.simple-scheme-hint {
    font-size: 0.68rem;
    color: #666;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
#simple-scheme-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    padding: 16px;
}
.simple-scheme-modal {
    position: relative;
    width: min(520px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    background: #0d0d0d;
    color: #f2f2f2;
    border: 1px solid #242424;
    border-radius: 18px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
    padding: 22px 22px 20px;
}
.simple-scheme-modal .edit-color-header {
    margin-bottom: 12px;
}
.simple-scheme-modal .modal-share-btn {
    color: #777;
    border: 1px solid #2a2a2a;
    background: #161616;
}
.simple-scheme-modal .modal-share-btn:hover {
    color: #fff;
    border-color: #555;
    background: #1e1e1e;
}
.simple-scheme-modal .edit-color-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #fff;
}
.simple-scheme-preview {
    height: 110px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin-bottom: 14px;
    text-shadow: 0 0 4px #000;
    padding: 0 16px;
    text-align: center;
    overflow: hidden;
}
.simple-scheme-preview.preview-on-light {
    color: #111;
    text-shadow: 0 1px 0 rgba(255,255,255,0.35);
}
.simple-scheme-scale-selector {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    color: #777;
    font-size: 0.7rem;
    font-weight: 700;
}
.simple-scheme-scale-selector select {
    min-width: 0;
    height: 34px;
    padding: 0 30px 0 10px;
    border: 1px solid #303030;
    border-radius: 9px;
    background: #171717;
    color: #eee;
    font-size: 0.7rem;
    font-weight: 700;
    outline: none;
}
.simple-scheme-scale-selector select:focus {
    border-color: #686868;
}
.simple-scheme-body {
    display: grid;
    gap: 12px;
}
.simple-scheme-block {
    background: #141414;
    border: 1px solid #242424;
    border-radius: 12px;
    padding: 12px 14px;
}
.simple-scheme-block-head h4 {
    margin: 0 0 4px 0;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #9a9a9a;
}
.simple-scheme-block-head p {
    margin: 0 0 10px 0;
    font-size: 0.78rem;
    color: #777;
}
.simple-scheme-swatches {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
    gap: 8px;
}
.simple-scheme-swatch {
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    min-height: 58px;
    padding: 8px 6px;
    cursor: pointer;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    text-shadow: 0 0 3px rgba(0,0,0,0.75);
}
.simple-scheme-swatch.is-matched {
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.simple-scheme-swatch.is-matched span,
.simple-scheme-swatch.is-matched small {
    width: 100%;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.simple-scheme-swatch.is-matched small {
    font-size: 0.52rem;
    font-weight: 700;
    opacity: 0.7;
}
.simple-scheme-swatch.on-light {
    color: #111;
    text-shadow: 0 1px 0 rgba(255,255,255,0.4);
}
.simple-scheme-swatch.copied {
    outline: 2px solid #fff;
    outline-offset: 1px;
}

.simple-stage-brand {
    align-self: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
    margin-bottom: 10px;
    color: #fff;
    text-align: center;
}
.simple-stage-wordmark {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    line-height: 1;
    text-transform: uppercase;
}
.simple-stage-wordmark strong {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.12em;
}
.simple-stage-wordmark small {
    color: rgba(255,255,255,0.4);
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.18em;
}
.brand-logo {
    position: relative;
    width: 23px;
    height: 23px;
    display: inline-block;
    flex-shrink: 0;
    border: 1px solid #4d8fe8;
    border-radius: 3px;
    background: transparent;
    box-shadow: 0 6px 16px rgba(0,0,0,0.25);
    transform: rotate(45deg);
}
.brand-logo-swatch {
    display: none;
}
.brand-logo-core {
    position: absolute;
    inset: 4px;
    border-radius: 1px;
    background: transparent;
    border: 1px solid #ef5350;
    box-shadow: none;
}
.brand-logo-core::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    border-radius: 0;
    background: #48b96b;
    box-shadow: 0 0 0 1px rgba(72,185,107,0.28);
    transform: translate(-50%, -50%);
}

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

.main-layout {
    display: flex;
    flex: 1 1 0;
    align-items: stretch;
    overflow: hidden;
    padding: 15px;
    gap: 15px;
    min-height: 0;
    height: 0;
}

#ref-panel {
    flex: 3 1 0;
    display: flex;
    flex-direction: column;
    background: #2f2f2f;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
    position: relative;
    border: 2px solid transparent;
    min-width: 0;
    min-height: 0;
    height: 100%;
}
#ref-panel.drag-over { border-color: var(--primary); background: #555; }

.toolbar {
    padding: 10px; background: #eee; border-bottom: 1px solid #ddd;
    display: flex; gap: 10px; align-items: center; z-index: 20; color: #333;
    flex-shrink: 0;
}

#viewport {
    flex: 1 1 0;
    overflow: auto;
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    background: #333;
    min-width: 0;
    min-height: 0;
    height: 100%;
}
#viewport.zoom-fit {
    overflow-x: hidden;
    overflow-y: auto;
    align-items: flex-start;
    justify-content: center;
}
#viewport.zoom-pixel {
    overflow: auto;
    align-items: flex-start;
    justify-content: flex-start;
}

canvas#display-canvas { cursor: crosshair; display: block; transform-origin: top left; z-index: 10; max-width: none; }
canvas#display-canvas.sample-cursor-active { cursor: none; }
#sample-cursor {
    position: fixed;
    width: 21px;
    height: 21px;
    border: 2px solid rgba(255,255,255,0.95);
    box-shadow: 0 0 0 1px rgba(0,0,0,0.75), inset 0 0 0 1px rgba(0,0,0,0.25);
    border-radius: 50%;
    pointer-events: none;
    z-index: 60;
    display: none;
    transform: translate(-50%, -50%);
    box-sizing: border-box;
}
#sample-cursor::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 3px;
    height: 3px;
    background: rgba(255,255,255,0.95);
    border: 1px solid rgba(0,0,0,0.75);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}
canvas.ocr-active {
    cursor: crosshair !important;
    outline: 3px dashed var(--accent);
    outline-offset: -3px;
}

#drop-instruction {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%); color: #ccc;
    text-align: center; pointer-events: none; z-index: 5;
}

.side-panels {
    flex: 1 1 0;
    width: 380px;
    max-width: 420px;
    min-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: 100%;
    min-height: 0;
}

.panel {
    background: white; padding: 15px; border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1); display: flex; flex-direction: column;
}

.top-settings {
    margin: 8px 15px 0 15px;
    flex-shrink: 0;
    padding: 8px 12px;
}

.top-settings h3 {
    display: none;
}

.settings-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.settings-provider { width: 180px; margin-bottom: 0; }
.btn-load-image {
    width: 100%;
    margin-top: 6px;
    height: 28px;
    padding: 0 8px;
    font-size: 0.72rem;
}
.settings-collection { width: 190px; margin-bottom: 0; }
.settings-name {
    flex: 1;
    min-width: 220px;
    margin-bottom: 0;
}
.settings-size-group {
    width: 210px;
    margin-bottom: 0;
}
.settings-sample-group {
    width: 180px;
    margin-bottom: 0;
}
.settings-ref-actions {
    display: flex;
    gap: 5px;
    margin-top: 6px;
}
.btn-ref-settings {
    flex: 1;
    width: auto;
    height: 26px;
    padding: 0 6px;
    margin-bottom: 0;
    font-size: 0.68rem;
    border-radius: 5px;
    white-space: nowrap;
}
.settings-size-group-label {
    display: block;
    white-space: nowrap;
    font-size: 0.72rem;
    font-weight: 700;
    margin-bottom: 2px;
    color: #555;
}
.settings-size-inputs {
    display: flex;
    gap: 6px;
}
.settings-size-inputs input {
    width: 92px;
}
.settings-sample-radius {
    display: flex;
    align-items: center;
    gap: 6px;
}
.settings-sample-radius input[type="range"] {
    flex: 1;
    min-width: 0;
    height: 22px;
}
.settings-sample-radius input[type="number"] {
    width: 52px;
    height: 30px;
    padding: 4px 6px;
}
.settings-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 168px;
}
.settings-actions .btn {
    width: 100%;
    height: 28px;
    padding: 0 8px;
    font-size: 0.72rem;
}

.top-settings .control-group { margin-bottom: 0; }
.top-settings label {
    font-size: 0.72rem;
    margin-bottom: 2px;
}
.top-settings input {
    padding: 5px 7px;
    font-size: 0.82rem;
    height: 30px;
}

.list-panel { flex: 1; min-height: 0; }
.list-panel #zip-btn { flex-shrink: 0; }
.control-group { margin-bottom: 12px; }
label { display: block; font-size: 0.8rem; font-weight: bold; margin-bottom: 4px; color: #555; }
input { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; }

#color-preview {
    height: 92px; border-radius: 6px; border: 1px solid #ddd;
    margin: 0; padding: 0 10px; min-width: 170px;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; font-size: 0.82rem; color: white; text-shadow: 0 0 3px #000;
    align-self: flex-end;
    box-sizing: border-box;
}

.image-list {
    flex: 1; overflow-y: auto; border: 1px solid #eee;
    background: #fafafa; border-radius: 4px; margin: 10px 0; padding: 0;
}

.list-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px; border-bottom: 1px solid #eee;
    background: #fff; cursor: grab;
    transition: background 0.2s;
}
.list-item.dragging { opacity: 0.4; border: 2px dashed var(--primary); }
.list-item:hover { background: #f8fbff; }
.list-item.highlighted {
    background: #fff8db;
    border: 2px solid #f0b429;
    box-shadow: 0 0 0 3px rgba(240, 180, 41, 0.25);
    border-radius: 6px;
}
.list-item.highlighted .list-info strong {
    color: #8a5a00;
}

.list-thumb { width: 40px; height: 40px; border: 1px solid #ccc; border-radius: 4px; flex-shrink: 0; }
.list-info { flex: 1; pointer-events: none; }
.list-actions { display: flex; gap: 5px; align-items: center; }
.info-badge-btn {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border: none;
    border-radius: 999px;
    background: #0f766e;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 800;
    font-style: italic;
    font-family: Georgia, "Times New Roman", serif;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.info-badge-btn:hover { background: #0d9488; }

.btn { padding: 10px; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.btn-blue { background: var(--primary); color: white; width: 100%; }
.btn-green { background: var(--success); color: white; width: 100%; }
.btn-red { background: var(--danger); color: white; }
.btn-orange { background: #fd7e14; color: white; }
.btn-grey { background: #6c757d; color: white; }
.btn-action { padding: 6px; font-size: 0.8rem; min-width: 32px; }

.btn-zoom { padding: 5px 10px; background: white; border: 1px solid #ccc; font-size: 0.8rem; }
.btn-zoom.active { background: var(--primary); color: white; }
.btn-sort { background: #6f42c1; color: white; padding: 4px 10px; font-size: 0.75rem; }

.list-panel-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.list-panel-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-left: auto;
}

.list-sort-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}
.list-sort-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: #667085;
    line-height: 1;
    text-transform: none;
}
.list-sort-buttons {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-add-list {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 72px;
    height: 36px;
    padding: 0 14px;
    border: none;
    border-radius: 8px;
    background: #28a745;
    color: #fff;
    font-weight: 800;
    box-shadow: 0 2px 0 #1e7e34;
    cursor: pointer;
}
.btn-add-list:hover:not(:disabled) {
    background: #218838;
}
.btn-add-list:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}
.btn-add-list .add-btn-label {
    font-size: 1.35rem;
    line-height: 1;
    font-weight: 800;
    letter-spacing: 0;
    white-space: nowrap;
}
.btn-add-list .add-btn-count {
    min-width: 1.4em;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255,255,255,0.25);
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}



.btn-ocr { background: white; border: 1px solid #ccc; border-radius: 4px; cursor: pointer; padding: 4px 10px; font-size: 0.8rem; font-weight: bold; }
.btn-ocr.active { background: var(--accent); border-color: #e0a800; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.6; } }

#modal-overlay, #ref-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.8);
    display: none; align-items: center; justify-content: center; z-index: 1000;
}
#info-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.8);
    display: none; align-items: center; justify-content: center; z-index: 1000;
}
#saved-lists-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.8);
    display: none; align-items: center; justify-content: center; z-index: 1000;
}
.modal { background: white; padding: 20px; border-radius: 12px; max-width: 500px; width: 95%; position: relative; max-height: 90vh; overflow-y: auto; }
.modal-large { max-width: 1000px; }
#modal-preview-rect {
    width: 100%; height: 120px; border-radius: 8px; margin-bottom: 10px; border: 1px solid #ddd;
    display: flex; align-items: center; justify-content: center; color: white; font-weight: bold; text-shadow: 0 0 4px #000;
}

.search-container { margin: 15px 0; }
.search-input { width: 100%; padding: 10px; border: 2px solid #ddd; border-radius: 6px; font-size: 1rem; }
.ref-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.ref-table th, .ref-table td { border: 1px solid #ddd; padding: 8px; text-align: left; }
.ref-table th { background: #f4f4f4; position: sticky; top: 0; }
.ref-table input { border: none; width: 100%; background: transparent; padding: 4px; }

#ocr-loading { position: fixed; bottom: 20px; left: 20px; background: #333; color: white; padding: 10px 20px; border-radius: 50px; display: none; z-index: 200; }
kbd { background: #eee; border-radius: 3px; padding: 2px 4px; font-size: 0.7rem; border: 1px solid #ccc; }

.ral-tag { display: inline-block; background: #333; color: #fff; padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: bold; margin-top: 5px; }
.ral-tag-classic { background: #0056b3; }
.ral-tag-design { background: #6f42c1; }
.delta-badge {
    display: inline-block;
    margin-top: 0;
    font-size: 0.72rem;
    font-weight: 700;
    color: #333;
    background: #eef2f7;
    border: 1px solid #d7dee8;
    border-radius: 10px;
    padding: 2px 8px;
    white-space: nowrap;
}

.match-line {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px;
    margin: 2px 0;
    white-space: nowrap;
    line-height: 1.35;
}

.match-text {
    white-space: nowrap;
}

.confidence-badge {
    display: inline-block;
    margin-left: 0;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    flex-shrink: 0;
}
.conf-excellent { background: #1f8f3a; }
.conf-good { background: #2ea44f; }
.conf-fair { background: #d4a017; color: #222; }
.conf-weak { background: #b02a37; }

.info-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.info-pill {
    background: #f3f6fb;
    border: 1px solid #dde5ef;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.85rem;
}
.info-pill-edit {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.info-pill-edit label {
    font-size: 0.75rem;
    color: #667085;
}
.info-pill-edit input {
    width: 100%;
    border: 1px solid #cfd8e3;
    border-radius: 6px;
    padding: 7px 9px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #111;
    background: #fff;
}
.info-pill-edit input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.12);
}

.info-table-wrap {
    max-height: 56vh;
    overflow-y: auto;
    border: 1px solid #ddd;
}

.color-chip {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid #bbb;
}

.saved-lists-container {
    max-height: 60vh;
    overflow-y: auto;
    border: 1px solid #e5e9ef;
    border-radius: 8px;
}

.saved-list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid #eef2f7;
}

.saved-list-row:last-child {
    border-bottom: none;
}

.saved-list-title {
    font-weight: 700;
    color: #222;
}

.saved-list-meta {
    font-size: 0.78rem;
    color: #667085;
    margin-top: 2px;
}

.palette-print-controls {
    margin: 0 0 12px 0;
    padding: 10px 12px;
    background: #f7f9fc;
    border: 1px solid #e3e8ef;
    border-radius: 8px;
}
.palette-print-controls-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}
.palette-print-controls select {
    padding: 6px 8px;
    border: 1px solid #ccd5e0;
    border-radius: 6px;
    font-size: 0.85rem;
    min-width: 200px;
}

.palette-print-sheet {
    margin: 0 0 14px 0;
    padding: 12px;
    border: 1px solid #e5e9ef;
    border-radius: 8px;
    background: #fff;
}
.palette-header h3 {
    margin: 0 0 4px 0;
    font-size: 1.05rem;
}
.palette-subheader {
    color: #667085;
    font-size: 0.8rem;
    margin-bottom: 10px;
}
.palette-grid {
    display: grid;
    grid-template-columns: repeat(var(--palette-cols, 6), minmax(0, 1fr));
    gap: 10px 8px;
}
.palette-card {
    text-align: center;
    min-width: 0;
}
.palette-swatch {
    width: 100%;
    height: var(--palette-swatch-h, 72px);
    border-radius: 6px;
    border: 1px solid #c9d0d8;
    box-sizing: border-box;
}
.palette-name {
    margin-top: 5px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #222;
    line-height: 1.2;
    word-break: break-word;
}
.palette-ral {
    margin-top: 2px;
    font-size: 0.68rem;
    color: #555;
    line-height: 1.15;
}
.palette-empty {
    color: #777;
    font-size: 0.85rem;
    text-align: center;
    padding: 12px;
}

@media print {
    @page {
        size: A4;
        margin: 8mm;
    }

    body {
        background: #fff !important;
        overflow: visible !important;
        height: auto !important;
    }

    header,
    .top-settings,
    .main-layout,
    #simple-lookup-view,
    #studio-view,
    #modal-overlay,
    #simple-scheme-overlay,
    #ref-modal-overlay,
    #saved-lists-modal-overlay,
    #color-search-modal-overlay,
    #ral-search-modal-overlay,
    #ral-edit-modal-overlay,
    #ocr-loading {
        display: none !important;
    }

    #info-modal-overlay {
        position: static !important;
        inset: auto !important;
        background: transparent !important;
        display: block !important;
        align-items: initial !important;
        justify-content: initial !important;
        z-index: auto !important;
        padding: 0 !important;
    }

    #info-modal-overlay .modal {
        max-width: none !important;
        width: 100% !important;
        max-height: none !important;
        overflow: visible !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
    }

    .no-print {
        display: none !important;
    }

    .info-table-wrap {
        max-height: none !important;
        overflow: visible !important;
        border: 1px solid #bbb !important;
    }

    .ref-table th,
    .ref-table td {
        font-size: 10px !important;
        padding: 5px !important;
        vertical-align: top !important;
    }

    .match-line {
        display: block !important;
        white-space: nowrap !important;
        page-break-inside: avoid !important;
        margin: 1px 0 !important;
    }

    .match-text,
    .confidence-badge,
    .delta-badge {
        display: inline !important;
        white-space: nowrap !important;
        margin-right: 4px !important;
    }

    body.print-mode-info .palette-print-sheet {
        display: none !important;
    }
    body.print-mode-info .print-info-only {
        display: block !important;
    }

    body.print-mode-palette .print-info-only {
        display: none !important;
    }
    body.print-mode-palette .palette-print-sheet {
        display: block !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    body.print-mode-palette .info-meta {
        display: none !important;
    }
    body.print-mode-palette .palette-header h3 {
        font-size: 14pt !important;
        margin-bottom: 2mm !important;
    }
    body.print-mode-palette .palette-subheader {
        font-size: 9pt !important;
        margin-bottom: 4mm !important;
    }
    body.print-mode-palette .palette-grid {
        gap: 3mm 2.5mm !important;
    }
    body.print-mode-palette .palette-swatch {
        height: var(--palette-swatch-h, 18mm) !important;
        border-radius: 2px !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    body.print-mode-palette .palette-name {
        font-size: 7.5pt !important;
        margin-top: 1.2mm !important;
    }
    body.print-mode-palette .palette-ral {
        font-size: 6.5pt !important;
    }
    body.print-mode-palette .palette-card {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
}

#color-search-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.8);
    display: none; align-items: center; justify-content: center; z-index: 1000;
}
.color-search-bar {
    display: flex;
    gap: 8px;
    align-items: stretch;
    margin-bottom: 12px;
}
.color-search-bar .search-input {
    flex: 1;
}
.color-search-results {
    max-height: 55vh;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 8px;
    background: #fafafa;
}
.color-search-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    background: #fff;
}
.color-search-row:last-child { border-bottom: none; }
.color-search-swatch {
    width: 42px;
    height: 42px;
    border-radius: 6px;
    border: 1px solid #ccc;
    flex-shrink: 0;
}
.color-search-info { flex: 1; min-width: 0; }
.color-search-title {
    font-weight: 700;
    font-size: 0.92rem;
    color: #1f2937;
}
.color-search-meta {
    font-size: 0.78rem;
    color: #667085;
    margin-top: 2px;
}

.modal-edit-color {
    max-width: 640px;
}
.modal-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: #666;
    line-height: 1;
    padding: 4px 8px;
}
.modal-close-btn:hover { color: #111; }
.modal-share-btn {
    position: absolute;
    top: 12px;
    right: 54px;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: #666;
    border-radius: 999px;
    cursor: pointer;
    padding: 0;
}
.modal-share-btn:hover {
    color: #111;
    background: #f2f4f7;
}
.edit-color-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-right: 72px;
}
.edit-color-header h3 {
    margin: 0;
}
.edit-color-lib-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 999px;
    color: #fff;
}
.edit-color-lib-badge.classic { background: #0056b3; }
.edit-color-lib-badge.design { background: #6f42c1; }
.edit-color-lib-badge.pantone { background: #c2410c; }
.edit-color-lib-badge.ncs { background: #047857; }
.edit-color-lib-badge.sampled { background: #333; border: 1px solid #555; }
#modal-overlay.simple-skin .selected-match-block {
    border-color: #3a3a3a;
    background: #181818;
}
#modal-overlay.simple-skin .selected-match-block .simple-search-badge {
    margin-left: 4px;
}
.edit-color-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}
.edit-color-matches {
    margin-top: 12px;
    display: grid;
    gap: 10px;
}

/* Scheda dettagli in stile modalità Semplice */
#modal-overlay.simple-skin {
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
#modal-overlay.simple-skin .modal-edit-color {
    background: #0d0d0d;
    color: #f2f2f2;
    border: 1px solid #242424;
    border-radius: 18px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
    max-width: 520px;
    padding: 22px 22px 20px;
}
#modal-overlay.simple-skin .modal-close-btn {
    color: #777;
    border: 1px solid #2a2a2a;
    border-radius: 999px;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #161616;
    font-size: 0.95rem;
    padding: 0;
}
#modal-overlay.simple-skin .modal-share-btn {
    color: #777;
    border: 1px solid #2a2a2a;
    background: #161616;
}
#modal-overlay.simple-skin .modal-share-btn:hover {
    color: #fff;
    border-color: #555;
    background: #1e1e1e;
}
#modal-overlay.simple-skin .modal-close-btn:hover {
    color: #fff;
    border-color: #555;
    background: #1e1e1e;
}
#modal-overlay.simple-skin .edit-color-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: #fff;
}
#modal-overlay.simple-skin #modal-preview-rect {
    height: 140px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.12);
    margin-bottom: 14px;
    font-size: 1.05rem;
    letter-spacing: 0.04em;
}
#modal-overlay.simple-skin #modal-preview-rect.preview-on-light {
    color: #111;
    text-shadow: 0 1px 0 rgba(255,255,255,0.35);
}
#modal-overlay.simple-skin .edit-name-group,
#modal-overlay.simple-skin .edit-color-actions {
    display: none !important;
}
#modal-overlay.simple-skin .edit-match-block {
    background: #141414;
    border: 1px solid #242424;
    border-radius: 12px;
    padding: 12px 14px;
}
#modal-overlay.simple-skin .edit-match-block h4 {
    color: #9a9a9a;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin: 0 0 10px 0;
}
#modal-overlay.simple-skin .color-value-row {
    background: #1a1a1a;
    border-color: #2a2a2a;
    border-radius: 8px;
    grid-template-columns: 30px minmax(0, 1fr) auto;
    gap: 5px;
    padding: 4px 6px;
}
#modal-overlay.simple-skin .edit-color-values {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
}
#modal-overlay.simple-skin .color-value-label {
    font-size: 0.66rem;
}
#modal-overlay.simple-skin .color-value-text {
    font-size: 0.72rem;
}
#modal-overlay.simple-skin .color-value-copy {
    padding: 3px 6px;
    font-size: 0.62rem;
}
#modal-overlay.simple-skin .color-value-label { color: #888; }
#modal-overlay.simple-skin .color-value-text {
    color: #f5f5f5;
}
#modal-overlay.simple-skin .color-value-text:hover {
    color: #9ecbff;
}
#modal-overlay.simple-skin .color-value-copy {
    background: #222;
    border-color: #333;
    color: #ddd;
}
#modal-overlay.simple-skin .color-value-copy:hover {
    background: #2c2c2c;
    border-color: #555;
}
#modal-overlay.simple-skin .color-value-copy.copied {
    background: #16361f;
    border-color: #2f6b3f;
    color: #8dffb0;
}
#modal-overlay.simple-skin .match-text {
    color: #cfcfcf;
    font-size: 0.8rem;
}
#modal-overlay.simple-skin .edit-color-matches .match-line {
    padding: 4px 0;
}
.edit-match-block {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 12px;
    background: #fafbfc;
}
.edit-match-block h4 {
    margin: 0 0 8px 0;
    font-size: 0.82rem;
    color: #374151;
}
.edit-match-meta {
    font-size: 0.78rem;
    color: #667085;
    margin-bottom: 8px;
}
.edit-color-values {
    display: grid;
    gap: 6px;
}
.color-value-row {
    display: grid;
    grid-template-columns: 42px 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
}
.color-value-label {
    font-size: 0.72rem;
    font-weight: 800;
    color: #667085;
}
.color-value-text {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8rem;
    color: #111827;
    cursor: pointer;
    user-select: all;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.color-value-text:hover {
    color: #175cd3;
}
.color-value-copy {
    border: 1px solid #d0d5dd;
    background: #f8fafc;
    color: #344054;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
}
.color-value-copy:hover {
    background: #eef2f7;
}
.color-value-copy.copied {
    background: #dcfae6;
    border-color: #abefc6;
    color: #027a48;
}
.edit-color-matches .match-line {
    white-space: normal;
    flex-wrap: wrap;
}

.ref-modal-body {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 12px;
    align-items: stretch;
    min-height: 0;
}
.ref-table-wrap {
    max-height: 50vh;
    overflow-y: auto;
    border: 1px solid #ddd;
}
.sector-order-panel {
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fafbfc;
    padding: 10px;
    max-height: 50vh;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.sector-order-header {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 8px;
}
.sector-order-header strong {
    font-size: 0.85rem;
    color: #1f2937;
}
.sector-order-header span {
    font-size: 0.72rem;
    color: #667085;
}
.sector-order-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    min-height: 0;
}
.sector-order-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 6px 8px;
    cursor: grab;
    user-select: none;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.sector-order-item.dragging {
    opacity: 0.45;
    cursor: grabbing;
}
.sector-order-item.drag-over {
    border-color: #6f42c1;
    background: #f5f0ff;
    box-shadow: inset 0 0 0 1px rgba(111, 66, 193, 0.25);
}
.sector-order-handle {
    color: #98a2b3;
    font-size: 0.75rem;
    letter-spacing: -1px;
    cursor: grab;
    line-height: 1;
    padding: 0 2px;
}
.sector-order-item .sector-order-name {
    flex: 1;
    font-size: 0.78rem;
    font-weight: 600;
    color: #374151;
    min-width: 0;
    word-break: break-word;
}
.sector-order-item .sector-order-index {
    font-size: 0.7rem;
    color: #98a2b3;
    width: 1.2em;
    text-align: right;
}
.sector-order-btns {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sector-order-btns button {
    width: 26px;
    height: 18px;
    padding: 0;
    border: 1px solid #d0d5dd;
    border-radius: 4px;
    background: #f2f4f7;
    color: #344054;
    font-size: 0.65rem;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
}
.sector-order-btns button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
@media (max-width: 900px) {
    .ref-modal-body {
        grid-template-columns: 1fr;
    }
}

#ral-search-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.8);
    display: none; align-items: center; justify-content: center; z-index: 1000;
}
.ral-search-modal {
    max-width: 1080px;
    width: min(1080px, 96vw);
}
.ral-search-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}
.ral-search-help {
    margin: 4px 0 0 0;
    font-size: 0.8rem;
    color: #667085;
}
.ral-search-close {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    color: #667085;
    padding: 2px 6px;
}
.ral-source-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}
.ral-pill {
    border: 1px solid #d0d5dd;
    background: #fff;
    color: #344054;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}
.ral-pill.active {
    background: #1f2937;
    border-color: #1f2937;
    color: #fff;
}
.ral-search-input {
    margin-bottom: 12px;
}
.ral-search-body {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.05fr);
    gap: 14px;
    align-items: start;
}
.ral-panel-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #667085;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 6px;
}
.ral-panel-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}
.ral-panel-label-row .ral-panel-label {
    margin-bottom: 0;
}
.ral-clear-btn {
    width: auto !important;
    height: 28px;
    padding: 0 10px;
    font-size: 0.72rem;
}
.ral-search-results {
    max-height: 58vh;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fafafa;
}
.ral-search-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-bottom: 1px solid #eee;
    background: #fff;
    cursor: pointer;
}
.ral-search-row:hover { background: #f3f8ff; }
.ral-search-row.in-compare { background: #eefbf3; }
.ral-search-row:last-child { border-bottom: none; }
.ral-search-swatch {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 1px solid #ccc;
    flex-shrink: 0;
}
.ral-search-meta { min-width: 0; flex: 1; }
.ral-search-code {
    font-weight: 700;
    font-size: 0.86rem;
    color: #1f2937;
}
.ral-search-name {
    font-size: 0.74rem;
    color: #667085;
}
.ral-search-badge {
    font-size: 0.66rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    color: #fff;
    flex-shrink: 0;
}
.ral-search-badge.classic { background: #0056b3; }
.ral-search-badge.design { background: #6f42c1; }
.ral-search-badge.ncs { background: #047857; }
.ral-search-badge.pantone { background: #c2410c; }
.ral-search-badge.pantone-solid-c { background: #c2410c; }
.ral-search-badge.pantone-solid-u { background: #9a3412; }
.ral-search-badge.pantone-metallic { background: #78716c; }
.ral-search-badge.pantone-pastels { background: #db2777; }
.ral-search-badge.pantone-skin { background: #d97706; }
.ral-search-badge.pantone-coty { background: #7c3aed; }
.ral-search-badge.pantone-fashion { background: #0f766e; }
.ral-search-badge.lists { background: #334155; }
.ral-search-badge.sampled { background: #b54708; }
.ral-search-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}
.ral-action-btn {
    border: 1px solid #d0d5dd;
    background: #fff;
    border-radius: 6px;
    padding: 3px 7px;
    font-size: 0.68rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    color: #344054;
}
.ral-action-btn.ral-action-compare {
    color: #027a48;
    border-color: #abefc6;
    background: #f6fef9;
}
.ral-action-btn.ral-action-list {
    color: #175cd3;
    border-color: #b2ccff;
    background: #f5f8ff;
}
.ral-slot-tolist {
    width: 100% !important;
    margin-top: 8px;
    height: 30px;
    padding: 0 8px;
    font-size: 0.72rem;
}
.ral-list-feedback {
    margin-top: 8px;
    min-height: 1.2em;
    font-size: 0.78rem;
    font-weight: 700;
    color: #027a48;
    opacity: 0;
    transition: opacity 0.2s;
}
.ral-list-feedback.show {
    opacity: 1;
}
.ral-compare-board {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.ral-slot {
    border: 1px dashed #d0d5dd;
    border-radius: 10px;
    background: #fafbfc;
    min-height: 150px;
    padding: 8px;
    position: relative;
    box-sizing: border-box;
}
.ral-slot.filled {
    border-style: solid;
    border-color: #e5e7eb;
    background: #fff;
}
.ral-slot-empty {
    height: 100%;
    min-height: 134px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #98a2b3;
    font-size: 0.8rem;
    text-align: center;
    padding: 8px;
}
.ral-slot-swatch {
    width: 100%;
    height: 88px;
    border-radius: 8px;
    border: 1px solid #c9d0d8;
}
.ral-slot-name {
    margin-top: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #1f2937;
    word-break: break-word;
}
.ral-slot-meta {
    margin-top: 2px;
    font-size: 0.7rem;
    color: #667085;
    word-break: break-word;
}
.ral-slot-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 0.75rem;
    cursor: pointer;
    line-height: 1;
}
.ral-compare-deltas {
    margin-top: 10px;
    display: grid;
    gap: 6px;
}
.ral-delta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #f7f9fc;
    border: 1px solid #e3e8ef;
    font-size: 0.8rem;
}
.ral-delta-hint {
    margin-top: 8px;
    font-size: 0.72rem;
    color: #98a2b3;
}
@media (max-width: 900px) {
    .ral-search-body {
        grid-template-columns: 1fr;
    }
}

#ral-edit-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.8);
    display: none; align-items: center; justify-content: center; z-index: 1100;
}
.ral-edit-modal { max-width: 460px; }
.ral-edit-warning {
    margin: 0 0 12px 0;
    padding: 8px 10px;
    border-radius: 8px;
    background: #fff7ed;
    border: 1px solid #fdba74;
    color: #9a3412;
    font-size: 0.8rem;
}
.ral-edit-rgb-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}
.ral-edit-preview {
    margin-top: 10px;
    height: 70px;
    border-radius: 8px;
    border: 1px solid #d0d5dd;
}
.ral-action-btn.ral-action-edit {
    color: #b54708;
    border-color: #f9dbaf;
    background: #fffaf5;
}
.ral-search-row.ral-overridden .ral-search-code::after {
    content: " • mod";
    color: #b54708;
    font-size: 0.7rem;
}

/* Modalità avanzata: layout smartphone */
@media (max-width: 768px) {
    body.app-mode-advanced {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        overflow-x: hidden;
        overflow-y: auto;
    }

    body.app-mode-advanced header {
        position: sticky;
        top: 0;
        padding: 7px 10px;
        gap: 8px;
        box-shadow: 0 2px 12px rgba(0,0,0,0.2);
    }

    body.app-mode-advanced .brand {
        min-width: 0;
        gap: 7px;
    }

    body.app-mode-advanced .brand-title {
        max-width: 118px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.82rem;
    }

    body.app-mode-advanced .brand-logo {
        width: 24px;
        height: 24px;
    }

    body.app-mode-advanced .header-right {
        gap: 6px;
    }

    body.app-mode-advanced .app-mode-btn {
        min-height: 34px;
        padding: 5px 9px;
        font-size: 0.68rem;
    }

    body.app-mode-advanced .app-tools-btn {
        width: 36px;
        height: 36px;
        padding: 0;
    }

    body.app-mode-advanced .app-tools-btn span {
        display: none;
    }

    body.app-mode-advanced .app-tools-dropdown {
        position: fixed;
        top: 54px;
        right: 8px;
        left: 8px;
        min-width: 0;
    }

    #studio-view.mode-advanced-view {
        flex: none;
        width: 100%;
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    body.app-mode-advanced .top-settings {
        margin: 8px;
        padding: 10px;
        border-radius: 10px;
    }

    body.app-mode-advanced .top-settings h3 {
        display: block;
        margin: 0 0 9px;
        font-size: 0.88rem;
    }

    body.app-mode-advanced .settings-row {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    body.app-mode-advanced .settings-provider,
    body.app-mode-advanced .settings-collection,
    body.app-mode-advanced .settings-name,
    body.app-mode-advanced .settings-size-group,
    body.app-mode-advanced .settings-sample-group,
    body.app-mode-advanced .settings-actions {
        width: auto;
        min-width: 0;
    }

    body.app-mode-advanced .settings-name,
    body.app-mode-advanced .settings-actions {
        grid-column: 1 / -1;
    }

    body.app-mode-advanced .top-settings input,
    body.app-mode-advanced .btn-load-image,
    body.app-mode-advanced .settings-actions .btn {
        min-height: 42px;
        font-size: 0.82rem;
    }

    body.app-mode-advanced .settings-ref-actions {
        gap: 8px;
    }

    body.app-mode-advanced .btn-ref-settings {
        min-height: 40px;
        white-space: normal;
        line-height: 1.15;
    }

    body.app-mode-advanced .settings-size-inputs input {
        width: 50%;
    }

    body.app-mode-advanced .settings-sample-radius input[type="range"] {
        height: 36px;
    }

    body.app-mode-advanced .settings-sample-radius input[type="number"] {
        width: 62px;
        height: 42px;
    }

    body.app-mode-advanced #color-preview {
        width: 100%;
        min-width: 0;
        height: 74px;
        align-self: stretch;
    }

    body.app-mode-advanced .settings-actions {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 7px;
    }

    body.app-mode-advanced .main-layout {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: 0;
        overflow: visible;
        padding: 0 8px 12px;
        gap: 10px;
    }

    body.app-mode-advanced #ref-panel {
        flex: none;
        width: 100%;
        height: 58vh;
        height: 58dvh;
        min-height: 390px;
        max-height: 620px;
        border-radius: 10px;
    }

    body.app-mode-advanced .toolbar {
        min-height: 52px;
        padding: 7px 8px;
        gap: 7px;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    body.app-mode-advanced .toolbar > * {
        flex: 0 0 auto;
    }

    body.app-mode-advanced .toolbar > span:first-child,
    body.app-mode-advanced .toolbar > div {
        display: none;
    }

    body.app-mode-advanced .btn-zoom,
    body.app-mode-advanced .btn-ocr {
        min-height: 38px;
        padding: 7px 11px;
        border-radius: 8px;
        touch-action: manipulation;
    }

    body.app-mode-advanced #viewport {
        height: auto;
        min-height: 0;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    body.app-mode-advanced canvas#display-canvas {
        touch-action: none;
    }

    body.app-mode-advanced .side-panels {
        flex: none;
        width: 100%;
        max-width: none;
        min-width: 0;
        height: auto;
        min-height: 310px;
    }

    body.app-mode-advanced .list-panel {
        min-height: 310px;
        padding: 10px;
    }

    body.app-mode-advanced .list-panel-toolbar {
        align-items: flex-start;
    }

    body.app-mode-advanced .list-sort-buttons {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    body.app-mode-advanced .btn-add-list {
        min-width: 62px;
        height: 42px;
    }

    body.app-mode-advanced .btn-sort,
    body.app-mode-advanced .list-sort-buttons .btn-red {
        min-height: 36px;
        padding: 7px 9px !important;
        font-size: 0.72rem !important;
    }

    body.app-mode-advanced .image-list {
        min-height: 220px;
        max-height: 48vh;
        max-height: 48dvh;
    }

    body.app-mode-advanced .list-item {
        min-height: 58px;
        padding: 8px;
    }

    body.app-mode-advanced .list-actions .btn-action,
    body.app-mode-advanced .info-badge-btn {
        min-width: 38px;
        width: 38px;
        height: 38px;
    }

    body.app-mode-advanced #modal-overlay,
    body.app-mode-advanced #ref-modal-overlay,
    body.app-mode-advanced #info-modal-overlay,
    body.app-mode-advanced #saved-lists-modal-overlay,
    body.app-mode-advanced #color-search-modal-overlay,
    body.app-mode-advanced #ral-search-modal-overlay,
    body.app-mode-advanced #ral-edit-modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    body.app-mode-advanced .modal,
    body.app-mode-advanced .ral-search-modal,
    body.app-mode-advanced .ral-edit-modal {
        width: 100%;
        max-width: none;
        max-height: 96vh;
        max-height: 96dvh;
        margin: 0;
        padding: 16px;
        border-radius: 16px 16px 0 0;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    body.app-mode-advanced .modal-large > div:first-child,
    body.app-mode-advanced .info-modal-toolbar,
    body.app-mode-advanced .palette-print-controls-row {
        flex-wrap: wrap;
        gap: 8px;
    }

    body.app-mode-advanced .ref-table-wrap,
    body.app-mode-advanced .info-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    body.app-mode-advanced .ref-table {
        min-width: 680px;
    }

    body.app-mode-advanced .ral-search-body {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    body.app-mode-advanced .ral-search-left,
    body.app-mode-advanced .ral-search-right {
        min-height: 260px;
    }

    body.app-mode-advanced .ral-source-pills {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
    }

    body.app-mode-advanced .ral-pill {
        flex: 0 0 auto;
        min-height: 38px;
    }

    body.app-mode-advanced .ral-search-row {
        align-items: flex-start;
    }

    body.app-mode-advanced .ral-search-actions {
        width: 100%;
    }

    body.app-mode-advanced .ral-action-btn {
        min-height: 36px;
    }
}

@media (max-width: 520px) {
    body.app-mode-advanced .brand-title {
        display: none;
    }

    body.app-mode-advanced .settings-row {
        grid-template-columns: 1fr;
    }

    body.app-mode-advanced .settings-name,
    body.app-mode-advanced .settings-actions {
        grid-column: auto;
    }

    body.app-mode-advanced .settings-actions {
        grid-template-columns: 1fr;
    }

    body.app-mode-advanced .settings-ref-actions {
        flex-direction: column;
    }

    body.app-mode-advanced #ref-panel {
        height: 54vh;
        height: 54dvh;
        min-height: 360px;
    }

    body.app-mode-advanced .list-panel-toolbar {
        flex-direction: column;
    }

    body.app-mode-advanced .list-panel-actions {
        width: 100%;
        margin-left: 0;
    }

    body.app-mode-advanced .list-sort-group,
    body.app-mode-advanced .list-sort-buttons {
        width: 100%;
    }

    body.app-mode-advanced .list-sort-buttons {
        justify-content: stretch;
    }

    body.app-mode-advanced .list-sort-buttons .btn {
        flex: 1;
    }

    body.app-mode-advanced .edit-color-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    body.app-mode-advanced .edit-color-actions .btn-red {
        grid-column: 1 / -1;
    }
}

@media (max-width: 768px) {
    body.app-mode-simple {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
    }

    body.app-mode-simple header {
        display: none;
    }

    body.app-mode-simple .mode-simple-view {
        flex: none;
        width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        height: auto;
        justify-content: flex-start;
        overflow: visible;
        padding: clamp(34px, 8vh, 72px) 12px 16px;
        padding-bottom: calc(16px + var(--keyboard-inset, 0px));
    }

    body.app-mode-simple .simple-search-stage {
        width: min(560px, 100%);
        margin: 0;
        padding: 20px 14px;
        border: 1px solid transparent;
        border-radius: 18px;
    }

    body.app-mode-simple .simple-color-wheel-control {
        align-self: center;
        margin-left: auto;
        margin-right: auto;
    }

    body.app-mode-simple .mode-simple-view.has-quad-bg .simple-search-stage {
        padding: 20px 14px;
    }

    body.app-mode-simple .simple-bg-quads {
        position: fixed;
        inset: 0;
    }

    body.app-mode-simple .simple-search-results {
        min-height: 0;
    }

    body.app-mode-simple .simple-disclaimer {
        margin-top: 24px;
        padding-bottom: max(4px, env(safe-area-inset-bottom));
    }

    body.app-mode-simple .simple-search-input {
        height: 48px;
        padding: 0 12px;
        font-size: 0.92rem;
    }

    body.app-mode-simple .simple-eyedropper-btn {
        width: 48px;
        height: 48px;
    }

    body.app-mode-simple #simple-camera-preview-overlay {
        align-items: flex-end;
        padding: 0;
    }

    body.app-mode-simple .simple-camera-preview-modal {
        width: 100%;
        max-height: 96vh;
        max-height: 96dvh;
        border-radius: 18px 18px 0 0;
        padding-bottom: max(18px, env(safe-area-inset-bottom));
    }
}

/* Con tastiera virtuale: scroll sempre abilitato, indipendente dall'altezza viewport. */
html.keyboard-open,
html.keyboard-open body,
body.app-mode-simple.keyboard-open {
    height: auto !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y !important;
}
body.app-mode-simple.keyboard-open .mode-simple-view {
    flex: none !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    justify-content: flex-start !important;
    padding-bottom: calc(48px + var(--keyboard-inset, 0px)) !important;
    touch-action: pan-y !important;
}
body.app-mode-simple.keyboard-open .simple-color-wheel-wrap,
body.app-mode-simple.keyboard-open .simple-color-wheel,
body.app-mode-simple.keyboard-open .simple-favorite-slot,
body.app-mode-simple.keyboard-open .simple-color-list-item {
    touch-action: pan-y !important;
}
body.app-mode-simple.keyboard-open .simple-favorites-palette,
body.app-mode-simple.keyboard-open .simple-color-list-dashboard {
    max-height: min(42vh, calc(100svh - 72px)) !important;
}

/* Desktop con mouse: ripristina stage largo e centrato, senza layout tablet. */
@media (hover: hover) and (pointer: fine) {
    body.app-mode-simple .mode-simple-view {
        justify-content: center;
        align-items: center;
        overflow: hidden;
        height: auto;
        min-height: 0;
        max-height: none;
        padding: 24px 16px 20px;
    }

    body.app-mode-simple .simple-search-stage {
        width: min(560px, 100%);
        max-width: 560px;
        min-width: 0;
        max-height: none;
        margin: auto;
        overflow: visible;
        padding: 0;
        border: none;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }

    body.app-mode-simple .mode-simple-view.has-quad-bg .simple-search-stage {
        padding: 20px 18px;
        border: 1px solid rgba(255,255,255,0.08);
        border-radius: 18px;
        background: rgba(0, 0, 0, 0.48);
        box-shadow: 0 16px 50px rgba(0,0,0,0.35);
    }

    body.app-mode-simple .simple-search-row-input {
        width: 100%;
        gap: 10px;
    }

    body.app-mode-simple .simple-search-field {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
    }

    body.app-mode-simple .simple-search-input {
        height: 52px;
        font-size: 1.05rem;
        padding: 0 18px;
    }

    body.app-mode-simple .simple-eyedropper-btn {
        width: 52px;
        height: 52px;
        border-radius: 12px;
    }
}

/* Tablet: strumenti completi e dashboard laterali, mantenendo esclusi gli smartphone.
   Nessun min-height: con tastiera aperta l'altezza cala e le regole sparirebbero. */
@media (min-width: 600px) and (max-width: 1600px) and (hover: none) and (any-pointer: coarse) {
    html,
    body.app-mode-simple {
        height: 100%;
        max-height: 100%;
        overflow: hidden;
    }

    body.app-mode-simple {
        min-height: 0;
        -webkit-overflow-scrolling: touch;
    }

    body.app-mode-simple .mode-simple-view {
        flex: 1 1 auto;
        width: 100%;
        height: 100%;
        max-height: 100dvh;
        min-height: 0;
        justify-content: flex-start;
        align-items: center;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
        touch-action: pan-y;
        padding: 16px 12px 20px;
        padding-bottom: calc(20px + var(--keyboard-inset, 0px));
    }

    body.app-mode-simple .simple-bg-quads {
        position: fixed;
        inset: 0;
    }

    body.app-mode-simple .simple-camera-btn {
        display: inline-flex;
    }

    body.app-mode-simple #simple-eyedropper-btn {
        display: none;
    }

    body.app-mode-simple .simple-favorite-add-btn,
    body.app-mode-simple .simple-favorites-palette,
    body.app-mode-simple .simple-color-list-dashboard {
        display: flex !important;
    }

    body.app-mode-simple .simple-search-stage {
        width: min(520px, calc(100% - 120px));
        min-width: 0;
        max-height: calc(100dvh - 32px - var(--keyboard-inset, 0px));
        margin: 0 auto;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        touch-action: pan-y;
        padding: 16px 14px;
        border: 1px solid rgba(255,255,255,0.08);
        border-radius: 18px;
        background: rgba(0, 0, 0, 0.55);
        scrollbar-width: thin;
        scrollbar-color: #393939 #0b0b0b;
    }

    body.app-mode-simple .simple-search-stage.has-results {
        gap: 10px;
        max-height: calc(100dvh - 24px - var(--keyboard-inset, 0px));
    }

    body.app-mode-simple .simple-search-stage.has-results .simple-stage-brand {
        margin-bottom: 2px;
        gap: 6px;
    }

    body.app-mode-simple .simple-search-stage.has-results .simple-color-wheel-control {
        margin-bottom: 0;
        gap: 6px;
    }

    body.app-mode-simple .simple-search-stage.has-results .simple-search-title {
        font-size: 1.35rem;
        margin: 0;
    }

    body.app-mode-simple .simple-search-stage.has-results .simple-search-subtitle {
        margin: 0;
    }

    body.app-mode-simple .simple-search-results {
        flex: 0 0 auto;
        min-height: 0;
    }

    body.app-mode-simple .simple-disclaimer {
        flex: 0 0 auto;
        margin-top: 16px;
    }

    body.app-mode-simple .simple-favorites-palette {
        top: 28px;
        left: 10px;
        width: 150px;
        max-height: calc(100dvh - 56px - var(--keyboard-inset, 0px));
    }

    body.app-mode-simple .simple-color-list-dashboard {
        top: 28px;
        right: 10px;
        width: 150px;
        max-height: calc(100dvh - 56px - var(--keyboard-inset, 0px));
    }

    body.app-mode-simple .simple-favorites-palette.is-collapsed,
    body.app-mode-simple .simple-color-list-dashboard.is-collapsed {
        width: 48px;
    }

    body.app-mode-simple .simple-favorite-slot {
        height: 92px;
    }

    body.app-mode-simple .simple-search-row-input {
        gap: 7px;
    }

    body.app-mode-simple .simple-eyedropper-btn {
        width: 46px;
        height: 46px;
        border-radius: 11px;
    }
}

/* Tablet + tastiera: la card centrale resta la zona scrollabile principale. */
@media (min-width: 600px) and (max-width: 1600px) and (hover: none) and (any-pointer: coarse) {
    body.app-mode-simple.keyboard-open,
    html.keyboard-open body.app-mode-simple {
        height: 100% !important;
        max-height: 100% !important;
        overflow: hidden !important;
    }

    body.app-mode-simple.keyboard-open .mode-simple-view {
        height: 100% !important;
        max-height: 100dvh !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        padding-bottom: calc(16px + var(--keyboard-inset, 0px)) !important;
    }

    body.app-mode-simple.keyboard-open .simple-search-stage {
        max-height: calc(100dvh - 20px - var(--keyboard-inset, 0px)) !important;
        overflow-y: auto !important;
        touch-action: pan-y !important;
    }
}
