/* ═══════════════════════════════════════════════════════════════
   MISSANGAS JANE — Editor Web (desktop-first)
   Paleta: Rosa (#EC4899) · Ciano (#22D3EE) · Amarelo (#FCD34D)
           Roxo (#7C3AED) · Fundo (#FFF0F7)
   Fontes: Fredoka One (títulos/logo) · Nunito (interface)
═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@400;600;700;800;900&display=swap');

/* ── VARIÁVEIS ─────────────────────────────────────────────── */
:root {
    --pink:          #EC4899;
    --pink-hover:    #DB2777;
    --pink-light:    #FBCFE8;
    --pink-bg:       #FFF0F7;
    --cyan:          #22D3EE;
    --yellow:        #FCD34D;
    --orange:        #F97316;
    --purple:        #7C3AED;
    --purple-dark:   #4C1D95;

    --danger:        #EF4444;
    --danger-light:  #FEF2F2;
    --success:       #22C55E;

    --bg-app:        #FFF0F7;
    --bg-card:       #FFFFFF;
    --text:          #3B0764;
    --text-muted:    #A78BBA;
    --border:        rgba(236, 72, 153, 0.20);

    --shadow-card:   0 4px 20px rgba(236, 72, 153, 0.10);
    --shadow-btn:    0 4px 14px rgba(236, 72, 153, 0.35);
    --shadow-danger: 0 4px 14px rgba(239, 68,  68, 0.35);

    --radius:        20px;
    --radius-sm:     14px;
    --radius-xs:     10px;
    --radius-full:   999px;

    --header-h:      60px;
    --toolbar-w:     82px;     /* largura da toolbar esquerda */

    --skin-bg:       #FDDBB4;  /* alterado via JS */
}

/* ── RESET ─────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Nunito', 'Noto Sans JP', system-ui, sans-serif;
    background: var(--bg-app);
    color: var(--text);
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Transição suave ao mudar idioma */
body.lang-changing {
    opacity: 0.97;
    transition: opacity 0.1s ease-out;
}

.lucide {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke-width: 2.2;
}

/* ══════════════════════════════════════════════════════════════
   APP WRAPPER
══════════════════════════════════════════════════════════════ */
.app-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.platform-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: linear-gradient(135deg, rgba(252,211,77,0.32), rgba(251,207,232,0.75));
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 800;
    text-align: center;
}
.platform-banner a { color: var(--purple-dark); }

/* ══════════════════════════════════════════════════════════════
   HEADER
══════════════════════════════════════════════════════════════ */
.main-header {
    background: linear-gradient(135deg, #F9A8D4 0%, #EC4899 45%, #9333EA 100%);
    padding: 0 1.25rem;
    height: var(--header-h);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    box-shadow: 0 4px 24px rgba(147, 51, 234, 0.30);
    position: relative;
    z-index: 10;
}

/* Esquerda: logo + link de volta */
.header-left {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    min-width: 0;
}

/* Direita: botões de ação */
.header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-width: 0;
    flex-shrink: 0;
}

.logo-home-link,
.logo-home-link:visited,
.logo-home-link:hover,
.logo-home-link:focus,
.logo-home-link:active {
    color: inherit;
    text-decoration: none !important;
    border-radius: var(--radius-sm);
}

.logo-home-link .logo-title {
    text-decoration: none !important;
}

.logo-img {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-xs);
    object-fit: contain;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.30));
    flex-shrink: 0;
}

.logo-title {
    font-family: 'Fredoka One', cursive;
    font-size: 1.45rem;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0,0,0,0.22);
    white-space: nowrap;
}

.home-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: var(--radius-sm);
    border: 2px solid rgba(255,255,255,0.30);
    background: rgba(255,255,255,0.14);
    color: #fff;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 800;
    white-space: nowrap;
    backdrop-filter: blur(6px);
    transition: background 0.16s, transform 0.10s;
}
.home-link:hover   { background: rgba(255,255,255,0.26); text-decoration: none; }
.home-link:active  { transform: scale(0.96); }
.home-link .lucide { width: 18px; height: 18px; }
.home-link span { display: none; }

.header-divider {
    width: 1px;
    height: 24px;
    background: rgba(255,255,255,0.36);
    margin: 0 0.1rem;
}

.icon-btn {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255,255,255,0.28);
    background: rgba(255,255,255,0.14);
    border-radius: var(--radius-sm);
    color: #fff;
    cursor: pointer;
    transition: background 0.16s, transform 0.10s;
    flex-shrink: 0;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    touch-action: manipulation;
}
.icon-btn:hover    { background: rgba(255,255,255,0.28); }
.icon-btn:active   { transform: scale(0.90); }
.icon-btn:disabled { opacity: 0.35; cursor: default; transform: none; }

.icon-btn--accent {
    background: rgba(252,211,77,0.28);
    border-color: rgba(252,211,77,0.55);
}
.icon-btn--accent:hover { background: rgba(252,211,77,0.44); }

