/*
 * Mac OS 9 Platinum UI Components
 * Pixel-perfect recreation of the classic Mac OS 9 interface elements.
 */

/* ========================================
   RESET & BASE
   ======================================== */

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-system);
  font-size: var(--font-size-base);
  line-height: 1.2;
  color: var(--menubar-text);
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: unset;
  image-rendering: pixelated;
}

/* ========================================
   DESKTOP
   ======================================== */

.desktop {
  position: fixed;
  top: var(--menubar-height);
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--desktop-bg);
  background-image: var(--desktop-pattern-image);
  background-repeat: repeat;
  background-size: var(--desktop-pattern-image-size);
  z-index: var(--z-desktop);
  overflow: hidden;
}

.desktop-icons {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  z-index: var(--z-desktop-icons);
}

/* ========================================
   MENU BAR
   ======================================== */

.menubar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--menubar-height);
  background-color: var(--menubar-bg);
  background-image: var(--menubar-pattern-image), var(--menubar-image);
  background-repeat: repeat-x;
  background-size: var(--menubar-pattern-image-size, auto 100%), auto 100%;
  border-bottom: 1px solid var(--menubar-border);
  display: flex;
  align-items: stretch;
  z-index: var(--z-menubar);
  user-select: none;
}

.menubar-left {
  display: flex;
  align-items: stretch;
}

.menubar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  padding-right: 8px;
}

.menu-title {
  display: flex;
  align-items: center;
  padding: 0 var(--menubar-padding-h);
  cursor: default;
  height: 100%;
  font-size: var(--font-size-menu);
  background-image: var(--menu-title-normal-image);
  background-repeat: repeat-x;
  background-size: auto 100%;
}

.menu-title:hover,
.menu-title.active {
  background-color: var(--menu-item-hover);
  color: var(--menu-item-hover-text);
}

.menu-title.apple-menu {
  padding: 0 8px;
}

.menu-title.apple-menu img {
  width: 14px;
  height: 14px;
}

.menubar-clock {
  font-size: var(--font-size-menu);
  padding: 0 4px;
}

.menubar-app {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  font-size: var(--font-size-menu);
}

.menubar-app-icon {
  width: 16px;
  height: 16px;
}

/* Menu Dropdown */
.menu-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 180px;
  background-color: var(--menu-bg);
  background-image: var(--menu-pattern-image);
  background-repeat: repeat;
  background-size: var(--menu-pattern-image-size);
  border: 1px solid var(--menu-border);
  box-shadow: var(--menu-shadow-offset) var(--menu-shadow-offset) 0 var(--menu-shadow);
  z-index: var(--z-menu);
  display: none;
}

.menu-dropdown.visible {
  display: block;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: var(--menu-item-padding);
  cursor: default;
  font-size: var(--font-size-menu);
  color: var(--menu-text);
  gap: 8px;
}

.menu-item:hover {
  background-color: var(--menu-item-hover);
  color: var(--menu-item-hover-text);
}

.menu-item.disabled {
  color: var(--menu-text-disabled);
  pointer-events: none;
}

.menu-item.disabled:hover {
  background: transparent;
  color: var(--menu-text-disabled);
}

.menu-item-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.menu-item-shortcut {
  margin-left: auto;
  opacity: 0.7;
}

.menu-item-arrow {
  margin-left: auto;
}

.menu-divider {
  height: 1px;
  background: var(--menu-divider);
  margin: 4px 0;
}

/* ========================================
   WINDOW
   ======================================== */

.window {
  position: absolute;
  background: #dddddd;
  border: 1px solid #000000;
  box-shadow: 
    1px 1px 0 #000000,
    inset 1px 1px 0 #ffffff,
    inset -1px -1px 0 #888888;
  min-width: 200px;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  z-index: var(--z-window-base);
}

.window.active {
  z-index: var(--z-window-active);
}

.window::before {
  content: '';
  position: absolute;
  top: 1px;
  left: 1px;
  right: 1px;
  bottom: 1px;
  border: 1px solid #ffffff;
  border-right-color: #888888;
  border-bottom-color: #888888;
  pointer-events: none;
}

