/* Settings use the active palette. Each theme thumbnail uses its own palette. */
:is(#preferences-view, #profile-settings-menu) {
  --settings-edge: var(--theme-border, #59496e);
  --settings-surface: var(--theme-surface, #21192f);
  --settings-panel: var(--theme-panel, #121022);
  --settings-ink: var(--theme-text, #f8f3ff);
  --settings-muted: var(--theme-muted, #bdb1cf);
  --settings-selection: var(--personal-soft);
  --settings-radius: 20px;
}

#preferences-view {
  color: var(--settings-ink);
  padding: clamp(18px, 2.5vw, 34px);
}

#preferences-view > :is(.preferences-heading, .preferences-layout, .android-download) {
  width: min(100%, 1260px);
  margin-inline: auto;
}

#preferences-view .preferences-heading {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 13px;
}

#preferences-back-profile {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  min-height: 42px;
}

#preferences-back-profile svg { width: 18px; height: 18px; }

#preferences-view .preferences-heading h2 {
  font-size: clamp(27px, 3vw, 36px);
  letter-spacing: -0.035em;
  line-height: 1.15;
}

#preferences-view .preferences-layout {
  grid-template-columns: 198px minmax(0, 1fr);
  align-items: start;
  gap: clamp(18px, 2.6vw, 34px);
  margin-top: 22px;
}

#preferences-view .preferences-categories,
#preferences-view .settings-block,
#preferences-view .preferences-group:not(#preferences-appearance) {
  min-width: 0;
  border: 1px solid var(--settings-edge);
  border-radius: var(--settings-radius);
  background: var(--settings-surface);
}

#preferences-view .preferences-categories {
  gap: 4px;
  padding: 9px;
}

#preferences-view .preferences-category {
  min-height: 43px;
  padding: 10px 12px;
  border-radius: 11px;
  font-size: 14px;
}

#preferences-view .preferences-category[aria-pressed="true"] {
  border-color: transparent;
  background: var(--settings-selection);
  color: var(--settings-ink);
}

#preferences-view .preferences-session {
  margin-top: 6px;
  padding: 9px 0 0;
  border-color: var(--settings-edge);
}

#preferences-view .preferences-session .welcome-logout {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border-color: transparent;
  border-radius: 11px;
  background: transparent;
  text-align: left;
}

#preferences-view .preferences-session .welcome-logout:hover {
  background: #ca587a18;
}

#preferences-view .preferences-form,
#preferences-view .preferences-group {
  gap: 16px;
  min-height: 0;
}

#preferences-view .preferences-group:not(#preferences-appearance) {
  padding: clamp(16px, 2.2vw, 26px);
}

#preferences-view .preferences-group h3 {
  font-size: 22px;
  letter-spacing: -0.02em;
}

#preferences-view .settings-block {
  margin: 0;
  padding: clamp(13px, 1.6vw, 20px);
}

#preferences-view .settings-block h4 {
  margin: 0;
  font-size: 15px;
  line-height: 1.4;
  font-weight: 650;
}

.appearance-workspace {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr);
  align-items: start;
  gap: 14px;
}

.appearance-side {
  display: grid;
  min-width: 0;
  gap: 14px;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.theme-option {
  position: relative;
  display: grid;
  min-width: 0;
}

.theme-option-card {
  position: relative;
  display: grid;
  align-content: start;
  gap: 5px;
  min-width: 0;
  min-height: 70px;
  padding: 5px;
  border: 1px solid var(--settings-edge);
  border-radius: 12px;
  background: var(--settings-panel);
  color: var(--settings-ink);
  cursor: pointer;
}

.theme-option:hover .theme-option-card,
.theme-option input:checked + .theme-option-card {
  border-color: var(--personal-accent);
}

.theme-option input:checked + .theme-option-card {
  background: var(--settings-selection);
  box-shadow: inset 0 0 0 1px var(--personal-accent);
}

.theme-option input:focus-visible + .theme-option-card {
  outline: 2px solid var(--personal-accent);
  outline-offset: 3px;
}

.theme-picker:disabled .theme-option-card {
  opacity: .65;
  cursor: wait;
}

.theme-option-name {
  min-width: 0;
  padding: 0 3px 1px;
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
}

.theme-swatch {
  position: relative;
  display: block;
  min-height: 41px;
  overflow: hidden;
  border: 1px solid var(--theme-border);
  border-radius: 7px;
  background: linear-gradient(90deg, var(--theme-panel) 28%, var(--theme-canvas) 28%);
}

.theme-swatch::before,
.theme-swatch::after,
.theme-swatch > span {
  position: absolute;
  display: block;
  border-radius: 4px;
  content: "";
}

.theme-swatch::before {
  inset: 0 0 auto;
  height: 7px;
  background: var(--theme-panel);
  border-bottom: 1px solid var(--theme-border);
  border-radius: 0;
}

.theme-swatch > span {
  top: 14px;
  left: 35%;
  width: 35%;
  height: 7px;
  border: 1px solid var(--theme-border);
  background: var(--theme-surface);
}

.theme-swatch::after {
  right: 8%;
  bottom: 6px;
  width: 40%;
  height: 7px;
  border: 1px solid var(--theme-border);
  background: var(--theme-tint);
}

.theme-option input:checked + .theme-option-card::after {
  position: absolute;
  top: 9px;
  right: 9px;
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--theme-action);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  content: "✓" / "";
}

.theme-preview-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 8px;
  margin-bottom: 12px;
}

