#app > #home > .home-head { gap: 8px; }
.app-theme-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  gap: 5px;
  min-width: 44px;
  min-height: 44px;
  margin-inline-start: auto;
  padding: 0 10px;
  border: var(--fm-border);
  border-radius: var(--fm-button-radius);
  background: var(--fm-card);
  color: var(--fm-icon);
  font: 600 13px/1 var(--fm-font);
}
.app-theme-open:hover { background: var(--fm-primary-soft); }
@media (max-width: 350px) {
  #app > #home > .home-head { gap: 4px; }
  .app-theme-open { padding: 0; }
  .app-theme-open span { display: none; }
}

#app-theme-dialog {
  width: min(calc(100% - 2rem), 26rem);
  overflow: hidden;
  background: var(--fm-bg);
  color: var(--fm-text);
}
.app-theme-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(var(--visible-height, 100dvh) - 5rem - env(safe-area-inset-bottom));
}
.app-theme-form h2 { margin: 0; font: 700 22px/1.35 var(--fm-font); }
.app-theme-summary, .app-theme-actions, .app-theme-custom-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-theme-summary { min-height: 50px; }
.app-theme-preview, .app-texture-grid .app-theme-chip {
  background-color: var(--fm-bg);
  background-image: var(--family-texture-image, none);
  background-size: var(--family-texture-size, auto);
}
.app-theme-preview {
  flex: none;
  width: 54px;
  height: 46px;
  border: 1px solid rgb(75 58 47 / 20%);
  border-radius: 10px;
}
.app-theme-summary small, .app-theme-summary strong { display: block; }
.app-theme-summary small, .app-theme-hint {
  color: var(--fm-icon);
  font: 500 12px/1.45 var(--fm-font);
}
.app-theme-summary strong { font: 650 15px/1.4 var(--fm-font); }
.app-theme-reset {
  flex: none;
  min-height: 44px;
  margin-inline-start: auto;
  padding: 0 6px;
  border: 0;
  border-radius: 8px;
  color: var(--fm-icon);
  background: transparent;
  font: 600 13px/1.4 var(--fm-font);
}
.app-theme-tabs {
  flex: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: var(--fm-border);
  border-radius: 14px;
}
.app-theme-tabs button {
  min-height: 42px;
  padding: 4px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--fm-icon);
  font-size: 14px;
}
.app-theme-tabs button[aria-selected="true"] {
  background: var(--fm-primary-soft);
  color: var(--fm-text);
  font-weight: 700;
}
.app-theme-panels { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.app-theme-grid, .app-texture-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  margin: 0;
  padding: 3px;
  min-width: 0;
  border: 0;
}
.app-texture-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
label.app-theme-option {
  position: relative;
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: flex-start;
  gap: 4px;
  min-width: 0;
  min-height: 46px;
  margin: 0;
  padding: 4px 1px;
  border-radius: 8px;
  color: var(--fm-text);
  font: 500 12px/1.3 var(--fm-font);
  word-break: keep-all;
  text-align: center;
  cursor: pointer;
}
.app-theme-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  clip-path: inset(50%);
}
.app-theme-chip {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 26px;
  border: 1px solid rgb(75 58 47 / 19%);
  border-radius: 8px;
}
.app-texture-grid .app-theme-chip { height: 54px; }
.app-theme-option input:checked + .app-theme-chip { border: 1.5px solid var(--fm-icon); }
.app-theme-option input:checked + .app-theme-chip::after {
  content: "";
  width: 9px;
  height: 5px;
  border: solid var(--fm-icon);
  border-width: 0 0 2px 2px;
  transform: translateY(-1px) rotate(-45deg);
}
.app-theme-option:has(input:checked) { font-weight: 700; }
.app-theme-option:has(input:focus-visible), .app-theme-native:focus-within {
  outline: 2px solid var(--fm-primary-pressed);
  outline-offset: 1px;
}
.app-theme-custom-row {
  justify-content: space-between;
  margin: 8px 3px 0;
  padding-top: 6px;
  border-top: var(--fm-border);
}
.app-theme-custom-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin: 0;
  font: 600 13px/1.3 var(--fm-font);
  cursor: pointer;
}
.app-theme-custom-choice input { accent-color: var(--fm-nav-active); width: 16px; height: 16px; }
.app-theme-native {
  position: relative;
  padding-inline: 10px;
  border: var(--fm-border);
  border-radius: 10px;
  color: var(--fm-text);
  background: var(--fm-card);
}
.app-theme-native input { width: 24px; height: 24px; padding: 0; border: 0; background: transparent; cursor: pointer; }
.app-theme-native input::-webkit-color-swatch-wrapper { padding: 2px; }
.app-theme-native input::-webkit-color-swatch { border: 1px solid rgb(75 58 47 / 35%); border-radius: 6px; }
.app-theme-hint { margin: 5px 4px 0; }
.app-theme-hint[hidden], .app-theme-error:empty { display: none; }
.app-theme-error { margin: 0; color: #85371f; font: 500 13px/1.45 var(--fm-font); }
.app-theme-actions { flex: none; justify-content: flex-end; padding-top: 5px; }
.app-theme-actions button { min-width: 74px; min-height: 44px; }
@media (min-width: 400px) {
  .app-theme-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 540px) {
  #app-theme-dialog[open] { width: min(100%, 440px); }
}
@media (max-height: 440px) {
  .app-theme-form { gap: 5px; max-height: calc(var(--visible-height, 100dvh) - 3.5rem); }
  .app-theme-summary { min-height: 32px; }
  .app-theme-preview { height: 30px; }
  .app-theme-reset { min-height: 32px; }
}