/* Title Bar */
.window-titlebar {
  height: var(--window-title-height);
  display: flex;
  align-items: center;
  padding: 0 4px;
  background: var(--titlebar-inactive-bg);
  border-bottom: 1px solid var(--window-border-inner-dark);
  cursor: default;
  user-select: none;
  flex-shrink: 0;
}

.window.active .window-titlebar {
  background: linear-gradient(
    to bottom,
    #ffffff 0px,
    #cccccc 1px,
    #cccccc 17px,
    #999999 18px
  );
}

/* Title Bar Stripes - Only visible on active windows */
.window-titlebar-stripes {
  flex: 1;
  height: 11px;
  margin: 0 4px;
  display: none;
}

.window.active .window-titlebar-stripes {
  display: block;
  background: repeating-linear-gradient(
    to bottom,
    #ffffff 0px,
    #ffffff 1px,
    #888888 1px,
    #888888 2px
  );
  background-size: 100% 2px;
}

.window-title {
  flex: 0 0 auto;
  font-size: var(--font-size-title);
  font-weight: var(--font-weight-bold);
  color: #777777;
  text-align: center;
  padding: 0 8px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
  background: #cccccc;
  position: relative;
}

.window.active .window-title {
  color: #000000;
  background: linear-gradient(to bottom, #dddddd, #bbbbbb);
}

.window-title-icon {
  width: 16px;
  height: 16px;
}

/* Window Widgets */
.window-widgets-left,
.window-widgets-right {
  display: flex;
  align-items: center;
  gap: var(--widget-spacing);
  flex-shrink: 0;
}

.window-widget {
  width: var(--widget-size);
  height: var(--widget-size);
  border: 1px solid var(--window-border-outer-dark);
  background: var(--window-bg);
  cursor: default;
  position: relative;
}

.window-widget::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid var(--window-border-outer-light);
  border-right-color: var(--window-border-inner-dark);
  border-bottom-color: var(--window-border-inner-dark);
}

.window-widget:active {
  background: var(--window-border-inner-dark);
}

.window-widget:active::before {
  border-color: var(--window-border-inner-dark);
  border-right-color: var(--window-border-outer-light);
  border-bottom-color: var(--window-border-outer-light);
}

/* Close box */
.window-close::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 7px;
  height: 7px;
  border: 1px solid transparent;
}

.window.active .window-close:hover::after {
  border-color: var(--window-border-outer-dark);
}

/* Zoom box (two overlapping squares) */
.window-zoom::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 5px;
  height: 5px;
  border: 1px solid transparent;
}

.window-zoom::before {
  content: '';
  position: absolute !important;
  bottom: 2px !important;
  right: 2px !important;
  top: auto !important;
  left: auto !important;
  width: 5px;
  height: 5px;
  border: 1px solid transparent !important;
}

.window.active .window-zoom:hover::after,
.window.active .window-zoom:hover::before {
  border-color: var(--window-border-outer-dark) !important;
}

/* Collapse box */
.window-collapse::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 7px;
  height: 2px;
  background: transparent;
  border-bottom: 1px solid transparent;
}

.window.active .window-collapse:hover::after {
  border-bottom-color: var(--window-border-outer-dark);
}

/* Window Content */
.window-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--window-content-bg);
  position: relative;
}

/* Finder Header */
.finder-header {
  height: var(--finder-header-height);
  background: var(--window-bg);
  border-bottom: 1px solid var(--window-border-inner-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-small);
  color: var(--menubar-text);
  padding: 0 8px;
  flex-shrink: 0;
}

/* Finder Icon View */
.finder-icon-view {
  flex: 1;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--icon-label-width));
  grid-auto-rows: min-content;
  gap: var(--icon-grid-gap);
  align-content: start;
  overflow: auto;
  background: var(--finder-list-bg);
}

