/* Standalone settings workspace. */
html {
  scroll-behavior: smooth;
  scrollbar-color: var(--settings-scrollbar-thumb) transparent;
  scrollbar-width: thin;
}
html.settings-page {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}
body {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 100dvh;
  min-height: 100svh;
  padding: 16px;
  overflow-x: clip;
  overflow-y: visible;
  background: var(--bg);
  align-items: initial;
  z-index: 0;
  box-sizing: border-box;
}

/* --- THEMED SCROLLBARS --- */
html,
body,
.settings-page-shell * {
  scrollbar-color: var(--settings-scrollbar-thumb) transparent;
  scrollbar-width: thin;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
.settings-page-shell *::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
.settings-page-shell *::-webkit-scrollbar-track {
  background: transparent;
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb,
.settings-page-shell *::-webkit-scrollbar-thumb {
  min-height: 34px;
  background: var(--settings-scrollbar-thumb);
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover,
.settings-page-shell *::-webkit-scrollbar-thumb:hover {
  background: var(--settings-scrollbar-thumb-hover);
  border-width: 1px;
}

html::-webkit-scrollbar-corner,
body::-webkit-scrollbar-corner,
.settings-page-shell *::-webkit-scrollbar-corner {
  background: transparent;
}

body > .bg-overlay,
body > .bg-image,
body > .bg-video {
  position: fixed;
  inset: 0;
}
.settings-page .bg-overlay.bg-overlay-active {
  z-index: 0;
  opacity: 1;
  pointer-events: none;
}
.settings-page-shell {
  position: relative;
  z-index: 2;
  width: min(1240px, 100%);
  min-height: calc(100dvh - 32px);
  margin: 0 auto;
  box-sizing: border-box;
  padding: 42px 46px 34px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: min(var(--radius), 18px);
  box-shadow: var(--shadow-lg);
}
.settings-page-header {
  margin-bottom: 42px;
}
.settings-back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 18px;
  color: var(--dim);
  text-decoration: none;
  font-size: 0.88rem;
}
.settings-back-link:hover {
  color: var(--text);
}
.settings-page-header h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(2rem, 4vw, 2.8rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
}
.settings-page-header p {
  margin: 9px 0 0;
  color: var(--dim);
  font-size: 0.95rem;
}
.settings-workspace {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 54px;
  align-items: start;
}
.settings-section-nav {
  position: sticky;
  top: 30px;
  align-self: start;
  display: grid;
  gap: 3px;
}
.settings-section-nav a,
.settings-section-nav .settings-search-nav {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: min(var(--radius), 8px);
  color: var(--dim);
  text-decoration: none;
  font-size: 0.84rem;
  font-family: inherit;
  text-align: left;
  background: transparent;
  cursor: pointer;
  transition:
    color 0.16s ease,
    background-color 0.16s ease,
    border-color 0.16s ease;
}
.settings-section-nav .settings-search-nav {
  width: 100%;
  gap: 8px;
}
.settings-section-nav a:hover,
.settings-section-nav a:focus-visible,
.settings-section-nav a.active,
.settings-section-nav .settings-search-nav:hover,
.settings-section-nav .settings-search-nav:focus-visible {
  color: var(--text);
  border-left-color: var(--accent);
  background: var(--interactive-bg-alpha);
  outline: none;
}
.settings-content {
  min-width: 0;
}
.settings-section {
  min-width: 0;
  scroll-margin-top: 28px;
  padding-bottom: 54px;
  margin-bottom: 54px;
  border-bottom: 1px solid var(--border);
}
.settings-section:last-child {
  margin-bottom: 0;
}
.settings-section-heading {
  margin-bottom: 34px;
}
.settings-section-heading h2 {
  margin: 0;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.65rem, 2.8vw, 2.1rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.settings-section-heading p {
  max-width: 700px;
  margin: 10px 0 0;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.55;
  letter-spacing: -0.005em;
}
.custom-background-control {
  width: 100%;
  max-width: 760px;
  display: grid;
  grid-template-columns: minmax(0, 280px) minmax(0, 1fr);
  align-items: start;
  gap: 24px;
}

.custom-background-control .bg-preview-card {
  grid-column: 1;
  grid-row: 1;
}

.custom-background-details {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  width: 100%;
  display: grid;
  gap: 12px;
  align-content: start;
}

.custom-background-control .bg-file-name {
  width: 100%;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-background-url-row {
  width: 100%;
  min-width: 0;
}

.custom-background-url-row .bg-url-input {
  display: block;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.custom-background-control .bg-radio-row {
  width: max-content;
  height: auto;
  margin: 0 !important;
  justify-content: flex-start !important;
  padding-top: 2px;
}

.custom-background-details .custom-background-url-row {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.bg-preview-card {
  width: min(280px, calc(150px * var(--bg-preview-ratio, 1.7778)));
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: min(var(--radius), 14px);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.bg-preview-media {
  display: block;
  width: 100%;
  aspect-ratio: var(--bg-preview-ratio, 1.7778);
  max-height: 150px;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}

.bg-preview-image,
.bg-preview-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@media (max-width: 900px) {
  .custom-background-control {
    width: 100%;
    max-width: 100%;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .custom-background-control .bg-preview-card,
  .custom-background-details {
    grid-column: 1;
  }

  .custom-background-control .bg-preview-card {
    grid-row: 1;
  }

  .custom-background-details {
    grid-row: 2;
  }
}

.bg-preview-card {
  cursor: pointer;
}

.bg-preview-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.custom-background-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.custom-background-preview-modal.hidden {
  display: none;
}

.custom-background-preview-modal.is-video-preview {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.custom-background-full-media {
  display: block;
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 32px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: min(var(--radius), 14px);
}

.custom-background-preview-close {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  z-index: 1;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.custom-background-preview-close:hover {
  color: var(--accent);
}

.custom-background-preview-close .icon-mask {
  width: 22px;
  height: 22px;
}

.bg-preview-image,
.bg-preview-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bg-preview-meta {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}

.bg-preview-type {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.bg-preview-name {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-subsection {
  margin-top: 42px;
}
.settings-subsection:first-of-type {
  margin-top: 0;
}
.settings-subsection > h3 {
  margin: 0 0 11px;
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.3;
}
.settings-group {
  min-width: 0;
  border-top: 1px solid var(--border);
}
.setting-row {
  min-width: 0;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child {
  border-bottom: 0;
}
.setting-row-control,
.setting-row-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 380px);
  gap: 38px;
  align-items: center;
}
.setting-row-stack {
  display: grid;
  gap: 13px;
}
.setting-copy {
  min-width: 0;
}
.setting-header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
}
.setting-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 0.96rem;
  font-weight: 650;
  line-height: 1.3;
}
.settings-page-shell .help-text {
  display: grid;
  gap: 8px;
  max-width: 680px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: min(var(--radius), 10px);
  background: transparent;
  color: var(--dim);
  font-size: 0.8rem;
  line-height: 1.5;
}

.settings-page-shell .help-text .icon-help {
  display: block;
  width: 14px;
  height: 14px;
  color: var(--dim);
  opacity: 0.9;
}
.settings-page-shell .help-text.show {
  animation: none;
}
.settings-page-shell .help-btn {
  display: none;
}

.settings-page-shell .setting-option-help {
  color: var(--dim);
  font-size: 0.76rem;
  line-height: 1.5;
}
.settings-page-shell input[type="text"],
.settings-page-shell input[type="url"],
.settings-page-shell input[type="number"],
.settings-page-shell .select-trigger {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  min-height: 40px;
  margin: 0;
  padding: 9px 12px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: min(var(--radius), 14px);
  font: inherit;
  font-size: 0.86rem;
  box-shadow: var(--shadow-sm);
  outline: none;
  transition:
    border-color 0.16s ease,
    background-color 0.16s ease,
    box-shadow 0.16s ease;
}
.settings-page-shell input[type="text"]::placeholder,
.settings-page-shell input[type="url"]::placeholder {
  color: var(--dim);
  opacity: 0.9;
}
.settings-page-shell input[type="text"]:hover,
.settings-page-shell input[type="url"]:hover,
.settings-page-shell input[type="number"]:hover,
.settings-page-shell .select-trigger:hover {
  border-color: var(--accent);
}
.settings-page-shell input[type="text"]:focus,
.settings-page-shell input[type="url"]:focus,
.settings-page-shell input[type="number"]:focus,
.settings-page-shell .select-trigger:focus-visible {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px var(--interactive-bg-alpha),
    var(--shadow-sm);
}
.setting-row > input[type="text"],
.setting-row > input[type="url"] {
  width: 100%;
}
.settings-page-shell .custom-select {
  width: 100%;
  min-width: 0;
}
.settings-page-shell .select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.settings-page-shell .select-dropdown {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: min(var(--radius), 14px);
  box-shadow: var(--shadow-lg);
}
.settings-page-shell .select-option {
  border-radius: min(var(--radius), 9px);
}
.settings-page-shell .select-option:hover,
.settings-page-shell .select-option.selected,
.settings-page-shell .select-option[aria-selected="true"] {
  background: var(--card-hover);
  color: var(--accent);
}
#themeSelect .select-option {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 38px;
}
#themeSelect .select-option::before {
  content: "";
  width: 30px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--theme-preview, var(--card-hover));
}
#themeSelect .select-option[data-value="dark"] {
  --theme-preview: linear-gradient(135deg, #050505, #18181c, #00aaff);
}
#themeSelect .select-option[data-value="amoled"] {
  --theme-preview: linear-gradient(135deg, #000, #090909, #fff);
}
#themeSelect .select-option[data-value="light"] {
  --theme-preview: linear-gradient(135deg, #f2f2f7, #fff, #007aff);
}
#themeSelect .select-option[data-value="material-you"] {
  --theme-preview: linear-gradient(
    135deg,
    #ff6b6b 0 25%,
    #ffd166 25% 50%,
    #06d6a0 50% 75%,
    #118ab2 75%
  );
}
#themeSelect .select-option[data-value="cyberpunk"] {
  --theme-preview: linear-gradient(135deg, #050505, #00ff41 48%, #f0e600);
}
#themeSelect .select-option[data-value="sunset"] {
  --theme-preview: linear-gradient(135deg, #2d1b2e, #ef476f, #ffd166);
}
#themeSelect .select-option[data-value="forest"] {
  --theme-preview: linear-gradient(135deg, #1a2f1a, #2d4c2d, #c3e6c3);
}
#themeSelect .select-option[data-value="paper"] {
  --theme-preview: linear-gradient(135deg, #f9f7f2, #fff, #222);
}
#themeSelect .select-option[data-value="luminous"] {
  --theme-preview: linear-gradient(135deg, #0f172a, #1e293b, #38bdf8);
}
#themeSelect .select-option[data-value="nord"] {
  --theme-preview: linear-gradient(135deg, #2e3440, #3b4252, #88c0d0);
}
#themeSelect .select-option[data-value="dracula"] {
  --theme-preview: linear-gradient(135deg, #282a36, #44475a, #bd93f9);
}
#themeSelect .select-option[data-value="retro"] {
  --theme-preview: linear-gradient(135deg, #0d0202, #1a0505, #ffb000);
}
#themeSelect .select-option[data-value="rose"] {
  --theme-preview: linear-gradient(135deg, #191724, #1f1d2e, #ebbcba);
}
#themeSelect .select-option[data-value="night-glow"] {
  --theme-preview: linear-gradient(135deg, #000, #0a0a0a, #fff);
}
#themeSelect .select-option[data-value="heatwave"] {
  --theme-preview: linear-gradient(135deg, #1f0a00, #2d0f02, #ff4500);
}
#themeSelect .select-option[data-value="slate"] {
  --theme-preview: linear-gradient(135deg, #1a1a1a, #252525, #ffd700);
}
#themeSelect .select-option[data-value="toxic-tide"] {
  --theme-preview: linear-gradient(135deg, #041614, #09201d, #2fbfa2);
}
#themeSelect .select-option[data-value="evergreen-archive"] {
  --theme-preview: linear-gradient(135deg, #1a2416, #253321, #d9c588);
}
.settings-page-shell .radio-option {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: fit-content;
  min-height: 34px;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--text);
  font-size: 0.84rem;
  box-shadow: none;
}
.settings-page-shell .radio-option:hover {
  background: transparent;
  border-color: transparent;
}
.setting-row .radio-option {
  justify-self: end;
}
.settings-page-shell input[type="checkbox"]:not(.manager-checkbox) {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 42px;
  height: 24px;
  flex: 0 0 42px;
  margin: 0;
  padding: 0;
  background: var(--card-hover);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition:
    background-color 0.16s ease,
    border-color 0.16s ease;
}
.settings-page-shell input[type="checkbox"]:not(.manager-checkbox)::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--dim);
  transition:
    transform 0.16s ease,
    background-color 0.16s ease;
}
.settings-page-shell input[type="checkbox"]:not(.manager-checkbox):checked {
  background: var(--accent);
  border-color: var(--accent);
}
.settings-page-shell
  input[type="checkbox"]:not(.manager-checkbox):checked::after {
  transform: translateX(18px);
  background: var(--bg);
}
.setting-row-stack > .radio-option,
.settings-subgroup > .radio-option {
  justify-self: start;
}
.setting-slider-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 68px;
  gap: 12px;
  align-items: center;
}
.settings-page-shell input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
.settings-page-shell .radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.settings-page-shell .radio-row .radio-option {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: min(var(--radius), 10px);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}
.settings-page-shell .radio-row .radio-option:hover {
  border-color: var(--accent);
  background: var(--card-hover);
}
.settings-subgroup {
  display: grid;
  gap: 11px;
  margin-top: 4px;
  padding: 12px 0 4px 18px;
  border-left: 2px solid var(--border);
}

.settings-subgroup .setting-option {
  min-width: 0;
}

.settings-subgroup .setting-option-title,
.settings-subgroup .settings-picker-label-block {
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.35;
}

.settings-subgroup .setting-option-help {
  margin-top: 3px;
  padding-left: 0;
  color: var(--dim);
  font-size: 0.76rem;
  line-height: 1.5;
}
.settings-row-actions,
.action-btn-row,
.editor-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.data-danger-actions {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.data-danger-heading {
  margin: 2px 0 -2px;
  color: var(--dim);
  font-size: 0.78rem;
  font-weight: 700;
}
.engine-management {
  display: grid;
  gap: 12px;
}

.engine-management .link-editor-box {
  margin-top: 2px;
}

.settings-page-shell button:not(.help-btn) {
  min-height: 38px;
  padding: 8px 14px;
  border-radius: min(var(--radius), 10px);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition:
    background-color 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease,
    transform 0.16s ease;
}
.settings-page-shell button:not(.help-btn):hover {
  background: var(--card-hover);
  border-color: var(--accent);
}
.settings-page-shell button:not(.help-btn):active {
  transform: translateY(1px);
}
.settings-page-shell .save-btn {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.settings-page-shell .save-btn:hover {
  background: var(--accent);
  color: var(--bg);
  filter: brightness(1.06);
}
.settings-page-shell .secondary {
  background: var(--card);
  color: var(--text);
}
.settings-page-shell .add-link-btn {
  width: auto;
  color: var(--accent);
  border-style: dashed;
  background: transparent;
}
.bg-control-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.custom-file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#clockStyleSelect.clock-style-picker {
  width: 100%;
  overflow: hidden;
}
#clockStyleSelect.clock-style-picker .select-trigger {
  display: none;
}
#clockStyleSelect.clock-style-picker .select-dropdown,
#clockStyleSelect.clock-style-picker .select-dropdown.hidden {
  position: static;
  display: flex;
  flex-direction: row;
  gap: 8px;
  width: 100%;
  max-height: none;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 3px 2px 10px;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
#clockStyleSelect.clock-style-picker .select-option {
  position: relative;
  flex: 0 0 132px;
  height: 76px;
  padding: 0 8px 9px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: var(--card);
  color: var(--dim);
  border: 1px solid var(--border);
  border-radius: min(var(--radius), 11px);
  font-size: 0.7rem;
  box-sizing: border-box;
  box-shadow: var(--shadow-sm);
}
#clockStyleSelect.clock-style-picker .settings-clock-preview {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  margin: 0;
  color: var(--text);
  font-size: 1.15rem;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
}
#clockStyleSelect.clock-style-picker .select-option:hover,
#clockStyleSelect.clock-style-picker .select-option[aria-checked="true"],
#clockStyleSelect.clock-style-picker .select-option.selected {
  border-color: var(--accent);
  background: var(--card-hover);
  color: var(--accent);
}
#clockStyleSelect.clock-style-picker .select-option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
#clockStyleSelect.clock-style-picker
  .select-option[data-value="default"]
  .settings-clock-preview {
  font-weight: 300;
}
#clockStyleSelect.clock-style-picker
  .select-option[data-value="bold"]
  .settings-clock-preview {
  font-weight: 900;
  letter-spacing: -1px;
}
#clockStyleSelect.clock-style-picker
  .select-option[data-value="mono"]
  .settings-clock-preview {
  font-family: "Courier New", monospace;
  letter-spacing: 1px;
}
#clockStyleSelect.clock-style-picker
  .select-option[data-value="lcd"]
  .settings-clock-preview {
  font-family: "Courier New", monospace;
  color: var(--accent);
  text-shadow: 0 0 4px var(--accent);
}
#clockStyleSelect.clock-style-picker
  .select-option[data-value="neon"]
  .settings-clock-preview {
  color: var(--text);
  text-shadow:
    0 0 4px var(--text),
    0 0 10px var(--accent),
    0 0 18px var(--accent);
}
#clockStyleSelect.clock-style-picker
  .select-option[data-value="minimal"]
  .settings-clock-preview {
  font-weight: 100;
  opacity: 0.7;
}
#clockStyleSelect.clock-style-picker
  .select-option[data-value="block"]
  .settings-clock-preview {
  width: auto;
  padding: 4px 8px;
  background: var(--card-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
}
#clockStyleSelect.clock-style-picker
  .select-option[data-value="outline"]
  .settings-clock-preview {
  color: transparent;
  -webkit-text-stroke: 1px var(--accent);
  font-weight: 700;
}
#clockStyleSelect.clock-style-picker
  .select-option[data-value="gradient"]
  .settings-clock-preview {
  background: linear-gradient(135deg, var(--accent), var(--text));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 800;
}
#clockStyleSelect.clock-style-picker
  .select-option[data-value="glitch"]
  .settings-clock-preview {
  font-family: "Courier New", monospace;
  font-weight: 800;
  text-shadow:
    1px 1px 0 var(--dim),
    -1px -1px 0 var(--accent);
}
#clockStyleSelect.clock-style-picker
  .select-option[data-value="glass"]
  .settings-clock-preview {
  background: linear-gradient(180deg, var(--text), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 0.5px var(--accent);
  font-weight: 700;
}
#clockStyleSelect.clock-style-picker
  .select-option[data-value="threed"]
  .settings-clock-preview {
  color: var(--accent);
  font-weight: 900;
  text-shadow:
    1px 1px 0 var(--dim),
    2px 2px 0 var(--dim),
    3px 3px 0 var(--dim);
}
.engine-management,
#linkListContainer {
  display: grid;
  gap: 10px;
}
.engine-selection-list,
.link-manager-list {
  max-height: 360px;
  overflow-y: auto;
  overscroll-behavior-y: auto;
  scrollbar-width: thin;
}

.engine-selection-list {
  scrollbar-gutter: stable;
}
.settings-page-shell .engine-item,
.settings-page-shell .link-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: min(var(--radius), 11px);
  box-shadow: var(--shadow-sm);
}
.settings-page-shell .engine-item:hover,
.settings-page-shell .link-item:hover {
  border-color: var(--accent);
  background: var(--card-hover);
}
.link-editor-box {
  margin-top: 2px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: min(var(--radius), 12px);
  box-shadow: var(--shadow-md);
}
.settings-page-footer {
  display: grid;
  gap: 12px;
  margin-top: 52px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  color: var(--dim);
  font-size: 0.75rem;
}
.settings-page-footer .footer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
}
.settings-page-footer .footer-row-primary {
  color: var(--text);
}
.settings-page-footer a {
  color: inherit;
  text-decoration: none;
}
.settings-page-footer a:hover {
  color: var(--text);
}
.settings-page-footer .footer-brand {
  font-weight: 700;
}
@media (max-width: 900px) {
  html.settings-page,
  html.settings-page body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }
  body {
    padding: 0;
  }
  .settings-page-shell {
    width: 100%;
    min-height: 100dvh;
    padding: 30px 24px 42px;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  .settings-workspace {
    display: block;
  }
  .settings-section-nav {
    position: sticky;
    top: 0;
    align-self: stretch;
    z-index: 30;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    margin: 0 -8px 38px;
    padding: 8px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
  }
  .settings-section-nav::-webkit-scrollbar {
    display: none;
  }
  .settings-section-nav a {
    flex: 0 0 auto;
    min-height: 34px;
    border: 1px solid var(--border);
    border-radius: min(var(--radius), 9px);
    padding: 0 12px;
  }
  .settings-section-nav a:hover,
  .settings-section-nav a:focus-visible,
  .settings-section-nav a.active,
  .settings-section-nav .settings-search-nav:hover,
  .settings-section-nav .settings-search-nav:focus-visible {
    border-color: var(--accent);
  }
  .setting-row-control,
  .setting-row-input {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }

  .setting-row .radio-option {
    justify-self: start;
  }

  .mobile-only-setting .radio-option {
    width: 100%;
    min-width: 0;
    justify-content: space-between;
    justify-self: stretch !important;
    box-sizing: border-box;
    white-space: normal;
  }

  #standardActionBtns {
    justify-content: flex-end;
  }

  #linkManagerContent .link-manager-item {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 6px;
  }

  #linkManagerContent .link-manager-item > .link-actions {
    display: contents;
  }

  #linkManagerContent .link-manager-item > .link-name {
    grid-column: 3;
    min-width: 0;
    overflow: hidden;
  }

  #linkManagerContent .link-manager-item > .link-actions .icon-btn.secondary {
    grid-column: 1;
    grid-row: 1;
    width: 34px;
    min-width: 34px;
    min-height: 34px;
    padding: 7px;
  }

  #linkManagerContent .link-manager-item > .link-actions .delete-btn {
    grid-column: 2;
    grid-row: 1;
    width: 34px;
    min-width: 34px;
    min-height: 34px;
    padding: 7px;
  }

  #linkManagerContent .link-manager-item > .link-actions .drag-handle {
    grid-column: 5;
    grid-row: 1;
    justify-self: end;
    margin-left: 0;
    padding-inline: 6px;
  }

  #linkManagerContent
    .link-manager-item
    > .link-actions
    > button:not(.delete-btn):not(.secondary),
  #linkManagerContent .link-manager-item > .link-actions > .move-out-btn {
    grid-column: 4;
    grid-row: 1;
    justify-self: end;
    width: 34px;
    min-width: 34px;
    min-height: 34px;
    padding: 7px;
  }

  #data .action-btn-row {
    justify-content: flex-end;
  }

  #data .restore-point-action {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
  }

  #data .restore-point-status {
    width: 100%;
    text-align: right;
  }

  .settings-page-footer {
    margin-top: 42px;
    padding-bottom: calc(176px + env(safe-area-inset-bottom));
  }

  .settings-page-footer .footer-row {
    align-items: flex-start;
  }

  .settings-page-footer .footer-row-secondary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 18px;
  }

  .settings-page-footer .footer-copy,
  .settings-page-footer .footer-link,
  .settings-page-footer .footer-credit {
    min-width: 0;
  }

  .settings-page-footer .footer-credit {
    grid-column: 1 / -1;
  }
}
@media (max-width: 520px) {
  .settings-page-shell {
    padding: 24px 16px 36px;
  }
  .settings-page-header {
    margin-bottom: 32px;
  }
  .settings-section {
    padding-bottom: 42px;
    margin-bottom: 42px;
  }
  .settings-section-heading {
    margin-bottom: 26px;
  }
  .settings-subsection {
    margin-top: 34px;
  }
  .setting-row {
    padding: 16px 0;
  }

  .setting-slider-row {
    grid-template-columns: minmax(0, 1fr) 58px;
    gap: 10px;
  }

  .settings-page-shell input[type="range"] {
    min-width: 0;
    min-height: 32px;
  }

  .settings-page-shell input[type="number"].slider-number-input {
    min-height: 38px;
    padding-inline: 8px;
  }

  #clockStyleSelect.clock-style-picker .select-option {
    flex-basis: 116px;
    height: 72px;
  }
}

