:root {
  color-scheme: light;
  --ink: #202421;
  --muted: #64706a;
  --line: #d9ded8;
  --panel: #ffffff;
  --soft: #f5f6f2;
  --accent: #0f7b6c;
  --accent-strong: #0a5f54;
  --load-accent: #0f7b6c;
  --shadow: 0 18px 50px rgba(32, 36, 33, 0.12);
}

body[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eef2ec;
  --muted: #aab5ad;
  --line: #354039;
  --panel: #151a17;
  --soft: #0f1311;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 960px;
  height: 100vh;
  min-height: 640px;
  color: var(--ink);
  background: var(--soft);
  font-family: Segoe UI, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  overflow: hidden;
}

* {
  scrollbar-color: var(--accent) color-mix(in srgb, var(--panel) 74%, var(--soft));
  scrollbar-width: thin;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: color-mix(in srgb, var(--panel) 74%, var(--soft));
}

::-webkit-scrollbar-thumb {
  border: 2px solid color-mix(in srgb, var(--panel) 74%, var(--soft));
  border-radius: 999px;
  background: var(--accent);
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 290px;
  grid-template-rows: 52px minmax(0, 1fr) 42px;
  grid-template-areas:
    "topbar topbar topbar"
    "left preview right"
    "status status status";
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
}

.app-topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.topbar-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.topbar-title span {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-button {
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: color-mix(in srgb, var(--panel) 84%, var(--soft));
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
}

.toolbar-button:hover {
  color: var(--accent-strong);
  border-color: color-mix(in srgb, var(--accent) 52%, var(--line));
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 26%, transparent);
}

.control-pane {
  grid-area: left;
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow: hidden;
  min-height: 0;
}

.panel-title-row,
.preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-title-row h1 {
  font-size: 18px;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 22px;
}

.field-block {
  display: grid;
  gap: 9px;
  min-width: 0;
}

.library-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.left-panel {
  display: grid;
  width: 100%;
  max-width: 100%;
  align-content: start;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  padding-right: 2px;
}

.left-panel.is-active {
  height: 100%;
}

.left-panel[hidden] {
  display: none;
}

.template-library {
  display: grid;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  gap: 6px;
  max-height: none;
  min-height: 92px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 90%, var(--soft));
}

.template-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  min-width: 0;
  min-height: 64px;
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  overflow: hidden;
}

.template-card[draggable="true"] {
  cursor: grab;
}

.template-card[draggable="true"]:active {
  cursor: grabbing;
}

.template-card:hover,
.template-card.is-selected,
.template-card.is-active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
}

.template-card.is-dragging {
  opacity: 0.58;
  border-color: var(--accent);
}

.template-card.is-drop-before::before,
.template-card.is-drop-after::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  z-index: 2;
  height: 3px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent);
}

.template-card.is-drop-before::before {
  top: 2px;
}

.template-card.is-drop-after::after {
  bottom: 2px;
}

