/* Till layout designer (#1691). Page chrome, structure tree, till-frame preview, inspectors, review panel.
   Every colour is a theme token; the only literals are the tile colours the merchant chose (inline style).
   Narrow (<=800px) turns the three columns into Structure / Preview / Settings tabs. */

.tl-page { display: flex; flex-direction: column; gap: 1rem; }

/* ── header ─────────────────────────────────────────────────────────────── */
/* The header sits directly under the sticky top bar; give it room (and a scroll margin) so the CATALOG eyebrow is never
   clipped behind it. Same fix as .cc-csa-head in box-builder.css. */
.tl-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem 1.5rem;
    padding-top: .75rem; scroll-margin-top: calc(var(--topnav-height, 58px) + .5rem); }
.tl-eyebrow { font-size: var(--text-xs); line-height: 1.4; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-secondary); }
.tl-h1 { font-size: 1.5rem; margin: .1rem 0 0; }
.tl-head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; }
.tl-scope { display: flex; align-items: center; gap: .4rem; font-size: var(--text-sm); color: var(--text-secondary); }
.tl-scope strong { color: var(--text-primary); }
.tl-pill {
    display: inline-flex; align-items: center; padding: .2rem .6rem; border-radius: 999px; font-size: var(--text-xs);
    font-weight: 700; background: var(--warning-light); color: var(--warning-text);
}
.tl-pill-quiet { background: var(--content-bg); color: var(--text-secondary); border: 1px solid var(--border); }
.tl-pill-live { background: var(--accent-light); color: var(--accent-strong); }
.tl-pill-override { background: var(--warning-light); color: var(--warning-text); }
.tl-pill-inherit { background: var(--content-bg); color: var(--text-secondary); border: 1px solid var(--border); }
.tl-scope-state { margin-top: .35rem; display: flex; align-items: center; flex-wrap: wrap; }
.tl-reset { font-size: var(--text-xs); }

/* ── 3-column body ─────────────────────────────────────────────────────── */
.tl-tabs { display: none; }
.tl-body { display: grid; grid-template-columns: 288px minmax(0, 1fr) 320px; gap: 1rem; align-items: start; }
.tl-col { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-md); min-width: 0; }
.tl-col-h { padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
.tl-col-b { padding: .75rem 1rem; }

@media (max-width: 800px) {
    .tl-tabs { display: flex; border-bottom: 1px solid var(--border); gap: .25rem; }
    .tl-tab-host { flex: 1; display: flex; }
    .tl-tab-host > .btn { flex: 1; }
    .btn.tl-tab {
        min-height: var(--cc-tap, 44px); border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none;
        font-weight: 600; color: var(--text-secondary); text-decoration: none; justify-content: center;
    }
    .btn.tl-tab[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--accent); }
    .tl-body { display: block; }
    .tl-pane { display: none; }
    .tl-pane.tl-pane-on { display: block; }
    .tl-head { flex-direction: column; align-items: stretch; }
}

/* ── structure tree ────────────────────────────────────────────────────── */
.tl-filter { width: 100%; min-height: var(--cc-tap, 44px); }
.tl-tree { list-style: none; margin: .5rem 0 0; padding: 0; }
.tl-row {
    display: flex; align-items: center; gap: .3rem; min-height: var(--cc-tap, 44px); padding: 0 .25rem; border-radius: var(--radius-sm);
    border: 1px solid transparent; font-size: var(--text-sm); position: relative;
}
.tl-row:hover { background: var(--content-bg); }
.tl-row[data-selected="true"] { background: var(--accent-light); border-color: var(--accent); }
.tl-row[data-drop="true"] { border-top: 2px solid var(--accent); }
.tl-row-sub { margin-left: 1rem; }
.tl-row-prod { margin-left: 2rem; }
.tl-grip { color: var(--text-muted); cursor: grab; flex: 0 0 auto; user-select: none; }
.tl-grow { flex: 1 1 auto; min-width: 0; display: flex; }
.tl-grow > .btn { flex: 1 1 auto; min-width: 0; }
.btn.tl-ctl { border: 0; padding: 0 .25rem; min-height: var(--cc-tap, 44px); font: inherit; text-decoration: none; background: none; box-shadow: none; }
.btn.tl-name { justify-content: flex-start; text-align: left; color: var(--text-primary); gap: .35rem; }
.btn.tl-name.tl-hidden .tl-ell { text-decoration: line-through; color: var(--text-muted); }
/* Names wrap instead of truncating: the 288px column once cut them to a single letter. The button tooltip carries the full name. */
.tl-ell { overflow-wrap: anywhere; white-space: normal; min-width: 0; line-height: 1.25; }
.btn.tl-name { height: auto; }
.tl-count { color: var(--text-muted); font-size: var(--text-xs); flex: 0 0 auto; }
.btn.tl-chev { color: var(--text-secondary); min-width: var(--cc-tap, 44px); justify-content: center; }
.tl-badge {
    flex: 0 0 auto; font-size: var(--text-xs); font-weight: 700; padding: 0 .35rem; border-radius: var(--radius-sm);
    border: 1px solid var(--border); color: var(--text-secondary);
}
.tl-badge-on { background: var(--accent-light); color: var(--accent-strong); border-color: var(--accent); }
.btn.tl-star { color: var(--text-muted); min-width: var(--cc-tap, 44px); justify-content: center; }
.btn.tl-star[aria-pressed="true"] { color: var(--accent-strong); }
.tl-hidden-pill { flex: 0 0 auto; font-size: var(--text-xs); padding: 0 .4rem; border-radius: 999px; background: var(--content-bg); color: var(--text-secondary); border: 1px solid var(--border); }
.tl-popular-cap { font-size: var(--text-xs); color: var(--text-muted); }
.tl-help { font-size: var(--text-xs); color: var(--text-secondary); margin: .4rem 0 0; }
.tl-foot-help { border-top: 1px solid var(--border); padding: .6rem 1rem; font-size: var(--text-xs); color: var(--text-secondary); }