/* Window Grow Box */
.window-growbox {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 15px;
  height: 15px;
  cursor: nwse-resize;
  background: 
    linear-gradient(135deg, 
      transparent 0%, transparent 50%,
      var(--window-border-inner-dark) 50%, var(--window-border-inner-dark) 60%,
      transparent 60%, transparent 70%,
      var(--window-border-inner-dark) 70%, var(--window-border-inner-dark) 80%,
      transparent 80%, transparent 90%,
      var(--window-border-inner-dark) 90%, var(--window-border-inner-dark) 100%
    );
}

/* ========================================
   SCROLLBAR
   ======================================== */

.scrollbar {
  position: absolute;
  background: var(--scrollbar-track);
  border: 1px solid var(--scrollbar-track-border);
}

.scrollbar-vertical {
  top: 0;
  right: 0;
  bottom: 15px;
  width: var(--scrollbar-width);
}

.scrollbar-horizontal {
  bottom: 0;
  left: 0;
  right: 15px;
  height: var(--scrollbar-width);
}

.scrollbar-arrow {
  position: absolute;
  width: 100%;
  height: var(--scrollbar-arrow-height);
  background: var(--scrollbar-arrow-bg);
  border: 1px solid var(--scrollbar-track-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}

.scrollbar-arrow::before {
  content: '';
  width: 0;
  height: 0;
  border: 4px solid transparent;
}

.scrollbar-vertical .scrollbar-arrow-up {
  top: 0;
}

.scrollbar-vertical .scrollbar-arrow-up::before {
  border-bottom-color: var(--scrollbar-arrow);
  border-top: none;
}

.scrollbar-vertical .scrollbar-arrow-down {
  bottom: 0;
}

.scrollbar-vertical .scrollbar-arrow-down::before {
  border-top-color: var(--scrollbar-arrow);
  border-bottom: none;
}

.scrollbar-horizontal .scrollbar-arrow-left {
  left: 0;
}

.scrollbar-horizontal .scrollbar-arrow-left::before {
  border-right-color: var(--scrollbar-arrow);
  border-left: none;
}

.scrollbar-horizontal .scrollbar-arrow-right {
  right: 0;
}

.scrollbar-horizontal .scrollbar-arrow-right::before {
  border-left-color: var(--scrollbar-arrow);
  border-right: none;
}

.scrollbar-track {
  position: absolute;
  background: var(--scrollbar-track);
}

.scrollbar-vertical .scrollbar-track {
  top: var(--scrollbar-arrow-height);
  bottom: var(--scrollbar-arrow-height);
  left: 0;
  right: 0;
}

.scrollbar-horizontal .scrollbar-track {
  left: var(--scrollbar-arrow-height);
  right: var(--scrollbar-arrow-height);
  top: 0;
  bottom: 0;
}

.scrollbar-thumb {
  position: absolute;
  background: var(--scrollbar-thumb);
  border: 1px solid var(--scrollbar-thumb-border-dark);
  box-shadow: inset 1px 1px 0 var(--scrollbar-thumb-border-light);
  cursor: default;
}

.scrollbar-vertical .scrollbar-thumb {
  left: 0;
  right: 0;
  min-height: 20px;
}

.scrollbar-horizontal .scrollbar-thumb {
  top: 0;
  bottom: 0;
  min-width: 20px;
}

/* ========================================
   ICON
   ======================================== */

.icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: var(--icon-label-width);
  cursor: default;
  user-select: none;
}

.icon-image {
  width: var(--icon-size);
  height: var(--icon-size);
  margin-bottom: 2px;
  image-rendering: pixelated;
}

.icon-label {
  font-size: var(--font-size-icon);
  text-align: center;
  word-wrap: break-word;
  max-width: 100%;
  line-height: 1.2;
  color: var(--icon-text);
  text-shadow: 1px 1px 0 var(--icon-text-shadow);
}

.desktop-icons .icon-label {
  color: var(--desktop-icon-text);
  text-shadow: 1px 1px 0 var(--desktop-icon-text-shadow);
}

.icon.selected .icon-image {
  filter: brightness(0.7) saturate(2);
}

.icon.selected .icon-label {
  background: var(--icon-selected-bg);
  color: var(--icon-selected-text);
  text-shadow: none;
}

.icon:active .icon-image {
  filter: brightness(0.6) saturate(2);
}