.template-card-main {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 6px;
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.template-card-main:hover {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}

.template-card-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.template-card-actions {
  display: grid;
  align-self: stretch;
  min-width: 54px;
  border-left: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  background: color-mix(in srgb, var(--soft) 56%, transparent);
}

.template-card-action {
  align-self: stretch;
  min-width: 54px;
  padding: 0 8px;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
  transition: color 0.14s ease, background 0.14s ease, border-color 0.14s ease;
}

.template-card-action + .template-card-action {
  border-top: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
}

.template-card-action:hover {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.template-card-action.is-danger:hover {
  color: #cf4e4e;
  background: rgba(190, 70, 70, 0.11);
}

.template-thumb {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  overflow: hidden;
  border-radius: 6px;
  background:
    linear-gradient(45deg, color-mix(in srgb, var(--line) 35%, transparent) 25%, transparent 25%),
    linear-gradient(-45deg, color-mix(in srgb, var(--line) 35%, transparent) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, color-mix(in srgb, var(--line) 35%, transparent) 75%),
    linear-gradient(-45deg, transparent 75%, color-mix(in srgb, var(--line) 35%, transparent) 75%),
    color-mix(in srgb, var(--panel) 80%, var(--soft));
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.template-thumb img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.confirm-template-thumb {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.confirm-template-thumb img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.template-card-title,
.template-card-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-card-title {
  font-size: 12px;
  font-weight: 800;
}

.template-card-meta {
  color: var(--muted);
  font-size: 11px;
}

.project-library {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  max-height: none;
  min-height: 88px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 90%, var(--soft));
}

.project-card {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 6px;
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  cursor: pointer;
  text-align: left;
}

.project-card .project-delete {
  width: 100%;
}

.project-open {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.project-delete {
  min-height: 22px;
  padding: 0 8px;
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  border-radius: 6px;
  color: var(--muted);
  background: color-mix(in srgb, var(--panel) 82%, var(--soft));
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

.project-delete:hover {
  color: #fff;
  border-color: #a34343;
  background: #a34343;
}

.project-card:hover,
.project-card.is-selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
}

.project-thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 6px;
  background:
    linear-gradient(45deg, color-mix(in srgb, var(--line) 35%, transparent) 25%, transparent 25%),
    linear-gradient(-45deg, color-mix(in srgb, var(--line) 35%, transparent) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, color-mix(in srgb, var(--line) 35%, transparent) 75%),
    linear-gradient(-45deg, transparent 75%, color-mix(in srgb, var(--line) 35%, transparent) 75%),
    color-mix(in srgb, var(--panel) 80%, var(--soft));
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.project-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.project-card-empty {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.project-card-title,
.project-card-meta,
.project-card-date {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-card-title {
  font-size: 10px;
  font-weight: 800;
}

.project-card-meta,
.project-card-date {
  color: var(--muted);
  font-size: 9px;
}

.search-highlight {
  padding: 0 2px;
  border-radius: 3px;
  color: var(--ink);
  background: color-mix(in srgb, var(--accent) 34%, transparent);
  box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--accent) 72%, transparent);
}

.archive-panel {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 94%, var(--soft));
}

.archive-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  list-style: none;
}

.archive-panel summary::-webkit-details-marker {
  display: none;
}

.archive-panel summary span:last-child {
  color: var(--muted);
  font-size: 11px;
}

.archive-library {
  max-height: 260px;
  margin-top: 8px;
}

.layer-panel {
  display: grid;
  min-height: 0;
  gap: 9px;
}

.layer-sidebar {
  grid-area: right;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  padding: 14px;
  border-left: 1px solid var(--line);
  background: var(--panel);
  min-height: 0;
  overflow: hidden;
}

.sidebar-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.tab-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: color-mix(in srgb, var(--panel) 84%, var(--soft));
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
}

.tab-button:hover {
  color: var(--accent-strong);
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  background: color-mix(in srgb, var(--accent) 10%, var(--panel));
}

.tab-button.is-active {
  color: var(--accent-strong);
  border-color: color-mix(in srgb, var(--accent) 54%, var(--line));
  background: color-mix(in srgb, var(--accent) 14%, var(--panel));
}

.sidebar-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 0;
  overflow: hidden;
}

.sidebar-panel.is-active {
  height: 100%;
}

.sidebar-panel[hidden] {
  display: none;
}

#panel-images {
  grid-template-rows: auto minmax(0, 1fr) auto;
}

#panel-layers {
  grid-template-rows: auto minmax(0, 1fr);
}

.panel-heading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.panel-heading-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.panel-heading-action-pair {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
}

.panel-heading-actions .text-button {
  font-size: 11px;
  white-space: nowrap;
}

.slot-list {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  padding-right: 2px;
}

.template-slot {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 58px;
  align-items: center;
  gap: 10px;
  min-height: 118px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 92%, var(--soft));
  transition: border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
}

.template-slot.is-dragging {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
  box-shadow: inset 0 0 0 1px var(--accent);
}

