/*! Preferences panel theme
 * Independent of Mac Platinum / Win9x dialog chrome.
 * Dense, sectional layout scoped to #tab-prefs.
 * Colors match the greater Palacespace UI (palacespace.css neutrals / accents).
 */

#tab-prefs.prefs-ui {
  --prefs-bg: #2c2c2c;
  --prefs-section: #252525;
  --prefs-section-edge: #444;
  --prefs-text: #eee;
  --prefs-muted: #888;
  --prefs-accent: #6cb2ff;
  --prefs-accent-fill: #345;
  --prefs-accent-edge: #567;
  --prefs-control: #222;
  --prefs-control-edge: #555;
  --prefs-hover: #384450;
  --prefs-divider: #333;
  --prefs-font: -apple-system, Segoe UI, Helvetica, Arial, sans-serif;
  padding: 6px 8px;
  background: var(--prefs-bg);
  color: var(--prefs-text);
  font-family: var(--prefs-font);
}

#tab-prefs.prefs-ui,
#tab-prefs.prefs-ui * {
  box-sizing: border-box;
}

#tab-prefs.prefs-ui .prefs-dashboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}

#tab-prefs.prefs-ui .prefs-card {
  min-width: 0;
  padding: 7px 9px 8px;
  border: 1px solid var(--prefs-section-edge);
  border-radius: 4px;
  background: var(--prefs-section);
}

#tab-prefs.prefs-ui .prefs-card-wide {
  grid-column: 1 / -1;
}

#tab-prefs.prefs-ui .prefs-card-header {
  display: flex;
  align-items: baseline;
  margin: 0 0 5px;
  padding: 0 0 4px;
  border-bottom: 1px solid var(--prefs-divider);
}

#tab-prefs.prefs-ui .prefs-card-header h3 {
  margin: 0;
  color: #888;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

#tab-prefs.prefs-ui .prefs-actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

#tab-prefs.prefs-ui .prefs-action-wrap {
  position: relative;
}

#tab-prefs.prefs-ui .prefs-cyborg-action {
  display: flex;
  align-items: center;
  gap: 6px;
}

#tab-prefs.prefs-ui .prefs-cyborg-action .macros-info-balloon {
  z-index: 40;
}

#tab-prefs.prefs-ui .prefs-action-btn,
#tab-prefs.prefs-ui .prefs-key-btn,
#tab-prefs.prefs-ui .name-edit-popover button {
  min-height: 22px;
  padding: 2px 9px;
  border: 1px solid var(--prefs-accent-edge);
  border-radius: 4px;
  background: #2a2a2a;
  color: #dff0ff;
  font: 11px/1.3 var(--prefs-font);
  cursor: pointer;
}

#tab-prefs.prefs-ui .prefs-action-btn:hover,
#tab-prefs.prefs-ui .prefs-key-btn:hover,
#tab-prefs.prefs-ui .name-edit-popover button:hover {
  background: var(--prefs-hover);
  border-color: #789;
  color: #dff0ff;
}

#tab-prefs.prefs-ui .prefs-action-btn:active,
#tab-prefs.prefs-ui .prefs-key-btn:active,
#tab-prefs.prefs-ui .name-edit-popover button:active {
  background: #2a2a2a;
}

#tab-prefs.prefs-ui .prefs-action-btn:focus-visible,
#tab-prefs.prefs-ui .prefs-key-btn:focus-visible,
#tab-prefs.prefs-ui .prefs-select:focus-visible,
#tab-prefs.prefs-ui input:focus-visible + i,
#tab-prefs.prefs-ui .prefs-segmented input:focus-visible + span {
  outline: 2px solid var(--prefs-accent);
  outline-offset: 1px;
}

#tab-prefs.prefs-ui .prefs-switch-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

#tab-prefs.prefs-ui .prefs-switch {
  /* Containing block for the opacity-0 absolute input. Without this, the
     input positions against a detached #roomTabs (position:fixed) and a
     click/focus scrolls that window's scrollTop -- shearing the chrome off. */
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 26px;
  padding: 2px 0;
  color: var(--prefs-text);
  cursor: pointer;
}

#tab-prefs.prefs-ui .prefs-switch + .prefs-switch {
  border-top: 1px solid var(--prefs-divider);
}

#tab-prefs.prefs-ui .prefs-switch > span,
#tab-prefs.prefs-ui .prefs-key-row > span {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  gap: 0;
}

#tab-prefs.prefs-ui .prefs-switch strong,
#tab-prefs.prefs-ui .prefs-key-row strong {
  font-size: 11px;
  line-height: 1.25;
  font-weight: 600;
}

#tab-prefs.prefs-ui .prefs-switch small,
#tab-prefs.prefs-ui .prefs-key-row small {
  color: var(--prefs-muted);
  font-size: 9px;
  line-height: 1.25;
}