/* ── Seletor de idioma ───────────────────────────────────── */
.lang-picker {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.lang-picker-btn {
    gap: 3px;
    background: rgba(255,255,255,0.88);
    border-color: rgba(255,255,255,0.95);
    color: var(--purple-dark);
    box-shadow: 0 2px 10px rgba(76, 29, 149, 0.16);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    min-width: 48px;
}
.lang-picker-btn:hover {
    background: #ffffff;
    color: var(--pink-hover);
}

.lang-picker-btn .lucide { width: 14px; height: 14px; }

.lang-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #ffffff;
    border: 1.5px solid rgba(236, 72, 153, 0.22);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 28px rgba(76, 29, 149, 0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 2000;
    min-width: 64px;
    opacity: 1;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.lang-dropdown.hidden { display: none; }

.lang-option {
    background: #ffffff;
    border: none;
    padding: 0.45rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    cursor: pointer;
    text-align: center;
    transition: background 0.15s, color 0.15s;
    touch-action: manipulation;
}

.lang-option:hover {
    background: var(--purple-light);
    color: var(--purple-dark);
}

.icon-btn--save {
    background: rgba(34, 197, 94, 0.20);
    border-color: rgba(34, 197, 94, 0.45);
    position: relative;
}
.icon-btn--save:hover { background: rgba(34, 197, 94, 0.35); }

/* Ponto laranja = alterações não salvas */
.icon-btn--save.has-unsaved::after {
    content: '';
    position: absolute;
    top: 5px;
    right: 5px;
    width: 8px;
    height: 8px;
    background: var(--orange);
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.80);
}

/* ══════════════════════════════════════════════════════════════
   LAYOUT PRINCIPAL: 3 colunas
══════════════════════════════════════════════════════════════ */
.content-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ══════════════════════════════════════════════════════════════
   TOOLBAR ESQUERDA
══════════════════════════════════════════════════════════════ */
.left-toolbar {
    order: 0;
    width: var(--toolbar-w);
    background: var(--bg-card);
    border-right: 2px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0.5rem 0.375rem;
    gap: 0.1rem;
    flex-shrink: 0;
    overflow-y: auto;
    scrollbar-width: none;
    box-shadow: 2px 0 12px rgba(147, 51, 234, 0.06);
    z-index: 5;
}
.left-toolbar::-webkit-scrollbar { display: none; }

.tool-group {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.toolbar-divider {
    height: 1px;
    background: var(--border);
    margin: 0.375rem 0.5rem;
    flex-shrink: 0;
}

.toolbar-spacer { flex: 1; }

/* Botão de ferramenta — vertical (ícone + label) */
.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.22rem;
    width: 100%;
    padding: 0.5rem 0.25rem 0.45rem;
    min-height: 58px;
    border: 2px solid transparent;
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: 'Nunito', sans-serif;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.10s;
    -webkit-user-select: none;
    touch-action: manipulation;
}
.tool-btn .lucide { width: 20px; height: 20px; }

.tool-btn:hover {
    background: var(--pink-bg);
    color: var(--pink);
    border-color: var(--pink-light);
}
.tool-btn:active { transform: scale(0.92); }

/* Ferramentas modo (Lápis, Borracha, Balde, Reta, etc.) — selecionáveis */
.tool-btn.active {
    background: linear-gradient(135deg, #F9A8D4, #EC4899);
    border-color: transparent;
    color: #fff;
    box-shadow: var(--shadow-btn);
}

/* Ações instantâneas (Espelhar, Girar, Imagem) — não ficam "ativas" */
.tool-btn--action:hover {
    background: #EDE9FE;
    color: var(--purple);
    border-color: rgba(124, 58, 237, 0.20);
}

/* Perigo (Apagar) */
.tool-btn--danger { color: var(--danger); }
.tool-btn--danger:hover {
    background: var(--danger-light);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.25);
}

/* ══════════════════════════════════════════════════════════════
   ÁREA DO CANVAS (centro)
══════════════════════════════════════════════════════════════ */
.canvas-area {
    order: 1;
    flex: 1;
    background: var(--bg-app);
    overflow: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0.875rem 1rem;
    gap: 0.75rem;
    touch-action: none;
    position: relative;
    min-width: 0;
}

/* ── CONTROLES: linhas, tom de pele, zoom ──────────────────── */
.canvas-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-shrink: 0;
    flex-wrap: wrap;
    width: 100%;
}

/* Controles de linhas e colunas */
.cols-control,
.rows-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    padding: 0.35rem 0.875rem;
    box-shadow: var(--shadow-card);
}

.ctrl-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
    touch-action: manipulation;
}
.ctrl-btn:hover { background: var(--pink-bg); color: var(--pink); }
.ctrl-btn:active { transform: scale(0.88); }
.ctrl-btn .lucide { width: 15px; height: 15px; }

.ctrl-label {
    font-family: 'Nunito', sans-serif;
    font-size: 0.80rem;
    font-weight: 700;
    color: var(--text-muted);
    white-space: nowrap;
    user-select: none;
}
.ctrl-label strong {
    color: var(--text);
    font-weight: 900;
    font-family: 'Fredoka One', cursive;
    font-size: 1rem;
}

/* Seletor de tom de pele */
.skin-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    padding: 0.35rem 0.875rem;
    box-shadow: var(--shadow-card);
}

