
:root,
body.has-custom-bg .settings-panel,
body.has-custom-bg .about-panel,
body.has-custom-bg .wallpaper-confirm-dialog,
body.has-wallpaper .settings-panel,
body.has-wallpaper .about-panel,
body.has-wallpaper .wallpaper-confirm-dialog {
  --bg-primary: #F5F5DC;
  --bg-secondary: color-mix(in srgb, var(--bg-primary) 88%, white);
  --bg-tertiary: color-mix(in srgb, var(--bg-primary) 75%, white);
  --text-primary: #70706a;
  --text-secondary: #71715b;
  --text-tertiary: #71715b;
  --motto-text: #918d83;
  --accent: #cd7e41;
  --accent-hover: #cd7e41;
  --accent-text: #a65a17;
  --accent-subtle: rgba(205, 126, 65, 0.08);
  --placeholder-text: #75745f;
  --border: color-mix(in srgb, var(--bg-primary) 75%, black);
  --border-focus: #cd7e41;
  --input-bg: color-mix(in srgb, var(--bg-primary) 50%, white);
  --input-shadow: 0 1px 3px rgba(44, 36, 22, 0.06), 0 4px 16px rgba(44, 36, 22, 0.04);
  --input-shadow-focus: 0 1px 3px rgba(44, 36, 22, 0.08), 0 6px 24px color-mix(in srgb, var(--search-focus-stroke) 10%, transparent);
  --shadow-sm: 0 1px 2px rgba(44, 36, 22, 0.04);
  --shadow-md: 0 4px 20px rgba(44, 36, 22, 0.08);
  --shadow-lg: 0 12px 40px rgba(44, 36, 22, 0.12);
  --danger-text: #b24238;
  --danger-border: #e16858;
  --danger-subtle: rgba(174, 57, 45, 0.08);
  --focus-ring-color: var(--selection-stroke-color);
  --canvas-text-primary: #70706a;
  --canvas-text-secondary: #71715b;
  --canvas-greeting-text: var(--canvas-text-secondary);
  --canvas-large-text: #5c5d56;
  --canvas-control-color: #8d8d7f;
  --search-surface: var(--input-bg);
  --search-text-color: #72726c;
  --search-input-text: var(--search-text-color);
  --search-placeholder-color: #75745f;
  --search-control-color: #606054;
  --search-control-hover-color: #8c490b;
  --search-control-hover-surface: var(--accent-subtle);
  --search-control-focus-color: #8c490b;
  --search-control-focus-ring: var(--focus-ring-color);
  --search-focus-stroke: #cd7e41;
  --search-selected-surface: var(--accent-subtle);
  --search-selected-text: #a65a17;
  --engine-menu-text: var(--search-text-color);
  --engine-menu-hover-surface: var(--bg-tertiary);
  --engine-menu-hover-text: var(--engine-menu-text);
  --engine-menu-selected-text: var(--search-selected-text);
  --panel-text-primary: #70706a;
  --panel-text-secondary: #71715b;
  --panel-control-text: #73736d;
  --panel-control-secondary: #75745f;
  --panel-control-icon: #919183;
  --panel-control-hover-text: #6a6a65;
  --panel-accent-text: #a25610;
  --panel-heading-text: var(--panel-text-primary);
  --panel-section-heading-text: var(--panel-text-secondary);
  --panel-focus-stroke: #cd7e41;
  --panel-warning-text: #6a6a64;
  --segment-border: color-mix(in srgb, var(--border) 88%, var(--accent));
  --segment-hover-bg: color-mix(in srgb, var(--input-bg) 92%, var(--accent));
  --segment-selected-bg: #a66631;
  --segment-selected-bg-hover: #a66531;
  --segment-selected-text: #fffdf5;
  --segment-selected-stroke: #8f5529;
  --selection-stroke-color: var(--segment-selected-stroke);
  --wallpaper-search-control-color: var(--wallpaper-text-color);
  --wallpaper-engine-color: var(--wallpaper-search-control-color);
  --wallpaper-submit-color: var(--wallpaper-search-control-color);
  --wallpaper-engine-hover-color: var(--wallpaper-engine-color);
  --wallpaper-submit-hover-color: var(--wallpaper-submit-color);
  --wallpaper-search-control-hover-color: var(--wallpaper-text-color);
  --wallpaper-search-control-focus-color: var(--wallpaper-text-color);
  --wallpaper-search-focus-stroke: var(--wallpaper-text-color);
  --wallpaper-action-border: var(--wallpaper-surface-border);
}

:root {
  --font-body: Georgia, 'Times New Roman', 'Songti SC', 'SimSun', serif;
  --text-shadow-time: 0 2px 8px rgba(0, 0, 0, 0.15);
  --text-shadow-greeting: 0 1px 4px rgba(0, 0, 0, 0.1);
  --wallpaper-text-color: var(--text-primary);
  --wallpaper-motto-text: var(--motto-text);
  --wallpaper-surface-blur: 16px;
  --wallpaper-input-bg: rgba(255, 255, 255, 0.15);
  --wallpaper-button-bg: rgba(255, 255, 255, 0.15);
  --wallpaper-button-hover-bg: rgba(255, 255, 255, 0.25);
  --wallpaper-menu-selected-bg: rgba(245, 245, 220, 0.76);
  --wallpaper-menu-selected-text: #68401f;
  --wallpaper-surface-border: rgba(255, 255, 255, 0.2);
  --wallpaper-protection-bg: rgba(0, 0, 0, 0);
  --radius-sm: 8px;

  --radius-lg: 20px;
  --radius-full: 9999px;
  --radius-ui: 20px;
  --selection-stroke-width: 1px;
  --selected-font-weight: 500;
  --focus-ring-width: 2px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --duration-press: 160ms;
  --duration-fast: 150ms;
  --duration-popover: 180ms;
  --duration-drawer-in: 220ms;
  --duration-drawer-out: 160ms;
  --duration-modal-in: 180ms;
  --duration-modal-out: 140ms;
  --duration-theme: 240ms;
  --transition-fast: var(--duration-fast) var(--ease-out);
  --transition: var(--duration-drawer-in) var(--ease-out);
  --transition-slow: var(--duration-theme) var(--ease-in-out);
}