.template-slot strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.template-slot p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.slot-thumb {
  display: grid;
  place-items: center;
  width: 56px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(45deg, color-mix(in srgb, var(--line) 35%, transparent) 25%, transparent 25%),
    linear-gradient(-45deg, color-mix(in srgb, var(--line) 35%, transparent) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, color-mix(in srgb, var(--line) 35%, transparent) 75%),
    linear-gradient(-45deg, transparent 75%, color-mix(in srgb, var(--line) 35%, transparent) 75%),
    color-mix(in srgb, var(--panel) 80%, var(--soft));
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.slot-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.slot-actions {
  display: grid;
  gap: 7px;
  justify-items: stretch;
  align-content: center;
}

.mini-button {
  width: 100%;
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid color-mix(in srgb, #a34343 58%, var(--line));
  border-radius: 6px;
  color: #a34343;
  background: color-mix(in srgb, #a34343 10%, transparent);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  backdrop-filter: blur(6px);
  transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
}

.mini-button:hover {
  color: color-mix(in srgb, #a34343 88%, var(--ink));
  border-color: #a34343;
  background: color-mix(in srgb, #a34343 20%, var(--panel));
  cursor: pointer;
}

.layer-tree {
  display: grid;
  align-content: start;
  max-height: none;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 92%, var(--soft));
}

.layer-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) max-content max-content;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 10px 7px calc(10px + var(--depth) * 16px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  color: var(--ink);
  font-size: 12px;
}

.layer-row.layer-child {
  padding-left: 30px;
}

.layer-row.is-hidden-layer {
  color: var(--muted);
}

.layer-visibility-button {
  min-width: 52px;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  border-radius: 7px;
  color: var(--ink);
  background: color-mix(in srgb, var(--panel) 82%, var(--soft));
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

.layer-visibility-button:hover {
  color: var(--accent-strong);
  border-color: color-mix(in srgb, var(--accent) 52%, var(--line));
  background: color-mix(in srgb, var(--accent) 11%, var(--panel));
}

.disclosure-button,
.eye-button {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  transition: color 0.14s ease, background 0.14s ease;
}

.disclosure-button:hover:not(:disabled),
.eye-button:hover:not(:disabled) {
  color: var(--accent-strong);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.disclosure-button:disabled {
  cursor: default;
  opacity: 0.24;
}

.eye-button:disabled {
  cursor: default;
  opacity: 0.34;
}

.eye-button {
  position: relative;
  color: var(--accent-strong);
}

.eye-button::before {
  content: "";
  width: 15px;
  height: 9px;
  border: 2px solid currentColor;
  border-radius: 999px;
}

.eye-button::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: currentColor;
}

.eye-button.is-hidden {
  color: var(--muted);
}

.eye-button.is-hidden::after {
  width: 18px;
  height: 2px;
  border-radius: 0;
  transform: rotate(-35deg);
  background: currentColor;
}

.layer-row:last-child {
  border-bottom: 0;
}

.layer-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-row small,
.muted-copy {
  color: var(--muted);
  font-size: 11px;
}

label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select,
input,
.secondary-button,
.primary-button {
  min-height: 42px;
  border-radius: 10px;
}

select,
input {
  width: 100%;
  padding: 0 12px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  outline: none;
  transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
}

select {
  appearance: none;
  padding-right: 36px;
  background:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%) right 18px center / 6px 6px no-repeat,
    linear-gradient(135deg, var(--accent) 50%, transparent 50%) right 12px center / 6px 6px no-repeat,
    color-mix(in srgb, var(--panel) 92%, var(--soft));
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 8%, transparent);
}

select:hover {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  background:
    linear-gradient(45deg, transparent 50%, var(--accent-strong) 50%) right 18px center / 6px 6px no-repeat,
    linear-gradient(135deg, var(--accent-strong) 50%, transparent 50%) right 12px center / 6px 6px no-repeat,
    color-mix(in srgb, var(--accent) 9%, var(--panel));
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, #fff 10%, transparent),
    0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent);
}

select option {
  color: var(--ink);
  background: var(--panel);
}

select option:checked {
  color: #fff;
  background: var(--accent);
}

select:focus-visible,
input:focus-visible {
  border-color: var(--accent);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, #fff 10%, transparent),
    0 0 0 2px color-mix(in srgb, var(--accent) 34%, transparent);
}

input::placeholder {
  color: color-mix(in srgb, var(--muted) 72%, transparent);
}

input[type="search"] {
  padding-right: 10px;
}

.custom-select {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.custom-select-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0 36px 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: color-mix(in srgb, var(--panel) 92%, var(--soft));
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
}

.custom-select-button::before,
.custom-select-button::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 7px;
  height: 2px;
  border-radius: 999px;
  background: var(--accent);
  pointer-events: none;
}