.skin-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
    flex-shrink: 0;
    touch-action: manipulation;
}
.skin-btn[data-skin="wood"] {
    background-color: #C8935A;
    background-image:
        repeating-linear-gradient(92deg,
            transparent 0px, transparent 3px,
            rgba(0,0,0,0.25) 3px, rgba(0,0,0,0.25) 4px,
            transparent 4px, transparent 7px,
            rgba(255,255,255,0.2) 7px, rgba(255,255,255,0.2) 8px);
}
.skin-btn[data-skin="pale"]   { background: #FFE0C4; }
.skin-btn[data-skin="light"]  { background: #FDDBB4; }
.skin-btn[data-skin="medium"] { background: #C8895A; }
.skin-btn[data-skin="dark"]   { background: #7D4E2D; }
.skin-btn[data-skin="deep"]   { background: #4A2C17; }

.skin-btn.active {
    border-color: var(--purple);
    transform: scale(1.20);
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.25);
}
.skin-btn:hover:not(.active) { transform: scale(1.10); }

/* Barra de zoom */
.zoom-bar {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    padding: 0.35rem 1rem;
    box-shadow: var(--shadow-card);
    flex-shrink: 0;
}

.zoom-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.15s, color 0.15s;
    touch-action: manipulation;
}
.zoom-btn:hover { background: var(--pink-bg); color: var(--pink); }
.zoom-btn .lucide { width: 18px; height: 18px; }

#input-zoom {
    width: 120px;
    cursor: pointer;
    accent-color: var(--pink);
}

/* ── WRAPPER E GRADE ───────────────────────────────────────── */
.canvas-wrapper {
    background: var(--skin-bg, #FDDBB4);
    padding: 0.75rem;
    box-shadow: var(--shadow-card), inset 0 2px 8px rgba(0,0,0,0.07);
    border-radius: var(--radius);
    border: 2px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    position: relative;
    touch-action: none;
    flex-shrink: 0;
    transition: background 0.30s ease;
}

/* Textura de madeira */
.canvas-wrapper.wood-mode {
    background-color: #C8935A;
    background-image:
        repeating-linear-gradient(92deg,
            transparent 0px,             transparent 5px,
            rgba(0,0,0,0.045) 5px,       rgba(0,0,0,0.045) 6px,
            transparent 6px,             transparent 11px,
            rgba(255,255,255,0.06) 11px, rgba(255,255,255,0.06) 12px,
            transparent 12px,            transparent 19px,
            rgba(0,0,0,0.03) 19px,       rgba(0,0,0,0.03) 20px,
            transparent 20px,            transparent 27px,
            rgba(255,255,255,0.04) 27px, rgba(255,255,255,0.04) 28px),
        repeating-linear-gradient(180deg,
            rgba(0,0,0,0.02) 0px, rgba(0,0,0,0.02) 1px,
            transparent 1px, transparent 8px);
    border-color: rgba(100,60,20,0.4);
    box-shadow: 0 4px 24px rgba(0,0,0,0.18), inset 0 2px 8px rgba(0,0,0,0.12);
}

/* Fios horizontais — ficam no gap entre linhas de miçangas */
.canvas-wrapper::before {
    content: '';
    position: absolute;
    left: 0.75rem;
    right: 0.75rem;
    top: 0;
    bottom: 0;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent calc(var(--cell-gap-size, 31px) - 1px),
        rgba(0, 0, 0, 0.18) calc(var(--cell-gap-size, 31px) - 1px),
        rgba(0, 0, 0, 0.18) calc(var(--cell-gap-size, 31px))
    );
    background-position: 0 calc(var(--thread-offset, 12px));
    pointer-events: none;
    z-index: 0;
    border-radius: inherit;
}


/* Guia de linhas (números) */
.thread-guide {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    padding-top: 2px;
}

.thread-number {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Fredoka One', cursive;
    font-size: 0.68rem;
    color: rgba(0,0,0,0.28);
    font-variant-numeric: tabular-nums;
    user-select: none;
}

/* Grade de missangas */
.grid-canvas {
    display: grid;
    touch-action: none;
    position: relative;
    z-index: 1;
    gap: 3px;
    padding: 2px;
    /* Fios de urdume verticais no background — aparecem nas células vazias
       (transparentes) e somem atrás das pintadas (fundo sólido) */
    background-image: repeating-linear-gradient(
        to right,
        rgba(0, 0, 0, 0.18) 0,
        rgba(0, 0, 0, 0.18) 1px,
        transparent 1px,
        transparent var(--cell-gap-size, 31px)
    );
    background-position: calc(var(--cell-gap-size, 31px) / 2 + 0.5px) 0;
}

/* Célula = missanga */
.cell {
    border-radius: 50%;
    cursor: crosshair;
    transition: transform 0.08s;
    position: relative;
    box-shadow: inset 0 -2px 3px rgba(0,0,0,0.18), inset 0 1px 2px rgba(255,255,255,0.35);
}
.cell.is-empty {
    background: transparent;
    border: 1.5px dashed rgba(0,0,0,0.22);
    box-shadow: none;
}
.cell:hover { transform: scale(1.20); z-index: 2; }

/* ══════════════════════════════════════════════════════════════
   SIDEBAR DIREITA: PALETA DE CORES
══════════════════════════════════════════════════════════════ */
.sidebar {
    order: 2;
    width: clamp(120px, 14vw, 170px);
    background: var(--bg-app);
    padding: 0.75rem 0.625rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--pink-light) transparent;
}
.colors-sidebar { border-left: 2px solid var(--border); }

.palette-side-toggle {
    height: 24px;
    width: 100%;
    margin: 0 0 0.45rem;
    border: 2px solid var(--pink-light);
    border-radius: 11px 11px 4px 4px;
    background: linear-gradient(135deg, #ffffff, #FFF0F7);
    color: var(--purple-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(236, 72, 153, 0.12);
    touch-action: manipulation;
}

.palette-side-toggle::before {
    content: '';
    width: 22px;
    height: 14px;
    margin-right: 0.45rem;
    border-radius: 3px;
    background: linear-gradient(135deg, #F9A8D4, #FBCFE8);
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 1px rgba(236, 72, 153, 0.24);
}

.palette-side-toggle .lucide {
    width: 26px;
    height: 16px;
    stroke-width: 3;
}

.palette-side-toggle:hover {
    border-color: var(--pink);
    background: #ffffff;
    color: var(--pink-hover);
}

.content-layout.palette-left .colors-sidebar {
    order: 1;
    border-left: 0;
    border-right: 2px solid var(--border);
    box-shadow: 2px 0 12px rgba(147, 51, 234, 0.06);
}

.content-layout.palette-left .canvas-area {
    order: 2;
}

.content-layout.palette-left .palette-side-toggle .lucide {
    transform: rotate(180deg);
}

.sidebar-brand {
    display: flex;
    justify-content: center;
    padding: 0.75rem 0.25rem 0.25rem;
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    width: 100%;
    touch-action: manipulation;
}
.sidebar-brand-img {
    width: 100%;
    max-width: 130px;
    opacity: 0.90;
    transition: opacity 0.2s, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    filter: drop-shadow(0 4px 10px rgba(147,51,234,0.18));
}
.sidebar-brand:hover .sidebar-brand-img {
    opacity: 1;
    transform: scale(1.10);
}

.card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    flex: 1;
}

.card-label {
    font-family: 'Fredoka One', cursive;
    font-size: 0.76rem;
    color: var(--pink);
    text-transform: uppercase;
    letter-spacing: 0.09em;
}

/* Cor atual em destaque */
.current-color-display {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.625rem;
    background: var(--bg-app);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
}

.current-color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--orange);
    border: 3px solid rgba(0,0,0,0.10);
    box-shadow: 0 2px 10px rgba(0,0,0,0.18), inset 0 2px 4px rgba(255,255,255,0.20);
    transition: background 0.22s ease;
    flex-shrink: 0;
}

.current-color-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.current-color-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    line-height: 1.2;
}