html[data-color-scheme="dark"] {
  --bg-primary: #141311;
  --bg-secondary: #1e1c18;
  --bg-tertiary: #2a2721;
  --text-primary: #7f7d77;
  --text-secondary: #7e7e7a;
  --text-tertiary: #7e7e7a;
  --motto-text: #7c776f;
  --accent: #9f5300;
  --accent-hover: #9f5300;
  --accent-text: #c47533;
  --accent-subtle: rgba(159, 83, 0, 0.08);
  --placeholder-text: #848480;
  --border: #3e3a30;
  --border-focus: #9f5300;
  --input-bg: #1e1c18;
  --input-shadow: none;
  --input-shadow-focus: 0 0 0 1px color-mix(in srgb, var(--search-focus-stroke) 15%, transparent);
  --shadow-sm: none;
  --shadow-md: 0 2px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --danger-text: #ef8176;
  --danger-border: #a73f39;
  --danger-subtle: rgba(217, 108, 99, 0.08);
  --canvas-text-primary: #7f7d77;
  --canvas-text-secondary: #7e7e7a;
  --canvas-greeting-text: #969691;
  --canvas-large-text: #cdc9bf;
  --canvas-control-color: #656158;
  --search-text-color: #918e87;
  --search-input-text: #c1bcb3;
  --search-placeholder-color: #848480;
  --search-control-color: #aaa79a;
  --search-control-hover-color: #e49c5a;
  --search-control-focus-color: #e49c5a;
  --search-focus-stroke: #9f5300;
  --search-selected-text: #c47533;
  --engine-menu-text: #a9a69f;
  --engine-menu-hover-text: #b5b2aa;
  --engine-menu-selected-text: #ea9959;
  --panel-text-primary: #9b9991;
  --panel-text-secondary: #9e998c;
  --panel-control-text: #a3a098;
  --panel-control-secondary: #a1a09d;
  --panel-control-icon: #8f8b82;
  --panel-control-hover-text: #afaba3;
  --panel-accent-text: #ec9859;
  --panel-heading-text: #a19f97;
  --panel-section-heading-text: #a19f97;
  --panel-focus-stroke: #9f5300;
  --panel-warning-text: #a3a099;
  --segment-selected-bg: #82512a;
  --segment-selected-bg-hover: #825129;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html {
  height: 100%;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100%;
  min-height: 100dvh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-primary);
  background-image:
    radial-gradient(ellipse 80% 60% at 50% 30%, var(--bg-secondary) 0%, transparent 100%),
    radial-gradient(ellipse 50% 40% at 50% 80%, var(--bg-tertiary) 0%, transparent 100%);
  color: var(--canvas-text-primary);
  font-family: var(--font-body);
  user-select: none;
  transition: background-color var(--transition-slow), color var(--transition-slow);
}

body.has-wallpaper {
  background-color: #1a1a1a;
  background-image: var(--wallpaper);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

body.has-wallpaper::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, var(--overlay-strength, 0.25));
  z-index: 0;
  pointer-events: none;
}

body.has-wallpaper.wallpaper-readable::after {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 50% 42%, var(--wallpaper-protection-bg) 0%, transparent 58%),
    linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 0.08) 100%);
  z-index: 0;
  pointer-events: none;
}

body.has-wallpaper .container {
  position: relative;
  z-index: 1;
}

body.has-wallpaper .search-input {
  backdrop-filter: blur(var(--wallpaper-surface-blur));
  -webkit-backdrop-filter: blur(var(--wallpaper-surface-blur));
  background: var(--wallpaper-input-bg);
  border-color: var(--wallpaper-surface-border);
  color: var(--wallpaper-text-color);
}

body.has-wallpaper .search-motto {
  color: var(--wallpaper-motto-text);
}

body.has-wallpaper .search-input:focus {
  border-color: var(--wallpaper-search-focus-stroke);
}

body.has-wallpaper .engine-toggle {
  color: var(--wallpaper-engine-color);
}

body.has-wallpaper .search-submit {
  color: var(--wallpaper-submit-color);
}

body.has-wallpaper .search-input-wrapper:focus-within .engine-toggle {
  color: var(--wallpaper-engine-color);
}

body.has-wallpaper .search-input-wrapper:focus-within .search-submit {
  color: var(--wallpaper-submit-color);
}

body.has-wallpaper .search-input-wrapper .engine-toggle:hover {
  color: var(--wallpaper-engine-hover-color);
}

body.has-wallpaper .search-input-wrapper .search-submit:hover {
  color: var(--wallpaper-submit-hover-color);
}

body.has-wallpaper .engine-toggle:hover,
body.has-wallpaper .search-submit:hover {
  background: transparent;
}

body.has-wallpaper .engine-toggle:hover .search-control-visual,
body.has-wallpaper .search-submit:hover .search-control-visual {
  background: var(--wallpaper-button-bg);
}

body.has-wallpaper .action-btn {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: var(--wallpaper-button-bg);
  border-color: var(--wallpaper-surface-border);
  color: var(--wallpaper-text-color);
}

body.has-wallpaper .action-btn:hover {
  background: var(--wallpaper-button-hover-bg);
  border-color: var(--wallpaper-action-border);
}

body.has-wallpaper .action-btn.icon-only {
  background: var(--wallpaper-button-bg);
  border-color: transparent;
}

body.has-custom-bg .settings-panel,
body.has-custom-bg .about-panel,
body.has-custom-bg .wallpaper-confirm-dialog,
body.has-wallpaper .settings-panel,
body.has-wallpaper .about-panel,
body.has-wallpaper .wallpaper-confirm-dialog {
  background: #F5F5DC;
}

body.has-wallpaper .settings-panel .action-btn,
body.has-wallpaper .wallpaper-confirm-dialog .action-btn {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: var(--input-bg);
  color: var(--text-secondary);
  border-color: var(--border);
  box-shadow: none;
}

