.appearance-page {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  padding:
    max(54px, calc(env(safe-area-inset-top) + 40px))
    max(22px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(22px, env(safe-area-inset-left));
  background: rgba(247, 247, 245, .94);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transform: translateY(18px) scale(.99);
  transition: none;
}

.screen.lock-state-loading .status-bar,
.screen.lock-state-loading .desktop-pager,
.screen.lock-state-loading .dock,
.screen.lock-state-loading .app-panel {
  opacity: 0;
  pointer-events: none;
}

.appearance-page.open {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.appearance-header {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 34px;
  align-items: start;
  gap: 10px;
}

.appearance-header button {
  display: grid;
  place-items: center;
  color: #111;
  background: transparent;
  cursor: pointer;
}

#appearanceClose {
  width: 30px;
  height: 30px;
}

#appearanceClose > span {
  display: block;
  width: 11px;
  height: 11px;
  border-left: 1.25px solid currentColor;
  border-bottom: 1.25px solid currentColor;
  transform: rotate(45deg) translate(2px, -2px);
}

.appearance-title {
  min-width: 0;
}

.appearance-title h1 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-size: 27px;
  font-weight: 620;
  line-height: 1.12;
  letter-spacing: 0;
}

.appearance-title h1 span {
  font-size: 13px;
}

.appearance-title p {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0;
  color: rgba(0, 0, 0, .52);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 12px;
  line-height: 1.35;
}

.appearance-title p span {
  color: #111;
  font-size: 10px;
}

.appearance-moon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
}

.appearance-moon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.appearance-content {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 1px 1px 8px;
}

.appearance-panel {
  display: grid;
  gap: 0;
  padding: 6px 10px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .36);
  box-shadow:
    4px 5px 14px rgba(0, 0, 0, .045),
    -4px -4px 12px rgba(255, 255, 255, .60),
    inset 1px 1px 0 rgba(255, 255, 255, .60),
    inset -1px -1px 0 rgba(0, 0, 0, .025);
}

.appearance-section-heading {
  display: grid;
  gap: 4px;
  padding: 8px 0 10px;
}

.appearance-section-heading h2 {
  margin: 0;
  color: #111;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
}

.appearance-section-heading p {
  margin: 0;
  color: rgba(0, 0, 0, .50);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 11px;
  line-height: 1.35;
}

.appearance-wallpaper-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: stretch;
}

.wallpaper-preview {
  --preview-default-wallpaper:
    radial-gradient(circle at 22% 14%, rgba(255, 255, 255, .72), transparent 34%),
    linear-gradient(150deg, #f7f7f5 0%, #dfdfdc 54%, #fbfbf9 100%);
  position: relative;
  min-height: 214px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 8px;
  background: var(--preview-wallpaper, var(--preview-default-wallpaper));
  background-position: center;
  background-size: cover;
  cursor: pointer;
  outline: none;
  touch-action: pan-x pan-y;
  -webkit-tap-highlight-color: transparent;
}

.wallpaper-preview:focus-visible {
  border-color: rgba(0, 0, 0, .35);
}

.wallpaper-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, .08), transparent 34%),
    linear-gradient(0deg, rgba(0, 0, 0, .16), transparent 38%);
  pointer-events: none;
}

.wallpaper-preview-status {
  position: absolute;
  z-index: 1;
  left: 12px;
  top: 12px;
  display: grid;
  gap: 2px;
  color: #111;
  text-shadow: 0 1px 9px rgba(255, 255, 255, .72);
}

.wallpaper-preview-status time {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 29px;
  line-height: .95;
}

.wallpaper-preview-status span {
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 11px;
}

.wallpaper-preview-dock {
  position: absolute;
  z-index: 1;
  left: 12px;
  right: 12px;
  bottom: 12px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, .34);
  border-radius: 8px;
  background: rgba(255, 255, 255, .30);
}

.appearance-control-stack {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 0;
}

.appearance-control-stack[hidden] {
  display: none;
}

.appearance-upload-button {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 8px;
  color: #111;
  background: rgba(255, 255, 255, .54);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
}