.current-color-hex {
    font-family: 'Courier New', monospace;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Seletor de tipo de material (vidro, madeira, plástico…) */
.material-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    width: 100%;
}
.material-btn {
    flex: 1 1 auto;
    padding: 0.25rem 0.35rem;
    border: 1.5px solid #E5E7EB;
    border-radius: 6px;
    background: #FAFAFA;
    font-family: 'Nunito', sans-serif;
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.14s;
    text-align: center;
    white-space: nowrap;
    min-width: 0;
}
.material-btn:hover { border-color: var(--pink); color: var(--pink); background: #FFF0F7; }
.material-btn.active {
    border-color: var(--pink);
    background: var(--pink);
    color: #fff;
    box-shadow: 0 2px 6px rgba(236,72,153,0.30);
}

/* Badge de material no swatch da paleta */
.swatch-material-badge {
    position: absolute;
    bottom: 1px;
    right: 2px;
    font-size: 7px;
    font-weight: 900;
    color: rgba(255,255,255,0.9);
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
    line-height: 1;
    pointer-events: none;
    user-select: none;
    letter-spacing: -0.02em;
}

/* Paleta */
.palette-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));
    gap: 0.35rem;
    justify-items: center;
}

.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: transform 0.12s, box-shadow 0.18s, border-color 0.18s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.14);
    position: relative;
    touch-action: manipulation;
}
.color-swatch:hover  { transform: scale(1.14); }
.color-swatch:active { transform: scale(0.88); }

.color-swatch.selected {
    border-color: var(--purple-dark);
    box-shadow: 0 0 0 3px rgba(76,29,149,0.22), 0 4px 12px rgba(0,0,0,0.20);
    transform: scale(1.18);
}

.color-swatch.selected::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
    background-size: 18px;
    background-repeat: no-repeat;
    background-position: center;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.55));
}

/* ══════════════════════════════════════════════════════════════
   MODAIS
══════════════════════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(76,29,149,0.50);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.modal-box {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 2rem 1.5rem 1.5rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 24px 60px rgba(76,29,149,0.25);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.875rem;
    text-align: center;
    position: relative;
}

/* Botão X no canto superior direito dos modais */
.modal-close-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 32px;
    height: 32px;
    border: none;
    background: #F3F4F6;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.modal-close-btn:hover  { background: var(--danger-light); color: var(--danger); }
.modal-close-btn:active { transform: scale(0.90); }
.modal-close-btn .lucide { width: 16px; height: 16px; }

/* Texto auxiliar abaixo do botão de ação */
.modal-helper-text {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: -0.25rem;
}

.modal-box h2 {
    font-family: 'Fredoka One', cursive;
    font-size: 1.5rem;
    color: var(--text);
}

.modal-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.modal-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-icon--danger { background: var(--danger-light); color: var(--danger); }
.modal-icon .lucide { width: 30px; height: 30px; }

.modal-actions { display: flex; gap: 0.625rem; width: 100%; }

/* ── BOTÕES GENÉRICOS ──────────────────────────────────────── */
.btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem;
    border-radius: var(--radius-sm);
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    cursor: pointer;
    border: none;
    font-size: 0.95rem;
    transition: all 0.16s;
}
.btn:active { transform: scale(0.96); }

