    * {
      box-sizing: border-box;
    }

    :root {
      /* Light theme colors */
      --bg-primary: #ffffff;
      --bg-secondary: #f8fafc;
      --bg-tertiary: #f1f5f9;
      --bg-panel: rgba(255, 255, 255, 0.9);
      --bg-panel-hover: rgba(255, 255, 255, 0.95);
      --bg-control: rgba(0, 0, 0, 0.05);
      --bg-control-hover: rgba(0, 0, 0, 0.1);
      --bg-control-active: rgba(0, 0, 0, 0.15);
      --text-primary: #0f172a;
      --text-secondary: #475569;
      --text-tertiary: #94a3b8;
      --accent-primary: #3b82f6;
      --accent-secondary: #6366f1;
      --accent-success: #10b981;
      --accent-warning: #f59e0b;
      --accent-danger: #ef4444;
      --border-primary: rgba(0, 0, 0, 0.1);
      --border-secondary: rgba(0, 0, 0, 0.05);
      --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
      --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
      --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.15);
      --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
      --blur-sm: blur(8px);
      --blur-md: blur(16px);
      --blur-lg: blur(24px);
      --border-radius: 12px;
      --spacing-sm: 8px;
      --spacing-md: 16px;
      --spacing-lg: 24px;
      --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      --toggle-bg: rgba(255, 255, 255, 0.8);
      --checker-size: 12px;
      --checker-light: #ffffff;
      --checker-dark: #e5e7eb;
      /* Icon filter: dark color for light theme */
      --icon-filter: brightness(0) saturate(100%) invert(8%) sepia(13%) saturate(2329%) hue-rotate(185deg) brightness(96%) contrast(93%);
      /* Legacy compatibility */
      --primary-color: var(--accent-primary);
      --primary-hover: #2563eb;
      --bg-light: var(--bg-secondary);
      --bg-card: var(--bg-panel);
      --border-color: var(--border-primary);
    }

    .dark-theme {
      /* Dark theme colors */
      --bg-primary: #0a0a0a;
      --bg-secondary: #111111;
      --bg-tertiary: #1a1a1a;
      --bg-panel: rgba(20, 20, 20, 0.8);
      --bg-panel-hover: rgba(30, 30, 30, 0.9);
      --bg-control: rgba(255, 255, 255, 0.05);
      --bg-control-hover: rgba(255, 255, 255, 0.1);
      --bg-control-active: rgba(255, 255, 255, 0.15);
      --text-primary: #ffffff;
      --text-secondary: #a0a0a0;
      --text-tertiary: #707070;
      --accent-primary: #3b82f6;
      --accent-secondary: #6366f1;
      --accent-success: #10b981;
      --accent-warning: #f59e0b;
      --accent-danger: #ef4444;
      --border-primary: rgba(255, 255, 255, 0.1);
      --border-secondary: rgba(255, 255, 255, 0.05);
      --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
      --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
      --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
      --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
      --blur-sm: blur(8px);
      --blur-md: blur(16px);
      --blur-lg: blur(24px);
      --toggle-bg: rgba(26, 26, 26, 0.7);
      --checker-size: 12px;
      --checker-light: #2f2f2f;
      --checker-dark: #1f1f1f;
      /* Icon filter: white color for dark theme */
      --icon-filter: brightness(0) saturate(100%) invert(100%);
      /* Legacy compatibility */
      --primary-color: var(--accent-primary);
      --primary-hover: #2563eb;
      --bg-light: var(--bg-secondary);
      --bg-card: var(--bg-panel);
      --border-color: var(--border-primary);
    }

    body {
      font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
      font-size: 14px;
      font-weight: 400;
      padding: 0;
      margin: 0;
      background: var(--bg-primary);
      min-height: 100vh;
      color: var(--text-primary);
      line-height: 1.5;
      transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1), color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Loading Screen */
    .loading-screen {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: var(--bg-primary);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 10000;
      transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .loading-screen.hidden {
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
    }

    .loading-content {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: var(--spacing-lg);
      animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    }

    @keyframes fadeInUp {
      from {
        opacity: 0;
        transform: translateY(20px);
      }
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    .loading-icon {
      width: 64px;
      height: 64px;
      background: transparent;
      border-radius: 12px;
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: 0 8px 32px rgba(59, 130, 246, 0.3);
      animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    }

    .loading-icon img {
      width: 100%;
      height: 100%;
      object-fit: contain;
      display: block;
    }

    @keyframes pulse {
      0%, 100% {
        transform: scale(1);
        box-shadow: 0 8px 32px rgba(59, 130, 246, 0.3);
      }
      50% {
        transform: scale(1.05);
        box-shadow: 0 12px 40px rgba(59, 130, 246, 0.4);
      }
    }

    .loading-title {
      font-size: 1.5rem;
      font-weight: 700;
      color: var(--text-primary);
      letter-spacing: -0.02em;
    }

    .app-container {
      margin: 0;
      padding: var(--spacing-lg);
      display: grid;
      grid-template-columns: 320px 1fr;
      row-gap: var(--spacing-sm);
      column-gap: var(--spacing-md);
      align-items: start;
      width: 100%;
      box-sizing: border-box;
    }

    .app-header {
      grid-column: 1 / -1;
      margin-bottom: var(--spacing-sm);
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: space-between;
    }

    .app-header-left {
      display: flex;
      align-items: center;
      gap: var(--spacing-md);
    }

    .app-icon {
      width: 40px;
      height: 40px;
      background: transparent;
      background-image: url('icons/icon.svg');
      background-size: contain;
      background-repeat: no-repeat;
      background-position: center;
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      color: transparent;
      font-weight: bold;
      font-size: 18px;
      cursor: pointer;
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      user-select: none;
      position: relative;
    }

    .app-icon:hover {
  transform: scale(1.05);
  background-image: url('icons/icon-halftonelab-on-hover-light.svg');
  filter: drop-shadow(0 8px 25px rgba(59, 130, 246, 0.4));
}

.dark-theme .app-icon:hover {
  background-image: url('icons/icon-halftonelab-on-hover-dark.svg');
}

    .app-icon:active {
      transform: scale(1.05) rotate(2deg);
      transition: transform 0.1s ease;
    }

    h1 {
      font-size: 2rem;
      font-weight: 700;
      margin: 0;
      color: #000000;
      cursor: pointer;
      transition: var(--transition);
      position: relative;
      user-select: none;
    }

    .dark-theme h1 {
      color: #ffffff;
    }

    h1:hover::after {
      content: '0.6.5';
      position: absolute;
      top: -8px;
      right: -48px;
      font-size: 0.7rem;
      font-weight: 500;
      color: var(--text-secondary);
      background: var(--bg-card);
      padding: 2px 6px;
      border-radius: 4px;
      box-shadow: var(--shadow-sm);
      border: 1px solid var(--border-color);
      opacity: 0.9;
      animation: fadeInVersion 0.2s ease-in-out;
    }

    @keyframes fadeInVersion {
      from {
        opacity: 0;
        transform: translateY(5px);
      }

      to {
        opacity: 0.9;
        transform: translateY(0);
      }
    }

    .app-subtitle {
      color: var(--text-secondary);
      font-size: 1rem;
      margin-top: var(--spacing-sm);
    }

    /* Tabs Bar Styles */
    .tabs-bar {
      grid-column: 1 / -1;
      display: flex;
      align-items: center;
      gap: var(--spacing-sm);
      margin-bottom: var(--spacing-sm);
      background: var(--bg-panel);
      backdrop-filter: var(--blur-lg);
      -webkit-backdrop-filter: var(--blur-lg);
      border: 1px solid var(--border-primary);
      border-radius: 16px;
      padding: var(--spacing-sm);
      box-shadow: var(--shadow-xl);
      overflow: hidden;
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .tabs-container {
      flex: 1;
      display: flex;
      align-items: center;
      gap: var(--spacing-sm);
      overflow-x: auto;
      overflow-y: hidden;
      scrollbar-width: thin;
      scrollbar-color: var(--border-color) transparent;
      padding: 2px;
      min-width: 0;
      position: relative;
    }

    .tabs-container::-webkit-scrollbar {
      height: 6px;
    }

    .tabs-container::-webkit-scrollbar-track {
      background: transparent;
    }

    .tabs-container::-webkit-scrollbar-thumb {
      background: var(--border-color);
      border-radius: 3px;
    }

    .tabs-container::-webkit-scrollbar-thumb:hover {
      background: var(--text-secondary);
    }

    .tab {
      display: flex;
      align-items: center;
      gap: var(--spacing-sm);
      padding: var(--spacing-sm) var(--spacing-sm) var(--spacing-sm) var(--spacing-md);
      background: var(--bg-light);
      border: 1px solid var(--border-color);
      border-radius: 8px;
      cursor: move;
      transition: var(--transition);
      user-select: none;
      white-space: nowrap;
      min-width: 160px;
      max-width: 240px;
      flex-shrink: 0;
    }

    .tab:hover {
      background: rgba(67, 97, 238, 0.05);
      border-color: var(--primary-color);
      transform: none !important;
    }

    .tab.active {
      background: rgba(67, 97, 238, 0.1);
      border-color: var(--primary-color);
      color: var(--text-primary);
      box-shadow: inset 0 0 0 1px var(--primary-color);
    }

    .tab.active .tab-name {
      color: var(--primary-color);
      font-weight: 600;
    }

    .tab.active .tab-close {
      color: var(--primary-color);
      opacity: 0.8;
    }

    .tab.active .tab-close:hover {
      opacity: 1;
      background: rgba(67, 97, 238, 0.2);
    }

    .tab.dragging {
      opacity: 0.4;
      transform: scale(0.95);
      cursor: grabbing;
    }

    .tab-name {
      flex: 1;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      font-size: 0.9rem;
      color: var(--text-primary);
      font-weight: 500;
      min-width: 0;
    }

    .tab-name.editing {
      overflow: visible;
    }

    .tab-name-input {
      flex: 1;
      background: var(--bg-card);
      border: 2px solid var(--primary-color);
      border-radius: 4px;
      padding: 2px 6px;
      font-size: 0.9rem;
      font-weight: 500;
      font-family: inherit;
      color: var(--text-primary);
      outline: none;
      min-width: 60px;
      max-width: 180px;
    }

    .tab-name-input:focus {
      box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.2);
    }

    .tab-close {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 20px;
      height: 20px;
      min-width: 20px;
      max-width: 20px;
      min-height: 20px;
      max-height: 20px;
      border-radius: 4px;
      background: transparent;
      border: none;
      color: var(--text-secondary);
      font-size: 16px;
      line-height: 1;
      cursor: pointer;
      transition: var(--transition);
      padding: 0;
      margin-left: auto;
      flex-shrink: 0;
      box-sizing: border-box;
    }

    .tab-close:hover {
      background: rgba(0, 0, 0, 0.1);
      color: var(--text-primary);
    }

    .dark-theme .tab-close:hover {
      background: rgba(255, 255, 255, 0.1);
    }

    .tab-new {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 36px;
      height: 36px;
      min-width: 36px;
      max-width: 36px;
      min-height: 36px;
      max-height: 36px;
      border-radius: 8px;
      background: rgba(67, 97, 238, 0.1);
      border: 1px solid var(--border-color);
      color: var(--primary-color);
      font-size: 20px;
      font-weight: bold;
      line-height: 1;
      cursor: pointer;
      transition: var(--transition);
      flex-shrink: 0;
      padding: 0;
      box-sizing: border-box;
      margin-right: 4px;
    }

    .tab-new:hover {
      background: rgba(67, 97, 238, 0.2);
      border-color: var(--primary-color);
      color: white;
      transform: scale(1.05);
    }

    .tab-new:active {
      transform: scale(0.95);
    }

    .tab-new:focus {
      outline: none;
      border-color: var(--primary-color);
      box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.1);
    }

    .tab-new.close-all-mode {
      background: rgba(239, 68, 68, 0.1);
      border-color: rgba(239, 68, 68, 0.3);
      color: #ef4444;
    }

    .tab-new.close-all-mode:hover {
      background: rgba(239, 68, 68, 0.5);
      border-color: #ef4444;
      color: white;
    }

    .drop-indicator {
      width: 2px;
      height: 32px;
      background: var(--primary-color);
      border-radius: 1px;
      position: absolute;
      pointer-events: none;
      opacity: 0;
      transition: opacity 0.2s ease;
    }

    .drop-indicator.visible {
      opacity: 1;
    }

    .controls-panel {
      background: var(--bg-panel);
      backdrop-filter: var(--blur-lg);
      -webkit-backdrop-filter: var(--blur-lg);
      border: 1px solid var(--border-primary);
      border-radius: 16px;
      padding: 0;
      box-shadow: var(--shadow-xl);
      position: sticky;
      top: var(--spacing-lg);
      height: calc(100vh - var(--spacing-lg) * 2 - 120px);
      /* Full height minus padding and header */
      min-height: 600px;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .controls-panel-header {
      flex-shrink: 0;
      z-index: 20;
      background: var(--bg-panel-hover);
      backdrop-filter: var(--blur-md);
      -webkit-backdrop-filter: var(--blur-md);
      padding: 12px;
      border-bottom: 1px solid var(--border-secondary);
      border-radius: 16px 16px 0 0;
      box-shadow: 0 10px 18px rgba(0, 0, 0, 0.08);
    }

    .controls-panel-header-row {
      display: flex;
      align-items: center;
      gap: var(--spacing-sm);
    }

    /* Settings Content */
    .settings-content {
      flex: 1;
      padding: 8px;
      overflow-y: scroll;
      overflow-x: hidden;
    }

    /* Custom Scrollbar for settings content */
    .settings-content::-webkit-scrollbar {
      width: 12px;
    }

    .settings-content::-webkit-scrollbar-track {
      background: transparent;
    }

    .settings-content::-webkit-scrollbar-thumb {
      background: var(--border-primary);
      border-radius: 6px;
      border: 3px solid var(--bg-panel);
      background-clip: padding-box;
    }

    .settings-content::-webkit-scrollbar-thumb:hover {
      background: var(--border-primary);
      opacity: 0.8;
    }

    .panel-section {
      margin-bottom: 24px;
      background: var(--bg-control);
      border: 1px solid var(--border-secondary);
      border-radius: 16px;
      padding: 20px;
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      backdrop-filter: var(--blur-sm);
      -webkit-backdrop-filter: var(--blur-sm);
    }

    .panel-section:hover {
      background: var(--bg-control-hover);
      border-color: var(--border-primary);
      transform: translateY(-1px);
      box-shadow: var(--shadow-md);
    }

    .panel-section:last-child {
      margin-bottom: 0;
    }

    .panel-section:first-child {
      margin-top: 8px;
    }

    .section-title {
      font-size: 15px;
      font-weight: 600;
      letter-spacing: -0.025em;
      margin: 0 -20px 16px -20px;
      padding: 0 20px;
      color: var(--text-primary);
      display: flex;
      align-items: center;
      gap: var(--spacing-sm);
      cursor: pointer;
      user-select: none;
      transition: var(--transition);
      position: relative;
      padding-right: 20px;
    }

    .section-title:hover {
      color: var(--accent-primary);
    }

    .section-title::before {
      content: '';
      display: block;
      width: 18px;
      height: 18px;
      background-color: var(--primary-color);
      -webkit-mask-repeat: no-repeat;
      mask-repeat: no-repeat;
      -webkit-mask-size: contain;
      mask-size: contain;
      -webkit-mask-position: center;
      mask-position: center;
      flex: 0 0 18px;
    }

    .section-title[data-section="image-upload"]::before {
      -webkit-mask-image: url('icons/panels/panel-import.svg');
      mask-image: url('icons/panels/panel-import.svg');
    }

    .section-title[data-section="pattern-settings"]::before {
      -webkit-mask-image: url('icons/panels/panel-settings.svg');
      mask-image: url('icons/panels/panel-settings.svg');
    }

    .section-title[data-section="colors"]::before {
      -webkit-mask-image: url('icons/panels/panel-colors.svg');
      mask-image: url('icons/panels/panel-colors.svg');
    }

    .section-title[data-section="imageAdjustments"]::before {
      -webkit-mask-image: url('icons/panels/panel-image-adjustments.svg');
      mask-image: url('icons/panels/panel-image-adjustments.svg');
    }

    .section-title[data-section="imageEffects"]::before {
      -webkit-mask-image: url('icons/panels/panel-effects.svg');
      mask-image: url('icons/panels/panel-effects.svg');
    }

    .section-title[data-section="options"]::before {
      -webkit-mask-image: url('icons/panels/panel-shuffle.svg');
      mask-image: url('icons/panels/panel-shuffle.svg');
    }

    .section-title[data-section="export"]::before {
      -webkit-mask-image: url('icons/panels/panel-export.svg');
      mask-image: url('icons/panels/panel-export.svg');
    }

    .section-title::after {
      content: '';
      position: absolute;
      right: 20px;
      width: 18px;
      height: 18px;
      background-color: var(--text-secondary);
      -webkit-mask-image: url('icons/ui/chevron-right.svg');
      mask-image: url('icons/ui/chevron-right.svg');
      -webkit-mask-repeat: no-repeat;
      mask-repeat: no-repeat;
      -webkit-mask-size: contain;
      mask-size: contain;
      -webkit-mask-position: center;
      mask-position: center;
      transform: rotate(90deg);
      transform-origin: center;
      transition: transform 0.3s ease, background-color 0.3s ease;
    }

    .section-title.collapsed {
      margin-bottom: 0;
    }

    .section-title.collapsed::after {
      transform: rotate(0deg);
    }

    .section-title:hover::after {
      background-color: var(--text-primary);
    }

    .section-content {
      transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
      max-height: 1000px;
      opacity: 1;
      padding: 0 2px;
      /* Add small padding to prevent thumb clipping */
      margin: 0 -2px;
      /* Compensate for the padding */
    }

    .section-content.collapsed {
      max-height: 0;
      opacity: 0;
      margin-bottom: 0;
      overflow: hidden;
      /* Only hide overflow when collapsed */
      padding: 0;
      margin: 0;
    }

    .control-group {
      display: flex;
      flex-direction: column;
      gap: var(--spacing-sm);
      margin-bottom: var(--spacing-md);
    }

    .control-group:last-child {
      margin-bottom: 0;
    }

    .control-divider {
      height: 1px;
      background-color: var(--border-color);
      margin: var(--spacing-md) 0;
      width: 100%;
    }

    .toggle-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 8px;
      margin: 0 -8px var(--spacing-sm) -8px;
      border-radius: 8px;
      transition: background-color 0.2s ease;
    }

    .toggle-row:hover {
      background-color: var(--bg-control-hover);
    }

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

    .toggle-row label {
      cursor: pointer;
      user-select: none;
    }

    .control-row {
      display: flex;
      align-items: center;
      gap: var(--spacing-md);
    }

    .color-controls {
      display: grid;
      grid-template-columns: 1fr;
      gap: var(--spacing-md);
    }

    label {
      font-size: 0.9rem;
      color: var(--text-secondary);
      font-weight: 500;
    }

    .range-control {
      display: flex;
      flex-direction: column;
      gap: 6px;
      width: 100%;
      padding: 2px 4px;
      /* Add padding to prevent thumb clipping */
      margin: 0 -4px;
      /* Compensate for horizontal padding */
    }

    .range-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .range-value {
      font-size: 13px;
      font-weight: 500;
      color: var(--accent-primary);
      background: var(--bg-control);
      padding: 4px 8px;
      border-radius: 6px;
      border: 1px solid var(--border-secondary);
      width: 50px;
      text-align: center;
      cursor: pointer;
      transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
      -webkit-appearance: none;
      -moz-appearance: textfield;
      appearance: none;
    }

    /* Hide number input arrows/spinners in WebKit browsers */
    .range-value::-webkit-outer-spin-button,
    .range-value::-webkit-inner-spin-button {
      -webkit-appearance: none;
      appearance: none;
      margin: 0;
    }

    /* Hide number input arrows/spinners in Firefox */
    .range-value[type=number] {
      -moz-appearance: textfield;
      appearance: textfield;
    }

    .range-value:hover {
      background: rgba(67, 97, 238, 0.2);
      border-color: var(--primary-color);
    }

    .range-value:focus {
      outline: none;
      background: var(--bg-card);
      border-color: var(--primary-color);
      box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.1);
    }

    .range-value.invalid {
      border-color: #ef4444;
      background-color: rgba(239, 68, 68, 0.1);
      color: #ef4444;
    }

    .select-control {
      display: flex;
      flex-direction: column;
      gap: 6px;
      width: 100%;
      margin-bottom: var(--spacing-md);
    }

    .custom-select {
      width: 100%;
      height: 36px;
      padding: 0 var(--spacing-sm);
      border: 1px solid var(--border-secondary);
      border-radius: 8px;
      background-color: var(--bg-control);
      color: var(--text-primary);
      font-size: 0.9rem;
      font-family: inherit;
      cursor: pointer;
      transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
      appearance: none;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234a5568' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 8px center;
      background-size: 16px;
    }

    .pattern-type-listbox {
      width: 100%;
      max-height: 216px;
      overflow-y: auto;
      border: 1px solid var(--border-secondary);
      border-radius: 8px;
      background-color: var(--bg-control);
      font-size: 0.9rem;
      font-family: inherit;
      padding: 6px;
      display: flex;
      flex-direction: column;
      gap: 4px;
      transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
      scrollbar-width: thin;
      scrollbar-color: var(--border-primary) transparent;
      user-select: none;
    }

    .pattern-type-search-wrapper {
      position: relative;
      width: 100%;
    }

    .pattern-type-search {
      width: 100%;
      height: 36px;
      padding: 0 36px 0 var(--spacing-sm);
      border: 1px solid var(--border-secondary);
      border-radius: 8px;
      background-color: var(--bg-control);
      color: var(--text-primary);
      font-size: 0.9rem;
      font-family: inherit;
      transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .pattern-type-search:hover {
      border-color: var(--border-primary);
      background-color: var(--bg-control-hover);
    }

    .pattern-type-search:focus {
      outline: none;
      border-color: var(--accent-primary);
      background-color: var(--bg-control-hover);
      box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    }

    .pattern-type-search-icon {
      position: absolute;
      right: 8px;
      top: 50%;
      transform: translateY(-50%);
      width: 18px;
      height: 18px;
      color: var(--text-tertiary);
      pointer-events: none;
      transition: opacity 0.2s ease;
      opacity: 1;
    }

    .pattern-type-search-icon.hidden {
      opacity: 0;
    }

    .pattern-type-search-clear {
      position: absolute;
      right: 4px;
      top: 50%;
      transform: translateY(-50%) scale(0.9);
      width: 28px;
      height: 28px;
      border: none;
      border-radius: 4px;
      background-color: rgba(128, 128, 128, 0.15);
      color: rgba(128, 128, 128, 0.7);
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 16px;
      font-weight: 600;
      line-height: 1;
      transition: opacity 0.2s ease, background-color 0.2s ease, color 0.2s ease;
      opacity: 0;
      pointer-events: none;
    }

    .pattern-type-search-clear.visible {
      opacity: 1;
      pointer-events: auto;
      transform: translateY(-50%) scale(1);
    }

    .pattern-type-search-clear:hover {
      background-color: rgba(239, 68, 68, 0.8);
      color: #fff;
      transform: translateY(-50%) scale(1) !important;
    }

    .pattern-type-search-clear:active {
      transform: translateY(-50%) scale(1) !important;
    }

    .pattern-type-tabs {
      background: var(--bg-card);
      border: 1px solid var(--border-color);
      border-radius: 10px;
      padding: 4px;
      display: flex;
      gap: 4px;
      margin-bottom: 8px;
      box-shadow: var(--shadow-sm);
      position: relative;
      overflow: hidden;
      z-index: 1;
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .pattern-type-tabs::before {
      content: '';
      position: absolute;
      top: 4px;
      left: 4px;
      bottom: 4px;
      width: calc(50% - 6px);
      background: rgba(67, 97, 238, 0.1);
      border-radius: 4px;
      transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      z-index: 1;
      pointer-events: none;
    }

    .dark-theme .pattern-type-tabs::before {
      background: rgba(67, 97, 238, 0.2);
    }

    .pattern-type-tabs:has(#pattern-type-favorites-tab.active)::before {
      transform: translateX(calc(100% + 4px));
    }

    .pattern-type-tab {
      flex: 1;
      padding: 8px 16px;
      font-size: 0.9rem;
      font-weight: 500;
      color: var(--text-secondary);
      background: transparent;
      border: none;
      border-radius: 4px;
      cursor: pointer;
      transition: var(--transition);
      position: relative;
      z-index: 2;
      user-select: none;
    }

    .pattern-type-tab.active {
      color: var(--primary-color);
      background: transparent !important;
    }

    .pattern-type-tab.active:hover {
      color: #ffffff;
      background: transparent !important;
    }

    .pattern-type-tabs:has(.pattern-type-tab.active:hover)::before {
      background: var(--primary-color);
    }

    .pattern-type-tab:hover:not(.active) {
      color: var(--text-primary);
      background: rgba(67, 97, 238, 0.05);
    }

    .pattern-type-tab:focus {
      outline: none;
    }

    .pattern-type-empty {
      padding: 10px;
      border-radius: 6px;
      color: var(--text-secondary);
      text-align: center;
      font-size: 0.85rem;
    }

    .pattern-type-favorites-empty {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 32px 16px;
      gap: 8px;
      text-align: center;
    }

    .pattern-type-favorites-empty[hidden] {
      display: none;
    }

    .pattern-type-favorites-empty-icon {
      width: 48px;
      height: 48px;
      opacity: 0.3;
      filter: brightness(0) saturate(100%) invert(42%) sepia(8%) saturate(1084%) hue-rotate(182deg) brightness(92%) contrast(88%);
    }

    .dark-theme .pattern-type-favorites-empty-icon {
      filter: brightness(0) saturate(100%) invert(87%) sepia(6%) saturate(434%) hue-rotate(182deg) brightness(94%) contrast(87%);
    }

    .pattern-type-favorites-empty-text {
      font-size: 0.95rem;
      color: var(--text-primary);
      font-weight: 500;
    }

    .pattern-type-favorites-empty-hint {
      font-size: 0.8rem;
      color: var(--text-secondary);
      max-width: 240px;
      line-height: 1.4;
    }

    .pattern-type-listbox:focus {
      outline: none;
      border-color: var(--primary-color);
      box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
    }

    .pattern-type-listbox::-webkit-scrollbar {
      width: 6px;
    }

    .pattern-type-listbox::-webkit-scrollbar-track {
      background: transparent;
    }

    .pattern-type-listbox::-webkit-scrollbar-thumb {
      background: var(--border-color);
      border-radius: 3px;
    }

    .pattern-type-listbox::-webkit-scrollbar-thumb:hover {
      background: var(--text-secondary);
    }

    .pattern-type-option {
      padding: 8px 10px;
      border-radius: 6px;
      cursor: pointer;
      color: var(--text-primary);
      transition: var(--transition);
      line-height: 1.2;
      display: flex;
      align-items: center;
      gap: 8px;
      position: relative;
    }

    .pattern-type-option:hover {
      background: rgba(67, 97, 238, 0.06);
    }

    .pattern-type-option[aria-selected="true"] {
      background: rgba(67, 97, 238, 0.12);
      box-shadow: inset 0 0 0 1px rgba(67, 97, 238, 0.35);
    }

    .pattern-type-option-text {
      flex: 1;
      min-width: 0;
      padding-right: 24px;
    }

    .shape-type-icon {
      position: absolute;
      right: 8px;
      top: 50%;
      transform: translateY(-50%);
      width: 20px;
      height: 20px;
      opacity: 0.08;
      pointer-events: none;
      fill: currentColor;
      stroke: currentColor;
      transition: opacity 0.2s ease;
    }

    .pattern-type-option:hover .shape-type-icon {
      opacity: 0.2;
    }

    .custom-shape-upload {
      min-height: 80px;
    }

    .custom-shape-upload .file-input-label {
      min-height: 80px;
    }

    .custom-shape-upload .select-text {
      font-size: 14px;
    }

    .custom-shape-upload .drag-text {
      font-size: 12px;
      opacity: 0.6;
    }

    .pattern-type-favorite-btn {
      position: absolute;
      right: 8px;
      top: 50%;
      transform: translateY(-50%) !important;
      width: 16px;
      height: 16px;
      min-width: 16px;
      max-width: 16px;
      min-height: 16px;
      max-height: 16px;
      border: none;
      background: none !important;
      box-shadow: none !important;
      cursor: pointer;
      padding: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      opacity: 0;
      flex-shrink: 0;
      overflow: visible;
    }

    .pattern-type-favorite-btn img {
      width: 100%;
      height: 100%;
      display: block;
      pointer-events: none;
      transition: filter 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      filter: brightness(0) saturate(100%) invert(42%) sepia(8%) saturate(1084%) hue-rotate(182deg) brightness(92%) contrast(88%);
    }

    .dark-theme .pattern-type-favorite-btn img {
      filter: brightness(0) saturate(100%) invert(87%) sepia(6%) saturate(434%) hue-rotate(182deg) brightness(94%) contrast(87%);
    }

    /* Not favorited - hide by default */
    .pattern-type-favorite-btn:not(.favorited) img {
      display: none;
    }

    /* Show add icon on hover for non-favorited */
    .pattern-type-option:hover .pattern-type-favorite-btn:not(.favorited) img {
      display: block;
    }

    /* Change add icon to primary blue on hover */
    /* Disabled: hover effect removed */
    /* .pattern-type-favorite-btn:not(.favorited):hover img {
      filter: brightness(0) saturate(100%) invert(38%) sepia(94%) saturate(2270%) hue-rotate(218deg) brightness(99%) contrast(92%);
    } */

    /* Favorited - show filled icon */
    .pattern-type-favorite-btn.favorited img {
      display: block;
      filter: brightness(0) saturate(100%) invert(38%) sepia(94%) saturate(2270%) hue-rotate(218deg) brightness(99%) contrast(92%);
    }

    /* Show remove icon on hover for favorited */
    .pattern-type-favorite-btn.favorited:hover img {
      filter: brightness(0) saturate(100%) invert(36%) sepia(93%) saturate(4533%) hue-rotate(347deg) brightness(95%) contrast(92%);
    }

    .pattern-type-option:hover .pattern-type-favorite-btn {
      opacity: 1;
    }

    .pattern-type-favorite-btn.favorited {
      opacity: 1;
      background: none !important;
      box-shadow: none !important;
    }

    .pattern-type-favorite-btn:hover {
      transform: translateY(-50%) !important;
      background: none !important;
      box-shadow: none !important;
    }

    .pattern-type-favorite-btn:active {
      transform: translateY(-50%) !important;
      background: none !important;
      box-shadow: none !important;
    }

    .pattern-type-favorites-section {
      display: flex;
      flex-direction: column;
      gap: 4px;
    }

    .pattern-type-favorites-header {
      font-size: 0.75rem;
      font-weight: 600;
      color: var(--text-secondary);
      text-transform: uppercase;
      letter-spacing: 0.5px;
      padding: 4px 10px;
      margin-bottom: 4px;
    }

    .custom-select:hover {
      border-color: var(--primary-color);
    }

    .custom-select:focus {
      outline: none;
      border-color: var(--primary-color);
      box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
    }

    .select-with-arrows {
      display: flex;
      align-items: center;
      gap: 8px;
      width: 100%;
    }

    .select-with-arrows .custom-select {
      flex: 1;
      min-width: 0;
      /* Allow the select to shrink */
    }

    .arrow-btn {
      width: 36px;
      height: 36px;
      min-width: 36px;
      max-width: 36px;
      min-height: 36px;
      max-height: 36px;
      border: 1px solid var(--border-secondary);
      border-radius: 8px;
      background-color: var(--bg-control);
      color: var(--text-primary);
      font-size: 18px;
      font-weight: bold;
      cursor: pointer;
      transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      flex-grow: 0;
      flex-basis: auto;
      user-select: none;
      box-sizing: border-box;
    }

    .arrow-btn:hover {
      border-color: var(--border-primary);
      background-color: var(--bg-control-hover);
      color: var(--accent-primary);
      transform: translateY(-1px);
      box-shadow: var(--shadow-sm);
    }

    .arrow-btn:active {
      background-color: var(--bg-control-active);
      transform: scale(0.98);
    }

    .arrow-btn:focus {
      outline: none;
      border-color: var(--accent-primary);
      box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
    }

    /* Label with toggle button styles */
    .label-with-toggle {
      display: flex;
      align-items: center;
      gap: 4px;
    }

    .toggle-visibility-btn {
      width: 24px;
      height: 24px;
      padding: 0;
      border: none;
      background: transparent;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 4px;
      transition: background-color 0.2s, opacity 0.2s;
      opacity: 0.7;
      margin-top: -2px; /* Move up 2px as requested */
    }

    .toggle-visibility-btn.faded {
      opacity: 0.3 !important;
    }

    .toggle-visibility-btn:hover {
      background-color: var(--bg-control-hover) !important;
      opacity: 1;
      transform: none !important;
      box-shadow: none !important;
    }

    .toggle-visibility-btn:active {
      transform: none !important;
      box-shadow: none !important;
    }

    .toggle-visibility-btn img {
      width: 16px;
      height: 16px;
      display: block;
      /* Apply theme color to the icon using CSS filter */
      filter: var(--icon-filter);
    }

    /* Range controls disabled state */
    .range-control.disabled {
      opacity: 0.5;
      pointer-events: none;
    }
    
    .range-control.disabled .toggle-visibility-btn {
      pointer-events: auto;
      opacity: 1;
    }

    input[type="range"] {
      width: 100%;
      height: 6px;
      -webkit-appearance: none;
      appearance: none;
      background: var(--border-color);
      border-radius: 3px;
      outline: none;
      position: relative;
    }

    input[type="range"]::-webkit-slider-thumb {
      -webkit-appearance: none;
      appearance: none;
      width: 16px;
      height: 16px;
      border-radius: 50%;
      background: var(--primary-color);
      cursor: pointer;
      transition: var(--transition);
      position: relative;
      z-index: 2;
    }

    input[type="range"]::-webkit-slider-thumb:hover {
      transform: scale(1.2);
    }

    /* Firefox slider track styles */
    input[type="range"]::-moz-range-track {
      width: 100%;
      height: 6px;
      background: var(--border-color);
      border-radius: 3px;
      border: none;
    }

    input[type="range"]::-moz-range-thumb {
      width: 16px;
      height: 16px;
      border-radius: 50%;
      background: var(--primary-color);
      cursor: pointer;
      border: none;
      transition: var(--transition);
    }

    input[type="range"]::-moz-range-thumb:hover {
      transform: scale(1.2);
    }

    /* Enhanced slider with filled track - background set by JavaScript */
    .range-control input[type="range"] {
      /* Background is dynamically set by updateRangeProgress() */
      transition: background 0.2s ease;
    }

    .color-control {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .color-input-wrapper {
      position: relative;
      height: 36px;
      width: 40px;
      flex-shrink: 0;
      transition: var(--transition);
      cursor: grab;
      padding: 2px;
      border: 2px solid transparent;
      border-radius: 8px;
    }

    .color-row {
      display: flex;
      align-items: center;
      gap: var(--spacing-sm);
    }

    .color-input-wrapper:hover {
      border-color: var(--border-color);
    }

    .color-input-wrapper:active {
      cursor: grabbing;
    }

    .color-input-wrapper.drag-over {
      transform: scale(1.05);
      box-shadow: 0 0 0 2px var(--primary-color), var(--shadow-lg);
      border-radius: 6px;
    }

    .color-input-wrapper.dragging {
      opacity: 0.5;
      transform: scale(0.95);
    }

    input[type="color"] {
      -webkit-appearance: none;
      appearance: none;
      width: 100%;
      height: 100%;
      border: none;
      border-radius: 4px;
      background: transparent;
      cursor: pointer;
      transition: var(--transition);
      display: block;
    }

    input[type="color"]:hover {
      transform: scale(1.02);
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }

    input[type="color"]::-webkit-color-swatch-wrapper {
      padding: 0;
    }

    input[type="color"]::-webkit-color-swatch {
      border: none;
      border-radius: 6px;
      box-shadow: var(--shadow-sm);
      transition: var(--transition);
    }

    input[type="color"]:hover::-webkit-color-swatch {
      box-shadow: var(--shadow-md);
    }

    .hex-input {
      flex: 1;
      height: 32px;
      padding: 0 var(--spacing-sm);
      border: 1px solid var(--border-color);
      border-radius: 6px;
      background-color: var(--bg-card);
      color: var(--text-primary);
      font-size: 0.85rem;
      font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
      transition: var(--transition);
      text-align: center;
      text-transform: uppercase;
    }

    .hex-input:hover {
      border-color: var(--primary-color);
    }

    .hex-input:focus {
      outline: none;
      border-color: var(--primary-color);
      box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
    }

    .hex-input.invalid {
      border-color: #ef4444;
      background-color: rgba(239, 68, 68, 0.05);
    }

    .file-upload {
      display: flex;
      flex-direction: column;
      gap: var(--spacing-sm);
    }

    .file-input-wrapper {
      position: relative;
      overflow: hidden;
      display: block;
      width: 100%;
      max-width: 100%;
      box-sizing: border-box;
      border: 2px dashed var(--border-color);
      border-radius: var(--border-radius);
      padding: var(--spacing-lg);
      text-align: center;
      cursor: pointer;
      transition: var(--transition);
    }

    .file-input-wrapper:hover {
      border-color: var(--primary-color);
      background-color: rgba(67, 97, 238, 0.03);
      box-shadow: var(--shadow-md);
    }

    .file-input-wrapper.drag-over {
      border-color: var(--primary-color);
      background-color: rgba(67, 97, 238, 0.08);
      border-width: 3px;
      transform: scale(1.02);
      box-shadow: 0 8px 20px rgba(67, 97, 238, 0.15);
    }

    .file-input-label {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: var(--spacing-sm);
      padding: 20px var(--spacing-md);
      background: rgba(67, 97, 238, 0.1);
      color: var(--primary-color);
      border-radius: 6px;
      font-weight: 500;
      cursor: pointer;
      transition: var(--transition);
      text-align: center;
      flex-direction: column;
      width: 100%;
      max-width: 100%;
      box-sizing: border-box;
    }

    .file-input-label:hover {
      background: rgba(67, 97, 238, 0.2);
      transform: scale(1.02);
    }

    .file-input-label::before {
      content: '';
      display: inline-block;
      width: 24px;
      height: 24px;
      background-color: currentColor;
      -webkit-mask-image: url('icons/ui/folder-open.svg');
      mask-image: url('icons/ui/folder-open.svg');
      -webkit-mask-size: contain;
      mask-size: contain;
      -webkit-mask-repeat: no-repeat;
      mask-repeat: no-repeat;
      -webkit-mask-position: center;
      mask-position: center;
      transition: var(--transition);
    }

    .file-input-wrapper:hover .file-input-label::before {
      transform: scale(1.1);
    }

    .file-input-label .drag-text {
      font-size: 0.8rem;
      color: var(--text-secondary);
      margin-top: 5px;
      transition: var(--transition);
    }

    .file-input-wrapper:hover .drag-text {
      color: var(--primary-color);
    }

    .file-name {
      display: block;
      margin-top: 8px;
      font-size: 0.85rem;
      color: var(--primary-color);
      font-weight: 500;
      word-break: break-word;
      max-width: 100%;
    }

    .file-name-btn {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 8px 12px;
      border-radius: 999px;
      border: 1px solid rgba(67, 97, 238, 0.35);
      background: rgba(67, 97, 238, 0.08);
      color: var(--primary-color);
      font-weight: 600;
      font-size: 0.85rem;
      line-height: 1;
      max-width: 100%;
      cursor: pointer;
    }

    .file-name-btn[hidden] {
      display: none !important;
    }

    .file-name-btn:hover {
      background: rgba(67, 97, 238, 0.08) !important;
      border-color: rgba(67, 97, 238, 0.35) !important;
      transform: none !important;
      box-shadow: none !important;
    }

    .file-name-btn .file-name-text {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      max-width: 240px;
    }

    .file-name-btn .file-remove-x {
      opacity: 0.6;
      transition: all 0.2s ease;
      font-weight: 700;
      line-height: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      width: 20px;
      height: 20px;
      border-radius: 50%;
      background: transparent;
      cursor: pointer;
      position: relative;
      z-index: 1;
    }

    .file-name-btn:hover .file-remove-x {
      opacity: 1;
      background: rgba(67, 97, 238, 0.3);
      transform: scale(1.05);
    }

    .file-input-label {
      position: relative;
      z-index: 2;
    }

    .file-input-wrapper.has-file .select-text,
    .file-input-wrapper.has-file .drag-text {
      display: none;
    }

    .file-input-wrapper.has-file .file-input-label::before {
      -webkit-mask-image: url('icons/ui/image.svg');
      mask-image: url('icons/ui/image.svg');
    }

    input[type="file"] {
      position: absolute;
      left: 0;
      top: 0;
      opacity: 0;
      width: 100%;
      height: 100%;
      cursor: pointer;
      z-index: 1;
    }

    .checkbox-group {
      display: flex;
      flex-direction: column;
      gap: var(--spacing-sm);
    }

    .checkbox-label {
      display: flex;
      align-items: center;
      gap: var(--spacing-sm);
      cursor: pointer;
      font-size: 0.9rem;
      color: var(--text-secondary);
    }

    .checkbox-label input[type="checkbox"] {
      -webkit-appearance: none;
      appearance: none;
      width: 18px;
      height: 18px;
      border: 2px solid var(--border-color);
      border-radius: 4px;
      outline: none;
      cursor: pointer;
      position: relative;
      transition: var(--transition);
    }

    .checkbox-label input[type="checkbox"]:checked {
      background-color: var(--primary-color);
      border-color: var(--primary-color);
    }

    .checkbox-label input[type="checkbox"]:checked::after {
      content: '';
      position: absolute;
      left: 50%;
      top: 45%;
      width: 5px;
      height: 10px;
      border: solid white;
      border-width: 0 2px 2px 0;
      transform: translate(-50%, -50%) rotate(45deg);
    }

    .action-buttons {
      display: flex;
      flex-direction: column;
      /* Always show the buttons */
      gap: var(--spacing-sm);
      margin-top: var(--spacing-md);
    }

    .button-row {
      display: flex;
      align-items: center;
      gap: var(--spacing-sm);
    }

    .copy-btn {
      width: 36px;
      height: 36px;
      min-width: 36px;
      max-width: 36px;
      min-height: 36px;
      max-height: 36px;
      border: 1px solid var(--border-secondary);
      border-radius: 8px;
      background-color: var(--bg-control);
      color: var(--text-primary);
      cursor: pointer;
      transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      flex-grow: 0;
      padding: 0;
    }

    .copy-btn:hover:not(:disabled) {
      border-color: var(--border-primary);
      background-color: var(--bg-control-hover);
      color: var(--accent-primary);
      transform: translateY(-1px);
      box-shadow: var(--shadow-sm);
    }

    .copy-btn:active:not(:disabled) {
      background-color: var(--bg-control-active);
      transform: scale(0.98);
    }

    .copy-btn:focus {
      outline: none;
      border-color: var(--accent-primary);
      box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
    }

    .copy-btn.success {
      background-color: rgba(34, 197, 94, 0.1);
      border-color: #22c55e;
      color: #22c55e;
    }

    .copy-btn svg {
      width: 16px;
      height: 16px;
      flex-shrink: 0;
    }

    .copyright {
      margin-top: 0;
      padding: var(--spacing-md);
      border-top: 1px solid var(--border-color);
      text-align: center;
      font-size: 0.75rem;
      color: var(--text-tertiary);
      background: var(--bg-panel);
      border-radius: 0 0 16px 16px;
      flex-shrink: 0;
    }

    .copyright .footer-link {
      color: inherit;
    }

    .footer-link {
      color: var(--text-secondary);
      text-decoration: none;
      position: relative;
      display: inline-block;
      transition: color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .footer-link:hover {
      color: var(--primary-color);
    }

    /* Underline Effect */
    .link-text {
      position: relative;
      display: inline-block;
    }

    .link-text::after {
      content: '';
      position: absolute;
      width: 100%;
      height: 1px;
      bottom: -2px;
      left: 0;
      background-color: var(--primary-color);
      transform: scaleX(0);
      transform-origin: center;
      transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .footer-link:hover .link-text::after {
      transform: scaleX(1);
    }

    /* Tooltip */
    .footer-link::before {
      content: attr(data-tooltip);
      position: absolute;
      bottom: 100%;
      left: 50%;
      transform: translateX(-50%) translateY(10px);
      padding: 6px 12px;
      background-color: rgba(15, 23, 42, 0.28);
      backdrop-filter: blur(18px) saturate(160%);
      -webkit-backdrop-filter: blur(18px) saturate(160%);
      color: var(--bg-primary);
      font-size: 0.75rem;
      border-radius: 6px;
      border: 1px solid rgba(255, 255, 255, 0.1);
      white-space: nowrap;
      opacity: 0;
      transition: opacity 0.3s ease, transform 0.3s ease;
      transition-delay: 0s;
      pointer-events: none;
      box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
      z-index: 100;
      margin-bottom: 8px;
    }

    /* Tooltip Arrow */
    .footer-link::after {
      content: '';
      position: absolute;
      bottom: 100%;
      left: 50%;
      transform: translateX(-50%) translateY(10px);
      border-width: 5px;
      border-style: solid;
      border-color: rgba(15, 23, 42, 0.28) transparent transparent transparent;
      opacity: 0;
      transition: opacity 0.3s ease, transform 0.3s ease;
      transition-delay: 0s;
      pointer-events: none;
      z-index: 100;
      margin-bottom: -2px;
    }

    .dark-theme .footer-link::before {
      background-color: rgba(255, 255, 255, 0.28);
      border-color: rgba(255, 255, 255, 0.2);
      color: #000;
    }

    .dark-theme .footer-link::after {
      border-color: rgba(255, 255, 255, 0.28) transparent transparent transparent;
    }

    .footer-link:hover::before,
    .footer-link:hover::after {
      opacity: 1;
      transform: translateX(-50%) translateY(0);
      transition-delay: 1.2s;
    }

    button {
      flex: 1;
      background: var(--accent-primary);
      color: white;
      font-weight: 600;
      font-size: 0.9rem;
      border: none;
      border-radius: 8px;
      padding: 10px var(--spacing-md);
      cursor: pointer;
      transition: var(--transition);
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      box-shadow: var(--shadow-sm);
    }

    button:hover:not(:disabled) {
      background: var(--primary-hover);
      transform: translateY(-1px);
      box-shadow: var(--shadow-md);
    }

    button:active:not(:disabled) {
      transform: translateY(0);
      box-shadow: var(--shadow-sm);
    }

    button:disabled {
      background: var(--bg-control);
      color: var(--text-tertiary);
      cursor: not-allowed;
      opacity: 0.6;
      box-shadow: none;
    }

    .secondary-btn {
      background: var(--bg-card);
      color: var(--text-primary);
      border: 1px solid var(--border-color);
    }

    .secondary-btn:hover:not(:disabled) {
      background: rgba(67, 97, 238, 0.05);
      border-color: var(--primary-color);
      color: var(--text-primary);
    }

    .secondary-btn:active:not(:disabled) {
      background: rgba(67, 97, 238, 0.1);
    }

    .shuffle-randomize-btn {
      width: 100%;
      flex: none;
      background: var(--bg-card);
      color: var(--text-primary);
      border: 1px solid var(--border-color);
    }

    .shuffle-randomize-btn:disabled {
      opacity: 0.4;
      cursor: not-allowed;
    }

    .shuffle-randomize-btn:hover:not(:disabled) {
      background: rgba(67, 97, 238, 0.05);
      border-color: var(--primary-color);
      color: var(--text-primary);
    }

    .shuffle-randomize-btn:active:not(:disabled) {
      background: rgba(67, 97, 238, 0.1);
      transform: scale(0.99);
    }

    .shuffle-randomize-btn:focus {
      outline: none;
      border-color: var(--primary-color);
      box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.1);
    }

    .shuffle-randomize-icon {
      width: 16px;
      height: 16px;
      display: inline-block;
      background-color: currentColor;
      -webkit-mask-image: url('icons/ui/random-seed.svg');
      mask-image: url('icons/ui/random-seed.svg');
      -webkit-mask-repeat: no-repeat;
      mask-repeat: no-repeat;
      -webkit-mask-size: contain;
      mask-size: contain;
      -webkit-mask-position: center;
      mask-position: center;
      flex: 0 0 16px;
    }

    .preview-area {
      display: flex;
      flex-direction: column;
      gap: var(--spacing-md);
      height: calc(100vh - var(--spacing-lg) * 2 - 120px);
      /* Full height minus padding and header */
      min-height: 600px;
      width: 100%;
      min-width: 0;
      /* Allow shrinking below content size */
      box-sizing: border-box;
    }

    .preview-panel {
      background: var(--bg-panel);
      backdrop-filter: var(--blur-lg);
      -webkit-backdrop-filter: var(--blur-lg);
      border: 1px solid var(--border-primary);
      border-radius: 16px;
      padding: var(--spacing-lg);
      box-shadow: var(--shadow-xl);
      display: flex;
      flex-direction: column;
      align-items: center;
      width: 100%;
      flex: 1;
      overflow: hidden;
      position: relative;
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      min-width: 0;
      /* Allow shrinking below content size */
      box-sizing: border-box;
    }

    .preview-panel.drag-highlight {
      box-shadow: 0 0 0 2px var(--primary-color), var(--shadow-lg);
    }

    .canvas-container {
      width: 100%;
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      flex: 1;
      position: relative;
      /* Added for SVG positioning */
      overflow: hidden;
      /* Prevent overflow during zoom */
      min-width: 0;
      /* Allow shrinking below content size */
      box-sizing: border-box;
    }

    canvas {
      max-width: 100%;
      max-height: 100%;
      width: auto;
      height: auto;
      object-fit: contain;
    }

    /* Empty State Styles */
    .empty-state {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      background: var(--bg-card);
      border: 2px dashed var(--border-color);
      border-radius: var(--border-radius);
      margin: 20px;
      cursor: pointer;
      transition: var(--transition);
      user-select: none;
    }

    .empty-state:hover {
      border-color: var(--primary-color);
      background: rgba(67, 97, 238, 0.02);
      transform: scale(1.01);
      box-shadow: 0 8px 25px rgba(67, 97, 238, 0.1);
    }

    .empty-state.drag-over {
      border-color: var(--primary-color);
      border-width: 3px;
      background: rgba(67, 97, 238, 0.05);
      transform: scale(1.02);
      box-shadow: 0 12px 35px rgba(67, 97, 238, 0.15);
    }

    .empty-state.drag-over .empty-state-title {
      color: var(--primary-color);
    }

    .empty-state.drag-over .empty-state-description {
      color: var(--primary-color);
    }

    .empty-state.hidden {
      display: none;
    }

    .empty-state-content {
      text-align: center;
      padding: var(--spacing-lg);
      max-width: 400px;
    }

    .empty-state-icon {
      margin-bottom: var(--spacing-lg);
      display: flex;
      justify-content: center;
    }

    .empty-state-icon svg {
      transition: var(--transition);
    }

    .empty-state:hover .empty-state-icon svg {
      transform: scale(1.1);
    }

    .empty-state-title {
      font-size: 1.5rem;
      font-weight: 600;
      color: var(--text-primary);
      margin: 0 0 var(--spacing-sm) 0;
      line-height: 1.3;
    }

    .empty-state-description {
      font-size: 1rem;
      color: var(--text-secondary);
      margin: 0 0 var(--spacing-lg) 0;
      line-height: 1.4;
    }

    .empty-state-formats {
      display: flex;
      justify-content: center;
      gap: var(--spacing-sm);
      flex-wrap: wrap;
    }

    .format-tag {
      display: inline-block;
      padding: 4px 12px;
      background: rgba(67, 97, 238, 0.1);
      color: var(--primary-color);
      border: 1px solid rgba(67, 97, 238, 0.2);
      border-radius: 16px;
      font-size: 0.75rem;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      transition: var(--transition);
    }

    .empty-state:hover .format-tag {
      background: rgba(67, 97, 238, 0.15);
      border-color: rgba(67, 97, 238, 0.3);
      transform: translateY(-1px);
    }

    .empty-state.drag-over .format-tag {
      background: rgba(67, 97, 238, 0.2);
      border-color: rgba(67, 97, 238, 0.4);
      transform: translateY(-2px);
    }

    .svg-container {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      display: none;
      /* Initially hidden */
      pointer-events: none;
      justify-content: center;
      align-items: center;
    }

    .svg-container.visible {
      display: flex;
    }

    #halftoneOverlay {
      max-width: 100%;
      max-height: 100%;
      width: auto;
      height: auto;
    }

    .toggle-switch {
      position: relative;
      display: inline-block;
      width: 60px;
      height: 30px;
      margin: 0 8px;
    }

    .toggle-switch input {
      opacity: 0;
      width: 0;
      height: 0;
    }

    .toggle-slider {
      position: absolute;
      cursor: pointer;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: #ccc;
      transition: .4s;
      border-radius: 34px;
    }

    .toggle-slider:before {
      position: absolute;
      content: "";
      height: 22px;
      width: 22px;
      left: 4px;
      bottom: 4px;
      background-color: white;
      transition: .4s;
      border-radius: 50%;
    }

    input:checked+.toggle-slider {
      background-color: var(--primary-color);
    }

    input:focus+.toggle-slider {
      box-shadow: 0 0 1px var(--primary-color);
    }

    input:checked+.toggle-slider:before {
      transform: translateX(30px);
    }

    .toggle-container {
      display: flex;
      align-items: center;
      justify-content: center;
      margin-top: var(--spacing-md);
      padding: var(--spacing-sm);
      background: var(--toggle-bg);
      border-radius: var(--border-radius);
      box-shadow: var(--shadow-sm);
      flex-wrap: wrap;
      gap: var(--spacing-md);
    }

    .zoom-controls-panel {
      background: var(--bg-panel);
      backdrop-filter: var(--blur-lg);
      -webkit-backdrop-filter: var(--blur-lg);
      border: 1px solid var(--border-primary);
      border-radius: 16px;
      padding: var(--spacing-md);
      box-shadow: var(--shadow-xl);
      flex-shrink: 0;
      width: 100%;
      box-sizing: border-box;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: var(--spacing-md);
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .toggle-label {
      font-size: 0.9rem;
      font-weight: 500;
      color: var(--text-secondary);
    }

    .zoom-control {
      display: flex;
      align-items: center;
      gap: var(--spacing-sm);
      flex: 1;
      justify-content: center;
      padding: 2px 0;
      /* Add vertical padding to prevent thumb clipping */
    }

    .zoom-btn {
      width: 36px;
      height: 36px;
      min-width: 36px;
      max-width: 36px;
      min-height: 36px;
      max-height: 36px;
      border-radius: 8px;
      background: transparent;
      color: var(--text-primary);
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      line-height: 0;
      cursor: pointer;
      transition: var(--transition);
      border: 1px solid var(--border-color);
      box-shadow: none;
      flex-shrink: 0;
      flex-grow: 0;
    }

    .zoom-btn svg {
      width: 20px;
      height: 20px;
      display: block;
      flex-shrink: 0;
    }

    .zoom-btn:hover {
      background: rgba(67, 97, 238, 0.08);
      border-color: var(--primary-color);
      box-shadow: none;
    }

    .zoom-btn:active {
      transform: translateY(1px) scale(0.98);
      box-shadow: none;
    }

    .zoom-btn:focus {
      outline: none;
      box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
    }

    .zoom-slider {
      width: 120px;
      margin: 0 var(--spacing-sm);
      cursor: pointer;
      height: 6px;
      -webkit-appearance: none;
      appearance: none;
      background: linear-gradient(to right,
          rgba(67, 97, 238, 0.2) 0%,
          rgba(67, 97, 238, 0.2) var(--range-progress, 0%),
          var(--border-color) var(--range-progress, 0%),
          var(--border-color) 100%);
      border-radius: 3px;
      outline: none;
      position: relative;
    }

    .zoom-slider::-webkit-slider-thumb {
      -webkit-appearance: none;
      appearance: none;
      width: 16px;
      height: 16px;
      border-radius: 50%;
      background: var(--primary-color);
      cursor: pointer;
      transition: var(--transition);
      position: relative;
      z-index: 2;
    }

    .zoom-slider::-webkit-slider-thumb:hover {
      transform: scale(1.2);
    }

    .zoom-slider:disabled {
      opacity: 0.5;
      cursor: not-allowed;
      background: linear-gradient(to right,
          var(--border-color) 0%,
          var(--border-color) 100%);
    }

    .zoom-slider:disabled::-webkit-slider-thumb {
      background: var(--text-secondary);
      cursor: not-allowed;
    }

    .zoom-slider:disabled::-webkit-slider-thumb:hover {
      transform: none;
    }

    /* Firefox slider track styles for zoom slider */
    .zoom-slider::-moz-range-track {
      width: 100%;
      height: 6px;
      background: var(--border-color);
      border-radius: 3px;
      border: none;
    }

    .zoom-slider::-moz-range-thumb {
      width: 16px;
      height: 16px;
      border-radius: 50%;
      background: var(--primary-color);
      cursor: pointer;
      border: none;
      transition: var(--transition);
    }

    .zoom-slider::-moz-range-thumb:hover {
      transform: scale(1.2);
    }

    .zoom-slider:disabled::-moz-range-thumb {
      background: var(--text-secondary);
      cursor: not-allowed;
    }

    .zoom-slider:disabled::-moz-range-thumb:hover {
      transform: none;
    }

    .zoom-value {
      font-size: 0.8rem;
      font-weight: 600;
      color: var(--primary-color);
      background: rgba(67, 97, 238, 0.1);
      padding: 0 6px;
      border-radius: 6px;
      border: 1px solid var(--border-color);
      width: 50px;
      height: 36px;
      text-align: center;
      cursor: pointer;
      transition: var(--transition);
      -webkit-appearance: none;
      -moz-appearance: textfield;
      appearance: none;
      display: flex;
      align-items: center;
      justify-content: center;
      box-sizing: border-box;
    }

    /* Hide number input arrows/spinners for zoom value */
    .zoom-value::-webkit-outer-spin-button,
    .zoom-value::-webkit-inner-spin-button {
      -webkit-appearance: none;
      appearance: none;
      margin: 0;
    }

    .zoom-value[type=number] {
      -moz-appearance: textfield;
      appearance: textfield;
    }

    .zoom-value:hover {
      background: rgba(67, 97, 238, 0.2);
      border-color: var(--primary-color);
    }

    .zoom-value:focus {
      outline: none;
      background: rgba(67, 97, 238, 0.1);
      border-color: var(--primary-color);
      box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.1);
    }

    .zoom-value.invalid {
      border-color: #ef4444;
      background-color: rgba(239, 68, 68, 0.1);
      color: #ef4444;
    }

    .zoom-value:disabled {
      opacity: 0.5;
      cursor: not-allowed;
      background: var(--bg-light);
      color: var(--text-secondary);
      border-color: var(--border-color);
    }

    .zoom-value:disabled:hover {
      background: var(--bg-light);
      border-color: var(--border-color);
    }

    /* Fullscreen button styles */
    .fullscreen-btn {
      width: 36px;
      height: 36px;
      min-width: 36px;
      max-width: 36px;
      min-height: 36px;
      max-height: 36px;
      border-radius: 8px;
      background: transparent;
      color: var(--text-primary);
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      line-height: 0;
      cursor: pointer;
      transition: var(--transition);
      border: 1px solid var(--border-color);
      box-shadow: none;
      flex-shrink: 0;
      flex-grow: 0;
    }

    .fullscreen-btn:hover {
      background: rgba(67, 97, 238, 0.08);
      border-color: var(--primary-color);
      box-shadow: none;
    }

    .fullscreen-btn:active {
      transform: translateY(1px) scale(0.98);
      box-shadow: none;
    }

    .fullscreen-btn:disabled {
      background: transparent;
      color: var(--text-secondary);
      cursor: not-allowed;
      opacity: 0.5;
      border-color: var(--border-color);
    }

    .fullscreen-btn:disabled:hover {
      background: transparent;
      border-color: var(--border-color);
      transform: none;
    }

    .fullscreen-btn svg {
      width: 20px;
      height: 20px;
      display: block;
      flex-shrink: 0;
    }

    /* Reset zoom button styles */
    .reset-zoom-btn {
      width: 36px;
      height: 36px;
      min-width: 36px;
      max-width: 36px;
      min-height: 36px;
      max-height: 36px;
      border-radius: 8px;
      background: transparent;
      color: var(--text-primary);
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      line-height: 0;
      cursor: pointer;
      transition: var(--transition);
      border: 1px solid var(--border-color);
      box-shadow: none;
      flex-shrink: 0;
      flex-grow: 0;
    }

    .reset-zoom-btn:hover {
      background: rgba(67, 97, 238, 0.08);
      border-color: var(--primary-color);
      box-shadow: none;
    }

    .reset-zoom-btn:active {
      transform: translateY(1px) scale(0.98);
      box-shadow: none;
    }

    .reset-zoom-btn:disabled {
      background: transparent;
      color: var(--text-secondary);
      cursor: not-allowed;
      opacity: 0.5;
      border-color: var(--border-color);
    }

    .reset-zoom-btn:disabled:hover {
      background: transparent;
      border-color: var(--border-color);
      transform: none;
    }

    .reset-zoom-btn svg {
      width: 20px;
      height: 20px;
      display: block;
      flex-shrink: 0;
    }

    /* Fullscreen mode styles */
    .fullscreen-mode {
      position: fixed !important;
      top: 0 !important;
      left: 0 !important;
      width: 100vw !important;
      height: 100vh !important;
      z-index: 9999 !important;
      background: var(--bg-light) !important;
      padding: 0 !important;
      margin: 0 !important;
      border-radius: 0 !important;
      box-shadow: none !important;
    }

    .fullscreen-mode .canvas-container {
      width: 100% !important;
      height: calc(100vh - 80px) !important;
      /* Leave space for controls */
    }

    .fullscreen-mode .zoom-controls-panel {
      position: fixed !important;
      bottom: 20px !important;
      left: 50% !important;
      transform: translateX(-50%) !important;
      width: auto !important;
      z-index: 10000 !important;
      border-radius: var(--border-radius) !important;
      box-shadow: var(--shadow-lg) !important;
    }

    .fullscreen-exit-btn {
      position: fixed !important;
      top: 20px !important;
      right: 20px !important;
      width: 40px !important;
      height: 40px !important;
      border-radius: 50% !important;
      background: rgba(0, 0, 0, 0.7) !important;
      color: white !important;
      display: flex !important;
      align-items: center !important;
      justify-content: center !important;
      font-size: 18px !important;
      font-weight: bold !important;
      cursor: pointer !important;
      transition: var(--transition) !important;
      border: none !important;
      z-index: 10001 !important;
      backdrop-filter: blur(10px) !important;
    }

    .fullscreen-exit-btn:hover {
      background: rgba(0, 0, 0, 0.9) !important;
      transform: scale(1.1) !important;
    }

    /* Theme toggle button styles */
    .theme-toggle {
      position: relative;
      display: inline-block;
      width: 60px;
      height: 30px;
      margin-top: var(--spacing-md);
    }

    .theme-toggle-input {
      opacity: 0;
      width: 0;
      height: 0;
    }

    .theme-toggle-slider {
      position: absolute;
      cursor: pointer;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: var(--bg-card);
      border: 1px solid var(--border-color);
      transition: all 0.3s ease;
      border-radius: 34px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 4px;
      box-shadow: var(--shadow-sm);
    }

    .theme-toggle-slider:before {
      position: absolute;
      content: "";
      height: 24px;
      width: 24px;
      left: 3px;
      bottom: 2px;
      background-color: var(--primary-color);
      transition: .4s;
      border-radius: 50%;
      z-index: 1;
    }

    .theme-toggle-input:checked+.theme-toggle-slider:before {
      transform: translateX(30px);
    }

    .theme-toggle-input:focus+.theme-toggle-slider {
      box-shadow: var(--shadow-sm);
      outline: none;
    }

    .dark-theme .theme-toggle-input:focus+.theme-toggle-slider {
      box-shadow: var(--shadow-sm);
      outline: none;
    }

    .theme-toggle-icon {
      z-index: 0;
      color: var(--text-secondary);
    }

    .moon-icon {
      margin-right: 4px;
    }

    .sun-icon {
      margin-left: 4px;
    }

    /* In dark mode, make the sun icon more visible */
    .dark-theme .sun-icon {
      color: var(--bg-dark);
    }

    /* In light mode, make the moon icon more visible */
    body:not(.dark-theme) .moon-icon {
      color: var(--bg-dark);
    }

    .theme-toggle:hover .theme-toggle-slider {
      box-shadow: var(--shadow-md);
      border-color: var(--primary-color);
      transform: scale(1.02);
    }

    /* Generic Toggle Switch */
    .switch {
      position: relative;
      display: inline-block;
      width: 32px;
      height: 18px;
    }

    .switch input {
      opacity: 0;
      width: 0;
      height: 0;
    }

    .slider {
      position: absolute;
      cursor: pointer;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: var(--bg-card);
      border: 1px solid var(--border-color);
      transition: .3s;
      border-radius: 18px;
    }

    .slider:before {
      position: absolute;
      content: "";
      height: 12px;
      width: 12px;
      left: 2px;
      bottom: 2px;
      background-color: var(--text-secondary);
      transition: .3s;
      border-radius: 50%;
    }

    input:checked+.slider {
      background-color: var(--primary-color);
      border-color: var(--primary-color);
    }

    input:checked+.slider:before {
      transform: translateX(14px);
      background-color: white;
    }

    .control-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: var(--spacing-xs);
    }

    .control-header label {
      margin-bottom: 0 !important;
    }

    @media (max-width: 900px) {
      .app-container {
        grid-template-columns: 1fr;
      }

      .controls-panel {
        order: 2;
        position: static;
        height: auto;
        min-height: auto;
      }

      .preview-area {
        order: 1;
        height: auto;
        min-height: auto;
      }

      .preview-panel {
        height: 500px;
        flex: none;
      }
    }

    @media (max-width: 600px) {
      .app-container {
        padding: var(--spacing-md);
      }

      .app-header-left h1 {
        font-size: 1.5rem;
      }

      .app-icon {
        width: 32px;
        height: 32px;
        font-size: 14px;
      }

      h1:hover::after {
        right: -35px;
        font-size: 0.6rem;
      }

      .color-controls {
        grid-template-columns: 1fr;
      }

      .action-buttons {
        flex-direction: column;
      }

      .button-row {
        flex-direction: column;
        align-items: stretch;
      }

      .copy-btn {
        width: 100%;
        max-width: none;
      }
    }

    /* SVG overlay styles */
    /* Removed duplicate #halftoneOverlay rule as it's already defined above */

    .render-mode-switch {
      display: flex;
      align-items: center;
      gap: var(--spacing-sm);
      margin-left: var(--spacing-md);
    }

    /* Segmented button styles for preview toggle */
    .preview-mode-selector {
      background: var(--bg-card);
      border: 1px solid var(--border-color);
      border-radius: 10px;
      padding: 4px;
      display: flex;
      gap: 4px;
      margin-bottom: 0;
      box-shadow: var(--shadow-sm);
      position: relative;
      overflow: hidden;
      flex: 1;
      z-index: 1;
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .preview-mode-slider {
      position: absolute;
      top: 4px;
      left: 4px;
      bottom: 4px;
      width: calc(33.33% - 5.33px);
      /* Default for 3 buttons */
      background: rgba(67, 97, 238, 0.1);
      border-radius: 4px;
      transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      z-index: 1;
      pointer-events: none;
    }

    .dark-theme .preview-mode-slider {
      background: rgba(67, 97, 238, 0.2);
    }

    .toggle-all-sections-btn {
      width: 40px;
      height: 40px;
      flex: 0 0 40px;
      border-radius: 10px;
      border: 1px solid var(--border-color);
      background: var(--bg-card);
      color: var(--text-secondary);
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: var(--shadow-sm);
      cursor: pointer;
      transition: var(--transition);
      padding: 0;
    }

    .toggle-all-sections-btn:hover {
      color: #ffffff;
      background: var(--primary-color);
      border-color: var(--primary-color);
      box-shadow: var(--shadow-md);
    }

    .toggle-all-sections-btn:active {
      transform: scale(0.98);
    }

    .toggle-all-sections-btn:focus {
      outline: none;
      border-color: var(--primary-color);
      box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.12);
    }

    .toggle-all-sections-btn svg {
      width: 18px;
      height: 18px;
      display: block;
    }

    .toggle-all-sections-icon {
      width: 18px;
      height: 18px;
      display: block;
      background-color: currentColor;
      -webkit-mask-repeat: no-repeat;
      mask-repeat: no-repeat;
      -webkit-mask-size: contain;
      mask-size: contain;
      -webkit-mask-position: center;
      mask-position: center;
    }

    .toggle-all-sections-icon.expand {
      -webkit-mask-image: url('icons/ui/list-expand.svg');
      mask-image: url('icons/ui/list-expand.svg');
    }

    .toggle-all-sections-icon.collapse {
      -webkit-mask-image: url('icons/ui/list-collapse.svg');
      mask-image: url('icons/ui/list-collapse.svg');
    }

    .compare-btn {
      width: 40px;
      height: 40px;
      flex: 0 0 40px;
      border-radius: 10px;
      border: 1px solid var(--border-color);
      background: var(--bg-card);
      color: var(--text-secondary);
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: var(--shadow-sm);
      cursor: pointer;
      transition: var(--transition);
      padding: 0;
    }

    .compare-btn:hover:not(:disabled) {
      color: #ffffff;
      background: var(--primary-color);
      border-color: var(--primary-color);
      box-shadow: var(--shadow-md);
    }

    .compare-btn:active:not(:disabled) {
      transform: scale(0.98);
    }

    .compare-btn:focus {
      outline: none;
      border-color: var(--primary-color);
      box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.12);
    }

    .compare-btn:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }

    .compare-btn.active {
      color: var(--primary-color);
      background: transparent;
      border-color: var(--primary-color);
      border-width: 2px;
    }

    .compare-icon {
      width: 18px;
      height: 18px;
      display: block;
      background-color: currentColor;
      -webkit-mask-image: url('icons/ui/square-split-horizontal.svg');
      mask-image: url('icons/ui/square-split-horizontal.svg');
      -webkit-mask-repeat: no-repeat;
      mask-repeat: no-repeat;
      -webkit-mask-size: contain;
      mask-size: contain;
      -webkit-mask-position: center;
      mask-position: center;
    }

    .preview-mode-option {
      flex: 1;
      padding: 8px 16px;
      font-size: 0.9rem;
      font-weight: 500;
      color: var(--text-secondary);
      background: transparent;
      border: none;
      border-radius: 4px;
      cursor: pointer;
      transition: var(--transition);
      position: relative;
      z-index: 2;
    }

    .preview-mode-option.active {
      color: var(--primary-color);
      background: transparent !important;
    }

    .preview-mode-option.active:hover {
      color: #ffffff;
      background: transparent !important;
    }

    /* When the slider is over the active button on hover */
    .preview-mode-selector:has(.preview-mode-option.active:hover) .preview-mode-slider {
      background: var(--primary-color);
    }

    .preview-mode-option:hover:not(.active) {
      color: var(--text-primary);
      background: rgba(67, 97, 238, 0.05);
    }

    .preview-mode-option:disabled {
      color: var(--text-secondary);
      opacity: 0.5;
      cursor: not-allowed;
    }

    /* Modal Dialog Styles */
    .modal-overlay {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0, 0, 0, 0.6);
      backdrop-filter: var(--blur-lg);
      -webkit-backdrop-filter: var(--blur-lg);
      display: none;
      align-items: center;
      justify-content: center;
      z-index: 9999;
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .modal-overlay.show {
      display: flex !important;
    }

    .modal-dialog {
      background: var(--bg-panel);
      backdrop-filter: var(--blur-lg);
      -webkit-backdrop-filter: var(--blur-lg);
      border: 1px solid var(--border-primary);
      border-radius: 16px;
      box-shadow: var(--shadow-xl);
      max-width: 650px;
      width: 90%;
      height: 70vh;
      overflow: hidden;
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      display: flex;
      flex-direction: column;
    }

    .modal-header {
      padding: var(--spacing-lg);
      border-bottom: 1px solid var(--border-secondary);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: var(--spacing-md);
      background: var(--bg-panel-hover);
      border-radius: 16px 16px 0 0;
      flex-shrink: 0;
    }

    .modal-tabs-header {
      display: flex;
      gap: var(--spacing-md);
      padding: 0 var(--spacing-lg);
      background: var(--bg-panel);
      border-bottom: 1px solid var(--border-secondary);
      position: sticky;
      top: 0;
      z-index: 10;
    }

    .modal-tab-btn {
      background: transparent;
      border: none;
      padding: var(--spacing-md) var(--spacing-sm);
      color: var(--text-secondary);
      font-size: 0.95rem;
      font-weight: 500;
      cursor: pointer;
      position: relative;
      transition: color 0.2s ease;
    }

    .modal-tab-btn:hover {
      color: var(--text-primary);
    }

    .modal-tab-btn.active {
      color: var(--primary-color);
      font-weight: 600;
    }

    .modal-tab-btn.active:hover {
      color: var(--text-primary);
      background: transparent;
    }

    .modal-tab-btn.active::after {
      content: '';
      position: absolute;
      bottom: -1px;
      left: 0;
      width: 100%;
      height: 2px;
      background: var(--primary-color);
      border-radius: 2px 2px 0 0;
    }

    .modal-title {
      font-size: 1.5rem;
      font-weight: 700;
      color: var(--text-primary);
      margin: 0;
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .modal-close {
      width: 32px;
      height: 32px;
      min-width: 32px;
      max-width: 32px;
      flex-shrink: 0;
      flex-grow: 0;
      border: 1px solid var(--border-secondary);
      background: var(--bg-control);
      color: var(--text-primary);
      cursor: pointer;
      border-radius: 4px;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      font-size: 1.2rem;
      box-shadow: none;
      transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
    }

    .modal-close svg {
      width: 18px;
      height: 18px;
      display: block;
      flex-shrink: 0;
    }

    .modal-close:hover {
      background: var(--primary-color);
      border-color: var(--primary-color);
      color: #ffffff;
      transform: scale(1.05);
    }

    .modal-body {
      padding: var(--spacing-lg);
      overflow: hidden;
      flex-grow: 1;
      display: flex;
      flex-direction: column;
    }

    .modal-tab-content {
      display: none;
      animation: fadeIn 0.3s ease;
      height: 100%;
      flex-direction: column;
    }

    .modal-tab-content.active {
      display: flex;
    }

    #modal-tab-about {
      overflow-y: auto;
      padding-right: 4px; /* Space for scrollbar */
    }

    #modal-tab-see-also {
      overflow-y: auto;
      padding-right: 4px;
    }

    .see-also-list {
      list-style: none;
      padding: 0;
      margin: 0;
      display: flex;
      flex-direction: column;
      gap: var(--spacing-sm);
    }

    .see-also-item {
      background: var(--bg-control);
      border: 1px solid var(--border-secondary);
      border-radius: 10px;
      overflow: hidden;
      transition: border-color 0.2s ease, box-shadow 0.2s ease;
    }

    .see-also-item.expanded {
      border-color: var(--border-color);
      box-shadow: var(--shadow-sm);
    }

    .see-also-row {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 10px 12px;
    }

    .see-also-link {
      display: flex;
      align-items: center;
      gap: 10px;
      flex: 1;
      min-width: 0;
      color: var(--text-primary);
      text-decoration: none;
      padding: 6px 8px;
      margin: 0;
      border-radius: 8px;
      transition: background 0.15s ease, color 0.15s ease;
    }

    .see-also-link:hover {
      background: rgba(67, 97, 238, 0.06);
      color: var(--text-primary);
    }

    .dark-theme .see-also-link:hover {
      background: rgba(67, 97, 238, 0.14);
    }

    .see-also-icon {
      width: 28px;
      height: 28px;
      flex: 0 0 28px;
      border-radius: 6px;
    }

    .see-also-name {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      font-size: 0.95rem;
      font-weight: 600;
      color: inherit;
    }

    .see-also-toggle {
      width: 36px;
      height: 36px;
      flex: 0 0 36px;
      border-radius: 8px;
      border: 1px solid var(--border-secondary);
      background: var(--bg-control);
      color: var(--text-primary);
      opacity: 0.8;
      padding: 0;
      gap: 0;
      box-shadow: none;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
    }

    .see-also-toggle:hover {
      background: var(--bg-control-hover);
      color: var(--text-primary);
      border-color: var(--border-color);
      opacity: 1;
    }

    .see-also-toggle:active {
      transform: scale(0.98);
    }

    .see-also-chevron {
      width: 22px;
      height: 22px;
      stroke-width: 2.5;
      display: block;
      transition: transform 0.2s ease;
    }

    .see-also-item.expanded .see-also-chevron {
      transform: rotate(180deg);
    }

    .see-also-desc {
      padding: 0 16px 0 54px;
      color: var(--text-secondary);
      font-size: 0.9rem;
      line-height: 1.5;
      max-height: 0;
      overflow: hidden;
      opacity: 0;
      transform: translateY(-2px);
      transition: max-height 0.25s ease, opacity 0.2s ease, transform 0.25s ease;
    }

    .see-also-item.expanded .see-also-desc {
      opacity: 1;
      transform: translateY(0);
      padding-bottom: 12px;
    }

    #modal-tab-license .modal-section {
      height: 100%;
      display: flex;
      flex-direction: column;
      margin-bottom: 0;
    }

    #modal-tab-license .license-text {
      flex: 1;
      max-height: none;
      overflow-y: auto;
    }

    @keyframes fadeIn {
      from { opacity: 0; transform: translateY(5px); }
      to { opacity: 1; transform: translateY(0); }
    }

    .modal-section {
      margin-bottom: var(--spacing-xl);
    }

    .modal-section:last-child {
      margin-bottom: 0;
    }

    .modal-section-title {
      font-size: 1.1rem;
      font-weight: 600;
      color: var(--text-primary);
      margin: 0 0 var(--spacing-md) 0;
      padding-bottom: var(--spacing-sm);
      border-bottom: 1px solid var(--border-secondary);
    }

    .modal-description {
      color: var(--text-secondary);
      line-height: 1.7;
      font-size: 1rem;
      margin: 0;
      max-width: 65ch;
    }

    .modal-footer {
      padding: var(--spacing-lg);
      border-top: 1px solid var(--border-secondary);
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: var(--spacing-md);
      background: var(--bg-panel-hover);
      border-radius: 0 0 16px 16px;
      flex-shrink: 0;
    }

    .modal-footer-actions {
      display: flex;
      justify-content: center;
      gap: var(--spacing-md);
      width: 100%;
      flex-wrap: wrap;
    }

    .modal-copyright {
      margin-top: 4px;
      font-size: 0.75rem;
      color: var(--text-tertiary);
      position: relative;
    }

    .modal-copyright a {
      color: inherit;
      text-decoration: none;
      position: relative;
      transition: color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      display: inline-block;
      padding-bottom: 2px;
    }

    .modal-copyright a:hover {
      color: var(--primary-color);
    }

    .modal-copyright a::after {
      content: '';
      position: absolute;
      bottom: 0;
      left: 0;
      width: 100%;
      height: 1px;
      background-color: var(--primary-color);
      transform: scaleX(0);
      transform-origin: center;
      transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .modal-copyright a:hover::after {
      transform: scaleX(1);
    }

    .modal-tooltip {
      position: absolute;
      bottom: 100%;
      left: 50%;
      transform: translateX(-50%) translateY(0);
      background: rgba(30, 41, 59, 0.28);
      backdrop-filter: blur(18px) saturate(160%);
      -webkit-backdrop-filter: blur(18px) saturate(160%);
      color: #fff;
      padding: 6px 12px;
      border-radius: 6px;
      border: 1px solid rgba(255, 255, 255, 0.1);
      font-size: 0.75rem;
      white-space: nowrap;
      pointer-events: none;
      opacity: 0;
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
      z-index: 10;
      margin-bottom: 8px;
    }

    .modal-tooltip::after {
      content: '';
      position: absolute;
      top: 100%;
      left: 50%;
      margin-left: -4px;
      border-width: 4px;
      border-style: solid;
      border-color: rgba(30, 41, 59, 0.28) transparent transparent transparent;
    }

    .modal-tooltip.visible {
      opacity: 1;
      transform: translateX(-50%) translateY(-4px);
    }

    .dark-theme .modal-tooltip {
      background: rgba(241, 245, 249, 0.28);
      border-color: rgba(255, 255, 255, 0.2);
      color: #0f172a;
    }

    .dark-theme .modal-tooltip::after {
      border-color: rgba(241, 245, 249, 0.28) transparent transparent transparent;
    }

    .feedback-btn {
      background: transparent;
      color: var(--text-primary);
      border: 1px solid var(--border-color);
      padding: 10px 20px;
      border-radius: 8px;
      font-size: 0.9rem;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
      text-decoration: none;
      display: inline-flex;
      align-items: center;
      gap: 8px;
      box-shadow: none;
    }

    .feedback-btn:hover {
      background: var(--bg-control-hover);
      border-color: var(--text-primary);
      transform: translateY(-1px);
    }

    .feedback-btn:active {
      transform: translateY(0);
    }

    .discover-more-btn {
      background: var(--accent-primary);
      color: white;
      border: none;
      padding: 10px 20px;
      border-radius: 8px;
      font-size: 0.9rem;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
      text-decoration: none;
      display: inline-flex;
      align-items: center;
      gap: 8px;
      box-shadow: var(--shadow-sm);
    }

    .discover-more-btn:hover {
      background: var(--primary-hover);
      transform: translateY(-1px);
      box-shadow: var(--shadow-md);
    }

    .discover-more-btn:active {
      transform: translateY(0);
      box-shadow: var(--shadow-sm);
    }

    .modal-features {
      list-style: none;
      padding: 0;
      margin: 0;
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
      gap: var(--spacing-md);
    }

    .modal-features li {
      padding: var(--spacing-sm);
      background: var(--bg-control);
      border-radius: 8px;
      border: 1px solid var(--border-secondary);
      display: flex;
      flex-direction: column;
      gap: 4px;
    }

    .modal-features li strong {
      color: var(--text-primary);
      font-weight: 600;
      font-size: 0.95rem;
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .modal-features li strong::before {
      content: '✓';
      color: var(--primary-color);
      font-weight: bold;
      font-size: 0.9rem;
    }

    .modal-features li span {
      color: var(--text-secondary);
      font-size: 0.85rem;
      line-height: 1.5;
      padding-left: 18px; /* Align with text start (skipping checkmark) */
    }

    .license-text {
      background: var(--bg-control);
      padding: var(--spacing-md);
      border-radius: 8px;
      border: 1px solid var(--border-secondary);
      max-height: 300px;
      overflow-y: auto;
      font-size: 0.9rem;
      color: var(--text-secondary);
      line-height: 1.6;
    }

    .license-text p {
      margin-bottom: var(--spacing-md);
    }

    .license-text p:last-child {
      margin-bottom: 0;
    }

    .license-text h4 {
      color: var(--text-primary);
      margin: var(--spacing-md) 0 var(--spacing-sm) 0;
      font-size: 1rem;
    }

    /* Shortcuts Tab Styles */
    .shortcuts-list {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 12px 24px;
      font-size: 0.95rem;
      color: var(--text-secondary);
      max-height: 400px;
      overflow-y: auto;
      padding-right: 8px;
    }

    .shortcut-item {
      display: contents;
    }

    .shortcut-description {
      align-self: center;
    }

    .shortcut-keys {
      display: flex;
      gap: 4px;
      justify-content: flex-end;
      align-items: center;
    }

    .kbd-key {
      background: var(--bg-control);
      border: 1px solid var(--border-secondary);
      border-radius: 4px;
      padding: 2px 8px;
      font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace;
      font-size: 0.85rem;
      color: var(--text-primary);
      box-shadow: 0 1px 0 var(--border-secondary);
      min-width: 24px;
      text-align: center;
      display: inline-block;
      line-height: 1.4;
    }

    .shortcuts-category {
      grid-column: 1 / -1;
      margin-top: 20px;
      margin-bottom: 8px;
      font-weight: 600;
      color: var(--text-primary);
      border-bottom: 1px solid var(--border-secondary);
      padding-bottom: 6px;
      font-size: 1rem;
    }

    .shortcuts-category:first-child {
      margin-top: 0;
    }

    .modal-version {
      background: var(--bg-control);
      color: var(--accent-primary);
      padding: 4px 8px;
      border: 1px solid var(--border-secondary);
      border-radius: 6px;
      font-size: 0.8rem;
      font-weight: 600;
    }

    /* Modal responsive styles */
    @media (max-width: 600px) {
      .modal-dialog {
        width: 95%;
        margin: var(--spacing-md);
      }

      .modal-header {
        padding: var(--spacing-md);
      }

      .modal-body {
        padding: var(--spacing-md);
      }

      .modal-footer {
        padding: var(--spacing-md);
        flex-direction: column;
        gap: var(--spacing-sm);
      }

      .modal-title {
        font-size: 1.2rem;
        flex-wrap: wrap;
        gap: var(--spacing-sm);
      }

      .modal-version {
        font-size: 0.7rem;
      }

      .discover-more-btn,
      .feedback-btn {
        font-size: 0.9rem;
        padding: 10px 20px;
        width: 100%;
        justify-content: center;
      }
    }

    /* Compare Mode Styles */
    .compare-divider {
      position: absolute;
      top: 0;
      bottom: 0;
      left: 50%;
      width: 2px;
      background: var(--primary-color);
      z-index: 20;
      cursor: col-resize;
      display: flex;
      align-items: center;
      justify-content: center;
      transform: translateX(-50%);
      pointer-events: auto;
      touch-action: none;
    }

    .compare-divider[hidden] {
      display: none !important;
    }

    .compare-handle {
      width: 40px;
      height: 40px;
      background: var(--bg-card);
      border: 2px solid var(--primary-color);
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--primary-color);
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
      transition: transform 0.2s ease, box-shadow 0.2s ease;
      flex-shrink: 0;
      aspect-ratio: 1 / 1;
    }

    .compare-divider:hover .compare-handle,
    .compare-divider.dragging .compare-handle {
      transform: scale(1.1);
      box-shadow: 0 4px 12px rgba(67, 97, 238, 0.25);
    }

    .compare-handle svg {
      width: 20px;
      height: 20px;
      display: block;
    }
