/* ==========================================================================
   Pixel-Eule Studio – 100 % lokal, Touch-freundlich (>= 44 px)
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

[hidden] {
    display: none !important;
}

html,
body {
    min-height: 100%;
    font-family: var(--le-font-sans);
    background: #fdf2f4;
    color: var(--le-ink);
    -webkit-tap-highlight-color: transparent;
}

button,
select {
    font-family: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    transition: transform 0.1s ease, background-color 0.14s ease, border-color 0.14s ease;
}

button:active:not(:disabled) {
    transform: scale(0.97);
}

button:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.mono {
    font-family: var(--le-font-mono);
    font-variant-numeric: tabular-nums;
}

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

/* ==========================================================================
   KOPFLEISTE
   ========================================================================== */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--le-border);
    padding: 8px 12px;
}

.top-bar-inner {
    max-width: 1320px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(225, 29, 72, 0.22);
}

.brand-title {
    font-size: 1.04rem;
    font-weight: 900;
    color: var(--le-ink);
}

.size-chip {
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--le-rose-soft);
    color: #9f1239;
    font-size: 0.76rem;
    font-weight: 800;
}

.top-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.action-btn {
    min-height: 44px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid var(--le-border-strong);
    background: var(--le-surface);
    font-size: 0.85rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.action-btn.primary {
    background: var(--le-rose);
    border-color: var(--le-rose);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(225, 29, 72, 0.24);
}

/* ==========================================================================
   3-SPALTEN STUDIO-LAYOUT
   ========================================================================== */
.studio-layout {
    width: 100%;
    max-width: 1320px;
    margin: 0 auto;
    padding: 14px 12px 28px;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr) 272px;
    gap: 14px;
    align-items: start;
}

.card {
    background: var(--le-surface);
    border: 1px solid var(--le-border);
    border-radius: 20px;
    box-shadow: var(--le-shadow-sm);
}

.side-panel {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.panel-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--le-border);
}

.panel-group:first-child {
    padding-top: 0;
    border-top: none;
}

.group-title {
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--le-ink-muted);
}

.tool-grid,
.sym-grid,
.template-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.opt-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.tool-btn,
.sym-btn,
.size-btn,
.tpl-btn,
.toggle-btn {
    min-height: 44px;
    padding: 6px 8px;
    border-radius: 12px;
    border: 1.5px solid var(--le-border);
    background: var(--le-surface-alt);
    font-size: 0.82rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-align: center;
}

.tool-btn.active,
.sym-btn.active,
.size-btn.active {
    background: var(--le-rose-soft);
    border-color: var(--le-rose);
    color: #9f1239;
}

.tpl-btn:hover {
    border-color: var(--le-rose);
    background: #fff1f2;
}

.toggle-btn {
    justify-content: space-between;
    padding: 6px 10px;
}

.toggle-pill {
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 900;
    background: #e2e8f0;
    color: #475569;
}

.toggle-btn[aria-pressed="true"] .toggle-pill {
    background: var(--le-green-soft);
    color: #166534;
}

/* ==========================================================================
   ZEICHEN-LEINWAND
   ========================================================================== */
.canvas-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.canvas-frame {
    width: min(540px, 100%);
    aspect-ratio: 1;
    padding: 10px;
    border-radius: 22px;
    background: var(--le-surface);
    border: 1px solid var(--le-border);
    box-shadow: var(--le-shadow-md);
    display: grid;
    place-items: center;
}

#pixelCanvas {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    touch-action: none;
    cursor: crosshair;
    image-rendering: pixelated;
}

.status-toast {
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--le-green-soft);
    border: 1px solid #86efac;
    color: #14532d;
    font-size: 0.85rem;
    font-weight: 800;
    text-align: center;
}

/* ==========================================================================
   FARBEN, VORSCHAU & GALERIE
   ========================================================================== */
.palette-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.color-picker-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.active-swatch {
    width: 44px;
    height: 36px;
    border-radius: 10px;
    border: 2px solid var(--le-ink);
    box-shadow: inset 0 0 0 2px #ffffff;
}

.color-picker-wrap input[type="color"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.palette-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
}

.pal-tab {
    min-height: 38px;
    border-radius: 9px;
    border: 1px solid var(--le-border);
    background: var(--le-surface-alt);
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--le-ink-muted);
}

.pal-tab.active {
    background: var(--le-rose);
    border-color: var(--le-rose);
    color: #ffffff;
}

.swatch-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

.swatch-btn {
    height: 44px;
    border-radius: 11px;
    border: 2px solid rgba(15, 23, 42, 0.16);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.45);
}

.swatch-btn.active {
    border-color: var(--le-ink);
    box-shadow: inset 0 0 0 3px #ffffff, 0 0 0 2px var(--le-rose);
    transform: scale(1.04);
}

.bg-select {
    min-height: 36px;
    padding: 4px 8px;
    border-radius: 9px;
    border: 1px solid var(--le-border-strong);
    background: var(--le-surface);
    font-size: 0.78rem;
    font-weight: 700;
}

.preview-box {
    padding: 10px;
    border-radius: 14px;
    background: repeating-conic-gradient(#e2e8f0 0% 25%, #ffffff 0% 50%) 50% / 14px 14px;
    border: 1px solid var(--le-border);
    display: grid;
    place-items: center;
}

#previewCanvas {
    width: 96px;
    height: 96px;
    border-radius: 8px;
    image-rendering: pixelated;
}

.gallery-count {
    font-size: 0.76rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--le-bg-soft);
}

.gallery-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.gallery-item {
    position: relative;
    border-radius: 10px;
    border: 1.5px solid var(--le-border);
    background: #ffffff;
    padding: 4px;
    display: grid;
    place-items: center;
}

.gallery-item img {
    width: 100%;
    aspect-ratio: 1;
    image-rendering: pixelated;
    border-radius: 6px;
}

.gallery-del {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: var(--le-rose);
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 900;
    display: grid;
    place-items: center;
}

.gallery-empty {
    grid-column: 1 / -1;
    font-size: 0.78rem;
    color: var(--le-ink-muted);
    text-align: center;
    padding: 8px 4px;
}

/* ==========================================================================
   RESPONSIVE (TABLET & SMARTPHONE)
   ========================================================================== */
@media (max-width: 1040px) {
    .studio-layout {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .canvas-stage {
        grid-column: 1 / -1;
        order: -1;
    }
}

@media (max-width: 600px) {
    .hide-sm {
        display: none;
    }

    .studio-layout {
        grid-template-columns: 1fr;
        padding: 10px 10px 22px;
        gap: 10px;
    }

    .size-chip {
        display: none;
    }
}
