/* ── Mark Tag Generator – 3-column fit-to-host layout ── */
section {
    max-width: 100%;
}

/* When the panel is hosted inside the Templates hub (`.tpl-detail__panel`)
   it must not use viewport-anchored offsets — let the host drive the height.
   When used standalone (`.marktag-page` is a direct child of `main`),
   fall back to the original viewport-fit behavior. */
.marktag-root-wrap {
    height: 100%;
    min-height: 640px;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

#main:has(> .marktag-page) {
    margin-top: 0;
    padding: 0;
    min-height: unset;
    display: flex;
    flex-direction: column;
}

#main > .marktag-page {
    height: calc(100vh - 88px);
    margin-top: 82px;
    max-height: calc(100vh - 88px);
}

.marktag-page {
    display: grid;
    grid-template-columns: 350px 1fr 350px;
    gap: .65rem;
    height: 100%;
    color: #e8e8e8;
    padding: .65rem;
}

@media (max-width: 1100px) {
    .marktag-page {
        grid-template-columns: 1fr;
        grid-auto-rows: minmax(min-content, auto);
        height: auto;
    }
    .marktag-root-wrap {
        min-height: 0;
    }
}

/* ── panels ── */
.marktag-panel {
    background: #181a1f;
    border: 1px solid rgba(255,255,255,.09);
    border-radius: .9rem;
    padding: .7rem .8rem;
    display: flex;
    flex-direction: column;
    gap: .45rem;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
}

.marktag-panel::-webkit-scrollbar { width: 4px; }
.marktag-panel::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }

/* ── center column ── */
.marktag-center {
    display: flex;
    flex-direction: column;
    gap: .55rem;
    min-width: 0;
    min-height: 0;
}

/* ── header ── */
.marktag-header {
    margin-bottom: .2rem;
    flex-shrink: 0;
}

.marktag-kicker {
    color: #e7d38f;
    font-size: .65rem;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
    margin: 0 0 .2rem;
}

.marktag-header h1 {
    margin: 0 0 .15rem;
    font-size: 1.2rem;
    line-height: 1.15;
}

.marktag-header p {
    color: #888;
    font-size: .68rem;
    margin: 0;
    line-height: 1.3;
}

/* ── typography inside panels ── */
.marktag-section-title {
    font-size: .6rem;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #555;
    margin: .2rem 0 .1rem;
    border-bottom: 1px solid rgba(255,255,255,.06);
    padding-bottom: .2rem;
    flex-shrink: 0;
}

/* ── grid rows ── */
.marktag-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .4rem;
}

.marktag-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: .4rem;
}

/* ── label / input ── */
.marktag-page label {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    color: #888;
    font-size: .6rem;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.marktag-page input,
.marktag-page select {
    width: 100%;
    border: 1px solid rgba(255,255,255,.13);
    background: #252729;
    color: #fff;
    border-radius: .45rem;
    padding: .35rem .45rem;
    font-size: .75rem;
    font-weight: 700;
    font-family: inherit;
}

.marktag-page input:focus,
.marktag-page select:focus {
    outline: none;
    border-color: rgba(255,51,51,.55);
}

.marktag-page input[type=range] {
    padding: 0;
    accent-color: #ff3333;
    height: 4px;
    margin-top: .1rem;
}

/* slider label: label text + value on same row */
.marktag-slider-label {
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.marktag-slider-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #888;
    font-size: .6rem;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.marktag-slider-row span {
    color: #ff3333;
    font-weight: 900;
    font-size: .68rem;
}

/* ── presets ── */
.marktag-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .4rem;
    flex-shrink: 0;
}

.marktag-btn {
    border: 0;
    border-radius: .5rem;
    background: #ff3333;
    color: #fff;
    padding: .5rem .5rem;
    font-size: .68rem;
    font-weight: 900;
    text-transform: uppercase;
    cursor: pointer;
    letter-spacing: .05em;
    transition: background .15s;
}

.marktag-btn:hover { background: #e52b2b; }
.marktag-btn-secondary { background: #2e3035; }
.marktag-btn-secondary:hover { background: #3a3d44; }
.marktag-btn-full { grid-column: 1 / -1; padding: .6rem; font-size: .75rem; }

/* ── warning ── */
.marktag-warning {
    background: #221d10;
    border: 1px solid rgba(255,217,141,.18);
    color: #ffd98d;
    border-radius: .6rem;
    padding: .5rem .6rem;
    font-size: .65rem;
    line-height: 1.4;
    flex-shrink: 0;
}

/* ── status ── */
.marktag-status {
    min-height: 1.1rem;
    color: #72f0a5;
    font-weight: 800;
    font-size: .7rem;
    text-align: center;
}

/* ── spacer to push download to bottom ── */
.marktag-spacer {
    flex: 1;
}

/* ── size badge ── */
.marktag-size-badge {
    background: #111315;
    border: 1px solid rgba(231,211,143,.35);
    color: #fff;
    border-radius: .65rem;
    padding: .5rem .75rem;
    font-weight: 900;
    font-size: .78rem;
    text-align: center;
    flex-shrink: 0;
}

.marktag-size-badge span {
    display: block;
    color: #e7d38f;
    font-size: .65rem;
    margin-top: .15rem;
}

/* ── preview wrap ── */
.marktag-preview-wrap {
    background: #181a1f;
    border: 1px solid rgba(255,255,255,.09);
    border-radius: .9rem;
    flex: 1;
    display: grid;
    place-items: center;
    background-color: #1c1e24;
    background-image:
        linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
    background-size: 16px 16px;
    overflow: hidden;
    min-height: 0;
}

#mtPreview svg {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    filter: drop-shadow(0 12px 24px rgba(0,0,0,.55));
}

/* ── responsive: stack below 860px ── */
@media (max-width: 860px) {
    .marktag-root-wrap {
        height: auto;
        overflow: visible;
    }

    .marktag-page {
        grid-template-columns: 1fr;
        height: auto;
    }

    .marktag-center {
        min-height: 420px;
    }

    .marktag-preview-wrap {
        min-height: 380px;
    }

    .marktag-spacer {
        display: none;
    }
}

@media (max-width: 480px) {
    .marktag-grid, .marktag-actions {
        grid-template-columns: 1fr;
    }
}
