:root {
	--bg: #f6f6f8;
	--surface: #ffffff;
	--surface-2: #f0f0f4;
	--text: #1c1c22;
	--muted: #6b6b78;
	--border: #e2e2ea;
	--primary: #6d5efc;
	--primary-ink: #ffffff;
	--star: #f5b301;
	--radius: 12px;
	--shadow: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
	:root {
		--bg: #16161a; --surface: #1f1f26; --surface-2: #26262f; --text: #ececf1;
		--muted: #9a9aa8; --border: #33333e; --shadow: 0 1px 3px rgba(0,0,0,.4);
	}
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
	background: var(--bg); color: var(--text);
	font: 15px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
	-webkit-text-size-adjust: 100%;
}
a { color: inherit; text-decoration: none; }
h1 { font-size: 1.5rem; margin: 0; }
h3 { font-size: 1.05rem; margin: 1.4rem 0 .6rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.pad { padding: 1rem; }
code { background: var(--surface-2); padding: .1rem .3rem; border-radius: 5px; font-size: .85em; }

/* --- boot / loading --- */
.boot { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; padding: 2rem; text-align: center; }
.boot-icon { font-size: 3rem; }
.boot-err { color: #d33; font-weight: 600; }

/* --- shell / nav --- */
.app-shell { min-height: 100vh; }
.topnav {
	position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem;
	padding: .6rem max(1rem, env(safe-area-inset-left)); background: var(--surface);
	border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; letter-spacing: .02em; }
.navlinks { display: flex; gap: .25rem; flex-wrap: wrap; }
.navlinks a { padding: .35rem .7rem; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: .9rem; }
.navlinks a.on { background: var(--primary); color: var(--primary-ink); }
main { max-width: 1100px; margin: 0 auto; padding: 1rem; }

/* --- view header / toolbar --- */
.view-head { display: flex; align-items: baseline; gap: .6rem; margin-bottom: .8rem; }
.count { color: var(--muted); font-size: .85rem; }
.toolbar { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; align-items: center; }
.search { flex: 1 1 12rem; }
.view-layout { display: grid; grid-template-columns: 220px 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 820px) { .view-layout { grid-template-columns: 1fr; } }
.filter-side { display: flex; flex-direction: column; gap: .7rem; padding: .85rem; border: 1px solid var(--border);
	border-radius: var(--radius); background: var(--surface); position: sticky; top: 4rem;
	max-height: calc(100vh - 5rem); overflow-y: auto; }
@media (max-width: 820px) { .filter-side { position: static; max-height: none; overflow: visible; } }
.filter-side .search { width: 100%; flex: none; }
.sort-field { display: flex; flex-direction: column; gap: .2rem; }
.sort-field select { width: 100%; padding: .4rem .5rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.side-head { display: flex; align-items: center; justify-content: space-between; }
.side-head strong { font-size: .9rem; }
.facet { display: flex; flex-direction: column; }
.facet-summary { display: flex; align-items: center; gap: .4rem; width: 100%; padding: .2rem 0; background: none;
	border: 0; cursor: pointer; color: var(--muted); font: inherit; text-align: left; }
.facet-label { display: flex; align-items: center; gap: .3rem; font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.facet-n { background: var(--primary); color: var(--primary-ink); border-radius: 999px; padding: 0 .4rem; font-size: .62rem; }
.facet-sel { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .72rem; opacity: .8; }
.facet-caret { margin-left: auto; font-size: .7rem; opacity: .7; }
.facet .check-list { display: flex; flex-direction: column; gap: .1rem; margin: .2rem 0 .3rem; }
.cswatches { display: flex; flex-wrap: wrap; gap: .3rem; margin: .25rem 0 .3rem; }
.cswatch { width: 1.4rem; height: 1.4rem; border-radius: 5px; border: 1px solid var(--border); cursor: pointer; padding: 0; }
.cswatch.on { outline: 2px solid var(--primary); outline-offset: 1px; }
.facet-sel-sw { display: flex; flex: 1; gap: 2px; align-items: center; overflow: hidden; }
.mini-sw { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); flex: 0 0 auto; }
.facet select { padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.main-col { min-width: 0; }
input, select, button, textarea { font: inherit; }
input[type=search], select {
	padding: .5rem .7rem; border: 1px solid var(--border); border-radius: 9px;
	background: var(--surface); color: var(--text);
}

/* --- card grid (uniform 3:4 photo tiles; outliers crop to fit) --- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .9rem; }
.card {
	position: relative; display: block;
	background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
	overflow: hidden; box-shadow: var(--shadow); transition: transform .08s, box-shadow .12s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.1); }
.card-thumb { display: block; width: 100%; aspect-ratio: 3/4; }
/* name overlay only used when there's no photo to identify the item by */
.card-name-overlay { position: absolute; left: 0; right: 0; bottom: 0; padding: .9rem .5rem .45rem;
	font-size: .78rem; font-weight: 600; line-height: 1.2; color: #fff;
	background: linear-gradient(transparent, rgba(0,0,0,.72)); }
.card-body { padding: .5rem .6rem .6rem; }
.card-name { font-weight: 600; font-size: .9rem; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-sub { display: flex; align-items: center; justify-content: space-between; gap: .3rem; margin-top: .25rem; color: var(--muted); font-size: .78rem; }

/* --- thumbnails --- */
.thumb { display: block; width: 100%; background: var(--surface-2); }
.thumb.has-photo img { display: block; width: 100%; }
.card-thumb img { height: 100%; object-fit: cover; }  /* normalized tile: crop to fit */
.detail-photo img { height: auto; }                    /* detail: whole photo, uncropped */
.thumb.palette, .thumb.empty { aspect-ratio: 3/4; } /* placeholders need a shape */
.thumb.palette { display: flex; }
.thumb.palette > span { display: block; height: 100%; }
.thumb.empty { background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 8px, var(--surface) 8px, var(--surface) 16px); }

/* --- stars --- */
.stars-ro { white-space: nowrap; letter-spacing: .02em; }
.stars-ro span { color: var(--border); font-size: .85rem; }
.stars-ro span.on { color: var(--star); }

/* --- detail --- */
.detail-top { margin-bottom: .8rem; }
.link-btn { background: none; border: 0; color: var(--primary); font-weight: 600; cursor: pointer; padding: 0; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 320px) 1fr; gap: 1.4rem; align-items: start; }
@media (max-width: 640px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-photo { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow); }
.detail-sub { display: flex; align-items: center; gap: .8rem; margin: .3rem 0 1rem; color: var(--muted); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem 1.2rem; margin: 0 0 1rem; }
.facts dt { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.facts dd { margin: 0; font-weight: 500; }
.chip-row { display: flex; flex-wrap: wrap; gap: .4rem; margin: .3rem 0 .8rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .55rem; border-radius: 999px; background: var(--surface-2); font-size: .8rem; }
.chip.subtle { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.chip .dot { width: .7rem; height: .7rem; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); }
.notes { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: .6rem .8rem; }
.mini-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.mini { padding: .35rem .7rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: .85rem; }
.mini:hover { border-color: var(--primary); }

/* --- buttons --- */
button { cursor: pointer; color: inherit; }
.btn, .head-btn, .form-actions button {
	display: inline-flex; align-items: center; gap: .3rem; padding: .5rem .9rem; border-radius: 9px;
	border: 1px solid var(--border); background: var(--surface); color: var(--text);
	font-weight: 600; font-size: .9rem; text-decoration: none;
}
.btn.primary, .head-btn, .form-actions button[type=submit] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.head-btn { margin-left: auto; }
.detail-top .btn { padding: .35rem .8rem; }
.form-actions button.danger, .btn.danger { background: transparent; color: #d9534f; border-color: #d9534f; }
.detail-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

/* --- form --- */
.item-form label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); }
.item-form input, .item-form select, .item-form textarea {
	display: block; width: 100%; margin-top: .25rem; padding: .5rem .6rem; border: 1px solid var(--border);
	border-radius: 8px; background: var(--surface); color: var(--text); font-weight: 400; font-size: .92rem;
}
.item-form input:disabled { opacity: .5; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem 1rem; margin: 1rem 0; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.block { display: block; margin: 1rem 0; }
.fs { margin: 1.1rem 0; }
.fs-label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: .4rem; }
.fs-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem; }
.mini-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: .2rem .6rem; font-size: .8rem; }
.row-edit { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.row-edit select { flex: 1; margin: 0; }
.row-edit input[type=number] { width: 4.5rem; margin: 0; }
.row-edit .dot { flex: 0 0 auto; width: 1rem; height: 1rem; border-radius: 50%; border: 1px solid var(--border); }
.row-edit .x { border: 0; background: rgba(0,0,0,.5); color: #fff; border-radius: 6px; width: 1.5rem; height: 1.5rem; flex: 0 0 auto; }
.pct { color: var(--muted); }
.warn { color: #c60; }
.check-row { display: flex; flex-wrap: wrap; gap: .5rem 1rem; }
.check { display: inline-flex; align-items: center; gap: .35rem; font-weight: 400; font-size: .9rem; color: var(--text); }
.check input { width: auto; margin: 0; display: inline-block; }
.tag-group { margin-bottom: .5rem; }
.rating-field { align-self: end; }
.star-picker { display: inline-flex; align-items: center; gap: .05rem; margin-top: .25rem; }
.star-picker .star { border: 0; background: none; font-size: 1.5rem; line-height: 1; color: var(--border); padding: 0 .05rem; }
.star-picker .star.on { color: var(--star); }
.star-picker .clear { border: 0; background: none; color: var(--muted); font-size: .75rem; margin-left: .4rem; cursor: pointer; }
.form-actions { display: flex; gap: .6rem; margin: 1.5rem 0; flex-wrap: wrap; }

/* --- photo editor (form) --- */
.photo-strip { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .3rem; }
.photo-tile { position: relative; width: 5rem; aspect-ratio: 3/4; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile.primary { outline: 2px solid var(--primary); outline-offset: -2px; }
.pri-badge { position: absolute; top: .2rem; left: .2rem; background: var(--primary); color: #fff; font-size: .6rem; padding: .05rem .3rem; border-radius: 5px; }
.photo-tile-actions { position: absolute; top: .2rem; right: .2rem; display: flex; gap: .2rem; }
.photo-tile-actions button { border: 0; background: rgba(0,0,0,.55); color: #fff; border-radius: 6px; width: 1.4rem; height: 1.4rem; font-size: .9rem; line-height: 1; }
.photo-add { display: flex; align-items: center; justify-content: center; width: 5rem; aspect-ratio: 3/4; border: 2px dashed var(--border); border-radius: 8px; font-size: 1.5rem; color: var(--muted); cursor: pointer; }
.photo-add input { display: none; }

/* --- detail gallery strip --- */
.thumb-strip { display: flex; gap: .4rem; margin-top: .5rem; flex-wrap: wrap; }
.strip-thumb { width: 3.2rem; aspect-ratio: 3/4; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); padding: 0; background: none; }
.strip-thumb.on { outline: 2px solid var(--primary); outline-offset: -2px; }
.strip-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.reason { border-left: 3px solid var(--primary); }
.detail-actions-row { display: flex; gap: .5rem; }
.worn-strip { display: flex; flex-wrap: wrap; gap: .5rem; }
.worn-photo img { height: 8rem; width: auto; border-radius: 8px; border: 1px solid var(--border); display: block; }

/* --- outfit preview (canvas / grid of item tiles) --- */
.outfit-preview { display: block; width: 100%; background: var(--surface-2); border-radius: 8px; overflow: hidden; position: relative; isolation: isolate; }
.ot-canvas { position: relative; }
.ot-canvas .ot-cell { position: absolute; padding: 1.2%; }
.ot-grid { display: grid; gap: 2px; padding: 2px; }
.ot-grid .ot-cell { aspect-ratio: 1; }
.ot-tile { display: block; width: 100%; height: 100%; border-radius: 6px; overflow: hidden; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }
.ot-tile.has-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ot-tile.palette { display: flex; }
.ot-tile.palette > span { display: block; height: 100%; }
.ot-empty { display: flex; align-items: center; justify-content: center; aspect-ratio: 1; color: var(--muted); font-size: .75rem; }

/* --- outfit cards: uniform 3:4 boxes; arrangement letterboxed, photo cover-cropped --- */
.outfit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(0, var(--card))); gap: .9rem; justify-content: start; --card: 210px; }
.outfit-grid.size-s { --card: 150px; }
.outfit-grid.size-l { --card: 290px; }
@media (max-width: 640px) { .outfit-grid { --card: 150px; } .outfit-grid.size-s { --card: 110px; } .outfit-grid.size-l { --card: 200px; } }
.ocard { display: block; width: 100%; max-width: 100%; margin: 0; background: var(--surface);
	border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
	transition: transform .08s, box-shadow .12s; }
.ocard:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.1); }
.ocard-box { display: flex; align-items: center; justify-content: center; width: 100%; aspect-ratio: 3/4; overflow: hidden; }
.ocard-preview { border-radius: 0; flex: none; }
.ocard-photo { display: block; width: 100%; height: 100%; object-fit: cover; }
.card-controls { display: inline-flex; gap: .5rem; align-items: center; margin-left: .4rem; }
/* Outfits tab / analysis: cards sized to their canvas so squares match across outfits */
.outfit-flow { display: flex; flex-wrap: wrap; gap: .9rem; align-items: flex-start; --sq: 190px; }
.outfit-flow.small { --sq: 120px; }
@media (max-width: 640px) { .outfit-flow { --sq: 130px; } .outfit-flow.small { --sq: 90px; } }
/* stacked (interchangeable) tiles */
.stack-btn, .stack-badge { position: absolute; right: 5%; bottom: 5%; z-index: 5; border: 0; border-radius: 50%; background: rgba(0,0,0,.5); color: #fff; line-height: 1; display: flex; align-items: center; justify-content: center; }
.stack-btn { cursor: pointer; width: 1.7rem; height: 1.7rem; font-size: .95rem; }
.stack-btn:hover { background: rgba(0,0,0,.8); }
.stack-badge { width: 1.1rem; height: 1.1rem; font-size: .6rem; opacity: .85; }
.ocard-body { display: flex; align-items: center; justify-content: space-between; gap: .4rem; padding: .5rem .6rem; }
.ocard-name { font-weight: 600; font-size: .85rem; line-height: 1.2; }
.detail-outfit-wrap { --sq: 220px; max-width: 100%; }
.detail-outfit { border: 1px solid var(--border); border-radius: 8px; }

/* --- piece groups + mini item tiles --- */
.piece-group { margin: .9rem 0; }
.piece-label { display: block; margin-bottom: .35rem; text-transform: uppercase; letter-spacing: .03em; font-size: .7rem; }
.mini-tiles { display: flex; flex-wrap: wrap; gap: .55rem; }
.imini { display: block; width: 4rem; text-decoration: none; }
.imini img, .imini-pal { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: block; }
.imini-pal { display: flex; }
.imini-pal > span { display: block; height: 100%; }
.imini-name { display: block; font-size: .68rem; color: var(--muted); margin-top: .2rem; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* filter chips (clickable) */
.chip.filter { cursor: pointer; border: 1px solid var(--border); background: var(--surface); }
.chip.filter.on { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

/* outfit-detail worn-photo strip */
.thumb-strip .strip-photo { display: inline-block; }
.thumb-strip .strip-photo img { height: 6rem; width: auto; border-radius: 6px; display: block; }

/* --- trips --- */
.trip-list { display: flex; flex-direction: column; gap: .6rem; }
.trip-card { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 1rem;
	background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.trip-card:hover { border-color: var(--primary); }
.trip-card-main { display: flex; flex-direction: column; gap: .15rem; }
.trip-counts { white-space: nowrap; }
.trip-acc { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.trip-summary { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .8rem 1rem; cursor: pointer; list-style: none; }
.trip-summary::-webkit-details-marker { display: none; }
.trip-summary::after { content: '▸'; color: var(--muted); }
.trip-acc[open] .trip-summary::after { content: '▾'; }
.trip-acc[open] .trip-summary { border-bottom: 1px solid var(--border); }
.trip-panel { padding: .6rem 1rem 1rem; }
.panel-h { margin: 1rem 0 .5rem; font-size: .95rem; }

/* --- gallery (masonry) --- */
.gallery-grid { columns: 180px; column-gap: .6rem; }
.gphoto { position: relative; display: block; break-inside: avoid; margin: 0 0 .6rem; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.gphoto img { width: 100%; height: auto; display: block; }
.gtype { position: absolute; top: .3rem; left: .3rem; font-size: .58rem; text-transform: uppercase; letter-spacing: .04em;
	background: rgba(0,0,0,.55); color: #fff; padding: .05rem .35rem; border-radius: 5px; }

/* photo strips are clickable buttons that open the lightbox */
.strip-photo, .worn-photo { border: 0; padding: 0; background: none; cursor: pointer; display: inline-block; }

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.86); display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 6px; box-shadow: 0 4px 30px rgba(0,0,0,.5); }
.lb-close, .lb-nav { border: 0; background: rgba(255,255,255,.16); color: #fff; cursor: pointer; }
.lb-close { position: absolute; top: 1rem; right: 1rem; width: 2.4rem; height: 2.4rem; border-radius: 50%; font-size: 1.4rem; line-height: 1; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 3rem; height: 3rem; border-radius: 50%; font-size: 1.8rem; line-height: 1; }
.lb-prev { left: 1rem; } .lb-next { right: 1rem; }
.lb-close:hover, .lb-nav:hover { background: rgba(255,255,255,.32); }
.lb-count { position: absolute; bottom: 1rem; left: 50%; transform: translateX(-50%); color: #fff; font-size: .85rem; background: rgba(0,0,0,.5); padding: .2rem .6rem; border-radius: 1rem; }

/* colour "move to family" control */
.row-move { flex: 0 0 auto; padding: .35rem .6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--muted); cursor: pointer; font-size: .8rem; white-space: nowrap; }
.row-move:hover { border-color: var(--primary); color: var(--text); }

/* --- outfit editor --- */
.opick-controls { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.opick-controls .search { flex: 1 1 12rem; }
.opick-controls select { width: auto; flex: 0 0 auto; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.opick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.5rem, 1fr)); gap: .5rem; max-height: 20rem; overflow-y: auto; padding: 2px; margin-top: .4rem; }
.opick-tile { -webkit-appearance: none; appearance: none; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); cursor: pointer; padding: 0; display: block; text-align: left; }
.opick-tile:hover { border-color: var(--primary); }
.opick-thumb { display: block; width: 100%; aspect-ratio: 3/4; background: var(--surface-2); }
.opick-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.opick-pal { display: flex; width: 100%; height: 100%; }
.opick-pal > span { display: block; height: 100%; }
.opick-name { display: block; font-size: .62rem; line-height: 1.2; padding: .15rem .25rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; color: var(--muted); }

/* --- outfit editor: canvas + tray --- */
.oed { display: grid; grid-template-columns: minmax(0, 1fr) minmax(19rem, 38%); gap: 1rem; align-items: start; margin: .6rem 0 1rem; }
@media (max-width: 900px) { .oed { grid-template-columns: 1fr; } }
.oed-bar { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; min-height: 2.3rem; margin-bottom: .45rem; }
.oed-selname { font-weight: 600; font-size: .85rem; max-width: 11rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: .3rem; }
.tb { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: .3rem .6rem; font-size: .8rem; cursor: pointer; white-space: nowrap; }
.tb:hover { border-color: var(--primary); }
.tb.on { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.tb.danger { color: #d9534f; border-color: #d9534f66; }
.tb:disabled { opacity: .45; cursor: default; }
.oed-bgs { display: inline-flex; gap: .35rem; align-items: center; margin-right: .4rem; }
.bg-sw { width: 1.45rem; height: 1.45rem; border-radius: 50%; border: 1px solid var(--border); cursor: pointer; padding: 0; }
.bg-sw.on { outline: 2px solid var(--primary); outline-offset: 2px; }
.oed-dims { display: inline-flex; align-items: center; gap: .2rem; margin-right: .3rem; }
.oed-dims .pill { width: 1.5rem; height: 1.5rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); cursor: pointer; padding: 0; line-height: 1; }
.dim-val { min-width: 2.2rem; text-align: center; font-size: .8rem; }
.oed-status { display: inline-flex; align-items: center; gap: .35rem; margin-left: auto; }
.spin { display: inline-block; width: .8rem; height: .8rem; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.arrange-canvas { position: relative; isolation: isolate; width: 100%; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; touch-action: none; user-select: none; box-shadow: var(--shadow); }
/* grid guides: squares, with fainter half-square lines */
.arrange-canvas.grid { background-image:
	linear-gradient(to right, rgba(127,127,127,.28) 1px, transparent 1px), linear-gradient(to bottom, rgba(127,127,127,.28) 1px, transparent 1px),
	linear-gradient(to right, rgba(127,127,127,.12) 1px, transparent 1px), linear-gradient(to bottom, rgba(127,127,127,.12) 1px, transparent 1px);
	background-size: calc(100% / var(--cols)) calc(100% / var(--rows)), calc(100% / var(--cols)) calc(100% / var(--rows)),
		calc(50% / var(--cols)) calc(50% / var(--rows)), calc(50% / var(--cols)) calc(50% / var(--rows)); }
.atile.cut .atile-img { background: transparent; }
.canvas-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: .9rem; }
.atile { position: absolute; cursor: grab; touch-action: none; padding: 1.2%; }
.atile:active { cursor: grabbing; }
.atile-img { position: relative; width: 100%; height: 100%; border-radius: 6px; overflow: hidden; box-shadow: 0 0 0 1px rgba(0,0,0,.12); }
.atile.cut .atile-img { border-radius: 0; overflow: visible; box-shadow: none; }
.atile img, .atile-pal { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.atile.cut img { object-fit: contain; filter: drop-shadow(0 1px 2px rgba(0,0,0,.12)); }
.atile-pal { display: flex; }
.atile-pal > span { display: block; height: 100%; }
.atile.pending .atile-img img { opacity: .55; }
.tile-spin { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 1.3rem; height: 1.3rem; border-width: 3px; }
.atile.sel .atile-img { outline: 1.5px dashed var(--primary); outline-offset: 3px; }
.atile.cropping .atile-img { outline-style: solid; cursor: move; }
.hdl { position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 2px solid var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.35); z-index: 3; }
/* kept inside the tile so it stays reachable when the tile touches the canvas edge */
.h-scale { right: 3px; bottom: 3px; cursor: nwse-resize; }
.h-scale::after { content: ''; position: absolute; inset: -8px; } /* larger invisible grab area */
.h-rot { left: 50%; top: -30px; transform: translateX(-50%); cursor: grab; }
.h-stem { position: absolute; left: 50%; top: -17px; width: 1.5px; height: 14px; background: var(--primary); transform: translateX(-50%); }

.oed-tray { display: flex; flex-direction: column; gap: .5rem; border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem; background: var(--surface); max-height: min(80vh, 46rem); position: sticky; top: 4rem; }
@media (max-width: 900px) { .oed-tray { position: static; max-height: 24rem; } }
.oed-tray .search { width: 100%; flex: none; }
.tray-cats { display: flex; gap: .3rem; overflow-x: auto; padding-bottom: .2rem; flex: none; scrollbar-width: thin; }
.tray-cats .chip { flex: none; }
.tray-scroll { flex: 1 1 auto; min-height: 6rem; overflow-y: auto; padding: 2px; }
.tray-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.2rem, 1fr)); gap: .4rem; }
.tray-grid .opick-thumb { aspect-ratio: 3/4; }
.piece-edit.sel { background: var(--surface-2); border-radius: 8px; }

/* cut-outs in previews: whole image, no box */
.ot-tile.cut { background: transparent; }
.ot-tile.cut img { object-fit: contain; }
.piece-edit { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.piece-thumb { flex: 0 0 auto; width: 2.4rem; height: 3rem; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); display: block; }
.piece-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.piece-pal { display: flex; width: 100%; height: 100%; }
.piece-pal > span { display: block; height: 100%; }
.piece-nm { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.item-form .piece-role { flex: 0 0 7.5rem; width: 7.5rem; margin: 0; padding: .4rem .5rem; }
.opt-check { flex: 0 0 auto; display: inline-flex; align-items: center; gap: .25rem; font-size: .8rem; color: var(--muted); }
.opt-check input { width: auto; margin: 0; }
.piece-edit .x { flex: 0 0 auto; border: 0; background: transparent; color: var(--muted); font-size: 1.25rem; line-height: 1; cursor: pointer; }
.piece-edit .x:hover { color: #d9534f; }

/* --- manage tab --- */
.manage-sec { margin: 1.4rem 0; }
.manage-sec h3 { margin: 0 0 .5rem; }
.medit-list { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .7rem; max-width: 34rem; }
.medit-row { display: flex; align-items: center; gap: .5rem; }
.medit-row input, .medit-row select { padding: .4rem .55rem; border: 1px solid var(--border); border-radius: 8px;
	background: var(--surface); color: var(--text); font: inherit; }
.medit-swatch { width: 2.2rem !important; height: 2.2rem; padding: .1rem !important; background: none !important; flex: 0 0 auto; }
.medit-name { flex: 1 1 auto; min-width: 4rem; }
.medit-sub { flex: 0 0 7.5rem; }
.subtabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.subtab { padding: .4rem .85rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
	color: var(--muted); font-weight: 600; font-size: .85rem; cursor: pointer; }
.subtab.on { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.vgroups-2col { columns: 2; column-gap: 1.6rem; }
@media (max-width: 640px) { .vgroups-2col { columns: 1; } }
.vgroups-2col .vgroup { break-inside: avoid; }
.medit-row .x { flex: 0 0 auto; border: 0; background: transparent; color: var(--muted); font-size: 1.25rem; line-height: 1; cursor: pointer; padding: 0 .2rem; }
.medit-row .x:hover { color: #d9534f; }
.manage-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .5rem; }
.manage-sec-head h3 { margin: 0; }
.sec-search { padding: .35rem .55rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; max-width: 12rem; }
.vgroup { margin-bottom: .7rem; }
.vgroup-head { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: .3rem; }
.row-count { flex: 0 0 auto; min-width: 1.4rem; text-align: center; font-size: .72rem; color: var(--muted); }
.row-count.zero { opacity: .4; }
.merge-tool { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .5rem; padding-top: .5rem; border-top: 1px dashed var(--border); }
.merge-tool select { padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.add-inline { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.add-inline input, .add-inline select { padding: .4rem .6rem; border: 1px solid var(--border); border-radius: 8px;
	background: var(--surface); color: var(--text); font: inherit; }
.add-inline input[type=color] { width: 2.4rem; height: 2.4rem; padding: .1rem; }
.manage .tag-group { margin-bottom: .6rem; }
.manage .tag-group > small { display: block; margin-bottom: .25rem; text-transform: uppercase; letter-spacing: .03em; }

/* --- trip editor --- */
.trip-actions { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; margin: .4rem 0 .6rem; }
.trip-actions .notes { margin: 0; flex: 1 1 auto; }
.trip-actions .detail-actions-row { margin-left: auto; }
.tpick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr)); gap: .5rem; max-height: 24rem; overflow-y: auto; padding: 2px; margin-top: .4rem; }
.tpick-tile { -webkit-appearance: none; appearance: none; position: relative; border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
	background: var(--surface); cursor: pointer; padding: 0; display: block; text-align: left; }
.tpick-tile:hover { border-color: var(--primary); }
.tpick-tile.on { outline: 2px solid var(--primary); outline-offset: -2px; border-color: var(--primary); }
.tpick-preview { border-radius: 0; }
.tpick-name { display: block; font-size: .68rem; line-height: 1.2; padding: .2rem .3rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; color: var(--muted); }
.tpick-check { position: absolute; top: .3rem; right: .3rem; width: 1.3rem; height: 1.3rem; border-radius: 50%; background: var(--primary); color: var(--primary-ink);
	font-size: .8rem; line-height: 1.3rem; text-align: center; font-weight: 700; }
.pack-grid .opick-tile { opacity: .45; }
.pack-grid .opick-tile.on { opacity: 1; outline: 2px solid var(--primary); outline-offset: -2px; }
.opick-thumb { position: relative; }
.tile-badge { position: absolute; top: .25rem; right: .25rem; min-width: 1.25rem; padding: 0 .3rem; height: 1.25rem; border-radius: 999px; background: rgba(0,0,0,.65); color: #fff;
	font-size: .68rem; line-height: 1.25rem; text-align: center; font-weight: 600; }

/* --- analysis --- */
.date-range { display: flex; flex-direction: column; gap: .3rem; }
.date-range label { display: flex; flex-direction: column; gap: .15rem; }
.date-range input { width: 100%; padding: .3rem .4rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: .82rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .6rem; margin-bottom: .4rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .9rem; display: flex; flex-direction: column; }
.stat b { font-size: 1.35rem; line-height: 1.2; }
.stat span { font-size: .75rem; color: var(--muted); }
.stat small { font-size: .7rem; margin-top: .15rem; }
.analysis h3 { margin-top: 1.6rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.5rem; }
@media (max-width: 640px) { .two-col { grid-template-columns: 1fr; } }
.vbars { display: flex; gap: .3rem; align-items: flex-end; overflow-x: auto; padding: 0 2px .2rem; }
.vbar-col { flex: 1 1 0; min-width: 1.5rem; display: flex; flex-direction: column; align-items: center; }
.vbars.wide .vbar-col { min-width: 3.6rem; flex: 1 1 3.6rem; }
.vbar-val { font-size: .62rem; color: var(--muted); height: 1.1em; line-height: 1.1em; white-space: nowrap; }
.vbar-track { height: 130px; width: 100%; display: flex; align-items: flex-end; border-bottom: 1px solid var(--border); }
.vbar { width: 100%; background: var(--primary); border-radius: 4px 4px 0 0; opacity: .9; }
.vbar-label { font-size: .62rem; color: var(--muted); white-space: nowrap; margin-top: .25rem; }
.vbars.wide .vbar-label { white-space: normal; text-align: center; line-height: 1.15; }
.hbars { display: flex; flex-direction: column; gap: .3rem; }
.hbar-row { display: grid; grid-template-columns: minmax(6rem, 11rem) 1fr auto; align-items: center; gap: .5rem; font-size: .82rem; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: .3rem; }
.hbar-label .dot { width: .7rem; height: .7rem; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); flex: 0 0 auto; }
.hbar-track { height: .7rem; background: var(--surface-2); border-radius: 999px; overflow: hidden; display: block; }
.hbar { display: block; height: 100%; background: var(--primary); border-radius: 999px; opacity: .9; }
.hbar-val { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pal-bar { display: flex; height: 1.5rem; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); margin: .3rem 0 .6rem; }
.pal-bar > span { display: block; height: 100%; }
.cat-pals { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .3rem 1.2rem; }
.cat-pal .pal-bar { height: 1rem; margin: .15rem 0 .4rem; }
.sub-details { margin-top: .6rem; }
.sub-details summary { cursor: pointer; }
.sub-block { margin: .6rem 0 .8rem; }
.sub-block strong { display: block; margin-bottom: .25rem; }
.stat-grid-tiles { max-height: none; overflow: visible; }
.stat-tile { text-decoration: none; }

/* clickable photos (expand in lightbox) */
.photo-open { border: 0; padding: 0; background: none; cursor: zoom-in; display: block; width: 100%; height: 100%; }
.photo-open img { display: block; width: 100%; height: 100%; object-fit: cover; }
.detail-photo.photo-open img { height: auto; object-fit: contain; }
.cover-tile { width: 7rem; }
.mini-file { display: inline-flex; align-items: center; align-self: center; cursor: pointer; }
.mini-file input { display: none; }
.cutout-prev { cursor: zoom-in; padding: 0; }
.detail-cut { margin-top: .5rem; width: 5rem; }

/* --- analysis: time chart --- */
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; margin-top: 1.6rem; }
.sec-head h3 { margin-top: 0; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: .25rem .7rem; font-size: .78rem; color: var(--muted); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--primary); color: var(--primary-ink); }
.tchart { display: grid; grid-template-columns: auto 1fr; gap: 0 .5rem; margin: .4rem 0 .6rem; }
.tc-y { position: relative; height: 150px; width: 3.2rem; font-size: .62rem; color: var(--muted); text-align: right; }
.tc-y span { position: absolute; right: 0; transform: translateY(-50%); white-space: nowrap; }
.tc-body { min-width: 0; }
.tc-plot { position: relative; height: 150px; border-bottom: 1px solid var(--border); }
.tc-grid { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--border); }
.tc-mean { position: absolute; left: 0; right: 0; border-top: 1.5px dashed var(--muted); opacity: .8; z-index: 2; }
.tc-bars { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 3px; padding: 0 2px; }
.tc-col { position: relative; flex: 1 1 0; min-width: 0; height: 100%; display: flex; align-items: flex-end; }
.tc-bar { display: block; width: 100%; background: var(--primary); border-radius: 3px 3px 0 0; opacity: .9; min-height: 0; }
.tc-col:hover .tc-bar { opacity: 1; filter: brightness(1.1); }
.tc-val { position: absolute; left: 50%; transform: translate(-50%, -2px); margin-bottom: 2px; font-size: .6rem; color: var(--muted); white-space: nowrap; pointer-events: none; }
.tchart.dense .tc-bars { gap: 1px; }
.tc-x { display: flex; gap: 3px; padding: .2rem 2px 0; font-size: .62rem; color: var(--muted); }
.tc-x span { flex: 1 1 0; min-width: 0; text-align: center; overflow: hidden; white-space: nowrap; }
.tchart.dense .tc-x { gap: 1px; }
.tc-groups { display: flex; padding: .15rem 2px 0; font-size: .68rem; font-weight: 600; color: var(--text); }
.tc-groups span { text-align: center; border-left: 1px solid var(--border); overflow: hidden; white-space: nowrap; }
.tc-groups span:first-child { border-left: 0; }

/* --- analysis: donut --- */
.donut-wrap { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.donut { width: 11rem; height: 11rem; flex: 0 0 auto; }
.donut-arc { cursor: pointer; transition: opacity .12s, stroke-width .12s; }
.donut-arc.dim { opacity: .3; }
.donut-centre { font-size: 11px; fill: var(--text); font-weight: 600; }
.donut-legend { display: flex; flex-direction: column; gap: .15rem; flex: 1 1 8rem; min-width: 0; }
.legend-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .4rem; border: 0; background: none; padding: .15rem .35rem; border-radius: 6px; font-size: .8rem; text-align: left; cursor: pointer; color: inherit; }
.legend-row:hover, .legend-row.on { background: var(--surface-2); }
.legend-row .dot { width: .75rem; height: .75rem; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); }
.legend-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-val { color: var(--muted); font-variant-numeric: tabular-nums; }
.donuts > div { min-width: 0; }

/* quick edits on detail pages */
.star-picker.sm .star { font-size: 1.15rem; }
.star-picker.sm { margin-top: 0; }
.worn-add { height: 8rem; width: 6rem; aspect-ratio: auto; }
.strip-add { height: 6rem; width: 4.5rem; aspect-ratio: auto; }

/* colour chooser (item form) */
.cpick { position: relative; flex: 1; min-width: 0; }
.cpick-btn { display: flex; align-items: center; gap: .5rem; width: 100%; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); cursor: pointer; text-align: left; }
.cpick-btn .dot { flex: 0 0 auto; width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 1px solid rgba(0,0,0,.2); }
.cpick-btn.empty .dot { border-style: dashed; }
.cpick-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cpick-btn.empty .cpick-name { color: var(--muted); }
.cpick-pop { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 100%; width: max-content; max-width: min(28rem, 90vw); max-height: 20rem; overflow-y: auto;
	padding: .6rem .7rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 26px rgba(0,0,0,.18); }