.custom-select-button::before {
  right: 18px;
  transform: rotate(45deg);
}

.custom-select-button::after {
  right: 13px;
  transform: rotate(-45deg);
}

.custom-select-button:hover,
.custom-select-button[aria-expanded="true"] {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--accent) 48%, var(--line));
  background: color-mix(in srgb, var(--accent) 10%, var(--panel));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent);
}

.custom-select-button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-menu {
  position: absolute;
  z-index: 20;
  inset: calc(100% + 4px) 0 auto 0;
  display: grid;
  gap: 3px;
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  padding: 5px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.custom-select-menu[hidden] {
  display: none;
}

.custom-select-option {
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.custom-select-option:hover {
  color: var(--accent-strong);
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
}

.custom-select-option.is-selected {
  color: #fff;
  background: var(--accent);
}

#template-select,
#project-select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.template-meta {
  display: grid;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.template-meta strong {
  color: var(--ink);
}

.template-detail-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 92%, var(--soft));
}

.detail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.detail-heading strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-heading span {
  flex: 0 0 auto;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 12px;
}

.detail-grid span {
  color: var(--muted);
}

.detail-grid strong {
  text-align: right;
}

.slot-checklist {
  display: grid;
  gap: 5px;
}

.slot-meter-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.slot-meter {
  --slot-progress: 0deg;
  --slot-optional-start: 336deg;
  --slot-optional-end: 360deg;
  --slot-meter-color: #b94b4b;
  position: relative;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 999px;
  background:
    conic-gradient(
      var(--slot-meter-color) 0deg var(--slot-progress),
      color-mix(in srgb, var(--line) 58%, transparent) var(--slot-progress) var(--slot-optional-start),
      #8157bd var(--slot-optional-start) var(--slot-optional-end)
    );
}

.slot-meter::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: inherit;
  background: var(--panel);
}

.slot-meter span {
  position: relative;
  z-index: 1;
  color: var(--ink);
  font-size: 11px;
  font-weight: 900;
}

.slot-meter:not(.has-optional) {
  background:
    conic-gradient(
      var(--slot-meter-color) 0deg var(--slot-progress),
      color-mix(in srgb, var(--line) 58%, transparent) var(--slot-progress) 360deg
    );
}

.slot-meter.has-optional:not(.optional-ready) {
  background:
    conic-gradient(
      var(--slot-meter-color) 0deg var(--slot-progress),
      color-mix(in srgb, var(--line) 58%, transparent) var(--slot-progress) var(--slot-optional-start),
      color-mix(in srgb, #8157bd 42%, var(--line)) var(--slot-optional-start) var(--slot-optional-end)
    );
}

.slot-meter-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.slot-meter-copy strong,
.slot-meter-copy span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-meter-copy strong {
  font-size: 12px;
}

.slot-meter-copy span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.slot-check {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 24px;
}

.slot-check span {
  width: 8px;
  height: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 72%, var(--soft));
}

.slot-check.is-ready span {
  border-color: var(--accent);
  background: var(--accent);
}

.slot-check.is-optional span {
  border-color: #8157bd;
}

.slot-check.is-optional.is-ready span {
  background: #8157bd;
}

.slot-check strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.slot-check em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
}

.slot-check.is-ready em {
  color: var(--accent-strong);
}

.slot-check.is-optional.is-ready em {
  color: #9b75d1;
}

.path-readout {
  min-height: 38px;
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 82%, var(--soft));
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.secondary-button,
.primary-button,
.danger-button,
.icon-button,
.text-button {
  border: 0;
  cursor: pointer;
  font-weight: 700;
  transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
}

.secondary-button {
  padding: 0 14px;
  color: var(--ink);
  background: color-mix(in srgb, var(--panel) 78%, var(--soft));
}

.secondary-button:hover:not(:disabled) {
  color: var(--accent-strong);
  background: color-mix(in srgb, var(--accent) 11%, var(--panel));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 28%, transparent);
}

