.pixel-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: var(--canvas-bg);
}

.pixel-workspace,
.pixel-main {
    background: var(--canvas-bg);
}

.pixel-header.site-header {
    flex-shrink: 0;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
    height: var(--header-h);
    overflow: visible;
}

.pixel-header .site-logo {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pixel-header__end {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: auto;
    flex-shrink: 0;
    z-index: 2;
}

/* Mobile: Menü zugeklappt — Hamburger */
.pixel-header__menu {
    display: none !important;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 40;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.85rem 1rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}

.pixel-header__menu.is-open {
    display: flex !important;
}

.pixel-header__menu .btn {
    width: 100%;
    justify-content: flex-start;
    min-height: 2.5rem;
}

.pixel-header__menu .btn span {
    font-size: inherit !important;
}

.pixel-header__menu .btn::before {
    content: none !important;
}

.pixel-header__menu .lang-switcher {
    width: 100%;
}

.pixel-header__menu .lang-switcher select {
    width: 100%;
    min-height: 2.5rem;
}

.pixel-header__menu .theme-toggle {
    width: 100%;
    justify-content: flex-start;
    min-height: 2.5rem;
    padding: 0 0.85rem;
}

.pixel-header__menu .theme-toggle__label {
    display: inline;
}

.pixel-menu-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 2.35rem;
    height: 2.35rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    flex-shrink: 0;
}

.pixel-menu-toggle__bars {
    position: relative;
    display: block;
    width: 1.05rem;
    height: 1.5px;
    background: currentColor;
    border-radius: 2px;
}

.pixel-menu-toggle__bars::before,
.pixel-menu-toggle__bars::after {
    content: '';
    position: absolute;
    left: 0;
    display: block;
    width: 1.05rem;
    height: 1.5px;
    background: currentColor;
    border-radius: 2px;
    transition: transform 0.2s ease, top 0.2s ease;
}

.pixel-menu-toggle__bars::before {
    top: -5px;
}

.pixel-menu-toggle__bars::after {
    top: 5px;
}

.pixel-menu-toggle[aria-expanded="true"] .pixel-menu-toggle__bars {
    background: transparent;
}

.pixel-menu-toggle[aria-expanded="true"] .pixel-menu-toggle__bars::before {
    top: 0;
    transform: rotate(45deg);
}

.pixel-menu-toggle[aria-expanded="true"] .pixel-menu-toggle__bars::after {
    top: 0;
    transform: rotate(-45deg);
}

.share-pixel-wrap {
    position: relative;
    width: 100%;
}

@media (min-width: 900px) {
    .pixel-menu-toggle {
        display: none !important;
    }

    .pixel-header__end {
        margin-left: 0.5rem;
        order: 3;
    }

    .pixel-header__menu,
    .pixel-header__menu.is-open {
        display: flex !important;
        position: static;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: flex-end;
        gap: 0.5rem;
        margin-left: auto;
        padding: 0;
        background: transparent;
        border: none;
        box-shadow: none;
        width: auto;
    }

    .pixel-header__menu .btn {
        width: auto;
        justify-content: center;
        min-height: 0;
    }

    .pixel-header__menu .lang-switcher {
        width: auto;
    }

    .pixel-header__menu .lang-switcher select {
        width: auto;
        min-height: 0;
    }

    .pixel-header__menu .theme-toggle {
        width: auto;
        justify-content: center;
        min-height: 0;
        padding: 0 0.65rem;
    }

    .pixel-header__menu .theme-toggle__label {
        display: none;
    }

    .share-pixel-wrap {
        width: auto;
    }
}

.share-menu {
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 160px;
    padding: 0.4rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
}

@media (max-width: 767px) {
    .share-menu {
        left: 0;
        right: 0;
        min-width: 0;
        width: 100%;
    }
}

.share-menu[hidden] {
    display: none;
}

.share-menu .share-btn {
    justify-content: flex-start;
    width: 100%;
    border: none;
    background: transparent;
    border-radius: 7px;
    padding: 0.55rem 0.7rem;
}

.share-menu .share-btn:hover {
    background: var(--hover);
}

.zoom-controls {
    display: flex;
    gap: 0.2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.2rem;
}

.zoom-controls button {
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 7px;
    font-size: 1rem;
    line-height: 1;
    color: var(--text);
    transition: background 0.15s;
}

.zoom-controls button:hover {
    background: var(--hover-strong);
}

