/* panels.css - owner: panels (see docs/CONTRACT.md).
   Inspector (Design tab), Layers tab, Library drawer, Templates drawer. Scoped to .rwp-* classes; controls reuse the
   shell's component classes (.rw-btn, .rw-input, .rw-seg, .rw-switch, .rw-chip, .rw-badge, .rw-swatch ...).
   Colours come only from the design tokens. 4 px grid throughout. */

/* ------------------------------------------------------------------ roots */
.rwp-root {
  box-sizing: border-box;
  height: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--rw-ink);
  font-family: var(--rw-font);
  font-size: var(--rw-text-md);
  line-height: var(--rw-leading);
  scrollbar-width: thin;
  scrollbar-color: var(--rw-line-strong) transparent;
}
.rwp-root *, .rwp-root *::before, .rwp-root *::after { box-sizing: border-box; }
.rwp-root h3, .rwp-root p { margin: 0; }
.rwp-root button { font: inherit; color: inherit; }
.rwp-ico { display: inline-flex; flex: none; align-items: center; justify-content: center; line-height: 0; }
.rwp-ico svg { display: block; }

/* shared focus ring for the panel's own row-like buttons */
.rwp-roomrow:focus-visible, .rwp-issue:focus-visible, .rwp-listrow:focus-visible, .rwp-layer:focus-visible,
.rwp-level__main:focus-visible, .rwp-card:focus-visible, .rwp-recent__item:focus-visible, .rwp-tpl__hit:focus-visible,
.rwp-tpl__blank:focus-visible, .rwp-finish:focus-visible, .rwp-search__clear:focus-visible {
  outline: 2px solid var(--rw-select);
  outline-offset: 1px;
}