.appearance-upload-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.appearance-url-form,
.appearance-dialog-field {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: #111;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 12px;
  line-height: 1.3;
}

.appearance-url-form > label,
.appearance-dialog-field > span {
  color: rgba(0, 0, 0, .62);
  font-weight: 600;
}

.appearance-url-form div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.appearance-url-form input,
.appearance-dialog-field input {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 0 10px;
  color: #111;
  border: 1px solid rgba(0, 0, 0, .10);
  border-radius: 8px;
  outline: none;
  background: rgba(255, 255, 255, .68);
  font: inherit;
}

.appearance-url-form input:focus,
.appearance-dialog-field input:focus {
  border-color: rgba(0, 0, 0, .35);
}

.appearance-url-form button,
.appearance-secondary-action,
.appearance-dialog-actions button {
  min-height: 38px;
  padding-inline: 12px;
  border-radius: 8px;
  color: #111;
  background: rgba(0, 0, 0, .055);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
}

.appearance-secondary-action {
  width: 100%;
}

.appearance-status {
  min-height: 18px;
  margin: 0;
  color: rgba(0, 0, 0, .58);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 11px;
  line-height: 1.4;
}

.appearance-status[data-tone="error"] {
  color: #9b1c1c;
}

.appearance-status[data-tone="success"] {
  color: #166534;
}

.appearance-icon-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.appearance-icon-item {
  display: grid;
  justify-items: center;
  gap: 7px;
  min-width: 0;
  padding: 8px 5px;
  border: 1px solid rgba(0, 0, 0, .065);
  border-radius: 8px;
  background: rgba(255, 255, 255, .34);
  cursor: pointer;
}

.appearance-icon-item img {
  display: block;
  width: 42px;
  aspect-ratio: 1;
  border-radius: 8px;
  object-fit: contain;
}

.appearance-icon-item span {
  max-width: 100%;
  min-height: 16px;
  overflow-wrap: anywhere;
  color: #111;
  text-align: center;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 11px;
  line-height: 1.2;
}

.appearance-icon-controls {
  display: grid;
  gap: 0;
  margin-bottom: 10px;
}

.appearance-icon-controls .appearance-toggle-row + .appearance-toggle-row,
.appearance-css-panel {
  border-top: 1px solid rgba(0, 0, 0, .04);
}

.appearance-css-panel {
  display: grid;
  gap: 7px;
  padding: 10px 0 12px;
}

.appearance-css-panel[hidden] {
  display: none;
}

.appearance-css-panel label {
  color: rgba(0, 0, 0, .54);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 11px;
  line-height: 1.25;
}

.appearance-css-panel textarea {
  width: 100%;
  min-height: 168px;
  resize: vertical;
  padding: 10px 11px;
  color: #111;
  border: 1px solid rgba(0, 0, 0, .10);
  border-radius: 8px;
  background: rgba(255, 255, 255, .36);
  font: 12px/1.45 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  outline: none;
}

.appearance-css-panel textarea:focus {
  border-color: rgba(0, 0, 0, .35);
}

.appearance-desktop-reset {
  margin-top: 10px;
}

.appearance-toggle-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  gap: 12px;
  padding: 5px 0;
  color: #111;
  font-family: "Noto Serif SC", "Songti SC", serif;
  text-align: left;
  cursor: pointer;
}

.appearance-leading {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.appearance-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.appearance-copy strong {
  overflow-wrap: anywhere;
  color: #111;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.18;
}

.appearance-copy small {
  overflow-wrap: anywhere;
  color: rgba(0, 0, 0, .48);
  font-size: 11px;
  line-height: 1.25;
}

.appearance-row-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: rgba(0, 0, 0, .82);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.15;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.appearance-trailing {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.appearance-trailing input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.appearance-switch {
  position: relative;
  flex: 0 0 auto;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: #111;
  box-shadow: inset 1px 1px 2px rgba(255, 255, 255, .12);
  transition: background .18s ease;
}

.appearance-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .96);
  box-shadow: 1px 1px 4px rgba(0, 0, 0, .16);
  transition: transform .18s ease;
}