body.has-wallpaper .settings-panel .action-btn:hover,
body.has-wallpaper .wallpaper-confirm-dialog .action-btn:hover {
  background: var(--accent-subtle);
  color: var(--text-primary);
  border-color: var(--accent);
}

body.has-wallpaper .settings-panel .action-btn.icon-only {
  background: transparent;
  border-color: transparent;
}

body.has-wallpaper .settings-panel .action-btn.icon-only:hover {
  background: var(--bg-secondary);
}

body.has-wallpaper .about-panel .action-btn.icon-only {
  background: transparent;
  border-color: transparent;
  color: var(--text-primary);
}

body.has-wallpaper .about-panel .action-btn.icon-only:hover {
  background: var(--bg-tertiary);
  color: var(--accent);
}

body.has-wallpaper .suggestions-dropdown {
  backdrop-filter: blur(var(--wallpaper-surface-blur));
  -webkit-backdrop-filter: blur(var(--wallpaper-surface-blur));
  background: var(--wallpaper-input-bg);
  color: var(--wallpaper-text-color);
}

body.has-wallpaper .suggest-item {
  color: var(--wallpaper-text-color);
}

body.has-wallpaper .suggest-item:hover,
body.has-wallpaper .suggest-item.active {
  background: var(--wallpaper-button-bg);
}

body.has-wallpaper .suggest-icon {
  color: var(--wallpaper-text-color);
  opacity: 0.7;
}

body.has-wallpaper .engine-dropdown {
  backdrop-filter: blur(var(--wallpaper-surface-blur));
  -webkit-backdrop-filter: blur(var(--wallpaper-surface-blur));
  background: var(--wallpaper-input-bg);
  border-color: var(--wallpaper-surface-border);
  color: var(--wallpaper-text-color);
}

body.has-wallpaper .engine-dropdown-separator {
  border-top-color: var(--wallpaper-surface-border);
}

body.has-wallpaper .engine-dropdown-item {
  color: var(--wallpaper-text-color);
}

body.has-wallpaper .engine-dropdown-item:hover,
body.has-wallpaper .engine-dropdown-item:focus-visible {
  background: var(--wallpaper-button-bg);
}

body.has-wallpaper .engine-dropdown-item.active {
  background: var(--wallpaper-menu-selected-bg);
  color: var(--wallpaper-menu-selected-text);
}

body.has-wallpaper .time-display {
  text-shadow: var(--text-shadow-time);
  color: var(--wallpaper-time-color, #f6efe2);
}

body.has-wallpaper .greeting {
  text-shadow: var(--text-shadow-greeting);
  color: var(--wallpaper-greeting-color, #d0c8b8);
}

body.has-custom-bg {
  background-image: none;
}

.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
  width: 100%;
  max-width: 640px;
  padding: 40px 24px;
}

.clock-section {
  text-align: center;
}

.time-display {
  display: block;
  font-size: clamp(3.5rem, 8vw, 5.5rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--canvas-large-text);
  font-variant-numeric: tabular-nums;
  font-family: 'Courier New', 'Source Code Pro', 'Menlo', monospace;
  text-shadow: var(--text-shadow-time);
}

.greeting {
  margin-top: 8px;
  font-size: 1.1rem;
  color: var(--canvas-greeting-text);
  font-style: italic;
  text-shadow: var(--text-shadow-greeting);
  letter-spacing: 0.01em;
}

body.has-custom-bg .greeting {
  color: var(--canvas-text-secondary);
}

.search-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.engine-toggle {
  --search-control-optical-shift: 4px;
  position: absolute;
  left: var(--search-control-inset);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: var(--radius-ui);
  background: transparent;
  color: var(--search-control-color);
  cursor: pointer;
  transition: color var(--duration-fast) ease;
  z-index: 51;
}

.engine-toggle:hover {
  color: var(--search-control-hover-color);
}

.engine-toggle:hover .search-control-visual {
  background: var(--search-control-hover-surface);
}

.engine-toggle svg {
  display: block;
  width: 22px;
  height: 22px;
}

.search-submit {
  --search-control-optical-shift: -4px;
  position: absolute;
  right: var(--search-control-inset);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: var(--radius-ui);
  background: transparent;
  color: var(--search-control-color);
  cursor: pointer;
  transition: color var(--duration-fast) ease;
  z-index: 51;
}

.search-submit:hover {
  color: var(--search-control-hover-color);
}

.search-submit:hover .search-control-visual {
  background: var(--search-control-hover-surface);
}

.search-submit svg {
  display: block;
  width: 22px;
  height: 22px;
}

.search-control-visual {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  pointer-events: none;
  transform: translateX(var(--search-control-optical-shift));
  transition: background-color var(--duration-fast) ease, transform var(--duration-press) var(--ease-out);
}

.engine-toggle:active .search-control-visual,
.search-submit:active .search-control-visual {
  transform: translateX(var(--search-control-optical-shift)) scale(0.97);
}

.engine-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 6px;
  min-width: 200px;
  padding: 6px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-ui);
  box-shadow: var(--shadow-lg);
  list-style: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity var(--duration-popover) var(--ease-out), transform var(--duration-popover) var(--ease-out), visibility var(--duration-popover) var(--ease-out);
  z-index: 50;
}

.engine-dropdown.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.engine-dropdown[data-open-source="keyboard"] {
  transition: none;
}

.engine-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 13px 12px;
  border: 0;
  border-radius: calc(var(--radius-ui) * 0.7);
  background: transparent;
  cursor: pointer;
  color: var(--engine-menu-text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  text-align: left;
  transition: background-color var(--transition-fast);
}

.engine-dropdown-item:hover,
.engine-dropdown-item:focus-visible {
  background: var(--engine-menu-hover-surface);
  color: var(--engine-menu-hover-text);
}

.engine-dropdown-item.active {
  background: var(--search-selected-surface);
  color: var(--engine-menu-selected-text);
}

.engine-dropdown-name {
  flex: 1;
}

.search-form {
  width: 100%;
}

.search-input-wrapper {
  --search-control-inset: 4px;
  --search-control-size: 44px;
  --search-control-gap: 8px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  display: block;
  color: inherit;
  transition: color var(--transition), transform var(--transition);
}