/* ── preview ───────────────────────────────────────────────────────────── */
.tl-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; padding: .6rem 1rem; border-bottom: 1px solid var(--border); }
.tl-fs { border: 0; margin: 0; padding: 0; min-width: 0; }
.tl-btnrow { display: flex; gap: .5rem; flex-wrap: wrap; }
.tl-fit { margin-left: auto; font-size: var(--text-sm); color: var(--text-secondary); }
.tl-custom { display: inline-flex; align-items: center; gap: .3rem; font-size: var(--text-sm); }
.tl-custom input { width: 5.5rem; min-height: var(--cc-tap, 44px); }

.tl-stage { container-type: inline-size; background: var(--content-bg); padding: 1rem; display: flex; justify-content: center; min-height: 12rem; }
.tl-caption { text-align: center; font-size: var(--text-xs); color: var(--text-secondary); padding: .5rem 1rem 1rem; }

/* every length in the frame is a multiple of --u, so the whole till shrinks together to fit the stage */
.tl-frame {
    --u: min(calc(var(--f) * 1px), calc(100cqw / var(--dw)));
    width: calc(var(--u) * var(--dw)); height: calc(var(--u) * var(--dh));
    border: calc(var(--u) * 8) solid var(--cc-green); border-radius: calc(var(--u) * 14); box-sizing: content-box;
    background: var(--card-bg); display: flex; flex-direction: column; overflow: hidden; font-size: calc(var(--u) * 14);
    margin: calc(var(--u) * -8); /* keep the bezel inside the stage */
}
.tl-frame-top { height: calc(var(--u) * 56); background: var(--cc-green); color: var(--text-inverse); display: flex; align-items: center; justify-content: space-between; padding: 0 calc(var(--u) * 16); font-weight: 700; flex: 0 0 auto; }
.tl-frame-search { background: rgba(255, 255, 255, .16); border-radius: calc(var(--u) * 6); padding: calc(var(--u) * 6) calc(var(--u) * 14); font-weight: 400; font-size: calc(var(--u) * 13); }
.tl-frame-main { display: flex; flex: 1 1 auto; min-height: 0; }
.tl-frame-main.tl-stack { flex-direction: column; }
.tl-grid-wrap { flex: 0 0 60%; min-width: 0; min-height: 0; overflow: hidden; padding: calc(var(--u) * 10); display: flex; flex-direction: column; gap: calc(var(--u) * 8); }
.tl-stack .tl-grid-wrap { flex: 1 1 auto; }
.tl-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: calc(var(--u) * 6); font-size: calc(var(--u) * 12); flex: 0 0 auto; }
.tl-crumbs .cc-tip-host { display: inline-flex; }
.btn.tl-crumb { border: 1px solid var(--border); background: var(--content-bg); border-radius: 999px; padding: calc(var(--u) * 2) calc(var(--u) * 10); color: var(--text-primary); font: inherit; min-height: 0; text-decoration: none; gap: .3rem; }
.btn.tl-crumb[aria-current="true"] { background: var(--cc-green); color: var(--text-inverse); border-color: var(--cc-green); }
.tl-eb { font-size: calc(var(--u) * 11); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-secondary); margin-top: calc(var(--u) * 4); }
.tl-tiles { display: grid; gap: calc(var(--u) * 8); grid-auto-rows: calc(var(--u) * 96); grid-auto-flow: dense; }
.tl-cell { min-width: 0; min-height: 0; display: flex; }
.tl-cell > .cc-tip-host { display: flex; flex: 1; min-width: 0; }
.btn.tl-tile, .btn.tl-tile:hover, .btn.tl-tile:active, .btn.tl-tile:focus {
    position: relative; overflow: hidden; border: 0; border-radius: calc(var(--u) * 8); padding: calc(var(--u) * 8); text-align: left;
    display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; gap: 0; width: 100%; height: 100%; min-height: 0;
    font: inherit; text-decoration: none; background-color: var(--cc-green); color: var(--text-inverse);
}
.tl-tile > .bi { display: none; }
.tl-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tl-tile .tl-tile-scrim { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0, 0, 0, .65), rgba(0, 0, 0, 0) 60%); }
.tl-tile-name { position: relative; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tl-tile-sub { position: relative; font-size: calc(var(--u) * 11); opacity: .9; }
.btn.tl-tile[data-selected="true"] { outline: calc(var(--u) * 2.5) solid var(--accent); outline-offset: calc(var(--u) * 1); }
.btn.tl-tile[data-soldout="true"] { opacity: .55; }
.tl-tile-initial { position: relative; font-size: calc(var(--u) * 32); font-weight: 700; margin-bottom: auto; }
.tl-cart { flex: 1 1 auto; border-left: 1px solid var(--border); padding: calc(var(--u) * 12); display: flex; flex-direction: column; gap: calc(var(--u) * 8); min-width: 0; }
.tl-stack .tl-cart { border-left: 0; border-top: 1px solid var(--border); flex: 0 0 auto; }
.tl-cart-line { display: flex; justify-content: space-between; gap: calc(var(--u) * 8); }
.tl-cart-ph { display: inline-block; width: 3rem; height: .6rem; border-radius: 3px; background: var(--border); align-self: center; }
.tl-pay { margin-top: auto; background: var(--accent); color: var(--on-accent); border-radius: calc(var(--u) * 8); text-align: center; font-weight: 700; padding: calc(var(--u) * 12); }
.tl-stack .tl-pay { margin-top: 0; }

.tl-empty { padding: 1.5rem; text-align: center; color: var(--text-secondary); }
.tl-empty p { margin: 0 0 .75rem; }

/* ── inspectors ────────────────────────────────────────────────────────── */
.tl-insp { padding: 1rem; }
.tl-insp + .tl-insp { border-top: 1px solid var(--border); }
.tl-insp > * + * { margin-top: 1rem; }
.tl-insp h2 { font-size: 1.1rem; margin: .1rem 0 0; }
.tl-sub { color: var(--text-secondary); font-size: var(--text-sm); }
.tl-prod-thumb { display: block; width: 96px; height: 96px; object-fit: cover; border-radius: var(--radius-md); border: 1px solid var(--border); margin-top: .5rem; background: var(--content-bg); }
.tl-field > label, .tl-label { display: block; font-size: var(--text-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary); margin-bottom: .3rem; }
.tl-field input[type=text], .tl-field select { width: 100%; min-height: var(--cc-tap, 44px); }
.tl-inline { display: flex; gap: .5rem; align-items: stretch; }
.tl-inline input { flex: 1 1 auto; }
.tl-switchrow { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.tl-sw-hit { min-height: var(--cc-tap, 44px); display: inline-flex; align-items: center; margin: 0; cursor: pointer; }
.tl-sw {
    appearance: none; -webkit-appearance: none; position: relative; width: 42px; height: 24px; margin: 0; border-radius: 999px;
    border: 1px solid var(--border); background: var(--text-muted); cursor: pointer; flex: 0 0 auto; transition: background .12s;
}
.tl-sw::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--cc-white); transition: left .12s; }
.tl-sw:checked { background: var(--cc-green); border-color: var(--cc-green); }
.tl-sw:checked::after { left: 20px; }
.tl-sw:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tl-sw:disabled { opacity: .5; cursor: default; }
.tl-thumbs { display: flex; gap: .4rem; flex-wrap: wrap; }
.btn.tl-thumb { width: 44px; height: 44px; padding: 0; border: 2px solid var(--border); border-radius: var(--radius-md); overflow: hidden; background: var(--content-bg); position: relative; display: block; min-height: 0; }
.btn.tl-thumb > .bi { display: none; }
.btn.tl-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.btn.tl-thumb[aria-pressed="true"] { border-color: var(--accent); }
.tl-thumb-ok { position: absolute; right: 1px; bottom: 1px; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-size: 11px; }
.tl-swatches { display: flex; gap: .4rem; flex-wrap: wrap; }
.tl-swatches[data-dim="true"] { opacity: .45; }
.tl-swatches .cc-tip-host { display: inline-flex; }
.btn.tl-swatch, .btn.tl-swatch:hover, .btn.tl-swatch:active { width: var(--cc-tap, 44px); height: var(--cc-tap, 44px); min-height: 0; border-radius: var(--radius-md); border: 2px solid transparent; padding: 0; display: grid; place-items: center; font-weight: 700; }
.btn.tl-swatch > .bi { visibility: hidden; }
.btn.tl-swatch[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--card-bg) inset; }
.btn.tl-swatch[aria-pressed="true"] > .bi { visibility: visible; }
.tl-rule { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
.btn.tl-danger-link { color: var(--danger); }
.tl-note { background: var(--content-bg); border: 1px solid var(--border); border-radius: var(--radius-md); padding: .6rem .75rem; font-size: var(--text-sm); color: var(--text-secondary); }
.tl-live { border-bottom: 1px solid var(--border); }
.tl-live-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.tl-mini { font-size: var(--text-xs); }

/* ── review & publish ─────────────────────────────────────────────────── */
.cc-panel.tl-review { width: min(440px, 100%); }
.tl-rv-group + .tl-rv-group { margin-top: 1.25rem; }
.tl-rv-list { list-style: none; margin: .4rem 0 0; padding: 0; }
.tl-rv-list li { padding: .45rem 0; border-bottom: 1px solid var(--border); font-size: var(--text-sm); }
.tl-rv-pill { margin-left: .4rem; }
.tl-rv-sync { margin-top: 1.25rem; }
.tl-rv-foot { display: flex; justify-content: space-between; align-items: center; gap: .5rem; width: 100%; }
.tl-rv-foot-r { display: flex; gap: .5rem; }

/* ── Tile style presets (plan C.8). Product tiles only; category tiles keep their own look. ───────────────────────────────── */
.tl-style-cards { display: grid; gap: .6rem; margin-top: .6rem; }
.tl-style-card { display: grid; gap: .25rem; text-align: left; padding: .6rem; border: 2px solid var(--border); border-radius: 10px; background: var(--content-bg); color: var(--text-primary); cursor: pointer; min-height: var(--cc-tap, 44px); }
.tl-style-card.tl-style-on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tl-style-title { font-weight: 700; }
.tl-style-blurb { font-size: var(--text-xs); color: var(--text-secondary); }
.tl-style-thumb { display: flex; gap: 6px; height: 54px; }
.tl-thumb-tile { flex: 1; position: relative; border-radius: 6px; background: var(--cc-green); overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; padding: 4px; gap: 2px; }
.tl-thumb-name, .tl-thumb-price { display: block; height: 4px; border-radius: 2px; background: var(--text-primary); }
.tl-thumb-name { width: 70%; } .tl-thumb-price { width: 35%; opacity: .7; }
.tl-style-thumb.tl-style--photofirst .tl-thumb-name, .tl-style-thumb.tl-style--photofirst .tl-thumb-price { background: rgb(255 255 255); }
.tl-style-thumb.tl-style--classic .tl-thumb-tile, .tl-style-thumb.tl-style--compact .tl-thumb-tile, .tl-style-thumb.tl-style--menulist .tl-thumb-tile { background: var(--content-bg); border: 1px solid var(--border); }
.tl-style-thumb.tl-style--menulist { flex-direction: column; }
.tl-style-thumb.tl-style--menulist .tl-thumb-tile { flex-direction: row; align-items: center; justify-content: flex-start; }

.tl-style--photofirst .tl-cell-product .tl-tile-name, .tl-style--photofirst .tl-cell-product .tl-tile-sub { color: rgb(255 255 255); }
.tl-style--classic .tl-cell-product .btn.tl-tile, .tl-style--compact .tl-cell-product .btn.tl-tile, .tl-style--menulist .tl-cell-product .btn.tl-tile { background-color: rgb(255 255 255); color: var(--text-primary); box-shadow: inset 0 0 0 1px var(--border); }
.tl-style--classic .tl-cell-product .tl-tile img, .tl-style--compact .tl-cell-product .tl-tile img { height: 60%; bottom: auto; }
.tl-style--classic .tl-cell-product .tl-tile-scrim, .tl-style--compact .tl-cell-product .tl-tile-scrim, .tl-style--menulist .tl-cell-product .tl-tile-scrim { display: none; }
.tl-style--compact .tl-cell-product .tl-tile-name { font-size: calc(var(--u) * 15); } .tl-style--compact .tl-cell-product .tl-tile-sub { font-size: calc(var(--u) * 15); }
.tl-style--menulist .tl-cell-product .tl-tile-name { font-size: calc(var(--u) * 22); }
.tl-style--menulist .tl-cell-product .tl-tile img { right: auto; width: 38%; }
.tl-style--menulist .tl-cell-product .btn.tl-tile { padding-left: 42%; justify-content: center; }
.tl-style--menulist .tl-cell-product .tl-tile-sub { position: absolute; left: calc(var(--u) * 4); bottom: calc(var(--u) * 4); background: rgb(168 72 28); color: rgb(255 255 255); opacity: 1; padding: 0 calc(var(--u) * 6); border-radius: 999px; }