.appearance-trailing input:not(:checked) + .appearance-switch {
  background: rgba(0, 0, 0, .16);
}

.appearance-trailing input:not(:checked) + .appearance-switch::after {
  transform: translateX(-20px);
}

.lock-wallpaper-panel {
  display: grid;
  gap: 10px;
  padding: 10px 0 8px;
  border-top: 1px solid rgba(0, 0, 0, .04);
}

.lock-wallpaper-panel[hidden] {
  display: none;
}

.lock-wallpaper-preview {
  min-height: 236px;
  --preview-default-wallpaper:
    radial-gradient(circle at 52% 18%, rgba(255, 255, 255, .36), transparent 30%),
    linear-gradient(180deg, #2d3342, #151923 60%, #0d1017 100%);
}

.lock-preview-clock {
  position: absolute;
  z-index: 1;
  top: 26px;
  left: 0;
  right: 0;
  display: grid;
  justify-items: center;
  gap: 5px;
  color: #fff;
  text-shadow: 0 2px 14px rgba(0, 0, 0, .36);
}

.lock-preview-clock time {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 36px;
  line-height: .9;
}

.lock-preview-clock span {
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 11px;
}

.lock-preview-handle {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 18px;
  width: 46px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .82);
  transform: translateX(-50%);
}

.password-toggle-row {
  min-height: 58px;
  padding: 0;
}

.appearance-icon-dialog,
.appearance-reset-dialog,
.appearance-password-dialog,
.appearance-crop-dialog {
  position: absolute;
  inset: 0;
  z-index: 13;
  display: grid;
  place-items: end center;
  padding: 24px 28px calc(140px + env(safe-area-inset-bottom));
  background: rgba(245, 245, 243, .56);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  contain: paint;
}

.appearance-crop-dialog {
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
}

.appearance-icon-dialog.open,
.appearance-reset-dialog.open,
.appearance-password-dialog.open,
.appearance-crop-dialog.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.appearance-dialog-card {
  display: grid;
  gap: 12px;
  width: min(100%, 372px);
  max-height: min(88dvh, 760px);
  overflow: auto;
  padding: 16px;
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 8px;
  background: rgba(250, 250, 249, .97);
}

.appearance-dialog-card header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.crop-dialog-card header {
  grid-template-columns: 1fr;
}

.appearance-dialog-card header img,
.reset-dialog-icon,
.password-dialog-icon {
  display: block;
  width: 52px;
  aspect-ratio: 1;
  border-radius: 8px;
  object-fit: contain;
  background: rgba(0, 0, 0, .055);
}

.reset-dialog-icon {
  position: relative;
}

.reset-dialog-icon::before,
.reset-dialog-icon::after {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1.5px solid #111;
  border-radius: 50%;
}

.reset-dialog-icon::after {
  inset: 18px 14px 14px 18px;
  border-top-color: transparent;
  border-left-color: transparent;
  border-radius: 0;
  transform: rotate(45deg);
}

.password-dialog-icon {
  position: relative;
}

.password-dialog-icon::before,
.password-dialog-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.password-dialog-icon::before {
  top: 12px;
  width: 18px;
  height: 16px;
  border: 2px solid #111;
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
}

.password-dialog-icon::after {
  bottom: 12px;
  width: 28px;
  height: 22px;
  border-radius: 8px;
  background: #111;
}

.appearance-dialog-card h2,
.appearance-dialog-card p {
  margin: 0;
  font-family: "Noto Serif SC", "Songti SC", serif;
}

.appearance-dialog-card h2 {
  color: #111;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
}

.appearance-dialog-card header p {
  margin-top: 4px;
  color: rgba(0, 0, 0, .50);
  font-size: 11px;
  line-height: 1.35;
}

.appearance-dialog-actions {
  display: flex;
  justify-content: end;
  gap: 10px;
}

.appearance-dialog-actions button[type="submit"] {
  color: #fff;
  background: #111;
}