.cpick-fam { margin-bottom: .35rem; }
.cpick-fam > small { display: block; text-transform: uppercase; letter-spacing: .04em; font-size: .62rem; margin-bottom: .1rem; }
.cpick-pop .cswatch { width: 1.6rem; height: 1.6rem; }

/* backup panel */
.backup-row { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin: .4rem 0; }
.backup-prev { display: flex; flex-direction: column; gap: .5rem; padding: .8rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.warn { color: #d9534f; }

/* first-run welcome */
.welcome h1 { font-size: 1.6rem; }
.welcome p { max-width: 28rem; }
.welcome-actions { display: flex; gap: .7rem; flex-wrap: wrap; justify-content: center; margin-top: .6rem; }
.welcome-actions .btn { cursor: pointer; }
.btn.disabled { opacity: .5; pointer-events: none; }

/* cut-out preview (item form / detail) */
.cutout-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.cutout-prev { display: inline-block; width: 4rem; aspect-ratio: 3/4; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; cursor: zoom-in; padding: 0;
	background-color: #fff;
	background-image: linear-gradient(45deg, #00000010 25%, transparent 25%, transparent 75%, #00000010 75%), linear-gradient(45deg, #00000010 25%, transparent 25%, transparent 75%, #00000010 75%);
	background-size: 14px 14px; background-position: 0 0, 7px 7px; }
.cutout-prev img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* modal (cut-out touch-up) */
.modal { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal-box { background: var(--surface); color: var(--text); border-radius: var(--radius); box-shadow: 0 10px 40px rgba(0,0,0,.35); width: min(60rem, 100%); max-height: 94vh; display: flex; flex-direction: column; gap: .6rem; padding: .9rem 1rem 1rem; }
.modal-head { display: flex; align-items: baseline; gap: .6rem; }
.modal-close { position: static; margin-left: auto; width: 2rem; height: 2rem; font-size: 1.2rem; background: var(--surface-2); color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; }
.ce-tools { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.ce-spacer { flex: 1; }
.ce-radius { display: inline-flex; align-items: center; gap: .3rem; }
.ce-radius input { width: 6rem; }
.ce-stage { display: flex; gap: 1rem; align-items: flex-start; min-height: 0; }
.ce-frame { position: relative; flex: 1 1 auto; min-width: 0; display: flex; justify-content: center; border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
	background-color: #fff;
	background-image: linear-gradient(45deg, #00000012 25%, transparent 25%, transparent 75%, #00000012 75%), linear-gradient(45deg, #00000012 25%, transparent 25%, transparent 75%, #00000012 75%);
	background-size: 16px 16px; background-position: 0 0, 8px 8px; }
.ce-canvas { display: block; max-width: 100%; max-height: 66vh; touch-action: none; user-select: none; }
.ce-canvas.trim { cursor: row-resize; }
.ce-canvas.erase { cursor: crosshair; }
.ce-line { position: absolute; left: 0; right: 0; border-top: 2px dashed #d9534f; pointer-events: none; }
.ce-line::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 200vh; transform: translateY(-100%); background: rgba(217,83,79,.12); }
.ce-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.ce-side { flex: 0 0 8rem; display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.ce-orig { width: 8rem; aspect-ratio: 3/4; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.ce-orig img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 640px) { .ce-side { display: none; } .arrange-canvas { width: 100%; } }

/* retouch dialog extras */
.ce-swatch { display: inline-block; width: .8rem; height: .8rem; border-radius: 50%; border: 1px solid rgba(0,0,0,.25); vertical-align: -1px; margin-right: .2rem; }
.ce-color { width: 1.8rem; height: 1.8rem; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: none; cursor: pointer; }
.ce-canvas.paint, .ce-canvas.pick { cursor: crosshair; }
.ce-frame.plain { background-image: none; background-color: var(--surface-2); }
.oed-size { display: inline-flex; align-items: center; gap: .25rem; margin-right: .2rem; }
/* canvas with a stationary size-control strip on its right (doesn't move as the canvas resizes) */
.canvas-wrap { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem; align-items: start; }
.canvas-wrap .arrange-canvas { grid-column: 1; justify-self: center; }
.size-ctl { grid-column: 2; display: flex; flex-direction: column; gap: .5rem; align-self: start; padding-top: .2rem; }
.cols-ctl, .rows-ctl { display: flex; flex-direction: column; align-items: center; gap: .25rem; }
.cols-ctl .pill, .rows-ctl .pill { width: 1.6rem; height: 1.6rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); cursor: pointer; padding: 0; line-height: 1; font-size: .95rem; }
.cols-ctl .pill:disabled, .rows-ctl .pill:disabled { opacity: .35; cursor: default; }

/* remove button on photos in detail views */
.photo-rm-wrap { position: relative; display: inline-block; }
.photo-rm { position: absolute; top: .3rem; right: .3rem; width: 1.5rem; height: 1.5rem; border: 0; border-radius: 6px; background: rgba(0,0,0,.6); color: #fff;
	font-size: 1rem; line-height: 1; cursor: pointer; padding: 0; opacity: 0; transition: opacity .1s; }
.photo-rm-wrap:hover .photo-rm, .photo-rm:focus { opacity: 1; }
@media (hover: none) { .photo-rm { opacity: .85; } }

/* trips: smaller outfit previews, counts */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.panel-head .panel-h { margin-bottom: .3rem; }
.chip-n { opacity: .7; font-size: .72rem; margin-left: .1rem; }
.imini { position: relative; }
.imini-badge { top: .25rem; right: .25rem; }
/* trips: packed items grouped by closet & category */
.pack-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: .6rem 1.4rem; }
.pack-closet-h { font-weight: 600; font-size: .9rem; margin: .2rem 0 .3rem; padding-bottom: .2rem; border-bottom: 1px solid var(--border); }
.pack-cat { margin-bottom: .5rem; }
.pack-cat-h { text-transform: uppercase; letter-spacing: .03em; font-size: .68rem; margin-bottom: .25rem; }
.link-btn.small { font-size: .8rem; }
/* clickable category bars */
.vbars.clickable .vbar-col { cursor: pointer; border-radius: 6px; }
.vbars.clickable .vbar-col:hover .vbar { filter: brightness(1.12); }
.vbar-col.on .vbar { outline: 2px solid var(--text); outline-offset: -2px; }
.vbar-col.dim { opacity: .45; }
/* analysis → items click-throughs */
.hbars.clickable .hbar-row { cursor: pointer; border-radius: 6px; padding: .1rem .25rem; margin: 0 -.25rem; }
.hbars.clickable .hbar-row:hover { background: var(--surface-2); }
.pick-chip { cursor: pointer; }

/* split stacks: interchangeable options side by side in one tile */
.ot-split { display: flex; }
.ot-split.horiz { flex-direction: column; }
.ot-slice { position: relative; display: block; overflow: hidden; flex: none; }
.ot-split.vert .ot-slice { height: 100%; }
.ot-split.horiz .ot-slice { width: 100%; }
/* merged neighbours: each piece in its own region, slanted seams */
.ot-merge { position: relative; }
.ot-region { position: absolute; display: block; overflow: hidden; }
.ot-region img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ot-region.strip img { max-width: none; max-height: none; }
.ot-slice img { display: block; max-width: none; max-height: none; object-fit: cover; }
.ot-split.vert .ot-slice img { height: 100%; }
.ot-split.horiz .ot-slice img { width: 100%; }
.ot-slice-pal { display: flex; width: 100%; height: 100%; }
.ot-slice-pal > span { display: block; height: 100%; }

.chip-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 .2rem; }

/* in-place trip packing */
.pick-panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: .7rem .8rem; margin: .3rem 0 .8rem; }
.pick-panel .tpick-grid { max-height: 20rem; }
.pick-panel .opick-grid { max-height: 14rem; }
.panel-h .link-btn { margin-left: .5rem; font-weight: 500; }
.outfit-grid .photo-rm-wrap { display: block; }
.mini-tiles .photo-rm-wrap .photo-rm { top: .2rem; left: .2rem; right: auto; width: 1.3rem; height: 1.3rem; font-size: .9rem; }

.sunburst { width: 13rem; height: 13rem; }
.legend-sub { margin: .1rem 0 .3rem 1.1rem; display: flex; flex-direction: column; gap: .05rem; }
.legend-row.sub { font-size: .76rem; padding: .1rem .35rem; }

/* trailing "add" tile at the end of a trip's outfit / packed rows */
.add-tile { display: flex; align-items: center; justify-content: center; width: 4rem; aspect-ratio: 3/4; border: 2px dashed var(--border); border-radius: 8px; background: transparent; color: var(--muted); font-size: 2rem; line-height: 1; cursor: pointer; padding: 0; align-self: flex-start; }
.add-tile:hover { border-color: var(--primary); color: var(--primary); }
.add-tile.on { border-style: solid; border-color: var(--primary); color: var(--primary); }
.add-tile.card { width: 100%; border-radius: var(--radius); font-size: 3rem; }