.search-input {
  width: 100%;
  padding: 16px calc(var(--search-control-inset) + var(--search-control-size) + var(--search-control-gap));
  border: 1px solid var(--border);
  border-radius: var(--radius-ui);
  background: var(--search-surface);
  color: var(--search-input-text);
  font-family: var(--font-body);
  font-size: 1.05rem;
  outline: none;
  user-select: text;
  box-shadow: var(--input-shadow);
  transition: background-color var(--duration-fast) ease, border-color var(--duration-fast) ease, color var(--duration-fast) ease, box-shadow var(--duration-drawer-in) var(--ease-out);
}

.search-input::placeholder {
  color: var(--search-placeholder-color);
  font-style: italic;
}

.search-motto {
  position: absolute;
  top: 50%;
  left: calc(var(--search-control-inset) + var(--search-control-size) + var(--search-control-gap));
  right: calc(var(--search-control-inset) + var(--search-control-size) + var(--search-control-gap));
  z-index: 2;
  overflow: hidden;
  color: var(--motto-text);
  font-family: var(--font-body);
  font-size: 1rem;
  font-style: italic;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  transform: translateY(-50%);
}

.search-motto[hidden] {
  display: none;
}

.search-input:focus {
  border-color: var(--search-focus-stroke);
  box-shadow: var(--input-shadow-focus);
}

.search-input:focus-visible {
  outline: none;
}

.search-input-wrapper.has-suggestions .search-input {
  border-radius: var(--radius-ui) var(--radius-ui) 0 0;
  border-color: var(--search-focus-stroke);
  border-bottom-color: transparent;
}

.search-input-wrapper.has-suggestions .suggestions-dropdown {
  border-color: var(--search-focus-stroke);
  border-top-color: transparent;
}

.suggestions-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 0;
  padding: 4px 0;
  background: var(--search-surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-ui) var(--radius-ui);
  box-shadow: 0 6px 24px rgba(44, 36, 22, 0.1);
  list-style: none;
  z-index: 49;
  max-height: min(320px, calc(100vh - 180px));
  overflow-x: hidden;
  overflow-y: auto;
}

.suggestions-dropdown[hidden] {
  display: none;
}

.suggest-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px 9px 22px;
  border-radius: 0;
  cursor: pointer;
  color: var(--search-text-color);
  font-family: var(--font-body);
  font-size: 0.92rem;
  transition: background-color var(--transition-fast);
}

.suggest-item:hover,
.suggest-item.active {
  background: var(--bg-tertiary);
}

.suggest-item:last-child {
  border-radius: 0 0 max(0px, calc(var(--radius-ui) - 1px)) max(0px, calc(var(--radius-ui) - 1px));
}

.suggest-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: var(--search-control-color);
}

.suggest-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions-section {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  gap: 12px;
  transform: translateX(-50%);
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-ui);
  background: var(--input-bg);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background-color var(--duration-fast) ease, border-color var(--duration-fast) ease, color var(--duration-fast) ease, box-shadow var(--duration-drawer-in) var(--ease-out), transform var(--duration-press) var(--ease-out);
}

.actions-section .action-btn {
  color: var(--search-control-color);
}

.action-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent);
  background: var(--accent-subtle);
  box-shadow: var(--shadow-md);
}

.action-btn:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-sm);
}

.action-btn.small {
  padding: 6px 14px;
  font-size: 0.82rem;
  min-height: 44px;
}

.action-btn.icon-only {
  border-radius: var(--radius-full);
  justify-content: center;
  padding: 6px;
  border: none;
  background: transparent;
  box-shadow: none;
  min-width: 44px;
  min-height: 44px;
}

.action-btn.icon-only:hover {
  background: var(--bg-secondary);
  transform: none;
  box-shadow: none;
}

.action-btn.icon-only:active {
  transform: scale(0.97);
}

.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-drawer-in) var(--ease-out);
}

body.has-custom-bg .panel-overlay {
  background: transparent;
}

.panel-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.panel-overlay.is-closing {
  transition-duration: var(--duration-drawer-out);
}

.panel-overlay[hidden] {
  display: none;
}

.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  max-width: 90vw;
  height: 100%;
  height: 100dvh;
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateX(100%);
  transition: transform var(--duration-drawer-in) var(--ease-drawer), opacity var(--duration-drawer-in) var(--ease-out);
}

.settings-panel,
.about-panel,
.wallpaper-confirm-dialog {
  --text-primary: var(--panel-text-primary);
  --text-secondary: var(--panel-text-secondary);
  --text-tertiary: var(--panel-text-secondary);
  --placeholder-text: var(--panel-control-secondary);
  --border-focus: var(--panel-focus-stroke);
  color: var(--panel-text-primary);
}

.settings-panel .action-btn,
.about-panel .action-btn,
.wallpaper-confirm-dialog .action-btn,
.settings-panel .settings-nav-btn,
.settings-panel .mode-option,
.settings-panel .theme-option,
.settings-panel .font-option {
  color: var(--panel-control-text);
}

.settings-panel .action-btn.icon-only,
.about-panel .action-btn.icon-only,
.wallpaper-confirm-dialog .action-btn.icon-only {
  color: var(--panel-control-icon);
}

.settings-panel input[type="text"],
.settings-panel input[type="number"] {
  color: var(--panel-control-text);
}

.settings-panel input::placeholder {
  color: var(--panel-control-secondary);
}

.settings-panel .settings-nav-summary,
.settings-panel .settings-nav-btn::after {
  color: var(--panel-control-secondary);
}

.settings-panel .action-btn:not(.icon-only):hover,
.about-panel .action-btn:not(.icon-only):hover,
.wallpaper-confirm-dialog .action-btn:not(.icon-only):hover,
.settings-panel .settings-nav-btn:hover,
.settings-panel .font-option:hover,
.settings-panel .about-trigger:hover,
.settings-panel .wallpaper-add-menu button:hover,
.settings-panel .wallpaper-add-menu button:focus-visible {
  color: var(--panel-control-hover-text);
}