.crop-stage {
  position: relative;
  width: 100%;
  max-height: 56dvh;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border-radius: 8px;
  background: #111;
  touch-action: none;
  cursor: grab;
}

.crop-stage:active {
  cursor: grabbing;
}

.crop-stage img {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-origin: center;
  user-select: none;
  pointer-events: none;
}

.crop-frame {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, .88);
  box-shadow: inset 0 0 0 999px rgba(0, 0, 0, .16);
  pointer-events: none;
}

.crop-zoom-field input[type="range"] {
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: #111;
}

.lock-screen {
  --lock-default-wallpaper:
    radial-gradient(circle at 50% 14%, rgba(255, 255, 255, .22), transparent 28%),
    linear-gradient(180deg, #2d3342, #151923 60%, #0d1017 100%);
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  background: var(--lock-wallpaper, var(--lock-default-wallpaper));
  background-position: center;
  background-size: cover;
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px);
  touch-action: none;
  user-select: none;
  transition:
    opacity .42s ease,
    transform .42s ease;
}

.screen.lock-state-loading .lock-screen {
  transition: none;
}

.lock-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, .18), transparent 40%),
    linear-gradient(0deg, rgba(0, 0, 0, .38), transparent 42%);
  pointer-events: none;
}

.lock-screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.lock-screen-content {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  justify-items: center;
  height: 100%;
  padding: max(78px, calc(env(safe-area-inset-top) + 58px)) 26px max(34px, env(safe-area-inset-bottom));
  color: #fff;
  text-align: center;
  text-shadow: 0 2px 16px rgba(0, 0, 0, .35);
}

.lock-screen-clock {
  display: grid;
  align-content: start;
  gap: 8px;
}

.lock-screen-clock time {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(56px, 18vw, 78px);
  line-height: .9;
}

.lock-screen-clock span {
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 14px;
}

.lock-screen-unlock {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-width: 130px;
  padding: 12px;
  outline: none;
  cursor: grab;
}

.lock-screen-unlock:active {
  cursor: grabbing;
}

.lock-screen-unlock span {
  width: 54px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .88);
}

.lock-screen-unlock b {
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 13px;
  font-weight: 400;
}

.lock-screen.passcode-open .lock-screen-unlock {
  display: none;
}

.lock-passcode {
  display: none;
  justify-items: center;
  gap: 14px;
  width: min(100%, 320px);
  padding-bottom: 2px;
}

.lock-screen.passcode-open .lock-passcode {
  display: grid;
}

.lock-passcode p {
  margin: 0;
  font-family: "Noto Serif SC", "Songti SC", serif;
}

#lockPasscodePrompt {
  font-size: 15px;
  line-height: 1.25;
}

.lock-passcode-dots {
  display: grid;
  grid-template-columns: repeat(6, 10px);
  gap: 13px;
  justify-content: center;
  min-height: 12px;
}

.lock-passcode-dots span {
  width: 10px;
  height: 10px;
  border: 1px solid rgba(255, 255, 255, .84);
  border-radius: 50%;
  background: transparent;
}

.lock-passcode-dots span.filled {
  background: rgba(255, 255, 255, .92);
}

.lock-passcode-status {
  min-height: 17px;
  color: rgba(255, 255, 255, .84);
  font-size: 12px;
  line-height: 1.35;
}

.lock-keypad {
  display: grid;
  grid-template-columns: repeat(3, 66px);
  gap: 12px 18px;
  justify-content: center;
}

.lock-keypad button {
  display: grid;
  place-items: center;
  width: 66px;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, .20);
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, .14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(12px);
}

.lock-keypad button:active {
  background: rgba(255, 255, 255, .26);
  transform: scale(.96);
}

.lock-keypad [data-action="delete"] {
  font-size: 20px;
}

.lock-passcode.shake {
  animation: lock-passcode-shake .22s ease;
}

@keyframes lock-passcode-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