#tab-prefs.prefs-ui .prefs-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

#tab-prefs.prefs-ui .prefs-switch i {
  position: relative;
  flex: 0 0 28px;
  width: 28px;
  height: 16px;
  border-radius: 8px;
  background: #1a1a1a;
  border: 1px solid var(--prefs-control-edge);
  transition: background 0.12s ease, border-color 0.12s ease;
}

#tab-prefs.prefs-ui .prefs-switch i::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #999;
  transition: transform 0.12s ease, background 0.12s ease;
}

#tab-prefs.prefs-ui .prefs-switch input:checked + i {
  background: var(--prefs-accent-fill);
  border-color: #6a9;
}

#tab-prefs.prefs-ui .prefs-switch input:checked + i::after {
  transform: translateX(12px);
  background: #dff0ff;
}

#tab-prefs.prefs-ui .prefs-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
  padding-top: 6px;
  margin-top: 4px;
  border-top: 1px solid var(--prefs-divider);
}

#tab-prefs.prefs-ui .prefs-field,
#tab-prefs.prefs-ui .prefs-range {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

#tab-prefs.prefs-ui .prefs-field-label,
#tab-prefs.prefs-ui .prefs-range {
  color: var(--prefs-muted);
  font-size: 10px;
  font-weight: 600;
}

#tab-prefs.prefs-ui .prefs-select,
#tab-prefs.prefs-ui .name-edit-popover input {
  width: 100%;
  height: 22px;
  padding: 2px 22px 2px 6px;
  border: 1px solid var(--prefs-control-edge);
  border-radius: 4px;
  background: var(--prefs-control);
  color: var(--prefs-text);
  font: 11px var(--prefs-font);
}

#tab-prefs.prefs-ui .prefs-segmented {
  display: flex;
  min-width: 0;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--prefs-control-edge);
  border-radius: 4px;
  background: var(--prefs-control);
}

#tab-prefs.prefs-ui .prefs-segmented label {
  position: relative;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

#tab-prefs.prefs-ui .prefs-segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

#tab-prefs.prefs-ui .prefs-segmented span {
  display: block;
  overflow: hidden;
  padding: 3px 5px;
  border-radius: 3px;
  color: #aaa;
  font-size: 10px;
  line-height: 1.25;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#tab-prefs.prefs-ui .prefs-segmented input:checked + span {
  background: var(--prefs-accent-fill);
  border: 1px solid #6a9;
  color: #dff0ff;
  font-weight: 600;
  padding: 2px 4px;
}

#tab-prefs.prefs-ui .prefs-range-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#tab-prefs.prefs-ui .prefs-range output {
  min-width: 34px;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--prefs-control);
  border: 1px solid var(--prefs-control-edge);
  color: #aaa;
  font-size: 9px;
  font-weight: 500;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

#tab-prefs.prefs-ui input[type="range"] {
  width: 100%;
  height: 14px;
  margin: 0;
  background: transparent;
  appearance: none;
}

#tab-prefs.prefs-ui input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: #222;
  border: 1px solid var(--prefs-control-edge);
}

#tab-prefs.prefs-ui input[type="range"]::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
  margin-top: -5px;
  border: 1px solid #6a9;
  border-radius: 50%;
  background: var(--prefs-accent);
  appearance: none;
}

#tab-prefs.prefs-ui input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 2px;
  background: #222;
  border: 1px solid var(--prefs-control-edge);
}

#tab-prefs.prefs-ui input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 1px solid #6a9;
  border-radius: 50%;
  background: var(--prefs-accent);
}

#tab-prefs.prefs-ui .prefs-key-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
  padding-top: 5px;
  margin-top: 4px;
  border-top: 1px solid var(--prefs-divider);
  color: var(--prefs-text);
}

#tab-prefs.prefs-ui .prefs-key-btn {
  min-width: 32px;
  height: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

#tab-prefs.prefs-ui .prefs-card > .prefs-field,
#tab-prefs.prefs-ui .prefs-card > .prefs-range {
  margin-top: 5px;
}

#tab-prefs.prefs-ui .name-edit-popover {
  top: 26px;
  padding: 6px;
  border: 1px solid var(--prefs-section-edge);
  border-radius: 6px;
  background: #2a2a2a;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

#tab-prefs.prefs-ui .name-edit-popover input {
  width: 140px;
  padding-right: 6px;
}

#tab-prefs.prefs-ui .name-edit-popover button {
  background: #345;
  border-color: #567;
  color: #dff0ff;
}

@media (max-width: 520px) {
  #tab-prefs.prefs-ui .prefs-dashboard,
  #tab-prefs.prefs-ui .prefs-field-grid {
    grid-template-columns: 1fr;
  }
}
