:root {
  color-scheme: light;
  --bg: #f6f6f3;
  --panel: #ffffff;
  --panel-subtle: #fbfbf8;
  --ink: #171717;
  --muted: #64645f;
  --line: #d9d9d2;
  --line-strong: #bcbcb4;
  --accent: #171717;
  --accent-soft: #eeeeea;
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 22px 20px 16px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  order: 2;
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2rem;
  line-height: 1;
  font-weight: 760;
}

h2 {
  margin-bottom: 4px;
  font-size: 1rem;
  font-weight: 720;
}

p {
  color: var(--muted);
  line-height: 1.45;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 392px;
  gap: 16px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 20px 28px;
}

.builder-panel,
.preview-panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.builder-panel {
  padding: 16px;
}

.preview-panel {
  position: sticky;
  top: 16px;
  align-self: start;
  padding: 16px;
}

.section-heading {
  margin-bottom: 14px;
}

.section-heading p {
  max-width: 560px;
  margin-bottom: 0;
  font-size: 0.94rem;
}

.section-heading.compact {
  margin-bottom: 12px;
}

.progress-track {
  height: 7px;
  margin: -4px 0 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--panel-subtle);
  border: 1px solid var(--line);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 160ms ease;
}

.preview-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.action-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  padding: 0 10px;
  font-weight: 680;
  cursor: pointer;
}

.action-button:hover {
  border-color: var(--line-strong);
  background: #fafaf7;
}

.action-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.category-block {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-subtle);
}

.category-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 730;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
  gap: 7px;
}

.option-card {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 46px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  padding: 7px;
  text-align: left;
  cursor: pointer;
}

.option-card:hover {
  border-color: var(--line-strong);
  background: #fafaf7;
}

.option-card.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.option-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.custom-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  margin-top: 7px;
}

.custom-form input {
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  padding: 0 10px;
}

.custom-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.custom-form button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  padding: 0 12px;
  font-weight: 680;
  cursor: pointer;
}

.custom-form button:hover {
  border-color: var(--line-strong);
  background: #fafaf7;
}

.option-icon,
.selected-icon {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 5px;
  object-fit: contain;
  background: white;
  border: 1px solid rgba(23, 23, 23, 0.08);
  padding: 4px;
}

.custom-icon {
  display: grid;
  place-items: center;
  color: white;
  background: var(--accent);
  border-color: transparent;
  font-size: 0.78rem;
  font-weight: 760;
  padding: 0;
}

.option-name {
  display: block;
  overflow-wrap: normal;
  font-size: 0.86rem;
  font-weight: 680;
  line-height: 1.15;
}

#stackCanvas {
  display: block;
  max-width: 100%;
  min-width: 0;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  background: white;
  border: 1px solid var(--line);
}

.selected-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.selected-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px;
  background: var(--panel-subtle);
}

.empty-selection {
  grid-column: 1 / -1;
  margin: 0;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--panel-subtle);
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.selected-item img,
.selected-item .selected-icon {
  width: 28px;
  height: 28px;
}

.selected-category,
.selected-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-category {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
}

.selected-name {
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 700;
}

.status-message {
  min-height: 18px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.is-hidden {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    position: static;
    order: -1;
  }
}

@media (max-width: 720px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
    padding: 18px 14px 12px;
  }

  .eyebrow {
    order: 0;
    font-size: 0.82rem;
  }

  h1 {
    font-size: 1.85rem;
  }

  .app-shell {
    padding: 14px 14px 22px;
  }

  .builder-panel,
  .preview-panel {
    padding: 12px;
  }

  .category-block {
    grid-template-columns: 1fr;
  }

  .selected-list {
    grid-template-columns: 1fr;
  }

  .preview-actions {
    grid-template-columns: 1fr;
  }
}