.primary-button {
  width: 100%;
  color: #fff;
  background: var(--accent);
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-strong);
}

.primary-button:disabled,
.secondary-button:disabled,
.danger-button:disabled,
.icon-button:disabled,
.text-button:disabled {
  cursor: default;
  opacity: 0.48;
}

.mini-button:disabled {
  color: var(--muted);
  border-color: var(--line);
  background: color-mix(in srgb, var(--panel) 82%, var(--soft));
  cursor: default;
  opacity: 0.48;
}

.danger-button {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 8px;
  color: #fff;
  background: #a34343;
}

.danger-button:hover:not(:disabled) {
  background: #843232;
}

.icon-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 38px;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-size: 0;
  line-height: 1;
  cursor: pointer;
}

.icon-button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent-strong) 82%, var(--accent));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent);
}

.icon-button[data-choose-slot]::before {
  content: "+";
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: inherit;
  font-size: 22px;
  line-height: 1;
}

.text-button {
  padding: 0;
  color: var(--accent-strong);
  background: transparent;
  font-size: 12px;
}

.text-button:hover:not(:disabled) {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.status-panel {
  grid-area: status;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px auto;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
}

.status-panel p {
  margin: 0;
}

progress {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
}

progress::-webkit-progress-bar {
  background: color-mix(in srgb, var(--panel) 72%, var(--soft));
}

progress::-webkit-progress-value {
  background: var(--load-accent);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  accent-color: var(--accent);
  height: 18px;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 28%, var(--line));
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -5px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
}

.preview-pane {
  grid-area: preview;
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 18px;
  min-height: 0;
  overflow: hidden;
}

.zoom-control {
  display: grid;
  grid-template-columns: auto 120px 42px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.preview-stage {
  display: grid;
  place-items: center;
  min-height: 0;
  height: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, color-mix(in srgb, var(--line) 35%, transparent) 25%, transparent 25%),
    linear-gradient(-45deg, color-mix(in srgb, var(--line) 35%, transparent) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, color-mix(in srgb, var(--line) 35%, transparent) 75%),
    linear-gradient(-45deg, transparent 75%, color-mix(in srgb, var(--line) 35%, transparent) 75%),
    color-mix(in srgb, var(--panel) 80%, var(--soft));
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.preview-stage p {
  margin: 0;
  color: var(--muted);
}

.preview-stage > img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.fast-preview,
.rendered-preview {
  position: relative;
  width: min(100%, 920px, calc((100vh - 185px) * 1.3333));
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 4 / 3;
  transform: scale(var(--preview-zoom, 0.82));
  transform-origin: center;
}

.rendered-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.fast-preview-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
  pointer-events: none;
}

.fast-preview-component {
  position: absolute;
  display: block;
  max-width: none;
  max-height: none;
  object-fit: contain;
  pointer-events: none;
}

.background-overlay {
  object-fit: cover;
}

.work-overlay {
  position: absolute;
  inset: 72px 18px 18px;
  z-index: 10;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(15, 19, 17, 0.32);
  backdrop-filter: blur(2px);
}

.work-overlay[hidden] {
  display: none;
}

.work-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-width: 220px;
  padding: 22px 24px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 8px;
  color: var(--ink);
  background: color-mix(in srgb, var(--panel) 94%, var(--soft));
  box-shadow: var(--shadow);
  text-align: center;
}

.work-card p,
.work-card strong {
  margin: 0;
}

.work-card p {
  color: var(--muted);
  font-size: 12px;
}

.work-progress {
  width: 100%;
  min-width: 180px;
}

.confirm-overlay,
.options-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 19, 17, 0.42);
  backdrop-filter: blur(3px);
}

.confirm-overlay[hidden],
.options-overlay[hidden] {
  display: none;
}