/* ------------------------------------------------------------------ header */
.rwp-head {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 12px;
  min-height: 72px;
  padding: 16px;
}
.rwp-head__tile {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border-radius: var(--rw-radius-lg);
  background: var(--tile, var(--rw-bg-subtle));
  box-shadow: inset 0 0 0 1px var(--rw-line);
  color: var(--rw-ink-2);
}
.rwp-head__tile .rwp-thumb { width: 32px; height: 32px; object-fit: contain; }
.rwp-head__tile--plan { color: var(--rw-ink); }
.rwp-head__count { font-size: var(--rw-text-lg); font-weight: var(--rw-weight-semibold); color: var(--rw-ink); }
.rwp-head__text { min-width: 0; }
.rwp-head__title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rwp-head__name {
  overflow: hidden;
  font-size: var(--rw-text-lg);
  font-weight: var(--rw-weight-semibold);
  line-height: 20px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.rwp-head__title .rw-badge { flex: none; display: inline-flex; align-items: center; gap: 4px; }
.rwp-head__sub {
  overflow: hidden;
  margin-top: 2px;
  color: var(--rw-ink-2);
  font-size: var(--rw-text-sm);
  line-height: 16px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.rwp-head__actions { display: flex; align-items: center; gap: 4px; align-self: start; }
.rwp-head--plan { grid-template-columns: 40px minmax(0, 1fr); }

/* plan name: reads as a title, becomes a field on hover / focus */
.rwp-root .rwp-title-input {
  display: block;
  width: calc(100% + 8px);
  height: 28px;
  margin: -2px 0 0 -8px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: var(--rw-radius-sm);
  background: transparent;
  box-shadow: none;
  color: var(--rw-ink);
  font: var(--rw-weight-semibold) var(--rw-text-lg)/26px var(--rw-font);
  text-overflow: ellipsis;
  transition: border-color var(--rw-dur-1) var(--rw-ease-out), background-color var(--rw-dur-1) var(--rw-ease-out);
}
.rwp-root .rwp-title-input:hover { border-color: var(--rw-line-strong); }
.rwp-root .rwp-title-input:focus { outline: none; border-color: var(--rw-select); background: var(--rw-bg); box-shadow: 0 0 0 3px var(--rw-focus-ring); }
.rwp-head--plan .rwp-head__sub { margin-top: 0; }

/* ------------------------------------------------------------------ sections */
.rwp-sec { padding: 16px; border-top: 1px solid var(--rw-line); }
.rwp-sec__head { display: flex; align-items: center; gap: 8px; min-height: 24px; margin: -2px 0 10px; }
.rwp-sec__title { margin: 0; color: var(--rw-ink); font-size: var(--rw-text-md); font-weight: var(--rw-weight-semibold); line-height: 20px; }
.rwp-sec__meta {
  overflow: hidden;
  min-width: 0;
  color: var(--rw-ink-3);
  font-size: var(--rw-text-sm);
  line-height: 16px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.rwp-sec__actions { display: flex; flex: none; align-items: center; gap: 4px; margin: -4px 0 -4px auto; }
.rwp-sec__actions:has(> .rw-btn--ghost) { margin-right: -8px; }
.rwp-sec__body { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.rwp-sec:not(:has(.rwp-sec__head)) { padding-top: 12px; padding-bottom: 12px; }

/* fields */
.rwp-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rwp-field > .rw-label { color: var(--rw-ink-2); font-size: var(--rw-text-sm); line-height: 16px; }
.rwp-field .rw-input, .rwp-field .rw-select, .rwp-field .rw-input-unit, .rwp-field .rw-seg { width: 100%; min-width: 0; }
.rwp-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.rwp-hint { color: var(--rw-ink-3); font-size: var(--rw-text-sm); line-height: 16px; }
.rwp-note { color: var(--rw-ink-2); font-size: var(--rw-text-sm); line-height: 18px; }
.rwp-readout {
  display: flex;
  align-items: center;
  height: var(--rw-control-h);
  padding: 0 10px;
  overflow: hidden;
  border-radius: var(--rw-radius-sm);
  background: var(--rw-bg-subtle);
  color: var(--rw-ink-2);
  white-space: nowrap;
}
.rwp-range-row { display: flex; align-items: center; min-height: 20px; }
.rwp-range-row .rw-range { width: 100%; margin: 0; }

/* switch rows */
.rwp-switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; }
.rwp-switch-row__text { min-width: 0; }
.rwp-switch-row__label { color: var(--rw-ink); line-height: 20px; }
.rwp-switch-row .rw-switch { flex: none; }

/* button helpers */
.rwp-btn-row { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: 8px; }
.rwp-btn-row > .rw-btn { min-width: 0; justify-content: center; }
.rwp-root .rwp-btn-block { width: 100%; justify-content: center; }
.rwp-root .rwp-btn-danger { color: var(--rw-danger-ink); }
.rwp-root .rwp-btn-danger:hover:not(:disabled) { border-color: var(--rw-danger); background: var(--rw-danger-tint); color: var(--rw-danger-ink); }
.rwp-actions { display: flex; flex-direction: column; gap: 8px; padding: 16px; border-top: 1px solid var(--rw-line); }

/* fallback swatch row (RW.ui.swatches brings its own layout) */
.rwp-swatches { display: flex; flex-wrap: wrap; gap: 6px; }

/* ------------------------------------------------------------------ overview */
.rwp-stats { overflow: hidden; border: 1px solid var(--rw-line); border-radius: var(--rw-radius-lg); }
.rwp-stats__row { display: grid; }
.rwp-stats__row + .rwp-stats__row { border-top: 1px solid var(--rw-line); }
.rwp-stats__row--2 { grid-template-columns: 1fr 1fr; }
.rwp-stats__row--3 { grid-template-columns: 1fr 1fr 1fr; }
.rwp-stat { min-width: 0; padding: 10px 12px; }
.rwp-stat + .rwp-stat { border-left: 1px solid var(--rw-line); }
.rwp-stat__value { overflow: hidden; color: var(--rw-ink); font-size: var(--rw-text-md); font-weight: var(--rw-weight-semibold); line-height: 20px; white-space: nowrap; text-overflow: ellipsis; }
.rwp-stat--lg { padding: 12px; }
.rwp-stat--lg .rwp-stat__value { font-size: var(--rw-text-xl); line-height: 28px; letter-spacing: -0.01em; }
.rwp-stat__label { color: var(--rw-ink-2); font-size: var(--rw-text-sm); line-height: 16px; }

/* health card */
.rwp-health-wrap { display: flex; flex-direction: column; gap: 12px; }
.rwp-health { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; column-gap: 12px; }
.rwp-health--idle { grid-template-columns: 44px minmax(0, 1fr); row-gap: 12px; }
.rwp-health--idle > .rw-btn { grid-column: 2; justify-self: start; }
.rwp-health__ring { position: relative; display: grid; place-items: center; width: 44px; height: 44px; }
.rwp-health__ring svg { display: block; }
.rwp-health__ring--idle { border-radius: 50%; background: var(--rw-ai-tint); box-shadow: inset 0 0 0 1px var(--rw-ai-line); color: var(--rw-ai); }
.rwp-ring__track { fill: none; stroke: var(--rw-line); stroke-width: 4; }
.rwp-ring__val { fill: none; stroke: var(--rw-ink-3); stroke-width: 4; stroke-linecap: round; }
.rwp-health--ok .rwp-ring__val { stroke: var(--rw-ok); }
.rwp-health--warn .rwp-ring__val { stroke: var(--rw-warn); }
.rwp-health--danger .rwp-ring__val { stroke: var(--rw-danger); }
.rwp-health__score { position: absolute; inset: 0; display: grid; place-items: center; font-size: var(--rw-text-md); font-weight: var(--rw-weight-semibold); }
.rwp-health__title { font-weight: var(--rw-weight-semibold); line-height: 20px; }
.rwp-health__sub { color: var(--rw-ink-2); font-size: var(--rw-text-sm); line-height: 16px; }
.rwp-issues { overflow: hidden; border: 1px solid var(--rw-line); border-radius: var(--rw-radius-md); }
.rwp-issue {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) 14px;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 36px;
  padding: 0 10px 0 12px;
  border: 0;
  background: transparent;
  color: var(--rw-ink);
  font-size: var(--rw-text-sm);
  text-align: left;
  cursor: pointer;
  transition: background-color var(--rw-dur-1) var(--rw-ease-out);
}
.rwp-issue + .rwp-issue { border-top: 1px solid var(--rw-line); }
.rwp-issue:hover { background: var(--rw-bg-hover); }
.rwp-issue:active { background: var(--rw-bg-active); }
.rwp-issue__title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rwp-issue__go { display: flex; color: var(--rw-ink-3); }
.rwp-sev { width: 8px; height: 8px; border-radius: 50%; background: var(--rw-ink-3); }
.rwp-sev--high { background: var(--rw-danger); }
.rwp-sev--medium { background: var(--rw-warn); }

/* room list */
.rwp-roomlist { display: flex; flex-direction: column; gap: 2px; margin: -4px -8px; }
.rwp-roomrow {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  grid-template-areas: "dot name area" ". bar bar";
  align-items: center;
  column-gap: 10px;
  row-gap: 6px;
  width: 100%;
  padding: 7px 8px 9px;
  border: 0;
  border-radius: var(--rw-radius-sm);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--rw-dur-1) var(--rw-ease-out);
}
.rwp-roomrow:hover { background: var(--rw-bg-hover); }
.rwp-roomrow:active { background: var(--rw-bg-active); }
.rwp-roomrow__dot { grid-area: dot; width: 10px; height: 10px; border-radius: 3px; background: var(--room); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--rw-ink) 22%, transparent); }
.rwp-roomrow__name { grid-area: name; overflow: hidden; line-height: 20px; white-space: nowrap; text-overflow: ellipsis; }
.rwp-roomrow__type { display: none; }
.rwp-roomrow__area { grid-area: area; color: var(--rw-ink-2); font-size: var(--rw-text-sm); }
.rwp-roomrow__bar { grid-area: bar; height: 4px; overflow: hidden; border-radius: 2px; background: var(--rw-bg-subtle); }
.rwp-roomrow__fill { display: block; width: var(--pct); height: 100%; border-radius: 2px; background: color-mix(in srgb, var(--room) 55%, var(--rw-ink-3)); transition: width var(--rw-dur-3) var(--rw-ease-out); }