/* Pass 4: concise, setting-specific helper copy and consistent control hierarchy. */
.settings-page-shell .setting-option {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.settings-page-shell .setting-option-help {
  order: 99;
  margin: 0;
  padding-left: 54px;
  color: var(--dim);
  font-size: 0.72rem;
  line-height: 1.45;
}

.settings-page-shell .setting-control-label {
  margin: 0 0 3px;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
}

.settings-page-shell .settings-subgroup .setting-option {
  gap: 8px;
}

.settings-page-shell .settings-subgroup .setting-option-help {
  padding-left: 54px;
  max-width: 620px;
}

.settings-page-shell .settings-inline-control.setting-option {
  width: 100%;
}

.settings-page-shell .settings-inline-control.setting-option .radio-option {
  width: max-content;
  max-width: 100%;
}

@media (max-width: 900px) {
  .settings-page-shell .setting-option-help,
  .settings-page-shell .settings-subgroup .setting-option-help {
    padding-left: 0;
  }

  .settings-page-shell .settings-inline-control.setting-option {
    width: 100%;
  }

  .settings-page-shell .settings-inline-control.setting-option .radio-option {
    width: 100%;
    max-width: none;
  }
}

/* Pass 5: keep all Settings helper copy inside the same contextual help card. */
.settings-page-shell .setting-option-help {
  display: grid;
  gap: 8px;
  width: 100%;
  max-width: 680px;
  box-sizing: border-box;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: min(var(--radius), 10px);
  background: transparent;
  color: var(--dim);
  font-size: 0.8rem;
  line-height: 1.5;
}

.settings-page-shell .setting-option-help .icon-help {
  display: block;
  width: 14px;
  height: 14px;
  color: var(--dim);
  opacity: 0.9;
}

.settings-page-shell .settings-subgroup .setting-option-help {
  max-width: 680px;
}

@media (max-width: 900px) {
  .settings-page-shell .setting-option-help,
  .settings-page-shell .settings-subgroup .setting-option-help {
    padding: 12px;
  }
}

.quick-link-manager-launch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--card) 72%, transparent);
}
.quick-link-manager-description {
  margin: 0;
  color: var(--dim);
  font-size: var(--font-size-sm);
}
.quick-link-manager-launch .add-link-btn {
  flex: 0 0 auto;
  text-decoration: none;
}
@media (max-width: 700px) {
  .quick-link-manager-launch {
    align-items: stretch;
    flex-direction: column;
  }
}