.settings-panel .wallpaper-add-menu button,
.settings-panel .about-trigger {
  color: var(--panel-control-text);
}

.settings-panel.is-open {
  opacity: 1;
  transform: translateX(0);
}

.settings-panel.is-closing {
  transition-duration: var(--duration-drawer-out);
  transition-timing-function: var(--ease-out);
}

.settings-panel[hidden] {
  display: none;
}

.settings-panel-header {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 72px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
  background: var(--bg-primary);
  z-index: 1;
}

.settings-panel-header h2 {
  flex: 1;
  font-size: 1.3rem;
  font-weight: 400;
  line-height: 1.35;
  color: var(--panel-heading-text);
  letter-spacing: -0.01em;
}

html[lang="zh-CN"] .settings-panel-header h2 {
  font-family: "Songti SC", "STSong", "华文宋体", "SimSun", serif;
  letter-spacing: 0;
}

.settings-back[hidden] {
  display: none;
}

.settings-content {
  flex: 1;
  min-height: 0;
  padding: 20px 24px 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.settings-view[hidden] {
  display: none;
}

.setting-group {
  margin-bottom: 24px;
  transition: opacity var(--transition);
}

.settings-content > .setting-group:last-of-type {
  margin-bottom: 0;
}

.setting-group.disabled {
  position: relative;
}

.setting-group.disabled .setting-row,
.setting-group.disabled .color-presets {
  opacity: 0.35;
  pointer-events: none;
}

.setting-group.disabled .setting-label {
  opacity: 0.5;
}

#color-section.disabled::after {
  content: attr(data-hint);
  position: absolute;
  top: 2px;
  right: 0;
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-style: italic;
}

.setting-group-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--panel-section-heading-text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.setting-row {
  margin-bottom: 16px;
}

.setting-row:last-child {
  margin-bottom: 0;
}

.setting-label {
  display: block;
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.color-presets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  border: var(--selection-stroke-width) solid transparent;
  cursor: pointer;
  padding: 0;
  transition: border-color var(--duration-fast) ease, transform var(--duration-press) var(--ease-out);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  background: var(--input-bg);
}

.color-swatch.active {
  border-color: var(--selection-stroke-color);
}

.custom-color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.custom-color-preview {
  display: block;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--input-bg);
  box-shadow: inset 0 0 0 2px var(--input-bg);
  transition: background-color var(--duration-fast) ease, border-color var(--duration-fast) ease;
}

.custom-color-hex {
  flex: 1;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-ui);
  background: var(--input-bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.88rem;
  outline: none;
  transition: background-color var(--duration-fast) ease, color var(--duration-fast) ease, border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.custom-color-hex::placeholder {
  color: var(--placeholder-text);
  font-style: italic;
}

.custom-color-hex:focus {
  border-color: var(--border-focus);
  box-shadow: inset 0 0 0 calc(var(--focus-ring-width) - 1px) var(--border-focus);
}

.custom-color-hex[aria-invalid="true"] {
  border-color: var(--danger-border);
  box-shadow: inset 0 0 0 calc(var(--focus-ring-width) - 1px) var(--danger-border);
}

.custom-color-sliders {
  display: grid;
  gap: 2px;
  margin-top: 8px;
}

.custom-color-slider-group {
  min-width: 0;
}

.custom-color-slider-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: var(--panel-control-text);
  font-size: 0.78rem;
}

.custom-color-slider-label output {
  color: var(--panel-control-secondary);
  font-variant-numeric: tabular-nums;
}

.color-range-slider {
  height: 34px;
}

.custom-color-error {
  margin-top: 4px;
  color: var(--danger-text);
  font-size: 0.78rem;
  line-height: 1.45;
}

.custom-color-error[hidden] {
  display: none;
}

.settings-nav-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-ui);
  background: var(--input-bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
  text-align: left;
  transition: background-color var(--duration-fast) ease, border-color var(--duration-fast) ease, transform var(--duration-press) var(--ease-out);
}

.settings-nav-btn:hover {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.settings-nav-btn::after {
  content: '\2192';
  color: var(--text-tertiary);
  font-size: 1.05rem;
  flex: 0 0 auto;
}

.settings-nav-summary {
  margin-left: auto;
  color: var(--text-tertiary);
  font-size: 0.78rem;
  white-space: nowrap;
}

.settings-inline-hint {
  margin: 6px 4px 0;
  color: var(--text-tertiary);
  font-size: 0.76rem;
}

.settings-inline-hint[hidden] {
  display: none;
}

.tab-title-input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-ui);
  background: var(--input-bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.tab-title-input::placeholder {
  color: var(--placeholder-text);
  font-style: italic;
}

.tab-title-input:focus {
  border-color: var(--border-focus);
  box-shadow: inset 0 0 0 calc(var(--focus-ring-width) - 1px) var(--border-focus);
}

.wallpaper-input {
  display: none;
}

.range-slider {
  display: block;
  width: 100%;
  height: 44px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  outline: none;
  cursor: pointer;
}

.range-slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--range-track, var(--border));
}

.range-slider::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--range-track, var(--border));
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--input-bg);
  cursor: pointer;
  transition: transform var(--transition-fast);
  margin-top: -7px;
}

.range-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--input-bg);
  cursor: pointer;
}

.mode-toggle {
  display: flex;
  gap: 0;
  border-radius: var(--radius-ui);
  overflow: hidden;
  border: 1px solid var(--segment-border);
}

.mode-option {
  flex: 1;
  padding: 8px 0;
  border: none;
  background: var(--input-bg);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background-color var(--duration-fast) ease, color var(--duration-fast) ease, border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
  text-align: center;
  min-height: 44px;
}

.mode-option:first-child {
  border-right: 1px solid var(--segment-border);
  border-radius: calc(var(--radius-ui) - 1px) 0 0 calc(var(--radius-ui) - 1px);
}

.mode-option:last-child {
  border-radius: 0 calc(var(--radius-ui) - 1px) calc(var(--radius-ui) - 1px) 0;
}

.mode-option:hover {
  background: var(--segment-hover-bg);
}

