:root {
    --ink: #1f1712;
    --muted: #736252;
    --line: rgba(77, 58, 43, 0.12);
    --accent: #dc7c32;
    --accent-soft: rgba(220, 124, 50, 0.12);
    --active-color: #ff7a00;
    --screen-top: #fffefb;
    --screen-bottom: #f5ecdf;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
/* Uma única scrollbar (tom do viewer original) — no documento, não no .screen */
html {
    scrollbar-width: thin;
    scrollbar-color: rgba(151, 108, 74, 0.85) transparent;
}
html::-webkit-scrollbar { width: 10px; }
html::-webkit-scrollbar-track { background: transparent; }
html::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(187,142,102,.95), rgba(124,88,59,.95));
}
body {
    font-family: "Trebuchet MS", Verdana, sans-serif;
    background: #fff;
    color: var(--ink);
}
h1,h2,h3,p { margin: 0; }
.viewer {
    border-radius: 34px;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: 0 28px 62px rgba(72, 51, 30, 0.12);
    padding: 22px;
}
/* Conteúdo edge-to-edge: sem caixa centrada nem padding lateral do viewer */
.viewer--full {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}
/* Área de conteúdo: rolagem só no documento (html), não aqui */
.screen {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0;
    min-height: 0;
    overflow: visible;
    background: linear-gradient(180deg, var(--screen-top), var(--screen-bottom));
    padding: 0 0 24px;
}
.viewer--full .card {
    border-radius: 0;
    border-left: none;
    border-right: none;
}
.viewer--full .artboard-wrap {
    padding-left: 0;
    padding-right: 0;
}
.card {
    border-radius: 24px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,.88);
    box-shadow: 0 14px 34px rgba(80, 55, 30, 0.06);
}
.preview-card {
    overflow: hidden;
}
.preview-head {
    padding: 18px 18px 12px;
    background: radial-gradient(circle at top right, rgba(220,124,50,.12), transparent 34%), radial-gradient(circle at top left, rgba(102,171,255,.08), transparent 28%);
}
.preview-note {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    color: var(--muted);
    font-size: .82rem;
    line-height: 1.5;
}
.preview-note svg { width: 16px; height: 16px; flex: 0 0 16px; }
.preview-head h2 {
    font-family: Georgia, serif;
    font-size: 1.45rem;
}
.mode-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 12px;
    padding: 6px;
    border-radius: 18px;
    background: rgba(245, 236, 223, 0.9);
    border: 1px solid rgba(77, 58, 43, 0.08);
}
.mode-tab {
    min-height: 42px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--muted);
    font-weight: 700;
    cursor: pointer;
}
.mode-tab.active {
    background: #fff;
    color: var(--ink);
    box-shadow: inset 0 0 0 1px rgba(220, 124, 50, 0.18);
}
.artboard-wrap {
    padding: 0 14px 14px;
}
.artboard {
    position: relative;
    min-height: 360px;
    border-radius: 22px;
    overflow: hidden;
    border: 1px solid rgba(77, 58, 43, 0.1);
    /* Moldura ao redor do desenho: xadrez + creme (o branco “papel” fica só na área mascarada — .base-image / canvas) */
    background:
        linear-gradient(45deg, rgba(230,220,207,.55) 25%, transparent 25%, transparent 75%, rgba(230,220,207,.55) 75%),
        linear-gradient(45deg, rgba(230,220,207,.55) 25%, transparent 25%, transparent 75%, rgba(230,220,207,.55) 75%),
        linear-gradient(180deg, #fff, #f8efe2);
    background-position: 0 0, 12px 12px, 0 0;
    background-size: 24px 24px, 24px 24px, auto;
}
.artboard-paper,
.base-image,
.draw-outline,
.compare-color,
.compare-user-bg,
.compare-user-paint,
.compare-user-outline,
.paint-layer {
    position: absolute;
    inset: 14px;
    width: calc(100% - 28px);
    height: calc(100% - 28px);
}
.artboard-paper {
    pointer-events: none;
    background: #fff;
    -webkit-mask-image: var(--mask-url);
    mask-image: var(--mask-url);
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
}
.base-image,
.draw-outline,
.compare-color,
.compare-user-outline {
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}
.base-image {
    background: #fff;
}
.base-image,
.paint-layer,
.compare-user-bg,
.compare-user-paint {
    -webkit-mask-image: var(--mask-url);
    mask-image: var(--mask-url);
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
}
.paint-layer {
    touch-action: none;
}
.paint-layer.tool-eyedropper {
    cursor: crosshair;
}
.base-image,
.draw-outline {
    pointer-events: none;
}
.draw-outline {
    mix-blend-mode: multiply;
}
.brush-cursor {
    position: absolute;
    inset: 14px auto auto 14px;
    width: 24px;
    height: 24px;
    margin-left: calc(var(--cursor-x, 0px) - 12px);
    margin-top: calc(var(--cursor-y, 0px) - 12px);
    border-radius: 999px;
    border: 1.5px solid rgba(0,0,0,.78);
    background: rgba(255,255,255,.08);
    box-shadow: 0 0 0 1px rgba(255,255,255,.55) inset;
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    transition: opacity .12s ease;
}
.brush-cursor.visible {
    opacity: 1;
}
.compare-shell { display: none; }
.compare-shell.active { display: block; }
.draw-shell {
    position: relative;
    display: none;
}
/* Só filhos absolute: sem altura o pai fica a 0 px e calc(100% - 28px) no img/canvas fica invisível.
   Referência parecia OK porque a imagem colorida força reflow; modo Desenho ficava vazio. */
.draw-shell.active,
.compare-shell.active {
    min-height: 360px;
}
.draw-shell.active { display: block; }
.compare-user-bg,
.compare-user-paint,
.compare-user-outline {
    clip-path: inset(0 calc(100% - var(--divider, 26%)) 0 0);
}
.compare-user-outline {
    mix-blend-mode: multiply;
    pointer-events: none;
}
.compare-user-bg {
    background: #fff;
}
.divider-line {
    position: absolute;
    top: 14px;
    bottom: 14px;
    left: var(--divider, 26%);
    width: 2px;
    background: rgba(31, 23, 18, 0.7);
    transform: translateX(-1px);
    box-shadow: 0 0 0 6px rgba(255,255,255,0.3);
    border-radius: 999px;
    pointer-events: none;
}
.tools,
.compare-tools {
    display: grid;
    gap: 10px;
    padding: 14px;
}
.compare-tools {
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 18px;
    z-index: 4;
    padding: 12px 14px;
    border-radius: 18px;
    border: 1px solid rgba(77,58,43,.1);
    background: rgba(255,255,255,.92);
    box-shadow: 0 12px 28px rgba(40, 28, 18, .12);
}
.tool-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.chip,
.ghost-btn,
.more-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    border-radius: 999px;
    border: 1px solid rgba(77, 58, 43, 0.12);
    background: rgba(255,255,255,.92);
    color: var(--ink);
    padding: 0 14px;
    cursor: pointer;
}
.chip svg,
.ghost-btn svg {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    display: block;
}
.chip.icon-only,
.ghost-btn.icon-only {
    width: 42px;
    min-width: 42px;
    padding: 0;
    gap: 0;
}
.chip.active {
    background: rgba(255,241,226,.96);
    border-color: rgba(220, 124, 50, 0.28);
}
.color-input {
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}
.palette-presets {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 4px 0 2px;
}
.palette-swatch {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 2px solid rgba(77, 58, 43, 0.25);
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.palette-swatch:hover {
    transform: scale(1.08);
}
.palette-swatch[aria-pressed="true"] {
    box-shadow: 0 0 0 2px #dc7c32, inset 0 0 0 1px rgba(255, 255, 255, 0.4);
    border-color: rgba(31, 23, 18, 0.55);
}
[data-theme="dark"] .palette-swatch {
    border-color: rgba(130, 165, 255, 0.28);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
[data-theme="dark"] .palette-swatch[aria-pressed="true"] {
    box-shadow: 0 0 0 2px #5eead4, inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.range {
    width: 100%;
    appearance: none;
    background: transparent;
}
.range::-webkit-slider-runnable-track {
    height: 10px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--active-color), color-mix(in srgb, var(--active-color) 72%, white));
    box-shadow: inset 0 0 0 1.5px rgba(0,0,0,.75);
}
.range::-webkit-slider-thumb {
    appearance: none;
    margin-top: -5px;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    border: 2px solid #111;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,.18);
}
.range::-moz-range-track {
    height: 10px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--active-color), color-mix(in srgb, var(--active-color) 72%, white));
    box-shadow: inset 0 0 0 1.5px rgba(0,0,0,.75);
}
.range::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border: 2px solid #111;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,.18);
}
.slider-block {
    display: grid;
    gap: 8px;
}
.slider-head {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
    font-size: .84rem;
    font-weight: 700;
}
.slider-head svg { width: 16px; height: 16px; flex: 0 0 16px; }
.slider-copy {
    color: var(--muted);
    font-size: .76rem;
    line-height: 1.45;
}
.list-card {
    position: relative;
    margin-top: 14px;
    padding: 14px;
}
.list-card h3 {
    font-family: Georgia, serif;
    font-size: 1.15rem;
    margin-bottom: 10px;
}
.drawing-list {
    display: grid;
    gap: 10px;
    position: relative;
}
.drawing-item {
    display: grid;
    grid-template-columns: 66px 1fr;
    gap: 10px;
    align-items: center;
    width: 100%;
    padding: 10px;
    border-radius: 18px;
    border: 1px solid rgba(77, 58, 43, 0.08);
    background: rgba(255,255,255,.9);
    color: var(--ink);
    text-align: left;
    cursor: pointer;
}
.drawing-item.active {
    background: rgba(255,241,226,.95);
    border-color: rgba(220, 124, 50, 0.26);
}
.drawing-thumb {
    width: 66px;
    height: 66px;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(77, 58, 43, 0.08);
    background:
        linear-gradient(45deg, rgba(230,220,207,.55) 25%, transparent 25%, transparent 75%, rgba(230,220,207,.55) 75%),
        linear-gradient(45deg, rgba(230,220,207,.55) 25%, transparent 25%, transparent 75%, rgba(230,220,207,.55) 75%),
        #fff;
    background-position: 0 0, 8px 8px, 0 0;
    background-size: 16px 16px;
}
.drawing-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: rgba(255,255,255,.88);
}
.drawing-copy strong {
    display: block;
    font-size: .92rem;
}
.fade-out {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 48px;
    height: 42px;
    background: linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,.95));
    pointer-events: none;
}
.list-actions {
    display: flex;
    justify-content: center;
    padding-top: 10px;
}
@media (max-width: 640px) {
    .viewer:not(.viewer--full) {
        padding: 14px;
    }
    .artboard {
        min-height: 320px;
    }
    .draw-shell.active,
    .compare-shell.active {
        min-height: 320px;
    }
}