html.night-mode .screen {
  --screen-default-wallpaper:
    radial-gradient(circle at 24% 8%, rgba(255, 255, 255, .06), transparent 30%),
    linear-gradient(180deg, #1b1a18 0%, #11100f 58%, #171614 100%);
  background: var(--screen-wallpaper, var(--screen-default-wallpaper));
  background-position: center;
  background-size: cover;
}

html.night-mode .appearance-page {
  background:
    radial-gradient(circle at 50% 5%, rgba(255, 255, 255, .07), transparent 32%),
    rgba(17, 16, 15, .94);
}

html.night-mode .appearance-header button,
html.night-mode .appearance-title h1,
html.night-mode .appearance-row-icon,
html.night-mode .appearance-section-heading h2,
html.night-mode .appearance-url-form,
html.night-mode .appearance-dialog-field,
html.night-mode .appearance-icon-item span,
html.night-mode .appearance-dialog-card h2,
html.night-mode .appearance-copy strong {
  color: var(--ink);
}

html.night-mode .appearance-title p,
html.night-mode .appearance-copy small,
html.night-mode .appearance-section-heading p,
html.night-mode .appearance-css-panel label,
html.night-mode .appearance-url-form > label,
html.night-mode .appearance-dialog-field > span,
html.night-mode .appearance-status,
html.night-mode .appearance-dialog-card header p {
  color: rgba(241, 238, 231, .58);
}

html.night-mode .appearance-panel {
  background: rgba(255, 255, 255, .055);
  box-shadow:
    4px 5px 16px rgba(0, 0, 0, .22),
    inset 1px 1px 0 rgba(255, 255, 255, .08),
    inset -1px -1px 0 rgba(0, 0, 0, .18);
}

html.night-mode .wallpaper-preview,
html.night-mode .appearance-icon-item,
html.night-mode .appearance-upload-button,
html.night-mode .appearance-css-panel textarea,
html.night-mode .appearance-dialog-card {
  border-color: rgba(255, 255, 255, .10);
  background-color: rgba(255, 255, 255, .055);
}

html.night-mode .appearance-icon-controls .appearance-toggle-row + .appearance-toggle-row,
html.night-mode .appearance-css-panel {
  border-top-color: rgba(255, 255, 255, .07);
}

html.night-mode .appearance-upload-button,
html.night-mode .appearance-url-form button,
html.night-mode .appearance-secondary-action,
html.night-mode .appearance-dialog-actions button {
  color: var(--ink);
  background: rgba(255, 255, 255, .09);
}

html.night-mode .appearance-url-form input,
html.night-mode .appearance-css-panel textarea,
html.night-mode .appearance-dialog-field input {
  color: var(--ink);
  border-color: rgba(255, 255, 255, .10);
  background: rgba(255, 255, 255, .07);
}

html.night-mode .appearance-url-form input:focus,
html.night-mode .appearance-css-panel textarea:focus,
html.night-mode .appearance-dialog-field input:focus {
  border-color: rgba(241, 238, 231, .42);
}

html.night-mode .wallpaper-preview:focus-visible {
  border-color: rgba(241, 238, 231, .42);
}

html.night-mode .appearance-dialog-actions button[type="submit"] {
  color: #11100f;
  background: var(--ink);
}

html.night-mode .appearance-switch {
  background: #f1eee7;
}

html.night-mode .appearance-switch::after {
  background: #11100f;
}

html.night-mode .appearance-trailing input:not(:checked) + .appearance-switch {
  background: rgba(255, 255, 255, .16);
}

html.night-mode .password-dialog-icon::before {
  border-color: var(--ink);
}

html.night-mode .password-dialog-icon::after {
  background: var(--ink);
}

html.night-mode .appearance-icon-dialog,
html.night-mode .appearance-reset-dialog,
html.night-mode .appearance-password-dialog,
html.night-mode .appearance-crop-dialog {
  background: rgba(17, 16, 15, .68);
}

html.night-mode .reset-dialog-icon::before,
html.night-mode .reset-dialog-icon::after {
  border-color: var(--ink);
}

html.night-mode .reset-dialog-icon::after {
  border-top-color: transparent;
  border-left-color: transparent;
}

html.night-mode .crop-zoom-field input[type="range"] {
  accent-color: var(--ink);
}

@media (max-width: 380px) {
  .appearance-page {
    padding-inline: max(18px, env(safe-area-inset-left)) max(18px, env(safe-area-inset-right));
  }

  .appearance-wallpaper-layout {
    grid-template-columns: 1fr;
  }

  .appearance-icon-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}


/* night mode: memory-style starfield background and non-reflective transparent bevels */
.night-memory-sky {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: none;
  overflow: hidden;
  pointer-events: none;
  background: #000;
}

.night-memory-sky::before,
.night-memory-sky::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

html.night-mode .screen {
  background: var(--screen-wallpaper, #000);
  background-position: center;
  background-size: cover;
}

html.night-mode .night-memory-sky {
  display: block;
}

html.night-mode .screen.custom-wallpaper .night-memory-sky {
  display: none;
}

html.night-mode .night-memory-sky::before {
  inset: 0;
  background:
    radial-gradient(circle at 9% 18%, rgba(170, 182, 218, .46) 0 .95px, transparent 1.9px),
    radial-gradient(circle at 23% 74%, rgba(126, 138, 174, .38) 0 .85px, transparent 1.8px),
    radial-gradient(circle at 44% 31%, rgba(148, 160, 196, .50) 0 1px, transparent 2px),
    radial-gradient(circle at 73% 19%, rgba(190, 200, 232, .40) 0 .9px, transparent 1.9px),
    radial-gradient(circle at 89% 63%, rgba(140, 154, 190, .42) 0 .95px, transparent 1.9px),
    radial-gradient(circle at 57% 82%, rgba(210, 218, 246, .34) 0 .75px, transparent 1.7px),
    linear-gradient(180deg, #000 0%, #010102 50%, #000 100%);
  background-size: 109px 131px, 149px 127px, 163px 181px, 137px 157px, 191px 173px, 227px 211px, 100% 100%;
  opacity: 1;
  filter: drop-shadow(0 0 7px rgba(215, 224, 255, .18));
  animation: night-memory-star-drift 19s linear infinite;
}

html.night-mode .night-memory-sky::after {
  inset: -18%;
  background:
    radial-gradient(circle at 12% 16%, rgba(255, 255, 255, .72) 0 .8px, transparent 1.45px),
    radial-gradient(circle at 38% 44%, rgba(215, 224, 255, .62) 0 .72px, transparent 1.35px),
    radial-gradient(circle at 69% 28%, rgba(255, 255, 255, .76) 0 .85px, transparent 1.55px),
    radial-gradient(circle at 82% 74%, rgba(188, 204, 246, .56) 0 .78px, transparent 1.45px),
    radial-gradient(circle at 27% 88%, rgba(255, 255, 255, .58) 0 .68px, transparent 1.3px),
    radial-gradient(circle, rgba(255, 255, 255, .54) 0 .68px, transparent 1.12px),
    radial-gradient(circle, rgba(170, 184, 224, .48) 0 .78px, transparent 1.22px),
    radial-gradient(circle at 50% 44%, rgba(255, 255, 255, .035), transparent 28%),
    radial-gradient(circle at 50% 50%, transparent 0 44%, rgba(0, 0, 0, .58) 78%, rgba(0, 0, 0, .92) 100%);
  background-position: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 37px 53px, center, center;
  background-size: 233px 277px, 197px 241px, 281px 227px, 251px 293px, 307px 263px, 73px 79px, 97px 109px, 100% 100%, 100% 100%;
  opacity: .78;
  filter: drop-shadow(0 0 10px rgba(230, 236, 255, .26));
  animation: night-memory-star-flare 2.7s ease-in-out infinite alternate;
}

/* 星空被打开的应用完全遮住时暂停动画:background-position 漂移是全屏主线程重绘,
   遮挡期间纯属浪费,iOS 上还会持续抬高发热与内存压力。 */
html.night-mode .screen.settings-open .night-memory-sky::before,
html.night-mode .screen.settings-open .night-memory-sky::after {
  animation-play-state: paused;
}

html.night-mode .status-bar {
  position: relative;
  z-index: 9;
}

html.night-mode .desktop-pager,
html.night-mode .dock {
  position: relative;
  z-index: 1;
}

html.night-mode .settings-page,
html.night-mode .appearance-page {
  background: transparent;
}

.night-meteor {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  display: block;
  width: clamp(102px, 27vw, 238px);
  height: 1px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(150, 168, 215, 0) 13%,
    rgba(176, 194, 238, .10) 38%,
    rgba(222, 232, 255, .40) 68%,
    rgba(255, 255, 255, .95) 96%,
    rgba(255, 255, 255, 0) 100%
  );
  box-shadow:
    0 0 3px rgba(244, 248, 255, .46),
    0 0 12px rgba(183, 204, 255, .22);
  filter: blur(.12px);
  opacity: 0;
  transform-origin: 100% 50%;
  will-change: transform, opacity;
}

.night-meteor::before {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .98);
  box-shadow:
    0 0 5px rgba(255, 255, 255, .78),
    0 0 14px rgba(210, 225, 255, .36);
  transform: translate(34%, -50%);
}

.night-meteor::after {
  content: "";
  position: absolute;
  right: 10%;
  top: 50%;
  width: 52%;
  height: 1px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(236, 242, 255, .18), rgba(255, 255, 255, .34));
  filter: blur(1.4px);
  opacity: .72;
  transform: translateY(-50%);
}