/* ------------------------------------------------------------------ room */
.rwp-finishes { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.rwp-finish {
  --sw-line: transparent;
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: var(--rw-radius-sm);
  background-color: var(--sw);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--rw-ink) 14%, transparent);
  cursor: pointer;
  transition: box-shadow var(--rw-dur-1) var(--rw-ease-out);
}
.rwp-finish:hover { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--rw-ink) 30%, transparent); }
.rwp-finish.is-active { box-shadow: 0 0 0 2px var(--rw-bg), 0 0 0 4px var(--rw-select), inset 0 0 0 1px color-mix(in srgb, var(--rw-ink) 14%, transparent); }
.rwp-finish--planks { background-image: repeating-linear-gradient(0deg, var(--sw-line) 0 1px, transparent 1px 8px), linear-gradient(90deg, transparent 45%, var(--sw-line) 45% calc(45% + 1px), transparent 0); background-size: auto, 100% 16px; }
.rwp-finish--herringbone { background-image: repeating-linear-gradient(45deg, var(--sw-line) 0 1px, transparent 1px 8px), repeating-linear-gradient(-45deg, var(--sw-line) 0 1px, transparent 1px 8px); }
.rwp-finish--tiles { background-image: linear-gradient(var(--sw-line) 1px, transparent 1px), linear-gradient(90deg, var(--sw-line) 1px, transparent 1px); background-size: 10px 10px; background-position: -1px -1px; }
.rwp-finish--large-tiles { background-image: linear-gradient(var(--sw-line) 1px, transparent 1px), linear-gradient(90deg, var(--sw-line) 1px, transparent 1px); background-size: 20px 20px; background-position: -1px -1px; }
.rwp-finish--marble { background-image: linear-gradient(120deg, transparent 30%, var(--sw-line) 31%, transparent 34%), linear-gradient(150deg, transparent 60%, var(--sw-line) 61%, transparent 63%); }
.rwp-finish--terrazzo { background-image: radial-gradient(var(--sw-line) 1.2px, transparent 1.6px), radial-gradient(var(--sw-line) 0.8px, transparent 1.2px); background-size: 9px 9px, 6px 6px; background-position: 0 0, 3px 4px; }
.rwp-finish--carpet { background-image: radial-gradient(var(--sw-line) 0.7px, transparent 1px); background-size: 4px 4px; }
.rwp-finish--concrete { background-image: radial-gradient(var(--sw-line) 0.8px, transparent 1.2px); background-size: 7px 5px; }
.rwp-finish--grass { background-image: repeating-linear-gradient(80deg, var(--sw-line) 0 1px, transparent 1px 5px); }
.rwp-finish--gravel { background-image: radial-gradient(var(--sw-line) 1.4px, transparent 1.8px); background-size: 6px 6px; }
.rwp-finish--paving { background-image: linear-gradient(var(--sw-line) 1px, transparent 1px), linear-gradient(90deg, var(--sw-line) 1px, transparent 1px); background-size: 14px 14px; background-position: -1px -1px; }
.rwp-finish--decking { background-image: repeating-linear-gradient(90deg, var(--sw-line) 0 1px, transparent 1px 6px); }