#theme-preview-name {
  color: var(--settings-muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.theme-example {
  overflow: hidden;
  border: 1px solid var(--theme-border);
  border-radius: 14px;
  background: var(--theme-canvas);
  color: var(--theme-text);
  font-size: 12px;
}

.theme-example-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--theme-border);
  background: var(--theme-panel);
}

.theme-example-avatar {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border-radius: 50%;
  background: var(--theme-tint);
  color: var(--theme-accent);
  font-weight: 700;
}

.theme-example-messages {
  display: grid;
  align-content: center;
  gap: 10px;
  min-height: 110px;
  padding: 12px 10px;
}

.theme-example-messages p {
  justify-self: start;
  max-width: 90%;
  margin: 0;
  padding: 7px 9px;
  border: 1px solid var(--theme-border);
  border-radius: 11px 11px 11px 3px;
  background: var(--theme-surface);
  line-height: 1.4;
}

.theme-example-messages p:last-child {
  justify-self: end;
  border-radius: 11px 11px 3px 11px;
  background: var(--theme-tint);
}

.theme-example-composer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 42px;
  padding: 6px 9px;
  border-top: 1px solid var(--theme-border);
  background: var(--theme-panel);
  color: var(--theme-muted);
}

.theme-example-send {
  display: grid;
  place-items: center;
  flex: 0 0 24px;
  height: 24px;
  border-radius: 8px;
  background: var(--theme-action);
  color: #fff;
  font-size: 16px;
}

#preferences-view .preferences-row {
  min-height: 52px;
  padding: 9px 0;
  border-color: var(--settings-edge);
}

#preferences-view .preferences-group > .preferences-row:last-child,
#preferences-view .settings-options > .preferences-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

#preferences-view .preferences-row select {
  flex-shrink: 0;
  min-width: 116px;
  max-width: 52%;
  min-height: 39px;
  border-color: var(--settings-edge);
  background: var(--settings-panel);
  color: var(--settings-ink);
}

#preferences-view .preferences-description {
  color: var(--settings-muted);
}

.profile-settings-content .preferences-form,
.profile-settings-content .preferences-group { gap: 12px; }
.profile-settings-content .preferences-group > h3,
.profile-settings-content .devices-heading h3 { display: none; }
.profile-settings-content .devices-heading { justify-content: flex-end; }
.profile-settings-content .preferences-description { margin: 4px 0 0; color: var(--settings-muted); overflow-wrap: anywhere; }
.profile-settings-content .preferences-row {
  gap: 9px;
  padding: 11px;
  border: 1px solid var(--settings-edge);
  border-radius: 12px;
  background: var(--settings-panel);
  overflow-wrap: anywhere;
}
.profile-settings-content .preferences-row > div { min-width: 0; }
.profile-settings-content .preferences-row :is(select, button, input[type="checkbox"]) { flex-shrink: 0; }
.profile-settings-content #preferences-account .preferences-row { flex-wrap: wrap; }
.profile-settings-content .settings-block {
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--settings-edge);
  border-radius: 12px;
  background: var(--settings-panel);
}
.profile-settings-content .settings-block h4 { margin: 0 0 8px; font-size: 14px; }
.profile-settings-content .appearance-workspace { grid-template-columns: minmax(0, 1fr); gap: 12px; }
.profile-settings-content .appearance-side { gap: 12px; }
.profile-settings-content .settings-options { order: -1; }
.profile-settings-content .settings-options .preferences-row { padding: 8px 0; border: 0; border-radius: 0; }
.profile-settings-content .theme-grid { grid-template-columns: minmax(0, 1fr); }
.profile-settings-content .theme-option-card {
  grid-template-columns: 76px minmax(0, 1fr);
  align-content: center;
  align-items: center;
  gap: 9px;
  min-height: 53px;
  padding: 5px 27px 5px 6px;
}
.profile-settings-content .theme-option-name { font-size: 13px; }
.profile-settings-content #profile-decorations { grid-template-columns: minmax(0, 1fr); }
.profile-settings-content #profile-decorations li {
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  justify-items: start;
  gap: 7px;
  border: 1px solid var(--settings-edge);
  text-align: left;
}
.profile-settings-content #profile-decorations img { width: 48px; height: 48px; }
.profile-settings-content #profile-decoration-status { color: var(--settings-muted); }
.profile-settings-content .preferences-session { border-color: var(--settings-edge); }
.profile-settings-content .service-links { flex-wrap: wrap; }

@media (max-width: 1100px) {
}

@media (max-width: 900px) {
  .appearance-workspace { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  #preferences-view { padding: 14px; }
  #preferences-view .preferences-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    margin-top: 14px;
  }
  #preferences-view .preferences-categories { gap: 3px; }
  #preferences-view .preferences-category { min-height: 39px; font-size: 13px; }
  #preferences-view .preferences-session .welcome-logout { min-height: 36px; }
  #preferences-view .preferences-group h3 { font-size: 20px; }
}

@media (max-width: 390px) {
  .theme-grid { gap: 6px; }
  .theme-option-name { padding-inline: 1px; font-size: 11px; }
  #preferences-view .preferences-row { gap: 9px; }
  #preferences-view .preferences-row select { min-width: 100px; }
}
.devices-list { display: grid; gap: 7px; }
.devices-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.devices-heading a { font-size: 11px; }
.device-row { flex-wrap: wrap; gap: 8px 14px; }
.device-row > div { min-width: 0; overflow-wrap: anywhere; }
.device-current { color: var(--theme-accent, #c291f6); font-size: 13px; font-weight: 650; }
.device-lock { margin: 0; }
#devices-status:empty { display: none; }
#preferences-devices a { color: var(--theme-accent, #c291f6); }