/* —— Tema escuro (site completo: variáveis + viewer) —— */
[data-theme="dark"] {
    color-scheme: dark;
}

html[data-theme="dark"] {
    --ink: #e8ecf4;
    --muted: #94a3b8;
    --line: rgba(130, 165, 255, 0.14);
    --accent: #7c9cff;
    --accent-soft: rgba(124, 156, 255, 0.14);
    --active-color: #5eead4;
    --screen-top: #131820;
    --screen-bottom: #0a0d12;
}

[data-theme="dark"] html {
    scrollbar-color: rgba(130, 110, 90, 0.75) transparent;
}
[data-theme="dark"] html::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(110, 92, 76, 0.95), rgba(55, 48, 40, 0.98));
}

[data-theme="dark"] body {
    background: #0b0f14;
    color: var(--ink);
}

[data-theme="dark"] .screen {
    background: linear-gradient(180deg, var(--screen-top), var(--screen-bottom));
}

[data-theme="dark"] .card {
    background: rgba(18, 24, 34, 0.94);
    border-color: var(--line);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .preview-head {
    background: radial-gradient(circle at top right, rgba(124, 156, 255, 0.12), transparent 42%),
        radial-gradient(circle at top left, rgba(45, 212, 191, 0.06), transparent 36%);
}

[data-theme="dark"] .mode-tabs {
    background: rgba(16, 22, 32, 0.92);
    border-color: rgba(130, 165, 255, 0.12);
}

[data-theme="dark"] .mode-tab.active {
    background: #1c2534;
    color: var(--ink);
    box-shadow: inset 0 0 0 1px rgba(124, 156, 255, 0.35);
}

[data-theme="dark"] .artboard {
    border-color: rgba(130, 165, 255, 0.15);
    background:
        linear-gradient(45deg, rgba(40, 55, 75, 0.45) 25%, transparent 25%, transparent 75%, rgba(40, 55, 75, 0.45) 75%),
        linear-gradient(45deg, rgba(40, 55, 75, 0.45) 25%, transparent 25%, transparent 75%, rgba(40, 55, 75, 0.45) 75%),
        linear-gradient(180deg, #1a2230, #121820);
    background-position: 0 0, 12px 12px, 0 0;
    background-size: 24px 24px, 24px 24px, auto;
}

[data-theme="dark"] .divider-line {
    background: rgba(200, 210, 255, 0.45);
    box-shadow: 0 0 0 6px rgba(12, 16, 24, 0.55);
}

[data-theme="dark"] .compare-tools {
    background: rgba(16, 22, 32, 0.96);
    border-color: rgba(130, 165, 255, 0.14);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .chip,
[data-theme="dark"] .ghost-btn,
[data-theme="dark"] .more-btn {
    background: rgba(22, 30, 42, 0.95);
    border-color: rgba(130, 165, 255, 0.16);
    color: var(--ink);
}

[data-theme="dark"] .chip.active {
    background: rgba(35, 48, 72, 0.95);
    border-color: rgba(124, 156, 255, 0.45);
}

[data-theme="dark"] .drawing-item {
    background: rgba(18, 24, 34, 0.92);
    border-color: rgba(130, 165, 255, 0.1);
    color: var(--ink);
}

[data-theme="dark"] .drawing-item.active {
    background: rgba(30, 42, 62, 0.96);
    border-color: rgba(124, 156, 255, 0.4);
}

[data-theme="dark"] .drawing-thumb {
    border-color: rgba(130, 165, 255, 0.12);
    background: #141c28;
}

[data-theme="dark"] .drawing-thumb img {
    background: rgba(255, 255, 255, 0.04);
}

[data-theme="dark"] .fade-out {
    background: linear-gradient(180deg, rgba(14, 18, 26, 0), rgba(14, 18, 26, 0.97));
}

[data-theme="dark"] .brush-cursor {
    border-color: rgba(180, 200, 255, 0.9);
    background: rgba(0, 0, 0, 0.2);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4) inset;
}