.rwp-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding: 12px 16px;
  border-top: 1px solid var(--rw-line);
  color: var(--rw-ink-2);
  font-size: var(--rw-text-sm);
  line-height: 16px;
}
.rwp-count b { color: var(--rw-ink); font-weight: var(--rw-weight-semibold); }

/* ------------------------------------------------------------------ wall / opening */
.rwp-paint { display: flex; flex-direction: column; gap: 8px; }
.rwp-paint__head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.rwp-paint__head .rw-label { overflow: hidden; color: var(--rw-ink-2); font-size: var(--rw-text-sm); line-height: 16px; white-space: nowrap; text-overflow: ellipsis; }
.rwp-paint__name { flex: none; color: var(--rw-ink-3); font-size: var(--rw-text-sm); line-height: 16px; }

.rwp-list { display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--rw-line); border-radius: var(--rw-radius-md); }
.rwp-listrow {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--rw-dur-1) var(--rw-ease-out);
}
.rwp-listrow + .rwp-listrow { border-top: 1px solid var(--rw-line); }
.rwp-listrow:hover { background: var(--rw-bg-hover); }
.rwp-listrow__icon { color: var(--rw-ink-2); }
.rwp-listrow__name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rwp-listrow__meta { color: var(--rw-ink-3); font-size: var(--rw-text-sm); }