.confirm-dialog,
.options-dialog {
  display: grid;
  gap: 14px;
  width: min(430px, 100%);
  padding: 22px;
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.options-dialog {
  width: min(560px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow-y: auto;
}

.confirm-dialog p,
.confirm-dialog h2,
.options-dialog p,
.options-dialog h2 {
  margin: 0;
}

.confirm-dialog > p:not(.eyebrow) {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.confirm-thumbnail {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  min-height: 170px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, color-mix(in srgb, var(--line) 35%, transparent) 25%, transparent 25%),
    linear-gradient(-45deg, color-mix(in srgb, var(--line) 35%, transparent) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, color-mix(in srgb, var(--line) 35%, transparent) 75%),
    linear-gradient(-45deg, transparent 75%, color-mix(in srgb, var(--line) 35%, transparent) 75%),
    color-mix(in srgb, var(--panel) 80%, var(--soft));
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.confirm-thumbnail img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.options-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.options-close {
  width: 32px;
  min-width: 32px;
  height: 32px;
  font-size: 16px;
}

.option-group {
  display: grid;
  gap: 9px;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.segment-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: color-mix(in srgb, var(--panel) 84%, var(--soft));
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.segment-button.is-active {
  color: var(--accent-strong);
  border-color: color-mix(in srgb, var(--accent) 54%, var(--line));
  background: color-mix(in srgb, var(--accent) 14%, var(--panel));
}

.accent-picker {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.accent-swatch {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, var(--swatch) 0 54%, color-mix(in srgb, var(--swatch) 64%, #ffffff) 54% 100%);
  cursor: pointer;
}

.accent-swatch.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 38%, transparent);
}

.accent-swatch.is-active::after {
  content: "✓";
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: color-mix(in srgb, var(--swatch) 14%, #ffffff);
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.38);
}


.export-size-list {
  display: grid;
  gap: 10px;
}

.export-size-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel) 84%, var(--soft));
}

.export-size-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--ink);
}

.export-size-toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.export-size-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.export-size-copy strong,
.export-size-copy small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.export-size-copy small {
  color: var(--muted);
  font-size: 11px;
}

.export-size-input {
  display: grid;
  grid-template-columns: auto minmax(78px, 96px) auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.export-size-input input {
  min-height: 36px;
  padding: 0 10px;
  text-align: right;
}

.export-size-input small,
.export-size-fixed {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.export-size-fixed {
  padding: 0 2px;
}

.export-size-row.is-disabled {
  opacity: 0.62;
}

.export-size-row.is-disabled .export-size-input input {
  cursor: default;
}

.throbber {
  width: 34px;
  height: 34px;
  border: 3px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: throbber-spin 0.8s linear infinite;
}

@keyframes throbber-spin {
  to {
    transform: rotate(360deg);
  }
}

/* PSD template onboarding */
.template-import-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.template-import-toolbar .secondary-button,
.template-import-toolbar .text-button {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: color-mix(in srgb, var(--panel) 84%, var(--soft));
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
}

.template-import-toolbar .secondary-button:hover,
.template-import-toolbar .text-button:hover {
  color: var(--accent-strong);
  border-color: color-mix(in srgb, var(--accent) 52%, var(--line));
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 26%, transparent);
}

#open-template-folder {
  grid-column: 1 / -1;
}

.template-import-status {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  max-width: 100%;
  min-width: 0;
  gap: 8px;
}

.template-manager-button {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: color-mix(in srgb, var(--panel) 84%, var(--soft));
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
}

.template-manager-button:hover {
  color: var(--accent-strong);
  border-color: color-mix(in srgb, var(--accent) 52%, var(--line));
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 26%, transparent);
}

.template-manager-button.has-items {
  color: var(--ink);
}

.template-manager-overlay {
  position: fixed;
  inset: 0;
  z-index: 31;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 19, 17, 0.42);
  backdrop-filter: blur(3px);
}

.template-manager-overlay[hidden] {
  display: none;
}

.template-manager-dialog {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  width: min(720px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  min-height: 0;
  padding: 22px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.template-manager-dialog p,
.template-manager-dialog h2 {
  margin: 0;
}

.template-manager-dialog #template-manager-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.template-manager-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
  scrollbar-gutter: stable;
}

.template-manager-item {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 82px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 90%, var(--soft));
}