.pixel-main {
    flex: 1;
    position: relative;
    min-height: 0;
}

/* Workspace: Canvas + rechte Ads-Rail (kein Overlay) */
.pixel-workspace {
    flex: 1;
    display: flex;
    min-height: 0;
    min-width: 0;
}

.pixel-workspace .pixel-main {
    flex: 1;
    min-width: 0;
}

.pixel-ad-rail {
    flex-shrink: 0;
    width: 176px;
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 0.65rem;
    background: var(--surface);
    border-left: 1px solid var(--border);
}

.pixel-ad-rail .ad-label {
    margin-bottom: 0.45rem;
}

.pixel-ad-rail .ad-slot--rail {
    position: sticky;
    top: 0.75rem;
}

@media (min-width: 1100px) {
    .pixel-ad-rail {
        display: flex;
    }
}

.pixel-ad-bottom {
    flex-shrink: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem 0.65rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
    min-height: 110px; /* CLS-Reserve */
}

@media (min-width: 900px) {
    .pixel-ad-bottom {
        display: flex;
    }
}

.pixel-ad-bottom .ad-slot {
    width: 100%;
    max-width: 728px;
}

#pixel-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    background: var(--canvas-bg);
}

.pixel-hint {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    padding: 0.5rem 1rem;
    background: var(--hint-bg);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.78rem;
    color: var(--text-muted);
    pointer-events: none;
    white-space: nowrap;
    max-width: calc(100% - 2rem);
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 899px) {
    .pixel-hint {
        white-space: normal;
        text-align: center;
        border-radius: 12px;
        max-width: calc(100% - 1.5rem);
    }

    .pixel-header.site-header {
        padding-inline: 0.75rem;
    }

    .pixel-header .site-logo {
        font-size: 0.88rem;
        max-width: min(46vw, 11rem);
    }

    .zoom-controls button {
        width: 2rem;
        height: 2rem;
    }
}

/* ── Modal ─────────────────────────────────────────────────────────── */

body.modal-open {
    overflow: hidden;
}

.story-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    background: var(--overlay);
    backdrop-filter: blur(4px);
}

@media (min-width: 520px) {
    .story-modal {
        align-items: center;
        padding: 1.25rem;
    }
}

.story-modal[hidden] {
    display: none;
}

.story-modal__panel {
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 1.75rem 1.5rem 1.5rem;
    box-shadow: var(--shadow-md);
    animation: slideUp 0.28s ease;
}

@media (min-width: 520px) {
    .story-modal__panel {
        border-radius: var(--radius-lg);
    }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.story-modal__panel h2 {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    margin-bottom: 0.25rem;
}

.story-modal__pos {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 1.35rem;
}

.story-field {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-bottom: 1.1rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
}

.story-field textarea,
.story-field input[type="text"] {
    font-weight: 400;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.7rem 0.85rem;
    background: var(--input-bg);
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}

.story-field textarea:focus,
.story-field input[type="text"]:focus {
    border-color: var(--text-soft);
    background: var(--surface);
}

.story-field textarea {
    resize: vertical;
    min-height: 5.5rem;
    line-height: 1.5;
}

.story-color-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.story-color-row input[type="color"] {
    width: 3rem;
    height: 3rem;
    padding: 0.15rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: none;
    cursor: pointer;
}

.story-color-row input[type="text"] {
    flex: 1;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.03em;
}

.story-counter {
    align-self: flex-end;
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--text-soft);
}

.story-counter.is-limit {
    color: #c0392b;
}

.story-error {
    color: #c0392b;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
    padding: 0.55rem 0.75rem;
    background: var(--danger-bg);
    border-radius: 8px;
}

.story-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

/* ── Tooltip ───────────────────────────────────────────────────────── */

.pixel-tooltip {
    position: fixed;
    z-index: 90;
    max-width: 280px;
    padding: 0.65rem 0.85rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    pointer-events: none;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.4rem 0.6rem;
    align-items: start;
}

.pixel-tooltip[hidden] {
    display: none;
}

.pixel-tooltip__swatch {
    width: 0.9rem;
    height: 0.9rem;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    margin-top: 0.12rem;
}

.pixel-tooltip__text {
    font-size: 0.84rem;
    line-height: 1.4;
    color: var(--text);
}

.pixel-tooltip__pos {
    grid-column: 2;
    font-size: 0.72rem;
    color: var(--text-soft);
}