/* ------------------------------------------------------------------ item */
.rwp-rot { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.rwp-rot__btns { display: flex; align-items: center; gap: 4px; }
.rwp-rot__btns .rw-btn--sm { min-width: 40px; }

/* ------------------------------------------------------------------ multi-selection */
.rwp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rwp-chip-count { margin-left: 6px; color: var(--rw-ink-3); }
.rwp-align { display: flex; flex-wrap: wrap; gap: 8px; }
.rwp-align__group { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--rw-line); border-radius: var(--rw-radius-md); }
.rwp-align__group .rw-btn { width: 28px; height: 28px; min-width: 28px; padding: 0; }

/* ------------------------------------------------------------------ layers tab */
.rwp-layerlist { display: flex; flex-direction: column; gap: 2px; margin: -4px -8px; }
.rwp-layer {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto 16px;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--rw-radius-sm);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--rw-dur-1) var(--rw-ease-out), color var(--rw-dur-1) var(--rw-ease-out);
}
.rwp-layer:hover:not(:disabled) { background: var(--rw-bg-hover); }
.rwp-layer:active:not(:disabled) { background: var(--rw-bg-active); }
.rwp-layer:disabled { cursor: default; opacity: 0.5; }
.rwp-layer__icon { color: var(--rw-ink-2); }
.rwp-layer__name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rwp-layer__count { min-width: 16px; color: var(--rw-ink-3); font-size: var(--rw-text-sm); text-align: right; }
.rwp-layer__eye { display: flex; color: var(--rw-ink-2); }
.rwp-layer.is-off .rwp-layer__name, .rwp-layer.is-off .rwp-layer__icon, .rwp-layer.is-off .rwp-layer__eye { color: var(--rw-ink-3); }
.rwp-layer.is-off .rwp-layer__name { text-decoration: line-through; text-decoration-color: var(--rw-line-strong); }