/* ========================================
   BUTTON
   ======================================== */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--button-height);
  padding: var(--button-padding);
  background: var(--button-bg);
  border: 1px solid var(--button-border-dark);
  box-shadow: var(--button-inset);
  font-family: var(--font-system);
  font-size: var(--font-size-base);
  color: var(--button-text);
  cursor: default;
  user-select: none;
  white-space: nowrap;
}

.button:active {
  background: var(--button-pressed-bg);
  box-shadow: var(--button-pressed-inset);
}

.button:disabled {
  color: var(--button-disabled-text);
  pointer-events: none;
}

.button.default {
  border-width: 2px;
  border-color: var(--button-default-ring);
}

/* ========================================
   CHECKBOX
   ======================================== */

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: default;
  user-select: none;
  font-size: var(--font-size-base);
}

.checkbox-box {
  width: var(--checkbox-size);
  height: var(--checkbox-size);
  background: var(--checkbox-bg);
  border: 1px solid var(--checkbox-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.checkbox-box::after {
  content: '';
  display: none;
  width: 8px;
  height: 8px;
  background: var(--checkbox-check);
  clip-path: polygon(
    14% 44%, 0% 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%
  );
}

.checkbox.checked .checkbox-box::after {
  display: block;
}

.checkbox:disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* ========================================
   RADIO BUTTON
   ======================================== */

.radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: default;
  user-select: none;
  font-size: var(--font-size-base);
}

.radio-circle {
  width: var(--radio-size);
  height: var(--radio-size);
  background: var(--checkbox-bg);
  border: 1px solid var(--checkbox-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.radio-circle::after {
  content: '';
  display: none;
  width: 6px;
  height: 6px;
  background: var(--radio-dot);
  border-radius: 50%;
}

.radio.checked .radio-circle::after {
  display: block;
}

.radio:disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* ========================================
   TEXT INPUT
   ======================================== */

.input {
  height: var(--input-height);
  padding: var(--input-padding);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  font-family: var(--font-system);
  font-size: var(--font-size-base);
  color: var(--input-text);
  box-shadow: inset 1px 1px 0 var(--window-border-inner-dark);
}

.input:focus {
  outline: none;
  border-color: var(--input-border-focus);
}

.input::placeholder {
  color: var(--input-placeholder);
}

/* ========================================
   SELECT / DROPDOWN
   ======================================== */

.select {
  display: inline-flex;
  align-items: center;
  height: var(--button-height);
  padding: 0 4px 0 8px;
  background: var(--button-bg);
  border: 1px solid var(--button-border-dark);
  box-shadow: var(--button-inset);
  font-family: var(--font-system);
  font-size: var(--font-size-base);
  color: var(--button-text);
  cursor: default;
  user-select: none;
  gap: 8px;
}

.select-value {
  flex: 1;
}

.select-arrows {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.select-arrow {
  width: 0;
  height: 0;
  border: 3px solid transparent;
}

.select-arrow-up {
  border-bottom-color: var(--button-text);
  border-top: none;
}

.select-arrow-down {
  border-top-color: var(--button-text);
  border-bottom: none;
}

/* ========================================
   TABS
   ======================================== */

.tabs {
  display: flex;
  flex-direction: column;
}

.tab-list {
  display: flex;
  padding-left: 8px;
  border-bottom: 1px solid var(--tab-border-dark);
}

.tab {
  height: var(--tab-height);
  padding: var(--tab-padding);
  background: var(--tab-bg);
  border: 1px solid var(--tab-border-dark);
  border-bottom: none;
  margin-right: -1px;
  cursor: default;
  user-select: none;
  font-size: var(--font-size-base);
  color: var(--tab-text);
  display: flex;
  align-items: center;
  position: relative;
  box-shadow: inset 1px 1px 0 var(--tab-border-light);
}

.tab.active {
  background: var(--tab-active-bg);
  border-bottom: 1px solid var(--tab-active-bg);
  margin-bottom: -1px;
  z-index: 1;
}

.tab-content {
  flex: 1;
  background: var(--tab-active-bg);
  border: 1px solid var(--tab-border-dark);
  border-top: none;
  padding: 16px;
}

/* ========================================
   PROGRESS BAR
   ======================================== */

.progress {
  height: 14px;
  background: var(--progress-track);
  border: 1px solid var(--progress-border);
  box-shadow: inset 1px 1px 0 var(--window-border-inner-dark);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--progress-fill);
  transition: width 0.1s ease-out;
}

/* Indeterminate progress - barberpole animation */
.progress.indeterminate .progress-fill {
  width: 100%;
  background: repeating-linear-gradient(
    -45deg,
    var(--progress-fill) 0px,
    var(--progress-fill) 8px,
    var(--progress-track) 8px,
    var(--progress-track) 16px
  );
  background-size: 22.627px 100%;
  animation: progress-indeterminate 0.5s linear infinite;
}

@keyframes progress-indeterminate {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 22.627px 0;
  }
}

/* ========================================
   SLIDER
   ======================================== */

.slider {
  display: flex;
  align-items: center;
  height: 20px;
  user-select: none;
}

.slider-track {
  flex: 1;
  height: 4px;
  background: var(--slider-track);
  border: 1px solid var(--slider-track-border);
  position: relative;
}

.slider-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 16px;
  background: var(--slider-thumb);
  border: 1px solid var(--slider-thumb-border-dark);
  box-shadow: inset 1px 1px 0 var(--slider-thumb-border-light);
  cursor: default;
}

.slider-ticks {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 6px;
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}

.slider-tick {
  width: 1px;
  height: 4px;
  background: var(--slider-tick);
}

/* ========================================
   LIST VIEW
   ======================================== */

.list-view {
  display: flex;
  flex-direction: column;
  background: var(--window-content-bg);
  border: 1px solid var(--input-border);
  overflow: auto;
}

.list-header {
  display: flex;
  background: var(--list-header-bg);
  border-bottom: 1px solid var(--list-header-border);
  flex-shrink: 0;
}

.list-header-cell {
  padding: 2px 8px;
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-bold);
  border-right: 1px solid var(--list-header-border);
  cursor: default;
  user-select: none;
}