.template-manager-thumb {
  display: grid;
  place-items: center;
  width: 104px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(45deg, color-mix(in srgb, var(--line) 35%, transparent) 25%, transparent 25%),
    linear-gradient(-45deg, color-mix(in srgb, var(--line) 35%, transparent) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, color-mix(in srgb, var(--line) 35%, transparent) 75%),
    linear-gradient(-45deg, transparent 75%, color-mix(in srgb, var(--line) 35%, transparent) 75%),
    color-mix(in srgb, var(--panel) 80%, var(--soft));
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.template-manager-psd-thumb {
  color: var(--accent-strong);
  background: color-mix(in srgb, var(--accent) 13%, var(--panel));
}

.template-manager-copy {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.template-manager-copy strong,
.template-manager-copy span,
.template-manager-copy em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-manager-copy strong {
  font-size: 13px;
  font-weight: 900;
}

.template-manager-copy span,
.template-manager-copy em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
}

#panel-templates.is-psd-dragging .template-import-status {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--panel));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

.slot-title-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.slot-title-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-role {
  flex: 0 0 auto;
  padding: 2px 5px;
  border-radius: 999px;
  color: var(--muted);
  background: color-mix(in srgb, var(--line) 45%, transparent);
  font-size: 9px;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
}

.template-import-overlay {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(14, 18, 16, 0.52);
  backdrop-filter: blur(4px);
}

.template-import-overlay[hidden] {
  display: none;
}

.template-import-dialog {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 18px;
  width: min(960px, calc(100vw - 44px));
  max-height: min(820px, calc(100vh - 44px));
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

#template-import-discovery,
#template-import-editor {
  min-height: 0;
  overflow: auto;
}

.template-import-source-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.template-import-source {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: color-mix(in srgb, var(--panel) 84%, var(--soft));
  cursor: pointer;
  text-align: left;
}

.template-import-source:hover {
  border-color: color-mix(in srgb, var(--accent) 52%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
}

.template-import-source > span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.template-import-source strong,
.template-import-source small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-import-source small,
.template-import-source em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.template-import-source-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel) 76%, var(--soft));
}

.template-import-source-summary span {
  color: var(--muted);
  font-size: 11px;
}

.template-import-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.template-import-fields label {
  display: grid;
  gap: 6px;
}

.template-import-fields label > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.template-import-fields input,
.template-import-object-fields input,
.template-import-object-fields select {
  width: 100%;
  min-height: 34px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
}

.template-import-fields input:focus,
.template-import-object-fields input:focus,
.template-import-object-fields select:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-color: var(--accent);
}

.template-import-background-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 14px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel) 78%, var(--soft));
}

.template-import-background-option > span {
  display: grid;
  gap: 3px;
}

.template-import-background-option small {
  color: var(--muted);
}

.template-import-object-heading {
  display: grid;
  gap: 5px;
  margin: 16px 0 8px;
}

.template-import-object-heading > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.template-import-object-heading span,
.template-import-object-heading small {
  color: var(--muted);
  font-size: 11px;
}

.template-import-objects {
  display: grid;
  gap: 8px;
}

.template-import-object {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 8px 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel) 88%, var(--soft));
}

.template-import-object.is-unavailable {
  opacity: 0.62;
}

.template-import-include {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
}

.template-import-object-fields {
  display: grid;
  grid-template-columns: minmax(180px, 1.35fr) minmax(170px, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.template-import-required {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
}

.template-import-object-meta {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  color: var(--muted);
  font-size: 10px;
}

.template-import-object-meta > span {
  color: var(--ink);
  font-weight: 600;
}

.template-import-warning {
  flex-basis: 100%;
  margin: 2px 0 0;
  color: #b94b4b;
}

.template-import-actions {
  margin-top: 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

@media (max-width: 1120px) {
  .template-import-object-fields {
    grid-template-columns: 1fr 1fr;
  }

  .template-import-required {
    grid-column: 1 / -1;
  }
}

.template-card-preview {
  grid-row: span 2;
  display: grid;
  width: 72px;
  aspect-ratio: 4 / 3;
  place-items: center;
  overflow: hidden;
  border-radius: 7px;
  background: color-mix(in srgb, var(--panel) 68%, var(--soft));
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.template-card-preview.is-empty::before {
  content: "No preview";
}

.template-card-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.template-card-copy small {
  color: var(--muted);
  font-size: 12px;
}

.slot-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.slot-card-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.slot-card-copy span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-delete:disabled {
  visibility: hidden;
}
