#customThemeDialog {
  width: min(690px, calc(100% - 24px));
  height: min(780px, calc(100dvh - 32px));
  overflow: hidden;
}
#customThemeDialog[open] {
  display: flex;
  flex-direction: column;
}
#customThemeDialog > :not(#customThemeForm) {
  flex-shrink: 0;
}
#customThemeScope {
  max-height: 3em;
  overflow-y: auto;
}
#customThemeForm {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}
#customThemeFields {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border: 0;
  padding: 0 4px;
  margin: 0 -4px;
  min-width: 0;
}
#customThemeFields .menu-panel > label,
.custom-theme-grid > label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-top: 12px;
}
#customThemeFields :is(input:not([type='checkbox']):not([type='color']), select) {
  display: block;
  width: 100%;
  margin-top: 6px;
  min-width: 0;
}
.custom-theme-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.custom-theme-preview {
  background: var(--theme-art) var(--custom-background-position, center) / cover;
  border: 1px solid var(--theme-line);
  border-radius: 12px;
  overflow: hidden;
  min-height: 170px;
}
.custom-preview-content {
  width: 68%;
  min-height: 170px;
  padding: 16px;
  background: var(--theme-content);
  overflow-wrap: anywhere;
}
.custom-preview-content strong {
  display: block;
  font-size: 18px;
}
.custom-preview-content small {
  display: block;
  color: var(--theme-quiet);
  margin: 4px 0 10px;
}
.custom-preview-content p {
  margin: 8px 0;
}
.custom-preview-accent {
  display: inline-block;
  background: var(--theme-accent);
  color: var(--theme-on-accent);
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 11px;
}
#customPreviewPeople {
  display: flex;
  gap: 6px;
}
#customPreviewPeople .avatar {
  width: 32px;
  height: 32px;
}
.custom-background-row {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 12px;
  align-items: center;
}
#customBackgroundImage {
  width: 112px;
  height: 96px;
  border-radius: 9px;
  object-fit: cover;
}
.custom-file-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
}
.custom-file-label input[type='file'] {
  font-size: 12px;
  padding: 7px;
  background: var(--theme-soft);
}
.custom-file-label input::file-selector-button {
  color: var(--theme-ink);
  background: var(--theme-surface);
  border: 1px solid var(--theme-line);
  border-radius: 5px;
  padding: 6px;
  margin-right: 7px;
  cursor: pointer;
}
.custom-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.custom-checkbox input[type='checkbox'] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--theme-accent);
}
#customThemeFields .text-button {
  min-height: 36px;
  padding: 6px 8px;
  font-size: 13px;
}
#customThemeFields output {
  float: right;
  font-weight: 400;
  color: var(--theme-quiet);
}
#customThemeFields input[type='range'] {
  padding: 0;
  accent-color: var(--theme-accent);
}
#customAvatars {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.custom-avatar-tile {
  width: 62px;
  position: relative;
}
.custom-avatar-tile img {
  width: 62px;
  height: 62px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--theme-line);
}
.custom-avatar-tile button {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 26px;
  min-height: 26px;
  padding: 0;
  background: var(--theme-surface);
  border: 1px solid var(--theme-line);
  border-radius: 50%;
}
.custom-palette-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}
.custom-palette-toolbar label {
  font-size: 12px;
  flex: 1;
  max-width: 220px;
  margin: 0;
}
@media (max-width: 700px), (pointer: coarse) {
  #customThemeFields .text-button {
    min-height: 44px;
  }
}
#customPalette {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
#customPalette label {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  font-size: 11px;
  min-width: 0;
}
#customPalette input[type='color'] {
  display: block;
  padding: 3px;
  margin-top: 5px;
  width: 100%;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
}
#customContrast {
  color: var(--theme-warn);
}
.custom-editor-footer {
  flex-shrink: 0;
  padding: 8px 0 0;
  border-top: 1px solid var(--theme-line);
  margin-top: 12px;
}
.theme-upload-feedback {
  display: flex;
  align-items: start;
  gap: 8px;
  height: 48px;
}
.theme-upload-feedback > p {
  flex: 1;
  max-height: 48px;
  overflow-y: auto;
  min-width: 0;
}
.theme-upload-feedback > button {
  flex-shrink: 0;
}
.custom-editor-footer .theme-actions {
  margin-top: 8px;
}
#customThemeFeedback {
  margin: 0;
  overflow-wrap: anywhere;
}
#communityTagline {
  overflow-wrap: anywhere;
}
@media (max-width: 500px) {
  #customThemeDialog {
    padding: 18px;
    max-height: calc(100dvh - 24px);
  }
  .custom-theme-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .custom-background-row {
    grid-template-columns: 1fr;
  }
  #customBackgroundImage {
    width: 100%;
    height: 120px;
  }
  #customPalette {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .theme-library-heading {
    flex-wrap: wrap;
  }
  .custom-preview-content {
    width: 78%;
  }
}