.mode-option.active {
  background: var(--segment-selected-bg);
  color: var(--segment-selected-text);
  font-weight: var(--selected-font-weight);
  box-shadow: inset 0 0 0 var(--selection-stroke-width) var(--selection-stroke-color);
}

.mode-option.active:hover {
  background: var(--segment-selected-bg-hover);
}

.setting-subgroup {
  position: relative;
  transition: opacity var(--transition);
}

.setting-subgroup.disabled {
  pointer-events: none;
}
.setting-subgroup.disabled .setting-row,
.setting-subgroup.disabled .color-presets,
.setting-subgroup.disabled .custom-color-row,
.setting-subgroup.disabled .custom-color-sliders,
.setting-subgroup.disabled .wallpaper-gallery {
  opacity: 0.35;
}

.theme-options {
  display: flex;
  gap: 0;
  border-radius: var(--radius-ui);
  overflow: hidden;
  border: 1px solid var(--segment-border);
}

.theme-option {
  flex: 1;
  padding: 8px 0;
  border: none;
  background: var(--input-bg);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background-color var(--duration-fast) ease, color var(--duration-fast) ease, border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
  text-align: center;
  min-height: 44px;
}

.theme-option:not(:last-child) {
  border-right: 1px solid var(--segment-border);
}

.theme-option:first-child {
  border-radius: calc(var(--radius-ui) - 1px) 0 0 calc(var(--radius-ui) - 1px);
}

.theme-option:last-child {
  border-radius: 0 calc(var(--radius-ui) - 1px) calc(var(--radius-ui) - 1px) 0;
}

.theme-option:hover {
  background: var(--segment-hover-bg);
}

.settings-panel .mode-option:not(.active):hover,
.settings-panel .theme-option:not(.active):hover {
  color: var(--panel-control-hover-text);
}

.theme-option.active {
  background: var(--segment-selected-bg);
  color: var(--segment-selected-text);
  font-weight: var(--selected-font-weight);
  box-shadow: inset 0 0 0 var(--selection-stroke-width) var(--selection-stroke-color);
}

.theme-option.active:hover {
  background: var(--segment-selected-bg-hover);
}

.theme-options.compact .theme-option {
  font-size: 0.78rem;
  padding: 8px 4px;
}

.theme-option:disabled,
.mode-option:disabled,
.action-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.setting-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--text-secondary);
  font-size: 0.88rem;
  cursor: pointer;
  min-height: 44px;
}

.setting-switch {
  width: 42px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  position: relative;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
  flex: 0 0 auto;
}

.setting-switch::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-tertiary);
  transition: transform var(--transition-fast), background-color var(--transition-fast);
}

.setting-switch:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.setting-switch:checked::before {
  transform: translateX(18px);
  background: #fff;
}

.wallpaper-settings-content {
  padding-top: 0;
}

.wallpaper-tabs {
  position: sticky;
  top: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0 -24px 18px;
  padding: 0 24px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
}

.wallpaper-tab {
  position: relative;
  min-height: 48px;
  padding: 10px 8px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
  transition: color var(--duration-fast) ease, background-color var(--duration-fast) ease;
}

.wallpaper-tab::after {
  content: '';
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: transparent;
  transition: background-color var(--duration-fast) ease;
}

.wallpaper-tab.active {
  color: var(--panel-accent-text);
}

.wallpaper-tab.active::after {
  background: var(--accent);
}

.wallpaper-tab-panel[hidden] {
  display: none;
}

.wallpaper-tab-panel:focus {
  outline: none;
}

.wallpaper-library-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-height: 44px;
  margin-bottom: 14px;
}

.wallpaper-library-count {
  flex: 0 0 auto;
  color: var(--text-secondary);
  font-size: 0.9rem;
  white-space: nowrap;
}

.wallpaper-toolbar-action {
  min-height: 44px;
  justify-content: center;
  padding-inline: 16px;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  box-shadow: none;
  white-space: nowrap;
}

.settings-panel .action-btn.wallpaper-toolbar-action:hover {
  color: var(--panel-accent-text);
  box-shadow: none;
}

.wallpaper-library-actions {
  display: grid;
  flex: 1 1 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.wallpaper-library-actions[hidden],
.wallpaper-manage-toolbar[hidden] {
  display: none;
}

.wallpaper-add-menu-wrap {
  position: relative;
  min-width: 0;
}

.wallpaper-add-btn {
  width: 100%;
  min-width: 0;
}

.wallpaper-manage-entry {
  width: 100%;
  min-width: 0;
}

.wallpaper-add-btn span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wallpaper-add-menu {
  position: absolute;
  z-index: 8;
  top: calc(100% + 6px);
  right: 0;
  width: max-content;
  min-width: 144px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  box-shadow: var(--shadow-md);
}

@media (max-width: 360px) {
  .wallpaper-library-header {
    gap: 6px;
  }

  .wallpaper-library-actions {
    gap: 6px;
  }

  .wallpaper-library-count {
    flex: 0 1 auto;
    max-width: 64px;
    overflow: hidden;
    font-size: 0.8rem;
    text-overflow: ellipsis;
  }

  .wallpaper-toolbar-action {
    padding-inline: 10px;
    font-size: 0.76rem;
  }

}

.wallpaper-add-menu[hidden] {
  display: none;
}

.wallpaper-add-menu button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 0;
  border-radius: calc(var(--radius-sm) * 0.75);
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.86rem;
  text-align: left;
  cursor: pointer;
}

.wallpaper-add-menu button:hover,
.wallpaper-add-menu button:focus-visible {
  background: var(--accent-subtle);
}

.wallpaper-manage-toolbar {
  margin-bottom: 14px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}

.wallpaper-selected-count {
  min-height: 24px;
  margin-bottom: 8px;
  color: var(--panel-control-hover-text);
  font-size: 0.82rem;
}

.wallpaper-manage-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.wallpaper-manage-actions .action-btn {
  min-width: 0;
  padding-inline: 8px;
  justify-content: center;
  white-space: nowrap;
}