html.night-mode .night-meteor-a {
  width: clamp(150px, 36vw, 282px);
  animation: night-meteor-flight-a 7.8s linear infinite;
  animation-delay: -1.1s;
}

html.night-mode .night-meteor-b {
  width: clamp(108px, 25vw, 214px);
  animation: night-meteor-flight-b 8.9s linear infinite;
  animation-delay: -3.7s;
}

html.night-mode .night-meteor-c {
  width: clamp(88px, 20vw, 172px);
  animation: night-meteor-flight-c 6.6s linear infinite;
  animation-delay: -5.2s;
}

html.night-mode .night-meteor-d {
  width: clamp(132px, 30vw, 246px);
  animation: night-meteor-flight-d 9.4s linear infinite;
  animation-delay: -7.4s;
}

html.night-mode .app-icon {
  --app-icon-border-opacity: .72;
  --app-icon-border-gradient:
    linear-gradient(142deg, rgba(238, 244, 255, .06) 0%, rgba(238, 244, 255, .04) 42%, rgba(0, 0, 0, .24) 100%),
    radial-gradient(ellipse at 86% 88%, rgba(0, 0, 0, .32), transparent 46%);
  background: rgba(238, 244, 255, .012);
  box-shadow:
    inset 0 0 0 1px rgba(238, 244, 255, .016),
    inset -1px -1px 0 rgba(0, 0, 0, .30);
  -webkit-backdrop-filter: blur(18px) saturate(112%);
  backdrop-filter: blur(18px) saturate(112%);
}