/* levels */
.rwp-levels { display: flex; flex-direction: column; gap: 4px; }
.rwp-level {
  display: flex;
  align-items: center;
  min-height: 52px;
  border: 1px solid var(--rw-line);
  border-radius: var(--rw-radius-md);
  background: var(--rw-bg);
  transition: border-color var(--rw-dur-1) var(--rw-ease-out), background-color var(--rw-dur-1) var(--rw-ease-out);
}
.rwp-level:hover { border-color: var(--rw-line-strong); }
.rwp-level.is-active { border-color: var(--rw-select-line); background: var(--rw-select-tint); }
.rwp-level__main {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 12px;
  min-width: 0;
  align-self: stretch;
  padding: 8px 4px 8px 12px;
  border: 0;
  border-radius: var(--rw-radius-md);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.rwp-level.is-active .rwp-level__main { cursor: default; }
.rwp-level__radio { flex: none; width: 16px; height: 16px; border: 1.5px solid var(--rw-line-strong); border-radius: 50%; background: var(--rw-bg); }
.rwp-level.is-active .rwp-level__radio { border-color: var(--rw-select); background: var(--rw-select); box-shadow: inset 0 0 0 3px var(--rw-bg); }
.rwp-level__text { display: flex; flex-direction: column; min-width: 0; }
.rwp-level__name { overflow: hidden; font-weight: var(--rw-weight-medium); line-height: 20px; white-space: nowrap; text-overflow: ellipsis; }
.rwp-level__sub { overflow: hidden; color: var(--rw-ink-3); font-size: var(--rw-text-sm); line-height: 16px; white-space: nowrap; text-overflow: ellipsis; }
.rwp-level.is-active .rwp-level__sub { color: var(--rw-ink-2); }
.rwp-level__edit { flex: 1; min-width: 0; padding: 0 4px 0 0; }
.rwp-level.is-editing .rwp-level__main { flex: none; padding-right: 8px; }
.rwp-level__edit .rw-input { width: 100%; }
.rwp-level__actions { display: flex; flex: none; gap: 2px; padding-right: 8px; opacity: 0; transition: opacity var(--rw-dur-1) var(--rw-ease-out); }
.rwp-level:hover .rwp-level__actions, .rwp-level:focus-within .rwp-level__actions, .rwp-level.is-active .rwp-level__actions, .rwp-level.is-editing .rwp-level__actions { opacity: 1; }
@media (hover: none) { .rwp-level__actions { opacity: 1; } }

/* underlay */
.rwp-under { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: center; gap: 12px; }
.rwp-under__thumb { display: grid; place-items: center; width: 64px; height: 48px; overflow: hidden; border-radius: var(--rw-radius-sm); background: var(--rw-bg-subtle); box-shadow: inset 0 0 0 1px var(--rw-line); color: var(--rw-ink-3); }
.rwp-under__thumb img { width: 100%; height: 100%; object-fit: cover; }
.rwp-under__title { font-weight: var(--rw-weight-medium); line-height: 20px; }
.rwp-under__labelrow { display: flex; align-items: baseline; justify-content: space-between; }
.rwp-under__labelrow .rw-label { color: var(--rw-ink-2); font-size: var(--rw-text-sm); line-height: 16px; }
.rwp-under__pct { color: var(--rw-ink); font-size: var(--rw-text-sm); line-height: 16px; }
.rwp-under-empty { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 4px 12px; align-items: start; }
.rwp-under-empty__icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--rw-radius-md); background: var(--rw-bg-subtle); box-shadow: inset 0 0 0 1px var(--rw-line); color: var(--rw-ink-2); }
.rwp-under-empty__title { font-weight: var(--rw-weight-medium); line-height: 20px; }
.rwp-under-empty > .rw-btn { grid-column: 2; justify-self: start; margin-top: 8px; }