.wallpaper-manage-actions .danger:not(:disabled):hover,
.wallpaper-confirm-actions .danger:not(:disabled):hover {
  border-color: var(--danger-border);
  color: var(--danger-text);
  background: var(--danger-subtle);
}

.wallpaper-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 10px;
  padding: 1px 3px 4px 1px;
}

.wallpaper-empty {
  grid-column: 1 / -1;
  min-height: 150px;
  padding: 28px 18px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  font-size: 0.82rem;
  line-height: 1.55;
  text-align: center;
  display: grid;
  place-items: center;
}

.wallpaper-thumb {
  position: relative;
  min-width: 0;
  padding: 2px;
  border: var(--selection-stroke-width) solid transparent;
  border-radius: calc(var(--radius-sm) + 3px);
  background: transparent;
  transition: border-color var(--duration-fast) ease, opacity var(--duration-fast) ease;
}

.wallpaper-thumb-main {
  display: block;
  width: 100%;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
}

.wallpaper-thumb-visual {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}

.wallpaper-thumb-main img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wallpaper-thumb-name {
  display: block;
  padding: 7px 3px 3px;
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-family: var(--font-body);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wallpaper-thumb-select {
  position: absolute;
  z-index: 4;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--accent);
  pointer-events: none;
  opacity: 0;
}

.wallpaper-gallery.selecting .wallpaper-thumb-select {
  opacity: 1;
}

.wallpaper-thumb.active {
  border-color: var(--accent);
}

.wallpaper-thumb.selected {
  border-style: dashed;
  border-color: var(--text-secondary);
}

.wallpaper-thumb.active.selected {
  border-color: var(--accent);
}

.wallpaper-reorder-handle {
  position: absolute;
  z-index: 3;
  right: 4px;
  bottom: 31px;
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #fff;
  line-height: 1;
  cursor: grab;
}

.wallpaper-reorder-handle-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 24px;
  padding: 3px 6px;
  border-radius: var(--radius-full);
  background: rgba(30, 28, 24, 0.6);
  font-family: var(--font-body);
  font-size: 0.66rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.16);
}

.wallpaper-gallery.selecting .wallpaper-reorder-handle {
  display: inline-flex;
}

.wallpaper-reorder-handle:active {
  cursor: grabbing;
}

.wallpaper-thumb.dragging {
  opacity: 0.42;
}

.wallpaper-thumb.drag-before::before,
.wallpaper-thumb.drag-after::after {
  content: '';
  position: absolute;
  z-index: 5;
  top: 4px;
  bottom: 4px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.wallpaper-thumb.drag-before::before {
  left: -6px;
}

.wallpaper-thumb.drag-after::after {
  right: -6px;
}

.wallpaper-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 103;
  background: rgba(0, 0, 0, 0.24);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-modal-in) var(--ease-out);
}

.wallpaper-confirm-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.wallpaper-confirm-overlay.is-closing,
.wallpaper-confirm-dialog.is-closing {
  transition-duration: var(--duration-modal-out);
}

.wallpaper-confirm-overlay[hidden],
.wallpaper-confirm-dialog[hidden] {
  display: none;
}

.wallpaper-confirm-dialog {
  position: fixed;
  z-index: 104;
  top: 50%;
  left: 50%;
  width: min(360px, calc(100vw - 32px));
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.97);
  transition: opacity var(--duration-modal-in) var(--ease-out), transform var(--duration-modal-in) var(--ease-out);
}

.wallpaper-confirm-dialog.is-open {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.wallpaper-confirm-dialog h2 {
  margin-bottom: 10px;
  font-size: 1.08rem;
  font-weight: 500;
  color: var(--panel-heading-text);
}

.wallpaper-confirm-dialog p {
  color: var(--text-secondary);
  font-size: 0.86rem;
  line-height: 1.55;
}

.wallpaper-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.font-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.font-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-ui);
  background: var(--input-bg);
  cursor: pointer;
  transition: background-color var(--duration-fast) ease, border-color var(--duration-fast) ease;
  text-align: left;
  width: 100%;
  color: var(--text-primary);
  min-height: 44px;
}

.font-option:hover {
  background: var(--accent-subtle);
  border-color: var(--accent);
}

.font-option.active {
  border-color: var(--selection-stroke-color);
  background: var(--accent-subtle);
  font-weight: var(--selected-font-weight);
}

.font-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-ui);
  background: var(--bg-secondary);
  font-size: 1rem;
  color: var(--panel-control-hover-text);
  flex-shrink: 0;
}

.font-name {
  font-size: 0.9rem;
  font-family: var(--font-body);
}

.actions-section.hidden {
  display: none;
}

.engine-dropdown-separator {
  height: 0;
  margin: 4px 8px;
  border-top: 1px solid var(--border);
  pointer-events: none;
}

.about-entry {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 24px;
}

.about-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-ui);
  background: var(--input-bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color var(--duration-fast) ease, border-color var(--duration-fast) ease, color var(--duration-fast) ease, transform var(--duration-press) var(--ease-out);
}

.about-trigger:hover {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.about-trigger::after {
  content: '\2192';
  color: var(--text-tertiary);
  font-size: 1.1rem;
  transition: transform var(--transition);
}

.about-trigger:hover::after {
  color: var(--accent);
}

.about-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  z-index: 101;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-modal-in) var(--ease-out);
}

.about-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.about-overlay.is-closing {
  transition-duration: var(--duration-modal-out);
}

.about-overlay[hidden] {
  display: none;
}

.about-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.97);
  width: 420px;
  max-width: 90vw;
  max-height: 80vh;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 102;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transition: transform var(--duration-modal-in) var(--ease-out), opacity var(--duration-modal-in) var(--ease-out);
}

.about-panel.is-open {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.about-panel.is-closing {
  transition-duration: var(--duration-modal-out);
}

.about-panel[hidden] {
  display: none;
}

.about-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--border);
}

.about-panel-header h2 {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--panel-heading-text);
}

.about-content {
  padding: 20px 24px 24px;
  overflow-y: auto;
}

.about-description {
  margin-bottom: 20px;
}