.list-header-cell:last-child {
  border-right: none;
}

.list-body {
  flex: 1;
  overflow-y: auto;
}

.list-row {
  display: flex;
  align-items: center;
  padding: 1px 0;
  cursor: default;
  user-select: none;
}

.list-row:nth-child(odd) {
  background: var(--list-row-odd);
}

.list-row:nth-child(even) {
  background: var(--list-row-even);
}

.list-row.selected {
  background: var(--list-row-selected);
  color: var(--list-text-selected);
}

.list-cell {
  padding: 2px 8px;
  font-size: var(--font-size-base);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ========================================
   GROUP BOX
   ======================================== */

.groupbox {
  border: 1px solid var(--groupbox-border);
  padding: 12px 8px 8px;
  margin: 8px 0;
  position: relative;
}

.groupbox-label {
  position: absolute;
  top: -8px;
  left: 8px;
  background: var(--groupbox-label-bg);
  padding: 0 4px;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
}

/* ========================================
   TOOLTIP
   ======================================== */

.tooltip {
  position: fixed;
  background: var(--tooltip-bg);
  border: 1px solid var(--tooltip-border);
  padding: 2px 6px;
  font-size: var(--font-size-small);
  color: var(--tooltip-text);
  z-index: var(--z-tooltip);
  pointer-events: none;
  white-space: nowrap;
}

/* ========================================
   CONTROL PANEL SPECIFIC
   ======================================== */

.control-panel {
  padding: 8px;
}

.control-panel-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.control-panel-label {
  font-size: var(--font-size-base);
  min-width: 100px;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.hidden {
  display: none !important;
}

.flex {
  display: flex;
}

.flex-1 {
  flex: 1;
}

.gap-4 {
  gap: 4px;
}

.gap-8 {
  gap: 8px;
}

.mt-8 {
  margin-top: 8px;
}

.mb-8 {
  margin-bottom: 8px;
}

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

/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ========================================
   THEME IMAGE SUPPORT
   These styles use extracted Kaleidoscope theme images
   with proper 9-slice scaling via border-image
   ======================================== */

/* 
 * Checkboxes - Use exact image size, no scaling needed
 * The cicn is already the exact size of the checkbox
 */
.theme-scherzo .checkbox-box,
.theme-bebox .checkbox-box {
  width: var(--checkbox-unchecked-image-width, 12px);
  height: var(--checkbox-unchecked-image-height, 12px);
  background: var(--checkbox-unchecked-image, none) center/contain no-repeat;
  border: none;
}

.theme-scherzo .checkbox.checked .checkbox-box,
.theme-bebox .checkbox.checked .checkbox-box {
  background-image: var(--checkbox-checked-image, none);
}

.theme-scherzo .checkbox.checked .checkbox-box::after,
.theme-bebox .checkbox.checked .checkbox-box::after {
  display: none;
}

.theme-scherzo .checkbox:active .checkbox-box,
.theme-bebox .checkbox:active .checkbox-box {
  background-image: var(--checkbox-unchecked-pressed-image, var(--checkbox-unchecked-image));
}

.theme-scherzo .checkbox.checked:active .checkbox-box,
.theme-bebox .checkbox.checked:active .checkbox-box {
  background-image: var(--checkbox-checked-pressed-image, var(--checkbox-checked-image));
}

/* 
 * Radio buttons - Use exact image size, no scaling needed 
 */
.theme-scherzo .radio-circle,
.theme-bebox .radio-circle {
  width: var(--radio-unselected-image-width, 12px);
  height: var(--radio-unselected-image-height, 12px);
  background: var(--radio-unselected-image, none) center/contain no-repeat;
  border: none;
  border-radius: 0;
}

.theme-scherzo .radio.checked .radio-circle,
.theme-bebox .radio.checked .radio-circle {
  background-image: var(--radio-selected-image, none);
}

.theme-scherzo .radio.checked .radio-circle::after,
.theme-bebox .radio.checked .radio-circle::after {
  display: none;
}

.theme-scherzo .radio:active .radio-circle,
.theme-bebox .radio:active .radio-circle {
  background-image: var(--radio-unselected-pressed-image, var(--radio-unselected-image));
}

.theme-scherzo .radio.checked:active .radio-circle,
.theme-bebox .radio.checked:active .radio-circle {
  background-image: var(--radio-selected-pressed-image, var(--radio-selected-image));
}

/* 
 * Buttons - Use border-image for 9-slice scaling
 * Corners preserved, edges stretched
 */
.theme-scherzo .button,
.theme-bebox .button {
  background: none;
  border: 4px solid transparent;
  border-image: var(--button-image, none) 4 fill / 4px / 0 stretch;
  box-shadow: none;
}

.theme-scherzo .button:active,
.theme-bebox .button:active {
  border-image-source: var(--button-pressed-image, var(--button-image));
}

.theme-scherzo .button.default,
.theme-bebox .button.default {
  border-image-source: var(--button-default-image, var(--button-image));
}

/* 
 * Window frames - Use full cicn with 9-slice
 */
.theme-scherzo .window,
.theme-bebox .window {
  background: none;
  border-style: solid;
  border-color: transparent;
  border-top-width: var(--window-frame-active-image-slice-top, var(--window-title-height));
  border-right-width: var(--window-frame-active-image-slice-right, 6px);
  border-bottom-width: var(--window-frame-active-image-slice-bottom, 6px);
  border-left-width: var(--window-frame-active-image-slice-left, 6px);
  border-image-source: var(--window-frame-active-image, none);
  border-image-slice: var(--window-frame-active-image-slice, 0);
  border-image-width: var(--window-frame-active-image-slice-top, var(--window-title-height)) var(--window-frame-active-image-slice-right, 6px) var(--window-frame-active-image-slice-bottom, 6px) var(--window-frame-active-image-slice-left, 6px);
  border-image-outset: 0;
  border-image-repeat: stretch;
  box-shadow: none;
}

.theme-scherzo .window:not(.active),
.theme-bebox .window:not(.active) {
  border-top-width: var(--window-frame-inactive-image-slice-top, var(--window-frame-active-image-slice-top, var(--window-title-height)));
  border-right-width: var(--window-frame-inactive-image-slice-right, var(--window-frame-active-image-slice-right, 6px));
  border-bottom-width: var(--window-frame-inactive-image-slice-bottom, var(--window-frame-active-image-slice-bottom, 6px));
  border-left-width: var(--window-frame-inactive-image-slice-left, var(--window-frame-active-image-slice-left, 6px));
  border-image-source: var(--window-frame-inactive-image, var(--window-frame-active-image, none));
  border-image-slice: var(--window-frame-inactive-image-slice, var(--window-frame-active-image-slice, 0));
  border-image-width: var(--window-frame-inactive-image-slice-top, var(--window-frame-active-image-slice-top, var(--window-title-height))) var(--window-frame-inactive-image-slice-right, var(--window-frame-active-image-slice-right, 6px)) var(--window-frame-inactive-image-slice-bottom, var(--window-frame-active-image-slice-bottom, 6px)) var(--window-frame-inactive-image-slice-left, var(--window-frame-active-image-slice-left, 6px));
}

.theme-scherzo .window::before,
.theme-bebox .window::before {
  display: none;
}

.theme-scherzo .window-titlebar,
.theme-bebox .window-titlebar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--window-frame-active-image-slice-top, var(--window-title-height));
  background: transparent;
  border-bottom: none;
  padding: 0 4px;
}