/* ------------------------------------------------------------------ library drawer */
.rwp-lib { display: flex; flex-direction: column; }
.rwp-lib > *, .rwp-tpl > * { flex: none; }
.rwp-lib__head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 12px 8px;
  border-bottom: 1px solid var(--rw-line);
  background: var(--rw-bg);
}
.rwp-search { position: relative; }
.rwp-search__icon { position: absolute; top: 50%; left: 10px; display: flex; color: var(--rw-ink-3); transform: translateY(-50%); pointer-events: none; }
.rwp-root .rwp-search__input { width: 100%; padding-right: 32px; padding-left: 32px; }
.rwp-search__input::-webkit-search-cancel-button { appearance: none; }
.rwp-search__clear {
  position: absolute;
  top: 50%;
  right: 4px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: var(--rw-radius-xs);
  background: transparent;
  color: var(--rw-ink-3);
  cursor: pointer;
  transform: translateY(-50%);
}
.rwp-search__clear:hover { background: var(--rw-bg-hover); color: var(--rw-ink); }
.rwp-search__clear.is-hidden { visibility: hidden; }
.rwp-chiprow {
  display: flex;
  gap: 6px;
  margin: 0 -12px;
  padding: 0 12px 2px;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-padding: 0 12px;
}
.rwp-chiprow::-webkit-scrollbar { display: none; }
.rwp-chiprow > .rw-chip { flex: none; }
.rwp-lib__body { padding: 0 12px 16px; }
.rwp-group { margin-top: 12px; }
.rwp-group__head { display: flex; align-items: center; justify-content: space-between; height: 24px; margin-bottom: 4px; }
.rwp-group__title { color: var(--rw-ink-2); font-size: var(--rw-text-sm); font-weight: var(--rw-weight-semibold); line-height: 16px; }
.rwp-group__meta { color: var(--rw-ink-3); font-size: var(--rw-text-sm); line-height: 16px; }
.rwp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.rwp-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 4px 4px 8px;
  border: 1px solid var(--rw-line);
  border-radius: var(--rw-radius-lg);
  background: var(--rw-bg);
  text-align: left;
  cursor: grab;
  transition: border-color var(--rw-dur-1) var(--rw-ease-out), box-shadow var(--rw-dur-1) var(--rw-ease-out);
}
.rwp-card:hover { border-color: var(--rw-line-strong); box-shadow: var(--rw-shadow-sm); }
.rwp-card:active { cursor: grabbing; box-shadow: none; }
.rwp-card.is-dragging { opacity: 0.5; }
.rwp-card__thumb { display: grid; place-items: center; aspect-ratio: 4 / 3; overflow: hidden; border-radius: var(--rw-radius-sm); background: var(--rw-bg-subtle); color: var(--rw-ink-3); }
.rwp-card__thumb img { width: 76px; height: 76px; object-fit: contain; pointer-events: none; }
.rwp-card__name { overflow: hidden; margin-top: 8px; padding: 0 4px; color: var(--rw-ink); font-size: var(--rw-text-sm); font-weight: var(--rw-weight-medium); line-height: 16px; white-space: nowrap; text-overflow: ellipsis; }
.rwp-card__size { overflow: hidden; padding: 0 4px; color: var(--rw-ink-3); font-size: var(--rw-text-xs); line-height: 16px; white-space: nowrap; text-overflow: ellipsis; }
.rwp-card__add {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: var(--rw-radius-sm);
  background: var(--rw-bg-raised);
  box-shadow: var(--rw-shadow-sm), inset 0 0 0 1px var(--rw-line);
  color: var(--rw-ink);
  opacity: 0;
  transition: opacity var(--rw-dur-1) var(--rw-ease-out);
  pointer-events: none;
}
.rwp-card:hover .rwp-card__add, .rwp-card:focus-visible .rwp-card__add { opacity: 1; }
@media (hover: none) { .rwp-card__add { display: none; } }
.rwp-recent { display: flex; gap: 6px; margin: 0 -12px; padding: 0 12px 2px; overflow-x: auto; scrollbar-width: none; }
.rwp-recent::-webkit-scrollbar { display: none; }
.rwp-recent__item {
  display: grid;
  flex: none;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--rw-line);
  border-radius: var(--rw-radius-md);
  background: var(--rw-bg-subtle);
  color: var(--rw-ink-3);
  cursor: grab;
  transition: border-color var(--rw-dur-1) var(--rw-ease-out);
}
.rwp-recent__item:hover { border-color: var(--rw-line-strong); }
.rwp-recent__item img { width: 40px; height: 40px; object-fit: contain; pointer-events: none; }
.rwp-lib__empty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 24px; }
.rwp-lib__ask { color: var(--rw-ai-ink); }
.rwp-lib__ask .rwp-ico { color: var(--rw-ai); }
.rwp-lib__foot { margin: 16px 4px 0; color: var(--rw-ink-3); font-size: var(--rw-text-sm); line-height: 16px; text-align: center; }