.btn--cancel { background: #F3F4F6; color: var(--text); }
.btn--cancel:hover { background: #E5E7EB; }

.btn--danger {
    background: linear-gradient(135deg, #FCA5A5, #EF4444);
    color: #fff;
    box-shadow: var(--shadow-danger);
}
.btn--danger:hover { background: linear-gradient(135deg, #F87171, #DC2626); }

.btn--pix {
    background: linear-gradient(135deg, #86EFAC, #22C55E);
    color: #fff;
    box-shadow: 0 4px 12px rgba(34,197,94,0.30);
    flex: none;
    width: 100%;
}
.btn--pix:hover { background: linear-gradient(135deg, #4ADE80, #16A34A); }

.btn--pink {
    background: linear-gradient(135deg, #F9A8D4, #EC4899);
    color: #fff;
    box-shadow: var(--shadow-btn);
    flex: none;
    width: 100%;
}
.btn--pink:hover  { background: linear-gradient(135deg, #F472B6, #DB2777); }
.btn--pink:active { transform: scale(0.96); }

/* ══════════════════════════════════════════════════════════════
   MODAL: CONTAGEM DE MISSANGAS
══════════════════════════════════════════════════════════════ */
.modal-box--count {
    max-width: 440px;
}

.modal-icon--count {
    background: linear-gradient(135deg, #EDE9FE, #DDD6FE);
    color: var(--purple);
}

.count-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 280px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--pink-light) transparent;
    padding-right: 0.25rem;
}

.count-group-header {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--purple);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.5rem 0.5rem 0.2rem;
    border-bottom: 1.5px solid rgba(124,58,237,0.15);
    margin-top: 0.35rem;
    width: 100%;
}
.count-group-header:first-child { margin-top: 0; }

.count-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-app);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}
.count-item:hover { background: #fff; }

.count-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid rgba(0,0,0,0.10);
    box-shadow: 0 1px 4px rgba(0,0,0,0.14);
}

.count-number {
    font-family: 'Fredoka One', cursive;
    font-size: 1.1rem;
    color: var(--text);
    min-width: 2.5rem;
    text-align: right;
    flex-shrink: 0;
}

.count-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* ══════════════════════════════════════════════════════════════
   PALETA: BOTÃO ADICIONAR COR PERSONALIZADA
══════════════════════════════════════════════════════════════ */
.palette-add-btn {
    grid-column: 1 / -1;
    width: 100%;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 2px dashed var(--pink-light);
    background: var(--pink-bg);
    color: var(--pink);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    font-size: 0.78rem;
    font-weight: 800;
    line-height: 1;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.palette-add-btn:hover {
    border-color: var(--pink);
    border-style: solid;
    background: #fce7f3;
}
.palette-add-btn:active { transform: scale(0.97); }

/* × real para remover cor personalizada */
.custom-remove-btn {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    background: var(--danger);
    color: #fff;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 900;
    line-height: 16px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.15s;
    cursor: pointer;
    z-index: 3;
}
.color-swatch--custom:hover .custom-remove-btn { opacity: 1; }

/* ══════════════════════════════════════════════════════════════
   MODAL: TEXTO EM MISSANGAS
══════════════════════════════════════════════════════════════ */
.modal-box--text {
    max-width: 400px;
}

.modal-icon--text {
    background: linear-gradient(135deg, #F3E8FF, #E9D5FF);
    color: var(--purple);
}

.text-pattern-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Fredoka One', cursive;
    font-size: 1.5rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text);
    background: var(--bg-app);
    outline: none;
    transition: border-color 0.15s;
}
.text-pattern-input:focus { border-color: var(--purple); }
.text-pattern-input::placeholder {
    color: var(--text-muted);
    font-size: 1rem;
    letter-spacing: 0;
}

.text-pattern-hint {
    font-size: 0.78rem;
    font-weight: 600;
    min-height: 1.1em;
    color: var(--text-muted);
    text-align: center;
}
.text-pattern-hint--error { color: var(--danger); }
.text-pattern-hint--ok    { color: var(--success); }

/* Botão de ampliar grade (aparece quando texto não cabe) */
.text-expand-btn {
    flex: none;
    width: 100%;
    font-size: 0.85rem;
    padding: 0.6rem 0.875rem;
    background: linear-gradient(135deg, #EDE9FE, #C4B5FD);
    color: var(--purple-dark);
    box-shadow: 0 4px 12px rgba(124,58,237,0.18);
}
.text-expand-btn:hover {
    background: linear-gradient(135deg, #DDD6FE, #A78BFA);
}

/* Bloco de opções Pro */
.text-pattern-options {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-app);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
}

.text-option-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.text-option-label {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.text-option-btns {
    display: flex;
    gap: 0.4rem;
}

.text-opt-btn {
    flex: 1;
    padding: 0.4rem 0.5rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-muted);
    font-family: 'Nunito', sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}
.text-opt-btn:hover  { border-color: var(--purple); color: var(--purple); }
.text-opt-btn.active {
    background: var(--purple);
    border-color: var(--purple);
    color: #fff;
}

.text-option-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
}
.text-option-checkbox input[type="checkbox"] { accent-color: var(--purple); }

/* ══════════════════════════════════════════════════════════════
   BARRA DE TAREFAS FIXA (rodapé do app)
══════════════════════════════════════════════════════════════ */
.bottom-taskbar {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0 1rem;
    height: 48px;
    background: var(--bg-card);
    border-top: 2px solid var(--border);
    box-shadow: 0 -2px 12px rgba(147, 51, 234, 0.06);
    flex-shrink: 0;
    position: relative;
    z-index: 6;
}

.taskbar-sep {
    width: 1px;
    height: 28px;
    background: var(--border);
    flex-shrink: 0;
}

.taskbar-spacer { flex: 1; min-width: 0; }

/* ── Botão ⚙ Grade + popover ─────────────────────────────── */
.taskbar-grid-wrap {
    position: relative;
    flex-shrink: 0;
}

.taskbar-grid-btn {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.65rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-xs);
    background: var(--bg-app);
    color: var(--text-muted);
    font-family: 'Nunito', sans-serif;
    font-size: 0.75rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    touch-action: manipulation;
}
.taskbar-grid-btn .lucide { width: 14px; height: 14px; }
.taskbar-grid-btn:hover  { border-color: var(--pink); color: var(--pink); background: var(--pink-bg); }
.taskbar-grid-btn.active { border-color: var(--pink); color: var(--pink); background: var(--pink-bg); }

.taskbar-chevron { transition: transform 0.22s; }
.taskbar-grid-btn.active .taskbar-chevron { transform: rotate(180deg); }

/* Popover — flutua acima da barra */
.grid-popover {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 0.875rem 1rem;
    box-shadow: 0 -6px 28px rgba(147, 51, 234, 0.14), var(--shadow-card);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 230px;
    z-index: 30;
}
.grid-popover.hidden { display: none; }

.popover-divider {
    height: 1px;
    background: var(--border);
    margin: 0.2rem 0;
}

/* Controles de grade dentro do popover */
.grid-popover .rows-control,
.grid-popover .cols-control {
    background: var(--bg-app);
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    padding: 0.3rem 0.75rem;
    box-shadow: none;
}

/* Tom de pele dentro do popover */
.grid-popover .skin-selector {
    background: var(--bg-app);
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    padding: 0.3rem 0.75rem;
    box-shadow: none;
    justify-content: center;
}

/* Selector de tamanho de miçanga */
.info-bead-size {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-app);
    border-radius: var(--radius-xs);
    padding: 2px;
}

.bead-size-btn {
    padding: 0.25rem 0.6rem;
    border: 1.5px solid transparent;
    border-radius: calc(var(--radius-xs) - 2px);
    background: transparent;
    font-family: 'Nunito', sans-serif;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    touch-action: manipulation;
}
.bead-size-btn.active {
    background: #fff;
    border-color: var(--border);
    color: var(--text);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.bead-size-btn:hover:not(.active) { color: var(--purple); }

/* Alternar rótulos por modo */
.bead-label-mm { display: none; }
body.mode-pro .bead-label-mm   { display: inline; }
body.mode-pro .bead-label-short { display: none; }

/* Separador vertical */
.info-divider {
    width: 1px;
    height: 32px;
    background: var(--border);
    flex-shrink: 0;
}

/* Stat individual: valor + label */
.info-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
}
.info-val {
    font-family: 'Fredoka One', cursive;
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1;
    white-space: nowrap;
}
.info-key {
    font-size: 0.58rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

/* Contador de cores ao vivo */
.info-color-counts {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
    overflow: hidden;
    min-width: 0;
}

.info-color-more {
    font-family: 'Fredoka One', cursive;
    font-size: 0.78rem;
    color: var(--pink);
    white-space: nowrap;
    flex-shrink: 0;
    padding: 0.1rem 0.35rem;
    border: 1.5px solid var(--pink-light);
    border-radius: var(--radius-full);
    background: var(--pink-bg);
    transition: background 0.15s;
}
.info-color-more:hover { background: var(--pink-light); }
.info-color-dot {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.info-dot {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 1.5px solid rgba(0,0,0,0.12);
    flex-shrink: 0;
}
.info-dot-count {
    font-family: 'Fredoka One', cursive;
    font-size: 0.78rem;
    color: var(--text);
    white-space: nowrap;
}
.info-dot-name {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}
.info-no-colors {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Modal contagem — nome da cor */
.count-name-group {
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
    flex: 1;
    text-align: left;
    min-width: 0;
}
.count-color-name {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--text);
}

/* ── CARD PIX ──────────────────────────────────────────────── */
.pix-card {
    background: #F8FAFC;
    border: 2px dashed var(--border);
    padding: 1rem;
    border-radius: var(--radius-sm);
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.pix-card code {
    font-family: monospace;
    font-size: 0.68rem;
    word-break: break-all;
    color: var(--text);
    background: #fff;
    padding: 0.5rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: block;
}


/* ══════════════════════════════════════════════════════════════
   TOGGLE BÁSICO / PRO
══════════════════════════════════════════════════════════════ */
.mode-toggle {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.32);
    border-radius: var(--radius-full);
    padding: 3px;
    cursor: pointer;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    flex-shrink: 0;
    position: relative;
    transition: border-color 0.2s;
    touch-action: manipulation;
}
.mode-toggle:hover { border-color: rgba(255,255,255,0.55); }

/* Pílula deslizante — posição e largura definidas por JS */
.toggle-pill {
    position: absolute;
    top: 3px;
    bottom: 3px;
    left: 0;
    width: 0;
    background: #fff;
    border-radius: var(--radius-full);
    box-shadow: 0 2px 8px rgba(0,0,0,0.14);
    transition: left 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
                width 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    z-index: 0;
}

.mode-option {
    padding: 0.28rem 0.85rem;
    border-radius: var(--radius-full);
    font-family: 'Nunito', sans-serif;
    font-size: 0.82rem;
    font-weight: 800;
    color: rgba(255,255,255,0.55);
    transition: color 0.22s ease;
    user-select: none;
    white-space: nowrap;
    position: relative;
    z-index: 1;
}

/* Modo PRO (padrão): opção Pro acesa — a pílula fica atrás, aqui só a cor */
body.mode-pro  .mode-option--pro,
body.mode-basic .mode-option--lite {
    color: var(--purple-dark);
}

/* ══════════════════════════════════════════════════════════════
   MODO BÁSICO — oculta ferramentas avançadas
══════════════════════════════════════════════════════════════ */
body.mode-basic .tool-group--shapes,
body.mode-basic .tool-group--transforms,
body.mode-basic .tool-group--import,
body.mode-basic .toolbar-divider--advanced,
body.mode-basic .rows-control,
body.mode-basic #btn-pdf,
body.mode-basic #btn-print {
    display: none !important;
}

body.mode-basic .tool-group--count    { display: none !important; }
body.mode-basic .text-pattern-options { display: none !important; }
body.mode-basic .cols-control         { display: none !important; }
body.mode-basic .info-thread-stat     { display: none !important; }
body.mode-basic .info-bead-size .bead-label-mm { display: none !important; }
body.mode-pro   .info-bead-size        { display: none !important; }
body.mode-basic .info-bead-select      { display: none !important; }

.info-bead-select { display: flex; align-items: center; }

.bead-type-select {
    font-family: 'Nunito', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text);
    background: var(--bg-app);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 0.2rem 0.5rem;
    cursor: pointer;
    max-width: 170px;
}
.bead-type-select:focus { outline: 2px solid var(--pink); outline-offset: 1px; }

/* Botão Desfazer na toolbar — só aparece no Lite (Pro já tem no header) */
body.mode-pro .tool-btn--undo-lite { display: none !important; }

/* Em modo básico, botões de ferramenta maiores e mais legíveis */
body.mode-basic .tool-btn {
    min-height: 72px;
    padding: 0.625rem 0.25rem;
    font-size: 0.7rem;
    gap: 0.3rem;
}
body.mode-basic .tool-btn .lucide {
    width: 26px;
    height: 26px;
}

/* Em modo básico, swatches de cor maiores */
body.mode-basic .current-color-swatch {
    width: 32px;
    height: 32px;
}

/* ══════════════════════════════════════════════════════════════
   MODAIS: SALVAR + GALERIA
══════════════════════════════════════════════════════════════ */
.modal-icon--save    { background: linear-gradient(135deg, #DCFCE7, #BBF7D0); color: var(--success); }
.modal-icon--gallery { background: linear-gradient(135deg, #EDE9FE, #DDD6FE); color: var(--purple); }
.modal-icon--export  { background: linear-gradient(135deg, #DBEAFE, #BFDBFE); color: #2563EB; }
.modal-icon--templates { background: linear-gradient(135deg, #FEF3C7, #FBCFE8); color: var(--pink-hover); }

/* ══════════════════════════════════════════════════════════════
   MODAL: EXPORTAR
══════════════════════════════════════════════════════════════ */
.modal-box--export { max-width: 440px; }

.export-format-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.625rem;
    width: 100%;
}

.export-format-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.875rem 0.5rem;
    border: 2px solid #E5E7EB;
    border-radius: 12px;
    background: #FAFAFA;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    font-family: 'Nunito', sans-serif;
    color: var(--text);
}
.export-format-card:hover {
    border-color: #EC4899;
    background: #FFF0F7;
}
.export-format-card.active {
    border-color: #EC4899;
    background: #FFF0F7;
    box-shadow: 0 0 0 3px rgba(236,72,153,0.18);
    color: #BE185D;
}
.export-format-card .lucide { width: 26px; height: 26px; }

.format-label {
    font-weight: 800;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
}
.format-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 600;
}
.export-format-card.active .format-desc { color: #BE185D; opacity: 0.75; }

.export-pdf-options {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    text-align: left;
}
.export-option-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-muted);
}
.export-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 2px solid #E5E7EB;
    border-radius: 8px;
    font-family: 'Nunito', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    background: #FAFAFA;
    color: var(--text);
    cursor: pointer;
}
.export-select:focus { outline: none; border-color: #EC4899; }

.modal-box--save    { max-width: 400px; }
.modal-box--gallery {
    max-width: 580px;
    width: min(95vw, 580px);
    max-height: 90vh;
}
.modal-box--templates {
    max-width: 680px;
    width: min(95vw, 680px);
    max-height: 92vh;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 0.75rem;
    width: 100%;
}

.template-card {
    min-height: 178px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: #fff;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    align-items: stretch;
    cursor: pointer;
    color: var(--text);
    font-family: 'Nunito', sans-serif;
    text-align: left;
    transition: border-color 0.16s, box-shadow 0.16s, transform 0.10s;
}
.template-card:hover {
    border-color: var(--pink);
    box-shadow: 0 8px 22px rgba(236, 72, 153, 0.14);
    transform: translateY(-2px);
}
.template-card:active { transform: scale(0.98); }

.template-preview {
    display: grid;
    gap: 2px;
    height: 74px;
    padding: 0.35rem;
    border-radius: 8px;
    background:
        repeating-linear-gradient(92deg,
            #C8935A 0px, #C8935A 5px,
            #B77D3F 5px, #B77D3F 7px,
            #D9AA72 7px, #D9AA72 9px);
    overflow: hidden;
}

.template-dot {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    align-self: center;
    justify-self: center;
    box-shadow: inset -1px -1px 2px rgba(0,0,0,0.24), inset 1px 1px 1px rgba(255,255,255,0.65);
}
.template-dot.is-empty {
    background: rgba(255,255,255,0.16);
    box-shadow: none;
}

.template-card-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 900;
    font-size: 0.9rem;
    color: var(--purple-dark);
    line-height: 1.2;
}
.template-card-title .lucide { width: 16px; height: 16px; color: var(--pink); }
.template-card-desc {
    font-size: 0.76rem;
    font-weight: 700;
    line-height: 1.35;
    color: var(--text-muted);
}

/* Grade de projetos */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.625rem;
    width: 100%;
    max-height: 52vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--pink-light) transparent;
    padding-right: 0.25rem;
}

.gallery-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 2rem 0;
}

/* Card de projeto */
.project-card {
    background: var(--bg-app);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color 0.15s, transform 0.10s;
}
.project-card:hover { border-color: var(--purple); transform: scale(1.02); }

.project-thumb {
    width: 100%;
    aspect-ratio: 3 / 2;
    object-fit: cover;
    display: block;
    background: #FDDBB4;
    image-rendering: pixelated;
}

.project-info {
    padding: 0.4rem 0.5rem 0.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}
.project-name {
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.project-date { font-size: 0.66rem; color: var(--text-muted); }

.project-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.5rem 0.5rem;
}
.btn-open-project {
    flex: 1;
    padding: 0.4rem 0.5rem;
    font-size: 0.78rem;
}
.btn-delete-project {
    width: 28px;
    height: 28px;
    border: 1.5px solid var(--border);
    background: transparent;
    border-radius: var(--radius-xs);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-delete-project:hover {
    background: var(--danger-light);
    color: var(--danger);
    border-color: rgba(239,68,68,0.30);
}
.btn-delete-project .lucide { width: 14px; height: 14px; }

/* ══════════════════════════════════════════════════════════════
   UTILITÁRIOS
══════════════════════════════════════════════════════════════ */
.hidden { display: none !important; }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVO — tablet  ≤ 1024px
══════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    :root { --toolbar-w: 70px; }
    .sidebar { width: clamp(110px, 13vw, 150px); }
    .palette-grid { gap: 0.3rem; }
    .color-swatch { width: 26px; height: 26px; }
    #input-zoom { width: 100px; }

    /* Oculta botões menos usados para não estourar o header em tablets */
    #btn-pdf, #btn-print { display: none; }

    /* Área mínima de toque adequada para dedos */
    .mode-option { min-height: 36px; display: flex; align-items: center; }
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVO — tablet portrait  ≤ 768px
   Toolbar: ícones sem labels (tooltip via title)
══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    :root {
        --header-h:  52px;
        --toolbar-w: 56px;
    }

    /* Header: logo-title e home-link somem, fica só ícone + toggle + ações */
    .logo-title        { display: none; }
    .home-link span    { display: none; }
    .home-link         { padding: 0.45rem 0.6rem; }
    .logo-img          { width: 34px; height: 34px; }
    .icon-btn          { width: 36px; height: 36px; }
    .mode-option       { padding: 0.22rem 0.6rem; font-size: 0.75rem; }
    .header-left       { gap: 0.5rem; }

    /* Toolbar: ícones apenas */
    .tool-btn { min-height: 48px; padding: 0.5rem 0.25rem; }
    .tool-btn span { display: none; }
    .tool-btn .lucide { width: 22px; height: 22px; }

    .sidebar { width: 96px; }
    .palette-grid { gap: 0.3rem; }
    .color-swatch { width: 30px; height: 30px; }
    .current-color-display { padding: 0.4rem; gap: 0.4rem; }
    .current-color-label { display: none; }

    .canvas-area { padding: 0.5rem 0.625rem; gap: 0.5rem; }
    .canvas-wrapper { padding: 0.5rem; }
    #input-zoom { width: 80px; }
    .ctrl-label { font-size: 0.72rem; }
}

/* ══════════════════════════════════════════════════════════════
   TABLET — touch ≥ 769 px  (pointer: coarse)
   Alvos mínimos de toque: 44–48 px em toda a interface.
   Ícones maiores; labels da toolbar removidas (ícone compensa).
══════════════════════════════════════════════════════════════ */
@media (pointer: coarse) and (min-width: 769px) {
    :root {
        --header-h:  64px;
        --toolbar-w: 76px;
    }

    /* ── Header ───────────────────────────────────────────── */
    .logo-img  { width: 44px; height: 44px; }
    .icon-btn  { width: 48px; height: 48px; }
    .home-link { padding: 0.6rem 1.1rem; font-size: 0.95rem; }
    .header-right { gap: 0.45rem; }

    /* ── Toolbar esquerda ─────────────────────────────────── */
    .tool-btn           { min-height: 66px; padding: 0.6rem 0.2rem; }
    .tool-btn .lucide   { width: 26px; height: 26px; }
    .tool-btn span      { display: none; }   /* ícone maior compensa o label */

    /* ── Controles de grade (linhas / colunas) ────────────── */
    .ctrl-btn          { width: 36px; height: 36px; }
    .ctrl-btn .lucide  { width: 18px; height: 18px; }
    .ctrl-label        { font-size: 0.85rem; }
    .ctrl-label strong { font-size: 1.05rem; }

    /* ── Tom de pele ──────────────────────────────────────── */
    .skin-btn { width: 34px; height: 34px; }

    /* ── Zoom ─────────────────────────────────────────────── */
    .zoom-btn         { width: 38px; height: 38px; }
    .zoom-btn .lucide { width: 20px; height: 20px; }
    #input-zoom       { width: 130px; }

    /* ── Sidebar direita ──────────────────────────────────── */
    .sidebar {
        width: clamp(158px, 17vw, 210px);
        padding: 0.875rem 0.75rem;
    }

    /* Cor atual */
    .current-color-swatch { width: 34px; height: 34px; }
    .current-color-label  { font-size: 0.72rem; }
    .current-color-hex    { font-size: 0.72rem; }

    /* Seletor de material */
    .material-btn {
        padding: 0.42rem 0.5rem;
        font-size: 0.72rem;
        min-height: 36px;
    }

    /* Paleta */
    .palette-grid {
        grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
        gap: 0.45rem;
    }
    .color-swatch     { width: 36px; height: 36px; }
    .palette-add-btn  { height: 44px; font-size: 0.82rem; }

    /* ── Área do canvas ───────────────────────────────────── */
    .canvas-area { padding: 0.75rem 0.875rem; gap: 0.75rem; }
}

/* ══════════════════════════════════════════════════════════════
   TELA DE REDIRECIONAMENTO — celulares < 600px
══════════════════════════════════════════════════════════════ */
.phone-redirect {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-app);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    padding: 2rem 1.5rem;
    text-align: center;
}

.phone-redirect-img {
    width: min(200px, 55vw);
    filter: drop-shadow(0 6px 18px rgba(147,51,234,0.22));
    animation: hero-float 4s ease-in-out infinite;
}

.phone-redirect h2 {
    font-family: 'Fredoka One', cursive;
    font-size: 1.45rem;
    color: var(--text);
}

.phone-redirect p {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.55;
    max-width: 320px;
}

.phone-redirect-play {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    background: linear-gradient(135deg, #F9A8D4, #EC4899);
    color: #fff;
    border-radius: var(--radius-full);
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 1rem;
    text-decoration: none;
    box-shadow: var(--shadow-btn);
    touch-action: manipulation;
}

.phone-redirect-play:active { transform: scale(0.96); }

@keyframes hero-float {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-12px); }
}

@media (max-width: 599px) {
    .phone-redirect { display: flex; }
    .app-wrapper     { display: none; }
}

/* ══════════════════════════════════════════════════════════════
   IMPRESSÃO
══════════════════════════════════════════════════════════════ */
@media print {
    .left-toolbar, .colors-sidebar, .main-header,
    .canvas-controls, .thread-guide { display: none !important; }

    body { background: #fff; }
    .content-layout { overflow: visible; }
    .canvas-area { overflow: visible; padding: 0; display: block; }
    .canvas-wrapper { box-shadow: none; border: none; background: #fff; }
}

/* ══════════════════════════════════════════════════════════════
   SUPORTE CJK (japonês / chinês / coreano)
══════════════════════════════════════════════════════════════ */
:lang(ja) {
    /* Kanji não usa espaçamento entre letras */
    letter-spacing: 0 !important;
    word-spacing: 0;
    /* Permite quebra em qualquer ponto (CJK não tem espaços) */
    word-break: break-all;
    overflow-wrap: break-word;
}

/* Botão de idioma japonês é mais largo que PT/EN/ES */
.lang-option[data-lang="ja"] {
    font-size: 0.72rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    letter-spacing: 0;
}

.home-link {
    width: 42px;
    height: 42px;
    padding: 0;
}

@media (max-width: 768px) {
    .home-link {
        width: 40px;
        height: 40px;
        padding: 0;
    }
}
