/* Design studio + design library additions (loaded after site.css). */

/* ---------------- Studio: top bar ---------------- */
.dz-top-link {
    display: inline-flex; align-items: center; gap: .4rem;
    color: #cfe3e3; font-size: .85rem; font-weight: 600; text-decoration: none;
    padding: .45rem .7rem; border: 1px solid rgba(255, 255, 255, .18); border-radius: 8px;
}
.dz-top-link:hover { color: #fff; border-color: var(--gold); }
@media (max-width: 700px) { .dz-top-link span { display: none; } .dz-top-link { padding: .5rem; } }

/* ---------------- Studio: canvas + area tabs ---------------- */
.designer-grid > * { min-width: 0; }
.designer-stage { min-width: 0; }
.designer-canvas-wrap { position: relative; min-height: 260px; max-width: 100%; }
.designer-canvas-wrap canvas { max-width: none; }
.designer-canvas-wrap .canvas-container { margin: 0 auto; touch-action: none; }
.dz-drop-hint {
    position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
    background: rgba(5, 105, 107, .12); color: var(--navy); font-weight: 700; font-size: 1rem;
    pointer-events: none; border-radius: var(--radius);
}
.designer-canvas-wrap.dragging .dz-drop-hint { display: flex; }

.dz-area-tabs {
    display: flex; gap: .4rem; overflow-x: auto; padding: 2px 2px .7rem;
    scrollbar-width: thin; -webkit-overflow-scrolling: touch;
}
.dz-area-tab {
    position: relative; flex: 0 0 auto;
    background: var(--paper); border: 1px solid #cbd5e1; border-radius: 999px;
    padding: .45rem .95rem; font-size: .82rem; font-weight: 600; color: var(--text-strong);
    cursor: pointer; white-space: nowrap; min-height: 36px;
}
.dz-area-tab:hover { border-color: var(--blue); color: var(--blue); }
.dz-area-tab.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.dz-area-has {
    display: inline-block; width: 7px; height: 7px; border-radius: 50%;
    background: var(--gold); margin-left: .45rem; vertical-align: middle;
}

.dz-select { width: 100%; padding: .55rem .7rem; border: 1px solid #cbd5e1; border-radius: var(--radius); font-size: .88rem; background: #fff; }

/* ---------------- Studio: tools ---------------- */
.dropzone.dragging { border-color: var(--blue); background: #eef7f7; }
.dz-upload-status { margin-top: .6rem; font-size: .8rem; border-radius: var(--radius); padding: .5rem .65rem; background: var(--mist); color: var(--text); }
.dz-upload-status.good { background: #e7f6ec; color: #1e6135; }
.dz-upload-status.bad { background: #fceeef; color: #8c1425; }
.dz-upload-status.warn { background: #fff6e0; color: #7a5200; }
.dz-uploads { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; margin-top: .6rem; }
.dz-upload-thumb {
    aspect-ratio: 1 / 1; border: 1px solid var(--line); border-radius: 6px; background: repeating-conic-gradient(#f1f4f7 0% 25%, #fff 0% 50%) 50% / 12px 12px;
    padding: 3px; cursor: pointer; overflow: hidden;
}
.dz-upload-thumb img { width: 100%; height: 100%; object-fit: contain; }
.dz-upload-thumb:hover { border-color: var(--blue); }

.dz-shape-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: .35rem; }
.dz-shape-grid .strip-btn { min-width: 0; width: 100%; height: 40px; display: inline-flex; align-items: center; justify-content: center; }

.strip-btn svg { display: block; }
.btn-strip .strip-btn { display: inline-flex; align-items: center; justify-content: center; }

.dz-palette { display: grid; grid-template-columns: repeat(8, 1fr); gap: .35rem; margin-bottom: .5rem; }
.dz-pal {
    aspect-ratio: 1 / 1; width: 100%; min-height: 24px; border-radius: 50%;
    border: 1px solid rgba(15, 37, 38, .2); cursor: pointer; padding: 0;
}
.dz-pal:hover { transform: scale(1.08); }
.dz-pal.active { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--blue); }
.dz-color-row { display: flex; align-items: center; gap: .55rem; font-size: .8rem; color: var(--text-muted); }
.dz-color-row input[type="color"] { width: 42px; height: 34px; border: 1px solid #cbd5e1; border-radius: var(--radius); padding: 2px; background: #fff; cursor: pointer; }
.dz-color-row .strip-btn { margin-left: auto; }

.dz-val { float: right; font-weight: 500; color: var(--text-muted); }
.fld input[type="range"] { width: 100%; accent-color: var(--blue); height: 28px; }
.fld textarea.form-input { resize: vertical; min-height: 44px; }

.dz-search {
    display: flex; align-items: center; gap: .45rem; border: 1px solid #cbd5e1; border-radius: var(--radius);
    padding: 0 .6rem; background: #fff; color: var(--text-muted); margin-bottom: .6rem;
}
.dz-search input { border: 0; outline: 0; flex: 1; min-width: 0; padding: .55rem 0; font-size: .88rem; background: transparent; }
.dz-tpl-chips { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .7rem; }
.dz-chip {
    border: 1px solid #cbd5e1; background: #fff; border-radius: 999px; padding: .3rem .7rem;
    font-size: .76rem; font-weight: 600; color: var(--text-strong); cursor: pointer;
}
.dz-chip:hover { border-color: var(--blue); color: var(--blue); }
.dz-chip.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.dz-tpl-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; max-height: 460px; overflow: auto; padding-right: 2px; }
.dz-tpl {
    display: flex; flex-direction: column; gap: .3rem; border: 1px solid var(--line); border-radius: var(--radius);
    background: #fff; padding: .4rem; cursor: pointer; text-align: left; transition: border-color .15s ease, transform .15s ease;
}
.dz-tpl:hover { border-color: var(--blue); transform: translateY(-1px); }
.dz-tpl img { width: 100%; aspect-ratio: 1 / 1; object-fit: contain; background: var(--mist); border-radius: 6px; }
.dz-tpl span { font-size: .74rem; font-weight: 600; color: var(--text-strong); line-height: 1.25; }
.dz-link { display: inline-block; margin-top: .7rem; font-size: .82rem; font-weight: 600; color: var(--blue); }

@media (max-width: 900px) {
    .dz-tpl-grid { grid-template-columns: repeat(3, 1fr); max-height: none; }
    .dz-palette { grid-template-columns: repeat(8, minmax(28px, 1fr)); }
}
@media (max-width: 420px) {
    .dz-tpl-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------------- Studio: preview + confirm ---------------- */
.dz-pv { padding: 1rem; }
.dz-pv-box {
    position: relative; background: var(--paper); border-radius: var(--radius-lg, 14px);
    width: 100%; max-width: 1180px; max-height: calc(100vh - 2rem);
    display: flex; flex-direction: column; box-shadow: var(--shadow-lg); overflow: hidden;
}
.dz-pv-box:fullscreen, .dz-pv-box.is-max { max-width: none; max-height: none; width: 100vw; height: 100vh; border-radius: 0; }
.dz-pv-box.is-max { position: fixed; inset: 0; z-index: 10; }
.dz-pv-head {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .75rem 1rem .75rem 1.25rem; border-bottom: 1px solid var(--line);
    font-family: var(--font-display); font-size: 1.1rem;
}
.dz-pv-head-actions { display: flex; gap: .4rem; }
.dz-pv-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 320px; }
.dz-pv-main { display: flex; flex-direction: column; min-height: 0; background: var(--mist); }
.dz-pv-toolbar { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .7rem 1rem; flex-wrap: wrap; }
.dz-pv-tabs { display: flex; gap: .35rem; overflow-x: auto; }
.dz-pv-tab {
    border: 1px solid #cbd5e1; background: #fff; border-radius: 999px; padding: .4rem .9rem;
    font-size: .82rem; font-weight: 600; color: var(--text-strong); cursor: pointer; white-space: nowrap;
}
.dz-pv-tab.is-empty { color: var(--text-muted); }
.dz-pv-tab.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.dz-pv-stage {
    position: relative; flex: 1; min-height: 320px; overflow: auto; text-align: center;
    padding: 0 1rem 1rem; touch-action: pan-x pan-y;
}
.dz-pv-stage.zoomed { cursor: grab; touch-action: none; }
.dz-pv-stage img { width: 100%; max-width: 620px; height: auto; display: inline-block; user-select: none; }
.dz-pv-stage.zoomed img { max-width: none; }
.dz-pv-box:fullscreen .dz-pv-stage img, .dz-pv-box.is-max .dz-pv-stage img { max-width: min(100%, 900px); }
.dz-pv-box:fullscreen .dz-pv-stage.zoomed img, .dz-pv-box.is-max .dz-pv-stage.zoomed img { max-width: none; }
.dz-pv-loading {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    background: rgba(244, 246, 249, .85); font-weight: 600; color: var(--text-muted);
}
.dz-pv-loading[hidden] { display: none; }
.dz-pv-side { overflow: auto; padding: 1rem 1.1rem; border-left: 1px solid var(--line); display: grid; gap: 1.1rem; align-content: start; }
.dz-pv-block .opt-label { margin-bottom: .5rem; }
.dz-pv-areas { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; }
.dz-pv-area {
    display: flex; flex-direction: column; gap: .25rem; border: 1px solid var(--line); background: #fff;
    border-radius: var(--radius); padding: .3rem; cursor: pointer; text-align: center;
}
.dz-pv-area:hover { border-color: var(--blue); }
.dz-pv-area.is-empty { opacity: .6; }
.dz-pv-area-img { display: block; aspect-ratio: 1 / 1; background: var(--mist); border-radius: 5px; overflow: hidden; }
.dz-pv-area-img img { width: 100%; height: 100%; object-fit: contain; }
.dz-pv-area-label { font-size: .7rem; font-weight: 600; color: var(--text-strong); line-height: 1.2; }
.dz-pv-summary dl { display: grid; grid-template-columns: auto 1fr; gap: .35rem .8rem; margin: 0; font-size: .84rem; }
.dz-pv-summary dt { color: var(--text-muted); }
.dz-pv-summary dd { margin: 0; font-weight: 600; color: var(--text-strong); text-align: right; }
.dz-pv-summary dd:last-of-type { font-family: var(--font-display); font-size: 1.15rem; color: var(--navy); }
.dz-pv-foot {
    display: flex; align-items: center; justify-content: flex-end; gap: .6rem; flex-wrap: wrap;
    padding: .8rem 1.1rem; border-top: 1px solid var(--line);
}
.dz-pv-foot .form-error { margin-right: auto; flex: 1 1 100%; }
.dz-pv-foot #dzConfirm { min-width: 190px; }

@media (max-width: 900px) {
    .dz-pv { padding: 0; }
    .dz-pv-box { max-height: 100vh; height: 100%; border-radius: 0; }
    .dz-pv-body { grid-template-columns: 1fr; overflow: auto; }
    .dz-pv-main { min-height: auto; }
    .dz-pv-stage { min-height: 0; flex: none; }
    .dz-pv-side { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
    .dz-pv-areas { grid-template-columns: repeat(4, 1fr); }
    .dz-pv-foot { position: sticky; bottom: 0; background: var(--paper); }
    .dz-pv-foot .btn { flex: 1 1 auto; }
    .dz-pv-foot #dzConfirm { flex: 1 1 100%; }
}

/* ---------------- Design library page ---------------- */
.dl-section { padding-top: 2.5rem; }
.dl-steps {
    list-style: none; margin: 0 0 1.75rem; padding: 0;
    display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem;
}
.dl-steps li {
    display: flex; align-items: center; gap: .6rem; background: var(--paper);
    border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem;
    font-size: .88rem; font-weight: 600; color: var(--text-strong);
}
.dl-step-num {
    flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--mist-deep); color: var(--navy); font-family: var(--font-display); font-size: .9rem;
}
.dl-steps li.is-current { border-color: var(--blue); }
.dl-steps li.is-current .dl-step-num { background: var(--blue); color: #fff; }

.dl-toolbar { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.dl-chips { display: flex; flex-wrap: wrap; gap: .45rem; min-width: 0; max-width: 100%; }
.dl-chip {
    display: inline-flex; align-items: center; gap: .4rem;
    border: 1px solid #cbd5e1; background: #fff; color: var(--text-strong);
    border-radius: 999px; padding: .45rem .95rem; font-size: .85rem; font-weight: 600; text-decoration: none;
    transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.dl-chip span { font-size: .72rem; color: var(--text-muted); font-weight: 600; }
.dl-chip:hover { border-color: var(--blue); color: var(--blue); }
.dl-chip.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.dl-chip.active span { color: rgba(255, 255, 255, .8); }
.dl-search {
    display: flex; align-items: center; gap: .5rem; min-width: 260px; flex: 0 1 320px;
    border: 1px solid #cbd5e1; border-radius: 999px; padding: 0 1rem; background: #fff; color: var(--text-muted);
}
.dl-search input { border: 0; outline: 0; flex: 1; min-width: 0; padding: .65rem 0; font-size: .92rem; background: transparent; }

.dl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.25rem; }
.dl-card {
    display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--line);
    border-radius: var(--radius-lg, 14px); overflow: hidden; box-shadow: var(--shadow-sm);
    transition: transform .2s ease, box-shadow .2s ease;
}
.dl-card[hidden] { display: none; }
.dl-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.dl-card-media {
    position: relative; display: block; width: 100%; aspect-ratio: 1 / 1; border: 0; padding: 2.2rem 1rem 1rem;
    background: linear-gradient(180deg, #f7f9fb, #eef2f6); cursor: pointer;
}
.dl-card-media img { width: 100%; height: 100%; object-fit: contain; }
.dl-card-flag {
    position: absolute; top: .7rem; left: .7rem; background: var(--gold); color: var(--navy);
    font-size: .7rem; font-weight: 700; padding: .2rem .55rem; border-radius: 6px; text-transform: uppercase; letter-spacing: .04em;
}
.dl-card-body { display: flex; flex-direction: column; align-items: stretch; gap: .7rem; padding: .85rem 1rem 1rem; flex: 1; justify-content: space-between; }
.dl-card-body .btn { width: 100%; white-space: nowrap; }
.dl-card-title { font-size: .98rem; margin: 0 0 .15rem; color: var(--text-strong); line-height: 1.25; }
.dl-card-cat { font-size: .78rem; color: var(--text-muted); }
.dl-empty { text-align: center; color: var(--text-muted); padding: 2rem 0; }

.dl-modal { position: fixed; inset: 0; z-index: 600; display: flex; align-items: center; justify-content: center; padding: 1.25rem; }
.dl-modal[hidden] { display: none; }
.dl-modal-backdrop { position: absolute; inset: 0; background: rgba(6, 32, 33, .7); }
.dl-modal-box {
    position: relative; width: 100%; max-width: 980px; max-height: calc(100vh - 2.5rem);
    display: flex; flex-direction: column; background: var(--paper); border-radius: var(--radius-lg, 14px); box-shadow: var(--shadow-lg); overflow: hidden;
}
.dl-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.dl-modal-head strong { display: block; font-family: var(--font-display); font-size: 1.1rem; color: var(--text-strong); }
.dl-modal-kicker { display: block; font-size: .75rem; color: var(--text-muted); font-weight: 600; margin-bottom: .15rem; }
.dl-modal-close { border: 1px solid var(--line); background: #fff; border-radius: 8px; width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-strong); }
.dl-modal-close:hover { border-color: var(--blue); color: var(--blue); }
.dl-modal-tools { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; padding: .85rem 1.25rem; border-bottom: 1px solid var(--line); }
.dl-modal-tools .form-input { flex: 1 1 220px; padding: .55rem .8rem; border: 1px solid #cbd5e1; border-radius: var(--radius); }
.dl-modal-body { overflow: auto; padding: 1rem 1.25rem 1.25rem; background: var(--mist); }
.dl-pgroup { margin-bottom: 1.25rem; }
.dl-pgroup[hidden] { display: none; }
.dl-pgroup-title { font-family: var(--font-display); font-size: .95rem; color: var(--text-strong); margin-bottom: .6rem; }
.dl-pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .7rem; }
.dl-pcard {
    display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    overflow: hidden; text-decoration: none; transition: border-color .15s ease, transform .15s ease;
}
.dl-pcard[hidden] { display: none; }
.dl-pcard:hover { border-color: var(--blue); transform: translateY(-2px); }
.dl-pcard-img { aspect-ratio: 1 / 1; background: var(--mist); }
.dl-pcard-img img { width: 100%; height: 100%; object-fit: cover; }
.dl-pcard-name { font-size: .8rem; font-weight: 600; color: var(--text-strong); padding: .5rem .6rem .1rem; line-height: 1.3; }
.dl-pcard-price { font-size: .74rem; color: var(--text-muted); padding: 0 .6rem .55rem; }

@media (max-width: 900px) {
    .dl-steps { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .dl-steps li { font-size: .8rem; padding: .55rem .6rem; }
    .dl-toolbar { flex-direction: column; align-items: stretch; }
    .dl-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .3rem; -webkit-overflow-scrolling: touch; }
    .dl-chip { flex: 0 0 auto; }
    .dl-search { min-width: 0; width: 100%; flex: none; }
    .dl-grid { grid-template-columns: repeat(2, 1fr); gap: .75rem; }
    .dl-card-body { flex-direction: column; align-items: stretch; padding: .7rem; }
    .dl-card-body .btn { width: 100%; }
    .dl-card-title { font-size: .88rem; }
    .dl-modal { padding: 0; }
    .dl-modal-box { max-height: 100vh; height: 100%; border-radius: 0; }
    .dl-pgrid { grid-template-columns: repeat(2, 1fr); }
}

/* =====================================================================
   Studio v3: tidy sidebar, text panel, font browser, mobile editor
   ===================================================================== */
:root { --mnav-h: 62px; }
body.dz-lock { overflow: hidden; }

/* Keep every sidebar card inside its column (fixes the crop panel overflow). */
.designer-side { grid-template-columns: minmax(0, 1fr); }
.side-panel.active { grid-template-columns: minmax(0, 1fr); }
.designer-side .tool-group { min-width: 0; }
.dz-crop-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.dz-crop-actions .btn { flex: 1 1 auto; white-space: normal; font-size: .82rem; padding: .5rem .75rem; line-height: 1.2; }
.dz-crop-actions .strip-btn { flex: 0 0 auto; }
.dz-crop-card { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(252, 169, 12, .35); }
.dz-btn-block { width: 100%; white-space: normal; line-height: 1.2; gap: .45rem; }
.dz-btn-block svg { flex: 0 0 auto; }

/* Desktop tabs: icon over label, five across. */
.side-tabs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .3rem; }
.side-tab {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: .2rem;
    padding: .5rem .1rem .45rem; font-family: var(--font-text); font-size: .7rem; font-weight: 600;
    text-transform: none; letter-spacing: 0; min-width: 0; transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.side-tab:hover { border-color: var(--blue); color: var(--blue); }
.side-tab.active:hover { color: #fff; }
.side-tab span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.side-tab .layer-count {
    position: absolute; top: 3px; right: 3px; margin: 0; min-width: 16px; height: 16px;
    font-size: .6rem; background: var(--gold); color: var(--navy); font-weight: 700;
}

.dz-pal-none { background: #fff linear-gradient(135deg, transparent 45%, #e63946 45%, #e63946 55%, transparent 55%); }

/* ---------------- Text panel ---------------- */
.tp-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .55rem; }
.tp-head .opt-label { margin: 0; }
.tp-new {
    display: inline-flex; align-items: center; gap: .25rem; border: 1px solid #cbd5e1; background: #fff;
    border-radius: 999px; padding: .25rem .65rem; font-size: .74rem; font-weight: 600; color: var(--blue); cursor: pointer;
}
.tp-new:hover { border-color: var(--blue); }
.tp-new[hidden] { display: none; }
.tp-input {
    display: block; width: 100%; min-height: 64px; resize: vertical; border: 1.5px solid #cbd5e1; border-radius: 10px;
    padding: .65rem .75rem; font: 500 .95rem/1.35 var(--font-text); color: var(--text-strong); background: #fff;
}
.tp-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(5, 105, 107, .15); }
#dzAddText { margin-top: .6rem; }
#dzAddText[hidden] { display: none; }

.tp-toolbar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem; margin: .8rem 0 .75rem; }
.tp-tool {
    display: flex; flex-direction: column; align-items: center; gap: .2rem; min-width: 0;
    padding: .5rem .2rem .42rem; border: 1px solid var(--line); border-radius: 10px; background: var(--mist);
    font-size: .68rem; font-weight: 600; color: var(--text-strong); cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.tp-tool span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tp-tool:hover { border-color: var(--blue); color: var(--blue); background: #fff; }
.tp-tool.active { background: var(--navy); border-color: var(--navy); color: #fff; }

.tp-rows { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: .85rem; background: #fff; }
.tp-row {
    display: flex; align-items: center; gap: .6rem; width: 100%; min-height: 48px; padding: .6rem .75rem;
    background: #fff; border: 0; cursor: pointer; text-align: left; color: var(--text-strong); font-family: var(--font-text);
}
.tp-row + .tp-row, .tp-pop + .tp-row { border-top: 1px solid var(--line); }
.tp-row:hover { background: #f8fafb; }
.tp-row-label { flex: 0 0 58px; font-size: .7rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.tp-row-value {
    flex: 1; min-width: 0; display: flex; align-items: center; gap: .45rem; font-size: .86rem; font-weight: 600;
    overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.tp-font-value { display: block; font-size: 1.15rem; font-weight: 400; line-height: 1.3; }
.tp-font-value.is-loading { opacity: .45; }
.tp-row > svg { color: var(--text-muted); flex: 0 0 auto; transition: transform .2s ease; }
.tp-row.open > svg { transform: rotate(90deg); }
.tp-swatch { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(15, 37, 38, .22); flex: 0 0 auto; box-shadow: inset 0 0 0 2px #fff; }
.tp-pop { padding: .75rem; background: var(--mist); border-top: 1px solid var(--line); }
.tp-pop[hidden] { display: none; }
.tp-pop .dz-palette { margin-bottom: .55rem; }

.tp-seg { display: grid; grid-template-columns: 1fr 1fr; background: #e3e9ef; border-radius: 9px; padding: 3px; margin-bottom: .7rem; }
.tp-seg button {
    border: 0; background: transparent; border-radius: 7px; padding: .42rem; font: 600 .8rem var(--font-text);
    color: var(--text-muted); cursor: pointer; transition: background .15s ease, color .15s ease;
}
.tp-seg button.active { background: #fff; color: var(--navy); box-shadow: 0 1px 3px rgba(10, 46, 47, .15); }
.tp-grad-bar { height: 30px; border-radius: 8px; border: 1px solid rgba(15, 37, 38, .12); margin-bottom: .6rem; }
.tp-stops { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: .35rem; align-items: center; margin-bottom: .55rem; }
.tp-stop {
    position: relative; display: flex; align-items: center; gap: .4rem; min-width: 0; background: #fff;
    border: 1px solid #cbd5e1; border-radius: 9px; padding: .35rem .4rem; cursor: pointer;
}
.tp-stop:hover { border-color: var(--blue); }
.tp-stop input[type="color"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.tp-stop { gap: .3rem; padding: .3rem; }
.tp-stop-sw { width: 20px; height: 20px; border-radius: 5px; border: 1px solid rgba(15, 37, 38, .2); flex: 0 0 auto; }
.tp-stop-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; font-size: .64rem; letter-spacing: -.01em; font-weight: 600; color: var(--text-strong); overflow: hidden; }
.tp-stop-txt small { font-size: .6rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.tp-swap {
    width: 30px; height: 30px; border-radius: 50%; border: 1px solid #cbd5e1; background: #fff; color: var(--text-strong);
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.tp-swap:hover { border-color: var(--blue); color: var(--blue); }
.tp-presets { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .35rem; margin-top: .55rem; }
.tp-preset { height: 22px; border-radius: 6px; border: 1px solid rgba(15, 37, 38, .15); cursor: pointer; padding: 0; transition: transform .12s ease; }
.tp-preset:hover { transform: translateY(-1px); }

.tp-slider { display: grid; grid-template-columns: 58px minmax(0, 1fr) 54px; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.tp-slider label { font-size: .7rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.tp-slider input[type="range"] { width: 100%; min-width: 0; accent-color: var(--blue); height: 26px; margin: 0; }
.tp-num {
    width: 54px; padding: .32rem .25rem; border: 1px solid #cbd5e1; border-radius: 7px; background: #fff;
    font: 600 .8rem var(--font-text); text-align: center; color: var(--text-strong);
}
.tp-num:focus { outline: none; border-color: var(--blue); }
.tp-num-ro { display: inline-block; border-color: transparent; background: transparent; }
.tp-pop .tp-slider { margin: .6rem 0 0; }
.tp-style { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin: .75rem 0 .6rem; }
.tp-style .strip-btn:disabled { opacity: .4; cursor: not-allowed; }
.tp-shadow { margin-bottom: .5rem; }
.tp-shadow-opts { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: .5rem; align-items: center; margin-top: .5rem; }
.tp-shadow-opts[hidden] { display: none; }
.tp-shadow-opts input[type="color"] { width: 44px; height: 32px; border: 1px solid #cbd5e1; border-radius: 7px; padding: 2px; background: #fff; cursor: pointer; }
.tp-shadow-opts .tp-slider { grid-template-columns: 40px minmax(0, 1fr); margin: 0; }
.tp-remove {
    display: inline-flex; align-items: center; gap: .35rem; border: 0; background: none; cursor: pointer;
    color: #b42318; font: 600 .8rem var(--font-text); padding: .35rem 0 0;
}
.tp-remove:hover { text-decoration: underline; }

/* Font browser */
.tp-fonts-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .7rem; }
.tp-fonts-head strong { font-family: var(--font-display); font-size: .95rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-strong); }
.tp-back {
    display: inline-flex; align-items: center; gap: .15rem; border: 1px solid var(--line); background: #fff; border-radius: 8px;
    padding: .3rem .55rem .3rem .3rem; font: 600 .78rem var(--font-text); color: var(--text-strong); cursor: pointer;
}
.tp-back:hover { border-color: var(--blue); color: var(--blue); }
.tp-font-list { display: grid; gap: .35rem; max-height: 470px; overflow-y: auto; padding-right: 2px; overscroll-behavior: contain; }
.tp-font {
    display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; width: 100%; text-align: left;
    border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: .5rem .75rem; cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}
.tp-font:hover { border-color: var(--blue); }
.tp-font.active { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); background: #f0f8f8; }
.tp-font-sample { font-size: 1.45rem; line-height: 1.3; color: var(--text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tp-font-name { font: 600 .7rem var(--font-text); color: var(--text-muted); }

/* Mobile-only chrome is hidden on larger screens. */
.dz-sheet-head, .dz-mnav, .dz-sheet-backdrop, .dz-modal-head .dz-sheet-handle { display: none; }

/* ---------------- Mobile editor (768px and below) ---------------- */
@media (max-width: 768px) {
    body.designer-page { overflow: hidden; overscroll-behavior: none; }
    .designer-shell { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }

    .dz-topbar { position: relative; flex-wrap: nowrap; min-height: 52px; padding: .4rem .7rem; gap: .5rem; }
    .dz-brand, .dz-topbar-sep, .dz-product-thumb, .dz-top-link { display: none; }
    .dz-topbar-left { gap: .5rem; flex: 1; }
    .dz-product-name { font-size: .86rem; }
    .dz-change-product { font-size: .72rem; }
    .dz-topbar-right { gap: .45rem; flex: 0 0 auto; }
    .dz-topbar-total { font-size: .72rem; }
    .dz-topbar-total strong { font-size: 1rem; margin-left: .2rem; }
    .dz-close { padding: .45rem; }
    .dz-close span { display: none; }

    .designer-main { flex: 1; min-height: 0; display: flex; padding: 0 0 calc(var(--mnav-h) + env(safe-area-inset-bottom, 0px)); }
    .designer-main .designer-grid { display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; width: 100%; max-width: 100%; gap: 0; margin: 0; }
    .designer-stage, .dz-area-tabs, .stage-toolbar, .designer-canvas-wrap { min-width: 0; max-width: 100%; }
    .designer-stage {
        order: 0; flex: 1; min-height: 0; display: flex; flex-direction: column;
        border: 0; border-radius: 0; padding: .5rem .6rem .35rem; background: var(--mist);
    }
    .stage-toolbar { flex-wrap: nowrap; margin-bottom: .4rem; gap: .4rem; }
    .stage-btn { width: 34px; height: 34px; }
    .dz-area-tabs { flex-wrap: nowrap; padding: 2px 2px .45rem; scrollbar-width: none; }
    .dz-area-tabs::-webkit-scrollbar { display: none; }
    .dz-area-tab { min-height: 32px; padding: .3rem .8rem; font-size: .78rem; }
    .designer-canvas-wrap {
        flex: 1 1 0; min-height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center;
        background: #fff; border-radius: 12px;
    }
    .designer-hint { display: none; }

    /* Sidebars become bottom sheets. */
    .designer-side {
        position: fixed; left: 0; right: 0; z-index: 60; display: block;
        bottom: calc(var(--mnav-h) + env(safe-area-inset-bottom, 0px));
        max-height: 60vh; max-height: min(60dvh, 560px); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
        background: var(--paper); border-radius: 18px 18px 0 0; box-shadow: 0 -14px 40px rgba(6, 32, 33, .22);
        padding: 0 .9rem 1rem; transform: translateY(calc(100% + var(--mnav-h) + 40px)); visibility: hidden;
        transition: transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .3s;
    }
    .designer-side.is-open { transform: translateY(0); visibility: visible; transition: transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s; }
    .dz-tools-side { max-height: 52vh; max-height: min(52dvh, 520px); }
    .dz-order-side { max-height: 80vh; max-height: 80dvh; }
    .dz-sheet-head {
        position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: .5rem;
        background: var(--paper); padding: 1.15rem 0 .6rem; margin-bottom: .2rem; border-bottom: 1px solid var(--line); touch-action: none;
    }
    .dz-sheet-handle {
        display: block; position: absolute; top: .45rem; left: 50%; width: 42px; height: 4px; margin-left: -21px;
        border-radius: 4px; background: #cbd5e1;
    }
    .dz-sheet-title { font-family: var(--font-display); font-size: 1rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-strong); }
    .dz-sheet-close {
        width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--mist);
        display: inline-flex; align-items: center; justify-content: center; color: var(--text-strong); cursor: pointer;
    }
    .side-tabs { display: none; }
    .side-panel { gap: 0; }
    .tp-head .opt-label { visibility: hidden; }
    .dz-tools-side.m-edit .side-panel[data-panel-body="layers"] { display: grid; grid-template-columns: minmax(0, 1fr); }
    .designer-side .tool-group, .designer-side .designer-summary {
        border: 0; border-radius: 0; box-shadow: none; padding: .85rem 0; border-bottom: 1px solid var(--line);
    }
    .designer-side .side-panel > .tool-group:last-child, .designer-side > .designer-summary { border-bottom: 0; }
    .opt-label { font-size: .95rem; }
    .tp-font-list { max-height: none; overflow: visible; }
    .dz-tpl-grid { grid-template-columns: repeat(3, 1fr); max-height: none; }
    .dz-palette { grid-template-columns: repeat(8, minmax(0, 1fr)); }
    .dz-pal { min-height: 30px; }
    .tp-slider input[type="range"] { height: 32px; }
    .tp-num { font-size: 16px; padding: .3rem .2rem; }
    .tp-input, .dz-search input, .team-fields .form-input, .dz-select, .size-cell input { font-size: 16px; }
    .dz-order-side .size-grid-compact .size-cell input { width: 56px; }

    /* Fixed bottom navigation. */
    .dz-mnav {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
        height: calc(var(--mnav-h) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px);
        background: var(--navy-deep); box-shadow: 0 -2px 12px rgba(6, 32, 33, .25);
    }
    .dz-mnav button {
        position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        min-width: 0; border: 0; background: none; color: #b7caca; font: 600 .64rem var(--font-text); cursor: pointer; padding: 0 2px;
    }
    .dz-mnav button span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
    .dz-mnav button.active { color: #fff; }
    .dz-mnav button.active::before {
        content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; border-radius: 0 0 3px 3px; background: var(--gold);
    }
    .dz-mnav .is-next { background: var(--gold); color: var(--navy); }
    .dz-mnav .is-next.active { color: var(--navy); }
    .dz-mnav .is-next.active::before { background: var(--navy); }
    .dz-mnav .dz-mnav-badge {
        position: absolute; top: 6px; left: calc(50% + 6px); min-width: 16px; max-width: none; height: 16px; padding: 0 4px; border-radius: 99px;
        background: var(--gold); color: var(--navy); font-size: .6rem; font-weight: 700; line-height: 16px; text-align: center;
    }
    .dz-mnav .dz-mnav-badge[hidden] { display: none; }
    .dz-sheet-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(6, 32, 33, .4); }
    .dz-sheet-backdrop[hidden] { display: none; }

    /* Product picker slides up as a sheet. */
    .dz-sheet-modal { padding: 0; align-items: flex-end; }
    .dz-sheet-modal .dz-modal-box {
        max-height: 90vh; max-height: 90dvh; border-radius: 18px 18px 0 0; animation: dzSheetUp .28s cubic-bezier(.2, .8, .2, 1);
    }
    .dz-sheet-modal .dz-modal-head { position: relative; padding: 1.2rem 1rem .7rem; font-size: 1rem; }
    .dz-modal-head .dz-sheet-handle { display: block; }
    .dz-products-body { padding: 1rem; }
    .dz-products-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }

    /* Preview: full screen with a sticky action bar. */
    .dz-pv-box { height: 100%; height: 100dvh; max-height: none; border-radius: 0; animation: dzSheetUp .28s cubic-bezier(.2, .8, .2, 1); }
    .dz-pv-head { padding: .55rem .7rem .55rem 1rem; font-size: 1rem; }
    .dz-pv-toolbar { padding: .55rem .7rem; }
    .dz-pv-tabs { flex-wrap: nowrap; scrollbar-width: none; max-width: 100%; }
    .dz-pv-stage { padding: 0 .6rem .6rem; }
    .dz-pv-side { padding: .9rem; }
    .dz-pv-areas { grid-template-columns: repeat(3, 1fr); }
    .dz-pv-foot { padding: .6rem .7rem calc(.6rem + env(safe-area-inset-bottom, 0px)); gap: .45rem; box-shadow: 0 -4px 14px rgba(6, 32, 33, .08); }
    .dz-pv-foot .btn-sm { flex: 1 1 0; font-size: .82rem; padding: .55rem .5rem; }
    .dz-pv-foot #dzConfirm { flex: 1 1 100%; }
}
@keyframes dzSheetUp { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    .designer-side, .dz-sheet-modal .dz-modal-box, .dz-pv-box { transition: none !important; animation: none !important; }
}

/* Colour palettes: wrap to fit the panel width instead of forcing 8 columns */
.dz-palette { grid-template-columns: repeat(auto-fill, minmax(26px, 1fr)) !important; gap: .4rem; width: 100%; }
.dz-pal { min-width: 0; max-width: 34px; justify-self: center; box-sizing: border-box; }
.dz-color-row { flex-wrap: wrap; }