/* Hide the CSS-drawn titlebar stripes when using theme */
.theme-scherzo .window-titlebar-stripes,
.theme-bebox .window-titlebar-stripes {
  display: none;
}

.theme-scherzo .window-title,
.theme-bebox .window-title {
  background: transparent;
}

/* Grow box from theme images */
.theme-scherzo .window-growbox,
.theme-bebox .window-growbox {
  background: var(--growbox-active-image, none) right bottom / 100% 100% no-repeat;
}

.theme-scherzo .window:not(.active) .window-growbox,
.theme-bebox .window:not(.active) .window-growbox {
  background: var(--growbox-inactive-image, var(--growbox-active-image, none)) right bottom / 100% 100% no-repeat;
}

/* 
 * Tabs - Use border-image for proper corner preservation
 */
.theme-scherzo .tab,
.theme-bebox .tab {
  background: none;
  border: 15px solid transparent;
  border-image: var(--tab-unselected-image, none) 3 15 3 15 fill / 3px 15px 3px 15px / 0 stretch;
  box-shadow: none;
  margin-right: 0;
}

.theme-scherzo .tab.active,
.theme-bebox .tab.active {
  border-image: var(--tab-selected-image, var(--tab-unselected-image, none)) 5 13 5 13 fill / 5px 13px 5px 13px / 0 stretch;
}

