.theme-shelf,
.theme-editor {
  --ts-surface: var(--surface);
  --ts-text: var(--ink);
  --ts-border: var(--line);
  --ts-accent: var(--accent);
  box-sizing: border-box;
  min-inline-size: 0;
  max-inline-size: 100%;
  color: var(--ts-text);
}

.theme-shelf *,
.theme-editor * {
  box-sizing: border-box;
}

.theme-shelf__header,
.theme-editor__header,
.theme-editor__fields,
.theme-editor__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
}

.theme-shelf__header,
.theme-editor__header {
  justify-content: space-between;
}

.theme-shelf h2,
.theme-shelf h3,
.theme-shelf p,
.theme-editor h3 {
  margin: 0;
}

.theme-shelf h2 {
  font-size: clamp(1.2rem, 1rem + 1vw, 1.75rem);
  line-height: 1.1;
}

.theme-shelf__status,
.theme-shelf__name {
  min-inline-size: 0;
  overflow-wrap: anywhere;
}

.theme-shelf__group {
  display: grid;
  gap: 0.5rem;
  margin-block-start: 1.15rem;
}

.theme-shelf__hint,
.theme-shelf__status {
  font-size: 0.9em;
}

.theme-shelf__list {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.65rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.theme-shelf__card {
  flex: 0 1 14rem;
  min-inline-size: 0;
  max-inline-size: 100%;
  padding: 0.25rem;
  border: 1px solid var(--ts-border);
  border-radius: 0.65rem;
  background: var(--ts-surface);
}

.theme-shelf button,
.theme-editor button,
.theme-editor input,
.theme-editor select {
  min-block-size: 2.75rem;
  max-inline-size: 100%;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--ts-border);
  border-radius: 0.4rem;
  background: var(--ts-surface);
  color: inherit;
  font: inherit;
}

.theme-shelf button,
.theme-editor button {
  cursor: pointer;
}

.theme-shelf button:hover,
.theme-editor button:hover {
  text-decoration: underline;
}

.theme-shelf button:focus-visible,
.theme-editor :is(button, input, select):focus-visible {
  outline: 2px solid var(--ts-accent);
  outline-offset: 2px;
}

.theme-shelf .theme-shelf__choice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.55rem;
  inline-size: 100%;
  border: 2px solid transparent;
  text-align: start;
}

.theme-shelf__choice[aria-pressed="true"],
.theme-shelf__choice[aria-current="true"] {
  border-color: var(--ts-accent);
}

.theme-shelf__name {
  flex: 1 1 6rem;
  font-weight: 650;
}

.theme-shelf__badge {
  padding: 0.06rem 0.4rem;
  border: 1px solid currentColor;
  border-radius: 0.4rem;
  font-size: 0.78em;
}

.theme-shelf__swatches {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 1px;
  inline-size: 1.75rem;
  block-size: 1.75rem;
  overflow: hidden;
  border: 1px solid var(--ts-border);
  border-radius: 0.3rem;
  background: var(--ts-border);
}

.theme-shelf__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.35rem 0.25rem 0.15rem;
}

.theme-shelf__actions button {
  font-size: 0.85em;
}

.theme-editor {
  display: grid;
  gap: 0.85rem;
  margin-block-start: 1.15rem;
  padding: clamp(0.65rem, 2vw, 1rem);
  border: 1px solid var(--ts-border);
  border-radius: 0.65rem;
  background: var(--ts-surface);
}

.theme-editor__fields {
  align-items: flex-end;
}

.theme-editor__fields label {
  display: grid;
  flex: 1 1 12rem;
  gap: 0.25rem;
  min-inline-size: 0;
}

.theme-editor__fields :is(input, select) {
  inline-size: 100%;
  min-inline-size: 0;
}

.theme-editor button[data-cmd="theme-save"] {
  border: 2px solid var(--ts-accent);
  font-weight: 700;
}

.palette15 {
  padding: clamp(.85rem, 2.5vw, 1.5rem);
}

.palette15 fieldset {
  margin: 0;
  padding: .45rem .55rem .55rem;
  min-inline-size: 0;
  border: 1px solid var(--line);
  border-radius: .65rem;
}

.palette15 legend {
  padding-inline: .3rem;
  color: var(--muted);
}

.palette15 .palette-role input[type="color"] {
  grid-row: 1 / 3;
}

.palette-sample span {
  border-radius: .45rem;
  padding: .3rem .55rem;
  font-weight: 650;
}

.palette15 form > .row { margin-block-start: .8rem; }