/* ------------------------------------------------------------------ templates drawer */
.rwp-tpl { display: flex; flex-direction: column; gap: 12px; padding: 12px; }
.rwp-tpl__ai {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 8px 12px;
  padding: 12px;
  border: 1px solid var(--rw-ai-line);
  border-radius: var(--rw-radius-lg);
  background: var(--rw-ai-tint);
}
.rwp-tpl__ai-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--rw-radius-md); background: var(--rw-ai); color: var(--rw-on-ai); }
.rwp-tpl__ai-title { color: var(--rw-ink); font-weight: var(--rw-weight-semibold); line-height: 20px; }
.rwp-tpl__ai .rwp-hint { color: var(--rw-ink-2); }
.rwp-tpl__ai > .rw-btn { grid-column: 2; justify-self: start; }
.rwp-tpl__tags { margin: 0 -12px; }
.rwp-tpl__list { display: flex; flex-direction: column; gap: 12px; }
.rwp-tpl__card {
  overflow: hidden;
  border: 1px solid var(--rw-line);
  border-radius: var(--rw-radius-lg);
  background: var(--rw-bg);
  transition: border-color var(--rw-dur-1) var(--rw-ease-out), box-shadow var(--rw-dur-1) var(--rw-ease-out);
}
.rwp-tpl__card:hover { border-color: var(--rw-line-strong); box-shadow: var(--rw-shadow-sm); }
.rwp-tpl__card.is-current { border-color: var(--rw-select-line); }
.rwp-tpl__hit { display: block; width: 100%; padding: 0; border: 0; border-radius: var(--rw-radius-lg) var(--rw-radius-lg) 0 0; background: transparent; cursor: pointer; }
.rwp-tpl__thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 264 / 156;
  overflow: hidden;
  border-bottom: 1px solid var(--rw-line);
  background: var(--cv-bg);
  color: var(--rw-ink-3);
}
.rwp-tpl__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.rwp-tpl__thumb.is-loading { background: var(--rw-skeleton); }
@media (prefers-reduced-motion: no-preference) {
  .rwp-tpl__thumb.is-loading { background: linear-gradient(90deg, var(--rw-skeleton) 0, var(--rw-skeleton-hi) 50%, var(--rw-skeleton) 100%) 0 0 / 200% 100%; animation: rwp-shimmer 1.2s linear infinite; }
}
@keyframes rwp-shimmer { to { background-position: -200% 0; } }
.rwp-tpl__meta { display: flex; flex-direction: column; gap: 4px; padding: 12px; }
.rwp-tpl__titlerow { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rwp-tpl__name { overflow: hidden; font-size: var(--rw-text-md); font-weight: var(--rw-weight-semibold); line-height: 20px; white-space: nowrap; text-overflow: ellipsis; }
.rwp-tpl__titlerow .rw-badge { flex: none; }
.rwp-tpl__desc { display: -webkit-box; overflow: hidden; color: var(--rw-ink-2); font-size: var(--rw-text-sm); line-height: 16px; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.rwp-tpl__foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; margin-top: 8px; }
.rwp-tpl__stats { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.rwp-stat-chip { height: 20px; padding: 0 6px; border-radius: var(--rw-radius-xs); background: var(--rw-bg-subtle); color: var(--rw-ink-2); font-size: var(--rw-text-xs); line-height: 20px; white-space: nowrap; }
.rwp-tpl__foot > .rw-btn { flex: none; }
.rwp-tpl__nothumb { display: flex; color: var(--rw-ink-3); }
.rwp-tpl__blank {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border: 1px dashed var(--rw-line-strong);
  border-radius: var(--rw-radius-lg);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--rw-dur-1) var(--rw-ease-out), border-color var(--rw-dur-1) var(--rw-ease-out);
}
.rwp-tpl__blank:hover { border-style: solid; background: var(--rw-bg-hover); }
.rwp-tpl__blank-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--rw-radius-md); background: var(--rw-bg-subtle); color: var(--rw-ink-2); }
.rwp-tpl__blank-text { display: flex; flex-direction: column; min-width: 0; }
.rwp-tpl__blank-title { font-weight: var(--rw-weight-semibold); line-height: 20px; }
.rwp-tpl__blank-go { display: flex; color: var(--rw-ink-3); }

/* library thumbnails drawn progressively: keep the slot quiet until the image arrives */
.rwp-thumb-pending { visibility: hidden; }