.theme-scherzo .tab-content,
.theme-bebox .tab-content {
  background: none;
  border: 3px solid transparent;
  border-image: var(--tab-pane-image, none) 3 fill / 3px / 0 stretch;
}

/* 
 * Scrollbar thumbs - Stretch vertically/horizontally 
 */
.theme-scherzo .scrollbar-vertical .scrollbar-thumb,
.theme-bebox .scrollbar-vertical .scrollbar-thumb,
.theme-platinum .scrollbar-vertical .scrollbar-thumb {
  background: none;
  border: 4px solid transparent;
  border-image: var(--scrollbar-thumb-v-image, none) 4 0 4 0 fill / 4px 0 / 0 stretch;
  box-shadow: none;
}

.theme-scherzo .scrollbar-horizontal .scrollbar-thumb,
.theme-bebox .scrollbar-horizontal .scrollbar-thumb,
.theme-platinum .scrollbar-horizontal .scrollbar-thumb {
  background: none;
  border: 4px solid transparent;
  border-image: var(--scrollbar-thumb-h-image, none) 0 4 0 4 fill / 0 4px / 0 stretch;
  box-shadow: none;
}

/* Scrollbar tracks with theme images */
.theme-scherzo .scrollbar-vertical .scrollbar-track,
.theme-bebox .scrollbar-vertical .scrollbar-track,
.theme-platinum .scrollbar-vertical .scrollbar-track {
  background: none;
  border: 4px solid transparent;
  border-image: var(--scrollbar-track-v-image, none) 4 fill / 4px / 0 stretch;
}