html.night-mode .app-button.active .app-icon {
  --app-icon-border-opacity: .76;
  background: rgba(238, 244, 255, .018);
  box-shadow:
    inset 0 0 0 1px rgba(238, 244, 255, .018),
    inset -1px -1px 0 rgba(0, 0, 0, .30);
}

html.night-mode .app-button.active:active .app-icon,
html.night-mode .app-button:active .app-icon {
  --app-icon-border-opacity: .66;
  background: rgba(0, 0, 0, .12);
}

html .screen.app-icon-border-disabled .app-button.active:active .app-icon,
html .screen.app-icon-border-disabled .app-button.active .app-icon,
html .screen.app-icon-border-disabled .app-button:active .app-icon,
html .screen.app-icon-border-disabled .app-button .app-icon {
  background: transparent;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

html .screen.app-icon-border-disabled .app-button .app-icon::before {
  content: none;
}

html.night-mode .dock {
  --dock-border-opacity: .72;
  --dock-border-gradient:
    linear-gradient(142deg, rgba(238, 244, 255, .06) 0%, rgba(238, 244, 255, .04) 42%, rgba(0, 0, 0, .24) 100%),
    radial-gradient(ellipse at 86% 88%, rgba(0, 0, 0, .32), transparent 46%);
  background: rgba(238, 244, 255, .012);
  box-shadow:
    inset 0 0 0 1px rgba(238, 244, 255, .016),
    inset -1px -1px 0 rgba(0, 0, 0, .30);
  -webkit-backdrop-filter: blur(18px) saturate(112%);
  backdrop-filter: blur(18px) saturate(112%);
}

html.night-mode .dock::before {
  color: rgba(238, 244, 255, .78);
  text-shadow: 0 0 18px rgba(215, 224, 255, .22);
}

html.night-mode .settings-moon,
html.night-mode .appearance-moon {
  position: relative;
  overflow: hidden;
  color: var(--ink);
  border: 1px solid rgba(238, 244, 255, .16);
  background: rgba(255, 255, 255, .055);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, .08),
    inset -1px -1px 0 rgba(0, 0, 0, .32),
    0 0 18px rgba(184, 204, 255, .10);
}