.about-description p {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.about-info {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.about-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.about-label {
  font-size: 0.85rem;
  color: var(--text-tertiary);
  flex-shrink: 0;
  min-width: 60px;
}

.about-value {
  font-size: 0.9rem;
  color: var(--text-primary);
}

.about-link {
  color: var(--panel-accent-text);
  text-decoration: none;
  transition: color var(--transition);
}

.about-link:hover {
  color: var(--panel-accent-text);
  text-decoration: underline;
}

.about-license {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.about-license p {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  line-height: 1.5;
  font-style: italic;
}

.about-footer {
  padding-top: 12px;
  text-align: center;
}

.about-footer p {
  font-size: 0.85rem;
  color: var(--text-tertiary);
  font-style: italic;
  letter-spacing: 0.02em;
}

@media (max-width: 480px) {
  .container {
    gap: 28px;
    padding: 24px 16px;
  }
  .actions-section {
    bottom: max(16px, env(safe-area-inset-bottom));
  }
  .actions-section .action-btn {
    padding: 8px 16px;
  }
  .suggestions-dropdown {
    max-height: min(260px, 32vh);
  }
  .engine-toggle {
    left: var(--search-control-inset);
  }
  .search-submit {
    right: var(--search-control-inset);
  }
  .search-input-wrapper {
    --search-control-inset: 2px;
  }
  .search-input {
    padding: 14px calc(var(--search-control-inset) + var(--search-control-size) + var(--search-control-gap));
  }
  .suggest-item {
    padding-left: 18px;
  }
  .engine-dropdown {
    left: 0;
    min-width: 170px;
  }
}

.toast {
  position: fixed;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-ui);
  color: var(--search-text-color);
  font-family: var(--font-body);
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}
.toast.visible {
  opacity: 1;
}

button:focus-visible,
a:focus-visible,
input:not(.search-input):not(.custom-color-hex):not(.tab-title-input):focus-visible,
[role="menuitem"]:focus-visible,
[role="menuitemradio"]:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: 2px;
}

.engine-dropdown-item:focus-visible {
  outline-color: var(--search-control-focus-ring);
}

.engine-toggle:focus-visible,
.search-submit:focus-visible {
  color: var(--search-control-focus-color);
  outline: none;
}

.engine-toggle:focus-visible .search-control-visual,
.search-submit:focus-visible .search-control-visual {
  outline: var(--focus-ring-width) solid var(--search-control-focus-ring);
  outline-offset: 2px;
}

.settings-panel button:focus-visible,
.settings-panel input:not(.custom-color-hex):not(.tab-title-input):focus-visible,
.about-panel button:focus-visible {
  outline-offset: calc(-1 * var(--focus-ring-width));
}

@media (forced-colors: active) {
  .search-input:focus-visible,
  .custom-color-hex:focus-visible,
  .tab-title-input:focus-visible {
    box-shadow: none;
    outline: var(--focus-ring-width) solid Highlight;
    outline-offset: 2px;
  }

  .engine-toggle:focus-visible .search-control-visual,
  .search-submit:focus-visible .search-control-visual {
    outline-color: Highlight;
  }
}

.range-slider:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: calc(-1 * var(--focus-ring-width));
  border-radius: var(--radius-full);
}

.wallpaper-thumb-main:focus-visible,
.wallpaper-reorder-handle:focus-visible {
  outline-offset: calc(-1 * var(--focus-ring-width));
}

@media (hover: hover) and (pointer: fine) {
  .action-btn:not(.icon-only):hover,
  .settings-nav-btn:hover,
  .about-trigger:hover {
    transform: translateY(-1px);
  }

  .about-trigger:hover::after {
    transform: translateX(4px);
  }

  .color-swatch:hover,
  .range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.03);
  }

  .wallpaper-thumb:not(.selected):hover {
    border-color: var(--accent);
  }
}

@media (max-width: 360px) {
  .wallpaper-gallery {
    grid-template-columns: 1fr;
  }

  .wallpaper-thumb.drag-before::before,
  .wallpaper-thumb.drag-after::after {
    right: 4px;
    left: 4px;
    width: auto;
    height: 2px;
  }

  .wallpaper-thumb.drag-before::before {
    top: -6px;
    bottom: auto;
  }

  .wallpaper-thumb.drag-after::after {
    top: auto;
    bottom: -6px;
  }
}

@media (max-height: 700px) {
  .engine-dropdown {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 6px;
    max-height: calc(50dvh - 16px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

@media (max-height: 500px) {
  body {
    align-items: flex-start;
  }

  .engine-dropdown {
    top: 100%;
    bottom: auto;
    margin-top: 6px;
    margin-bottom: 0;
    max-height: calc(100dvh - 160px);
  }

  .container {
    gap: 16px;
    padding: 16px 16px 72px;
  }

  .time-display {
    font-size: clamp(2.75rem, 12vh, 3.5rem);
  }

  .greeting {
    margin-top: 4px;
    font-size: 1rem;
  }

  .actions-section {
    bottom: max(12px, env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  body,
  .engine-dropdown,
  .panel-overlay,
  .settings-panel,
  .about-overlay,
  .about-panel,
  .wallpaper-confirm-overlay,
  .wallpaper-confirm-dialog,
  .action-btn,
  .engine-toggle,
  .search-submit,
  .search-control-visual,
  .setting-switch,
  .setting-switch::before,
  .toast {
    transition-duration: 120ms;
  }

  .engine-dropdown {
    transform: none;
  }

  .settings-panel,
  .settings-panel.is-open {
    transform: none;
  }

  .about-panel,
  .about-panel.is-open {
    transform: translate(-50%, -50%);
  }

  .wallpaper-confirm-dialog,
  .wallpaper-confirm-dialog.is-open {
    transform: translate(-50%, -50%);
  }

  .engine-toggle:active .search-control-visual,
  .search-submit:active .search-control-visual {
    transform: translateX(var(--search-control-optical-shift));
  }

  .action-btn:active,
  .action-btn.icon-only:active,
  .color-swatch:hover,
  .settings-nav-btn:hover,
  .about-trigger:hover,
  .about-trigger:hover::after {
    transform: none;
  }

  .setting-switch::before {
    transition: none;
  }
}