.theme-scherzo .scrollbar-horizontal .scrollbar-track,
.theme-bebox .scrollbar-horizontal .scrollbar-track,
.theme-platinum .scrollbar-horizontal .scrollbar-track {
  background: none;
  border: 4px solid transparent;
  border-image: var(--scrollbar-track-h-image, none) 4 fill / 4px / 0 stretch;
}

/* 
 * Progress bars - Use border-image for frame, tile fill 
 */
.theme-scherzo .progress,
.theme-bebox .progress,
.theme-platinum .progress {
  background: none;
  border: 2px solid transparent;
  border-image: var(--progress-track-image, none) 2 fill / 2px / 0 stretch;
  box-shadow: none;
}

.theme-scherzo .progress-fill,
.theme-bebox .progress-fill,
.theme-platinum .progress-fill {
  background: var(--progress-fill-image, none) left center / auto 100% repeat-x;
}

/* 
 * Menu bar - Tile horizontally 
 */
.theme-scherzo .menubar,
.theme-bebox .menubar {
  background-color: var(--menubar-bg);
  background-image: var(--menubar-pattern-image), var(--menubar-image);
  background-repeat: repeat-x;
  background-size: var(--menubar-pattern-image-size, auto 100%), auto 100%;
}

/* 
 * Select/Popup - Use border-image 
 */
.theme-scherzo .select,
.theme-bebox .select {
  background: none;
  border: 4px solid transparent;
  border-image: var(--popup-text-image, none) 4 fill / 4px / 0 stretch;
  box-shadow: none;
}

/* 
 * Menu dropdown - Use border-image for proper corners 
 */
.theme-scherzo .menu-dropdown,
.theme-bebox .menu-dropdown {
  background-color: var(--menu-bg);
  background-image: var(--menu-pattern-image);
  background-repeat: repeat;
  background-size: var(--menu-pattern-image-size);
  border: 6px solid transparent;
  border-image: var(--menu-bg-image, none) 6 fill / 6px / 0 stretch;
  box-shadow: none;
}

/* Menu title tiles */
.theme-scherzo .menu-title,
.theme-bebox .menu-title {
  background-image: var(--menu-title-normal-image, none);
  background-repeat: repeat-x;
  background-size: auto 100%;
}

.theme-scherzo .menu-title.active,
.theme-bebox .menu-title.active {
  background-image: var(--menu-title-pressed-image, var(--menu-item-pressed-image, var(--menu-title-normal-image)));
}

/* Menu item pressed state */
.theme-scherzo .menu-item:hover,
.theme-bebox .menu-item:hover {
  background-color: transparent;
  background-image: var(--menu-item-pressed-image, none);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  color: var(--menu-item-hover-text);
}

/* Menu dividers from theme */
.theme-scherzo .menu-divider,
.theme-bebox .menu-divider {
  background: var(--menu-divider-image, none) center / 100% 100% no-repeat;
}

/* ========================================
   THEME SELECTOR STYLES
   ======================================== */

.theme-selector {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.theme-preview {
  width: 100px;
  height: 70px;
  border: 2px solid var(--button-border-dark);
  border-radius: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  transition: border-color 0.1s;
}

.theme-preview.selected {
  border-color: var(--selection-bg);
  border-width: 3px;
}

.theme-preview:hover {
  border-color: var(--menu-item-hover);
}

.theme-preview-titlebar {
  height: 12px;
  background: linear-gradient(to bottom, #fff 0px, #ccc 1px, #ccc 10px, #999 11px);
  border-bottom: 1px solid #666;
}

.theme-preview-content {
  flex: 1;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  color: #666;
}

.theme-preview-label {
  text-align: center;
  font-size: 10px;
  margin-top: 4px;
}