html.night-mode .settings-moon::before,
html.night-mode .appearance-moon::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 1px solid rgba(238, 244, 255, .12);
  opacity: .82;
  pointer-events: none;
}

html.night-mode .settings-moon::after,
html.night-mode .appearance-moon::after {
  content: "";
  position: absolute;
  right: 7px;
  top: 7px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .92);
  box-shadow:
    0 0 8px rgba(255, 255, 255, .68),
    -10px 10px 0 -1px rgba(214, 226, 255, .58);
  pointer-events: none;
}

html.night-mode .settings-moon svg,
html.night-mode .appearance-moon svg {
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 0 8px rgba(215, 224, 255, .22));
  transform: rotate(-12deg) scale(.94);
}

@keyframes night-memory-star-drift {
  0% { background-position: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, center; }
  100% { background-position: 109px 131px, -149px 127px, 163px -181px, -137px 157px, 191px 173px, -227px 211px, center; }
}

@keyframes night-memory-star-flare {
  0% { opacity: .46; transform: translate3d(0, 0, 0) scale(1); }
  45% { opacity: .86; }
  100% { opacity: .62; transform: translate3d(14px, -10px, 0) scale(1.012); }
}

@keyframes night-meteor-flight-a {
  0% {
    opacity: 0;
    transform: translate3d(-34vw, -15vh, 0) rotate(24deg) scaleX(.82);
  }
  5% { opacity: .84; }
  78% { opacity: .64; }
  100% {
    opacity: 0;
    transform: translate3d(126vw, 74vh, 0) rotate(24deg) scaleX(.96);
  }
}

@keyframes night-meteor-flight-b {
  0% {
    opacity: 0;
    transform: translate3d(122vw, 0vh, 0) rotate(154deg) scaleX(.74);
  }
  6% { opacity: .66; }
  80% { opacity: .48; }
  100% {
    opacity: 0;
    transform: translate3d(-36vw, 64vh, 0) rotate(154deg) scaleX(.88);
  }
}

@keyframes night-meteor-flight-c {
  0% {
    opacity: 0;
    transform: translate3d(3vw, -13vh, 0) rotate(18deg) scaleX(.68);
  }
  5% { opacity: .60; }
  76% { opacity: .44; }
  100% {
    opacity: 0;
    transform: translate3d(108vw, 42vh, 0) rotate(18deg) scaleX(.80);
  }
}

@keyframes night-meteor-flight-d {
  0% {
    opacity: 0;
    transform: translate3d(-30vw, 22vh, 0) rotate(31deg) scaleX(.72);
  }
  6% { opacity: .72; }
  82% { opacity: .52; }
  100% {
    opacity: 0;
    transform: translate3d(130vw, 96vh, 0) rotate(31deg) scaleX(.94);
  }
}
