/* ==========================================
   Liquid Glass — Apple Cupertino Aesthetics
   Apple SF Design System, Liquid Specular Refraction,
   Dynamic Contrast Adaptation & Spotless Scrollbars
   ========================================== */

:root {
  --text-color: #000000;
  --bg-color: #FFFFFF;
  --overlay-opacity: 0.15;
  --custom-font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --custom-font-weight: 500;
  --custom-font-size: 16px;
  --bg-blur: 0px;
  --bg-fit: cover;
  --bg-scale: 1;
  --card-bg-opacity: 0.12;
  --card-border-opacity: 0.15;
  --mouse-x: 50%;
  --mouse-y: 50%;
}

/* Global Reset: Eliminate all browser default styles & native scrollbars */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--custom-font-family);
  font-weight: var(--custom-font-weight);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
  -webkit-tap-highlight-color: transparent !important;
  outline: none !important;
}

::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

input, textarea, select, button {
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  outline: none !important;
  border: none;
  background: transparent;
  color: inherit;
}

html, body {
  width: 100%;
  height: 100%;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

body {
  min-height: 100vh;
  background-color: var(--bg-color);
  overflow: hidden;
  position: relative;
  color: var(--text-color);
  font-size: var(--custom-font-size, 16px);
  user-select: none;
  transition: background-color 0.4s cubic-bezier(0.16, 1, 0.3, 1), color 0.3s ease;
}

/* Background layers */
#desktop-bg {
  position: absolute;
  inset: 0;
  background-size: var(--bg-fit, cover);
  background-position: center;
  background-repeat: no-repeat;
  background-image: none;
  filter: blur(var(--bg-blur, 0px));
  transform: scale(var(--bg-scale, 1));
  z-index: 0;
  pointer-events: none;
  transition: filter 0.3s ease, background-image 0.5s ease, transform 0.3s ease, opacity 0.3s ease;
}

#desktop-bg.hidden-bg {
  opacity: 0 !important;
  display: none;
}

.dynamic-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  display: none;
}

.dynamic-canvas.active {
  display: block;
}

body::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, var(--overlay-opacity));
  z-index: 1;
  pointer-events: none;
  transition: background 0.3s ease;
}

/* ==========================================
   Apple Liquid Glass Architecture
   Multi-layered Specular Lighting, Fluid Optics & Depth
   ========================================== */
.liquid-glass {
  --blur: 36px;
  --opacity: 0.12;
  --border-opacity: 0.16;
  --saturate: 180%;
  --contrast: 108%;
  --hue-rotate: 0deg;
  --radius: 22px;

  border-radius: var(--radius);
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, calc(var(--opacity) * 1.5)) 0%,
    rgba(255, 255, 255, calc(var(--opacity) * 0.7)) 100%
  );
  -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--saturate)) contrast(var(--contrast)) hue-rotate(var(--hue-rotate)) url(#liquid-refraction);
  backdrop-filter: blur(var(--blur)) saturate(var(--saturate)) contrast(var(--contrast)) hue-rotate(var(--hue-rotate)) url(#liquid-refraction);
  border: 1px solid rgba(255, 255, 255, var(--border-opacity));
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.42),
    0 4px 14px rgba(0, 0, 0, 0.2),
    inset 0 1px 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -1px 2px 0 rgba(0, 0, 0, 0.25);
  position: absolute;
  z-index: 10;
  color: var(--text-color);
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

/* Smart Dynamic Magnetic Alignment Axes */
.alignment-guides-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}

.snap-guide-line {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  background: var(--text-color);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.9), 0 0 2px rgba(255, 255, 255, 0.95);
  transition: opacity 0.12s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform, opacity, left, top;
}

.snap-guide-line.active {
  opacity: 0.95;
}

.snap-guide-v {
  top: 0;
  bottom: 0;
  width: 1.5px;
  transform: translateX(-50%);
}

.snap-guide-h {
  left: 0;
  right: 0;
  height: 1.5px;
  transform: translateY(-50%);
}

/* Equidistant Spacing Dimension Indicator (|------|) */
.equidistant-guide {
  position: absolute;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  z-index: 10000;
  transition: opacity 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform, left, top, width, height;
}

.equidistant-guide.active {
  opacity: 1;
}

.equidistant-guide-h {
  height: 20px;
  transform: translateY(-50%);
}

.equidistant-guide-h::before {
  content: '';
  position: absolute;
  left: 0;
  top: 2px;
  bottom: 2px;
  width: 2px;
  background: var(--text-color);
  border-radius: 1px;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.8), 0 0 2px rgba(255, 255, 255, 0.95);
}

.equidistant-guide-h::after {
  content: '';
  position: absolute;
  right: 0;
  top: 2px;
  bottom: 2px;
  width: 2px;
  background: var(--text-color);
  border-radius: 1px;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.8), 0 0 2px rgba(255, 255, 255, 0.95);
}

.equidistant-line-h {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1.5px;
  transform: translateY(-50%);
  background: var(--text-color);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.8), 0 0 2px rgba(255, 255, 255, 0.95);
}

.equidistant-guide-v {
  width: 20px;
  transform: translateX(-50%);
}

.equidistant-guide-v::before {
  content: '';
  position: absolute;
  top: 0;
  left: 2px;
  right: 2px;
  height: 2px;
  background: var(--text-color);
  border-radius: 1px;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.8), 0 0 2px rgba(255, 255, 255, 0.95);
}

.equidistant-guide-v::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 2px;
  right: 2px;
  height: 2px;
  background: var(--text-color);
  border-radius: 1px;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.8), 0 0 2px rgba(255, 255, 255, 0.95);
}

.equidistant-line-v {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1.5px;
  transform: translateX(-50%);
  background: var(--text-color);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.8), 0 0 2px rgba(255, 255, 255, 0.95);
}

.equidistant-badge {
  position: relative;
  z-index: 2;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--bg-color, #0a0e1a);
  color: var(--text-color);
  border: 0.5px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
  user-select: none;
  pointer-events: none;
}

body.light-theme .equidistant-badge {
  background: #ffffff;
  color: #1C1C1E;
  border-color: rgba(0, 0, 0, 0.25);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

body.light-theme .equidistant-guide-h::before,
body.light-theme .equidistant-guide-h::after,
body.light-theme .equidistant-line-h,
body.light-theme .equidistant-guide-v::before,
body.light-theme .equidistant-guide-v::after,
body.light-theme .equidistant-line-v {
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
}

.dynamic-alignment-axis {
  position: absolute;
  pointer-events: none;
  background: var(--text-color);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.8), 0 0 2px rgba(255, 255, 255, 0.9);
  z-index: 9999;
  border-radius: 1px;
}

/* Light mode adaptation */
body.light-theme {
  --text-color: #1C1C1E;
}

body.light-theme::after {
  background: rgba(255, 255, 255, var(--overlay-opacity));
}

body.light-theme .liquid-glass {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.82) 0%,
    rgba(255, 255, 255, 0.62) 100%
  );
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: #1C1C1E;
  box-shadow:
    0 20px 48px rgba(0, 0, 0, 0.08),
    0 2px 8px rgba(0, 0, 0, 0.04),
    inset 0 1px 2px 0 rgba(255, 255, 255, 0.95),
    inset 0 -1px 1px 0 rgba(0, 0, 0, 0.04);
}

body.light-theme .settings-trigger {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(0, 0, 0, 0.14);
  color: #1C1C1E;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

body.light-theme .control-panel,
body.light-theme .widget-hub-content,
body.light-theme .color-studio-content,
body.light-theme .cropper-modal-content,
body.light-theme .dock-manager-content {
  background: rgba(255, 255, 255, 0.96);
  border: 0.5px solid rgba(0, 0, 0, 0.12);
  color: #1C1C1E;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.05);
}

body.light-theme .panel-title,
body.light-theme .widget-item-title,
body.light-theme .time-display,
body.light-theme .search-input-box,
body.light-theme .search-history-item,
body.light-theme .custom-dropdown-trigger,
body.light-theme .custom-dropdown-item {
  color: #1C1C1E;
}

body.light-theme .control-label {
  color: rgba(28, 28, 30, 0.92);
}

body.light-theme .control-sublabel,
body.light-theme .widget-item-desc,
body.light-theme .panel-section-title,
body.light-theme .search-history-header,
body.light-theme .tools-label,
body.light-theme .date-display,
body.light-theme .history-empty-hint {
  color: rgba(28, 28, 30, 0.7);
}

body.light-theme .panel-section-title {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

body.light-theme .time-display {
  color: #1C1C1E;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

body.light-theme .date-display {
  color: rgba(28, 28, 30, 0.75);
}

body.light-theme .settings-segmented-nav {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.08);
}

body.light-theme .segmented-btn {
  color: rgba(28, 28, 30, 0.65);
}

body.light-theme .segmented-btn:hover {
  color: #1C1C1E;
}

body.light-theme .segmented-btn.active {
  background: #FFFFFF;
  color: #1C1C1E;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body.light-theme .search-wrapper {
  background: rgba(255, 255, 255, 0.85);
  border: 0.5px solid rgba(0, 0, 0, 0.14);
}

body.light-theme .search-icon {
  color: #1C1C1E;
  opacity: 0.65;
}

body.light-theme .clear-search-btn {
  color: #1C1C1E;
  opacity: 0.6;
}

body.light-theme .search-input-box {
  color: #1C1C1E;
}

body.light-theme .search-input-box[data-placeholder]:empty::before {
  color: rgba(28, 28, 30, 0.45) !important;
}

body.light-theme .search-history-dropdown {
  background: rgba(255, 255, 255, 0.98);
  border: 0.5px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
}

body.light-theme .search-history-title {
  color: rgba(28, 28, 30, 0.65);
}

body.light-theme .clear-all-history-btn {
  color: rgba(28, 28, 30, 0.7);
}

body.light-theme .search-history-item {
  color: #1C1C1E;
}

body.light-theme .search-history-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

body.light-theme .history-icon {
  color: #1C1C1E;
}

body.light-theme .history-text {
  color: #1C1C1E;
}

body.light-theme .history-del-btn {
  color: rgba(28, 28, 30, 0.7);
}

body.light-theme .history-del-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  color: #1C1C1E;
}

body.light-theme .custom-dropdown-trigger {
  background: rgba(0, 0, 0, 0.05);
  border: 0.5px solid rgba(0, 0, 0, 0.12);
  color: #1C1C1E;
}

body.light-theme .custom-dropdown-trigger:hover {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.25);
}

body.light-theme .custom-dropdown-menu {
  background: var(--bg-color, #ffffff);
  border: 0.5px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
}

body.light-theme .custom-dropdown-item {
  color: #1C1C1E;
}

body.light-theme .custom-dropdown-item:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #1C1C1E;
}

body.light-theme .custom-dropdown-item.active {
  background: rgba(0, 0, 0, 0.12);
  color: #1C1C1E;
  font-weight: 600;
}

body.light-theme .card-drag-handle {
  color: #1C1C1E;
}

body.light-theme .custom-number-box {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.1);
  color: #1C1C1E;
}

body.light-theme .custom-number-box .num-btn {
  color: #1C1C1E;
}

body.light-theme .custom-editable {
  border-bottom-color: rgba(0, 0, 0, 0.25);
  color: #1C1C1E;
}

body.light-theme .val-badge {
  background: rgba(0, 0, 0, 0.06);
  color: #1C1C1E;
}

body.light-theme .custom-toggle {
  background: rgba(0, 0, 0, 0.16);
}

body.light-theme .custom-slider {
  background: rgba(0, 0, 0, 0.12);
}

body.light-theme .custom-slider-thumb {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

body.light-theme .custom-dropzone {
  color: rgba(28, 28, 30, 0.75);
  background: rgba(0, 0, 0, 0.03);
  border: 1.5px dashed rgba(0, 0, 0, 0.18);
}

body.light-theme .custom-dropzone:hover,
body.light-theme .custom-dropzone.dragover {
  border-color: var(--accent-color);
  background: rgba(0, 0, 0, 0.06);
  color: #1C1C1E;
}

body.light-theme .liquid-dock {
  background: rgba(255, 255, 255, 0.65);
  border: 0.5px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.12), inset 0 0.5px 0 rgba(255, 255, 255, 0.85);
}

body.light-theme .dock-item {
  background: rgba(0, 0, 0, 0.06);
  border: 0.5px solid rgba(0, 0, 0, 0.08);
  color: #1C1C1E;
}

body.light-theme .dock-item:hover {
  background: rgba(0, 0, 0, 0.12);
  border-color: rgba(0, 0, 0, 0.18);
  color: #000000;
}

body.light-theme .dock-item .dock-tooltip {
  background: rgba(255, 255, 255, 0.95);
  color: #1C1C1E;
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

body.light-theme .dock-add-btn {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.15);
  color: rgba(28, 28, 30, 0.6);
}

body.light-theme .dock-add-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  color: #000000;
}

body.light-theme .dock-link-row {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
}

body.light-theme .dock-link-title {
  color: #1C1C1E;
}

body.light-theme .dock-link-url {
  color: rgba(28, 28, 30, 0.55);
}

body.light-theme .dock-link-badge {
  background: rgba(0, 0, 0, 0.08);
  color: #1C1C1E;
}

body.light-theme .color-target-tab {
  background: rgba(0, 0, 0, 0.05);
  color: rgba(28, 28, 30, 0.65);
}

body.light-theme .color-target-tab.active {
  color: var(--accent-color);
}

body.light-theme .palette-card {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}

body.light-theme .palette-card-name {
  color: rgba(28, 28, 30, 0.85);
}

body.light-theme .palette-card:hover {
  border-color: rgba(0, 0, 0, 0.2);
}

body.light-theme .color-swatch-item,
body.light-theme .color-hex-row,
body.light-theme .color-hex-mini {
  color: #1C1C1E;
}

body.light-theme .panel-close-btn {
  background: rgba(0, 0, 0, 0.06);
  color: #1C1C1E;
}

body.light-theme .secondary-btn,
body.light-theme .custom-btn.del-btn,
body.light-theme .custom-btn.reset-all-btn {
  background: rgba(0, 0, 0, 0.06);
  color: #1C1C1E;
  border-color: rgba(0, 0, 0, 0.12);
}

body.light-theme .secondary-btn:hover,
body.light-theme .custom-btn.del-btn:hover,
body.light-theme .custom-btn.reset-all-btn:hover {
  background: rgba(0, 0, 0, 0.12);
}

body.light-theme .crop-aspect-btn {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.12);
  color: #1C1C1E;
}

body.light-theme .crop-aspect-btn.active {
  background: var(--accent-color);
  color: var(--accent-text);
  border-color: var(--accent-color);
}

body.light-theme .note-textarea,
body.light-theme .note-preview,
body.light-theme .note-preview p,
body.light-theme .note-preview li,
body.light-theme .note-preview h1,
body.light-theme .note-preview h2,
body.light-theme .note-preview h3,
body.light-theme .note-preview blockquote,
body.light-theme .note-preview code {
  color: #1C1C1E;
}

body.light-theme .note-textarea[data-placeholder]:empty::before {
  color: rgba(0, 0, 0, 0.38);
}

body.light-theme .note-preview code,
body.light-theme .note-preview pre {
  background: rgba(0, 0, 0, 0.06);
  color: #1C1C1E;
}

body.light-theme .widget-item {
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

body.light-theme input,
body.light-theme textarea {
  color: #1C1C1E;
}

body.light-theme input::placeholder,
body.light-theme textarea::placeholder {
  color: rgba(28, 28, 30, 0.45);
}

body.light-theme .custom-slider-track {
  background: rgba(0, 0, 0, 0.1);
}

/* ==========================================
   Draggable Cards & Top Handle Dragging
   ========================================== */
.draggable-card {
  position: absolute;
}

.draggable-card .card-drag-handle {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%) rotate(90deg) !important;
  width: 28px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  opacity: 0.35;
  font-size: 14px;
  color: var(--text-color);
  border-radius: 6px;
  transition: opacity 0.2s ease, background-color 0.2s ease, transform 0.15s ease;
  z-index: 25;
  user-select: none;
}

.draggable-card:hover .card-drag-handle {
  opacity: 0.8;
}

.draggable-card .card-drag-handle:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.18);
  transform: translateX(-50%) rotate(90deg) scale(1.1);
}

.draggable-card .card-drag-handle:active {
  cursor: grabbing;
  transform: translateX(-50%) rotate(90deg) scale(0.95);
}

/* Mobile: Show drag handle for full control */
@media (max-width: 768px) {
  .draggable-card .card-drag-handle {
    opacity: 0.5;
    width: 28px;
    height: 20px;
    font-size: 14px;
    display: flex !important;
  }
  
  .draggable-card:hover .card-drag-handle {
    opacity: 1;
  }
  
  #clock-card .card-drag-handle,
  #search-card .card-drag-handle,
  .liquid-dock .card-drag-handle {
    display: flex !important;
    align-items: center;
    justify-content: center;
  }
}

/* Control Panel Drag Handle: Rotated 90 degrees */
.control-panel-drag-handle {
  position: static !important;
  transform: rotate(90deg) !important;
  width: 24px;
  height: 24px;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  flex-shrink: 0 !important;
  cursor: grab;
  opacity: 0.55;
  font-size: 14px;
  color: var(--text-color);
  border-radius: 6px;
  transition: opacity 0.2s ease, background-color 0.2s ease, transform 0.15s ease;
  user-select: none;
  margin-right: 4px;
}

.control-panel-drag-handle:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.18);
  transform: rotate(90deg) scale(1.1) !important;
}

.control-panel-drag-handle:active {
  cursor: grabbing;
  transform: rotate(90deg) scale(0.95) !important;
}

/* Dock Drag Handle: Kept strictly horizontal (unrotated 0deg) like search-wrapper */
.dock-drag-handle {
  position: static !important;
  transform: none !important;
  writing-mode: horizontal-tb !important;
  width: 24px;
  min-width: 24px;
  height: 28px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  flex-shrink: 0 !important;
  cursor: grab;
  opacity: 0.55;
  font-size: 14px;
  color: var(--text-color);
  border-radius: 6px;
  transition: opacity 0.2s ease, background-color 0.2s ease;
  user-select: none;
  margin-right: 2px;
}

.dock-drag-handle:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
  transform: none !important;
}

.dock-drag-handle:active {
  cursor: grabbing;
  transform: scale(0.95) !important;
}

.draggable-card.dragging {
  cursor: grabbing !important;
  z-index: 100 !important;
  transform: scale(1.01);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.draggable-card.dragging [contenteditable="true"],
.draggable-card.dragging input,
.draggable-card.dragging textarea {
  pointer-events: none !important;
}

.card-body {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
}

/* ==========================================
   Apple Control Center & Root Settings Menu
   ========================================== */
.settings-trigger {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 200;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.08);
  border: 0.5px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  color: var(--text-color);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.settings-trigger:hover {
  background: rgba(255, 255, 255, 0.16);
  transform: rotate(30deg) scale(1.05);
  border-color: rgba(255, 255, 255, 0.35);
}

.control-panel {
  position: absolute;
  top: 76px;
  right: 24px;
  width: 440px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 96px);
  padding: 22px;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
  display: none;
  scrollbar-width: thin;
  border-radius: var(--radius, 22px) !important;
  animation: appleSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
  resize: none !important;
  user-select: auto;
  word-break: break-word;
  -webkit-overflow-scrolling: touch; /* Smooth scroll on iOS */
}

.control-panel.active {
  display: block;
}

.control-panel.positioned {
  animation: none !important;
}

/* Enable smooth scrolling with momentum for control panel */
.control-panel::-webkit-scrollbar {
  width: 6px;
}

.control-panel::-webkit-scrollbar-track {
  background: transparent;
}

.control-panel::-webkit-scrollbar-thumb {
  background: rgba(128, 128, 128, 0.3);
  border-radius: 3px;
}

.control-panel:hover::-webkit-scrollbar-thumb {
  background: rgba(128, 128, 128, 0.5);
}

.panel-resize-handle {
  display: none !important;
  pointer-events: none !important;
}

.settings-drag-handle {
  display: none !important;
  pointer-events: none !important;
}

@keyframes appleSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-title {
  font-size: calc(var(--custom-font-size, 16px) * 1.05);
  font-weight: 700;
  color: var(--text-color);
  letter-spacing: -0.02em;
}

.panel-close-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.panel-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.08);
}

/* Apple Segmented Nav Switcher */
.settings-segmented-nav {
  display: flex;
  background: rgba(0, 0, 0, 0.25);
  border: 0.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 3px;
  margin-bottom: 18px;
  gap: 2px;
}

.segmented-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  padding: 7px 4px;
  border-radius: 9px;
  font-size: calc(var(--custom-font-size, 16px) * 0.78);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
  text-align: center;
}

.segmented-btn:hover {
  color: #fff;
}

.segmented-btn.active {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.settings-tab-content {
  display: none;
}

.settings-tab-content.active {
  display: block;
}

.panel-section-title {
  font-size: calc(var(--custom-font-size, 16px) * 0.72);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.5);
  margin: 16px 0 10px;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 5px;
}

.control-group {
  margin-bottom: 14px;
}

.control-group.flex-row {
  display: flex;
  gap: 8px;
}

.control-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: calc(var(--custom-font-size, 16px) * 0.84);
  color: rgba(255, 255, 255, 0.88);
  margin-bottom: 5px;
  gap: 8px;
}

.control-sublabel {
  font-size: calc(var(--custom-font-size, 16px) * 0.72);
  color: rgba(255, 255, 255, 0.45);
  line-height: 1.4;
  margin-top: 3px;
}

.val-badge {
  font-size: calc(var(--custom-font-size, 16px) * 0.72);
  background: rgba(255, 255, 255, 0.12);
  padding: 1px 6px;
  border-radius: 6px;
  font-family: monospace;
}

/* ==========================================
   UI Controls (Buttons, Toggles, Sliders)
   ========================================== */
.custom-btn {
  border: none;
  padding: 9px 16px;
  border-radius: 12px;
  font-weight: 600;
  font-size: calc(var(--custom-font-size, 16px) * 0.82);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.custom-btn.theme-btn {
  background: var(--text-color);
  color: var(--bg-color);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  width: 100%;
}

.custom-btn.secondary-btn {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-color);
  border: 0.5px solid rgba(255, 255, 255, 0.16);
  flex: 0 0 auto;
  white-space: nowrap;
}

.custom-btn.del-btn {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-color);
  border: 0.5px solid rgba(255, 255, 255, 0.14);
  flex: 0 0 auto;
  white-space: nowrap;
}

.custom-btn.del-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: var(--text-color);
}

.custom-btn.reset-all-btn {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-color);
  border: 0.5px solid rgba(255, 255, 255, 0.16);
  width: 100%;
  margin-top: 16px;
  padding: 10px 16px;
}

.custom-btn.reset-all-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: var(--text-color);
  border-color: rgba(255, 255, 255, 0.25);
}

.custom-btn.sm {
  padding: 6px 12px;
  font-size: calc(var(--custom-font-size, 16px) * 0.75);
  border-radius: 8px;
  width: auto;
}

.custom-btn.xs {
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 6px;
  width: auto;
  min-width: max-content;
  flex: 0 0 auto;
  white-space: nowrap !important;
  line-height: 1.2;
}

.custom-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.custom-btn:active {
  transform: scale(0.97);
}

/* iOS Toggle */
.custom-toggle {
  width: 44px;
  height: 26px;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 13px;
  position: relative;
  cursor: pointer;
  transition: background 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}

.custom-toggle.active {
  background: var(--text-color);
}

.custom-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  background: var(--bg-color, #000);
  border-radius: 50%;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), background 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.custom-toggle.active::after {
  transform: translateX(18px);
  background: var(--bg-color, #000);
}

body.light-theme .custom-toggle::after {
  background: #ffffff;
}

body.light-theme .custom-toggle.active::after {
  background: var(--bg-color, #ffffff);
}

/* Apple Slider */
.custom-slider {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  position: relative;
  cursor: pointer;
  margin: 10px 0 6px;
}

.custom-slider-fill {
  height: 100%;
  background: var(--text-color);
  border-radius: 3px;
  width: 50%;
  pointer-events: none;
}

.custom-slider-thumb {
  width: 18px;
  height: 18px;
  background: var(--text-color);
  border-radius: 50%;
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  transition: transform 0.1s;
}

.custom-slider:hover .custom-slider-thumb {
  transform: translateX(-50%) scale(1.15);
}

.hue-slider .custom-slider-fill {
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}

/* Dropzone */
.custom-dropzone {
  border: 1.5px dashed rgba(255, 255, 255, 0.2);
  padding: 18px;
  border-radius: 16px;
  text-align: center;
  font-size: calc(var(--custom-font-size, 16px) * 0.82);
  cursor: pointer;
  transition: all 0.2s ease;
  color: rgba(255, 255, 255, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.03);
}

.custom-dropzone:hover,
.custom-dropzone.dragover {
  border-color: var(--accent-color);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

/* Number box */
.custom-number-box {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 4px;
  border-radius: 6px;
  flex-shrink: 0;
}

.custom-number-box .custom-editable {
  min-width: 26px;
  max-width: 40px;
  text-align: center;
  font-size: 10px;
  border-bottom: none;
}

.num-btn {
  width: 16px;
  height: 16px;
  line-height: 14px;
  text-align: center;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  flex-shrink: 0;
}

.num-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.custom-editable {
  outline: none;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.3);
  padding: 2px 4px;
  display: inline-block;
  color: inherit;
  user-select: text;
}

/* Dropdowns */
.custom-dropdown {
  position: relative;
}

.custom-dropdown-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 0.5px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  cursor: pointer;
  font-size: calc(var(--custom-font-size, 16px) * 0.82);
  color: var(--text-color);
  transition: all 0.2s ease;
  gap: 8px;
}

.custom-dropdown-trigger.compact {
  padding: 7px 12px;
  font-size: calc(var(--custom-font-size, 16px) * 0.82);
  background: rgba(255, 255, 255, 0.1);
  border: 0.5px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  min-width: 96px;
  white-space: nowrap;
}

.custom-dropdown-trigger:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.35);
}

.custom-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 100%;
  background: var(--bg-color, rgba(18, 18, 20, 0.95));
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 0.5px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  z-index: 1000;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: appleSlideIn 0.2s ease;
}

.custom-dropdown-menu.drop-up {
  top: auto;
  bottom: calc(100% + 6px);
}

.custom-dropdown.open .custom-dropdown-menu,
.custom-dropdown-menu.active {
  display: block !important;
}

.custom-dropdown-item {
  padding: 10px 14px;
  font-size: calc(var(--custom-font-size, 16px) * 0.82);
  cursor: pointer;
  transition: background 0.15s;
  color: var(--text-color);
}

.custom-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-color);
}

.custom-dropdown-item.active {
  background: rgba(255, 255, 255, 0.18);
  color: var(--text-color);
  font-weight: 600;
}

/* ==========================================
   Custom Wallpaper Styles & Saved Wallpapers
   ========================================== */
.color-input-native {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.saved-wallpapers-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
  max-height: 160px;
  overflow-y: auto;
}

.saved-wallpaper-card {
  height: 60px;
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  border: 0.5px solid rgba(255, 255, 255, 0.15);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: flex-end;
  padding: 4px 6px;
}

.saved-wallpaper-card:hover {
  transform: scale(1.03);
  border-color: var(--accent-color);
}

.saved-wallpaper-card .sw-title {
  font-size: 10px;
  color: var(--text-color);
  background: rgba(0, 0, 0, 0.6);
  padding: 1px 4px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.saved-wallpaper-card .sw-del {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: var(--text-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  opacity: 0;
  transition: opacity 0.15s;
}

.saved-wallpaper-card:hover .sw-del {
  opacity: 1;
}

.saved-wallpaper-card .sw-del:hover {
  background: rgba(255, 255, 255, 0.3);
}

.wallpaper-preset-card.active {
  box-shadow: 0 0 0 2px var(--accent-color), 0 6px 20px rgba(0, 0, 0, 0.5);
  transform: scale(1.03);
}

.wallpaper-preset-card span {
  position: absolute;
  bottom: 4px;
  left: 6px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  background: rgba(0, 0, 0, 0.45);
  padding: 1px 4px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
}

/* ==========================================
   Color Studio & Palettes (Zero Border on SV Box)
   ========================================== */
.palette-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.palette-grid.compact {
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.palette-card {
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
  border: 0.5px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
}

.palette-card:hover {
  transform: scale(1.04);
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
}

.palette-card.active {
  border-color: var(--accent-color);
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 2px var(--accent-color);
}

.palette-card-name {
  display: none !important;
}

.palette-card-swatches {
  display: flex;
  gap: 6px;
  width: 100%;
  align-items: center;
  justify-content: center;
}

.palette-card-swatches span {
  flex: 1;
  height: 22px;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  border: 0.5px solid rgba(255, 255, 255, 0.1);
}

.color-target-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.color-target-tab {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  border-radius: 10px;
  font-size: 12px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.65);
  transition: all 0.2s;
}

.color-target-tab.active {
  background: color-mix(in srgb, var(--accent-color) 25%, transparent);
  color: var(--accent-color);
  font-weight: 600;
}

.color-picker-preview {
  width: 100%;
  height: 36px;
  border-radius: 10px;
  margin-bottom: 12px;
  border: 0.5px solid rgba(255, 255, 255, 0.2);
}

/* color-picker-sv strictly without border as requested */
.color-picker-sv {
  position: relative;
  width: 100%;
  height: 140px;
  border-radius: 12px;
  cursor: crosshair;
  margin-bottom: 12px;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  overflow: hidden;
  background: linear-gradient(to bottom, transparent, #000), linear-gradient(to right, #fff, hsl(210, 100%, 50%));
}

.color-picker-sv-cursor {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.color-hex-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  margin-top: 10px;
}

.color-current-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.color-swatch-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 0.5px solid rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

.color-hex-mini {
  font-size: 11px;
  min-width: 64px;
}

/* ==========================================
   Modals (Widget Hub, Cropper, Color Studio, Dock Manager)
   ========================================== */
.widget-hub-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 300;
  align-items: center;
  justify-content: center;
}

.widget-hub-modal.active {
  display: flex;
}

.widget-hub-content,
.color-studio-content,
.cropper-modal-content,
.dock-manager-content {
  width: 440px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 60px);
  padding: 26px;
  position: relative;
  overflow-y: auto;
  scrollbar-width: none;
  border-radius: var(--radius, 22px) !important;
  animation: appleSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.cropper-modal-content {
  width: 640px;
}

.widget-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.08);
  gap: 12px;
}

.widget-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-color);
}

.widget-item-desc {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 2px;
}

/* Cropper Modal */
.cropper-container {
  width: 100%;
  height: 320px;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0.5px solid rgba(255, 255, 255, 0.15);
}

#crop-preview-canvas {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.cropper-controls {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.crop-aspect-btn {
  flex: 1;
  padding: 7px 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 0.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.crop-aspect-btn.active {
  background: var(--accent-color);
  border-color: var(--accent-color);
}

/* ==========================================
   Clock Card Component & Dynamic Sizing
   ========================================== */
#clock-card {
  width: 360px;
  min-width: 200px;
  min-height: 120px;
  max-width: calc(100vw - 40px);
  position: absolute;
  left: calc(50% - 180px);
  top: 18%;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  overflow: visible;
}

#clock-card .card-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  padding: 0;
  box-sizing: border-box;
}

.time-display {
  font-size: calc(var(--custom-font-size, 16px) * 4);
  font-weight: 700;
  color: var(--text-color);
  line-height: 1.1;
  letter-spacing: -0.03em;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  transition: font-size 0.1s ease;
  user-select: none;
  overflow: visible;
  white-space: nowrap;
  max-width: 100%;
}

.date-display {
  font-size: calc(var(--custom-font-size, 16px) * 0.95);
  opacity: 0.8;
  color: var(--text-color);
  margin-top: 8px;
  font-weight: 500;
  transition: font-size 0.1s ease;
  user-select: none;
  overflow: visible;
  white-space: nowrap;
  max-width: 100%;
}

.clock-resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 24px;
  height: 24px;
  cursor: nwse-resize;
  z-index: 30;
  user-select: none;
  background: transparent;
  border: none;
}

.clock-resize-handle::after {
  display: none !important;
  content: none !important;
}

/* ==========================================
   Search Card & Auto-Loading Search History Dropdown (Resizable)
   ========================================== */
#search-card {
  width: 620px;
  min-width: 260px;
  min-height: 48px;
  max-width: calc(100vw - 32px);
  position: absolute;
  left: calc(50% - 310px);
  top: calc(18% + 190px);
  box-sizing: border-box;
}

#search-card .card-body {
  padding: 8px 12px;
  position: relative;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.search-resize-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 14px;
  cursor: ew-resize;
  z-index: 30;
  user-select: none;
  background: transparent;
  border: none;
}

.search-resize-handle::after {
  display: none !important;
  content: none !important;
}

.search-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.25);
  border: 0.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 8px 12px;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none !important;
  box-shadow: none !important;
}

.search-wrapper:focus-within,
.search-wrapper:focus {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: none !important;
  outline: none !important;
}

body.light-theme .search-wrapper {
  background: rgba(255, 255, 255, 0.35);
  border-color: rgba(0, 0, 0, 0.08);
}

body.light-theme .search-wrapper:focus-within,
body.light-theme .search-wrapper:focus {
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: none !important;
  outline: none !important;
}

#search-card .card-drag-handle,
.search-wrapper .card-drag-handle {
  position: static !important;
  transform: none !important;
  width: 26px;
  min-width: 26px;
  height: 26px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  flex-shrink: 0 !important;
  cursor: grab;
  opacity: 0.65;
  font-size: 14px;
  color: var(--text-color);
  border-radius: 6px;
  transition: opacity 0.2s ease, background-color 0.2s ease;
  user-select: none;
  margin-right: 2px;
}

#search-card:hover .card-drag-handle,
.search-wrapper:hover .card-drag-handle {
  opacity: 0.9;
}

#search-card .card-drag-handle:hover,
.search-wrapper .card-drag-handle:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.14);
}

#search-card .card-drag-handle:active,
.search-wrapper .card-drag-handle:active {
  cursor: grabbing;
}

.search-icon {
  opacity: 0.55;
  flex-shrink: 0;
}

.search-input-box {
  flex: 1 1 0;
  min-width: 0;
  outline: none;
  color: var(--text-color);
  font-size: calc(var(--custom-font-size, 16px) * 0.95);
  min-height: 22px;
  user-select: text;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.search-input-box[data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

.clear-search-btn {
  cursor: pointer;
  opacity: 0.45;
  font-size: 14px;
  flex-shrink: 0;
  padding: 2px 6px;
  transition: opacity 0.15s;
}

.clear-search-btn:hover {
  opacity: 0.9;
}

/* Auto-loading Search History Dropdown */
.search-history-dropdown {
  display: none;
  margin-top: 8px;
  background: rgba(20, 24, 36, 0.92);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 0.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  animation: appleSlideIn 0.2s ease;
}

.search-history-dropdown.active {
  display: block;
}

.search-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.08);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.clear-all-history-btn {
  background: transparent;
  border: none;
  color: var(--text-color);
  opacity: 0.6;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.clear-all-history-btn:hover {
  opacity: 1;
}

.search-history-list {
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: none;
}

.search-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  font-size: calc(var(--custom-font-size, 16px) * 0.82);
  color: var(--text-color);
  cursor: pointer;
  transition: background 0.15s ease;
  gap: 8px;
}

.search-history-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.history-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  overflow: hidden;
}

.history-icon {
  opacity: 0.45;
  flex-shrink: 0;
}

.history-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-del-btn {
  opacity: 0;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-color);
  transition: all 0.15s ease;
}

.search-history-item:hover .history-del-btn {
  opacity: 0.7;
}

.history-del-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
}

.history-empty-hint {
  padding: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-color);
  opacity: 0.5;
}

/* ==========================================
   Memo / Note Card Component & Markdown Engine
   ========================================== */
.note-card {
  width: 290px;
  min-width: 200px;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  position: absolute;
}

.note-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.08);
  user-select: none;
}

body.light-theme .note-header {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

.note-header-spacer {
  flex: 1;
}

.note-del-btn {
  padding: 2px 6px !important;
  font-size: 11px !important;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.note-del-btn:hover {
  opacity: 1;
}

.note-card .card-drag-handle {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%) rotate(90deg) !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  opacity: 0.35;
  width: 28px;
  height: 20px;
  font-size: 14px;
  cursor: grab;
  border-radius: 6px;
  transition: opacity 0.2s ease, background-color 0.2s ease, transform 0.15s ease;
  user-select: none;
  z-index: 25;
}

.note-card:hover .card-drag-handle {
  opacity: 0.85;
}

.note-card .card-drag-handle:hover {
  opacity: 1;
  transform: translateX(-50%) rotate(90deg) scale(1.1);
  background: rgba(255, 255, 255, 0.18);
}

.note-card .card-drag-handle:active {
  transform: translateX(-50%) rotate(90deg) scale(0.95);
  cursor: grabbing;
}

.note-resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 24px;
  height: 24px;
  cursor: nwse-resize;
  z-index: 30;
  user-select: none;
  background: transparent;
  border: none;
}

.note-resize-handle::after {
  display: none !important;
  content: none !important;
}

.note-card .card-body {
  padding: 12px 16px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  cursor: default;
}

.note-textarea {
  width: 100%;
  flex: 1;
  outline: none;
  color: var(--text-color);
  font-size: calc(var(--custom-font-size, 16px) * 0.88);
  line-height: 1.55;
  user-select: text;
  overflow-y: auto;
  scrollbar-width: none;
  white-space: pre-wrap;
  word-break: break-word;
  background: transparent;
  border: none;
  resize: none;
}

.note-textarea[data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: var(--text-color);
  opacity: 0.4;
  pointer-events: none;
}

.note-preview {
  width: 100%;
  flex: 1;
  color: var(--text-color);
  font-size: calc(var(--custom-font-size, 16px) * 0.88);
  line-height: 1.55;
  overflow-y: auto;
  scrollbar-width: none;
  user-select: text;
  word-break: break-word;
}

.note-preview h1, .note-preview h2, .note-preview h3 {
  color: var(--text-color);
  margin: 4px 0 6px;
  font-weight: 700;
}
.note-preview h1 { font-size: 1.25em; border-bottom: 0.5px solid rgba(255, 255, 255, 0.15); padding-bottom: 2px; }
.note-preview h2 { font-size: 1.1em; }
.note-preview h3 { font-size: 1em; }

.note-preview p {
  margin-bottom: 6px;
  color: var(--text-color);
}

.note-preview ul, .note-preview ol {
  margin: 4px 0 6px 18px;
  color: var(--text-color);
}

.note-preview li {
  margin-bottom: 3px;
  color: var(--text-color);
}

.note-preview blockquote {
  border-left: 3px solid var(--accent-color);
  padding-left: 8px;
  margin: 6px 0;
  opacity: 0.85;
  color: var(--text-color);
}

.note-preview code {
  background: rgba(255, 255, 255, 0.12);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
  color: var(--text-color);
}

.note-preview pre {
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 10px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 6px 0;
}

.note-preview pre code {
  background: transparent;
  padding: 0;
}

.note-preview hr {
  border: none;
  border-top: 0.5px solid rgba(255, 255, 255, 0.15);
  margin: 8px 0;
}

.note-preview a {
  color: var(--accent-color);
  text-decoration: underline;
}

.note-preview .task-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 3px 0;
  list-style-type: none;
}

.note-preview .task-checkbox {
  margin-top: 3px;
  cursor: pointer;
  accent-color: var(--accent-color);
  width: 14px;
  height: 14px;
}

.note-preview .task-done {
  text-decoration: line-through;
  opacity: 0.6;
}

/* ==========================================
   Apple Liquid Bookmarks Dock (User-Customizable & Movable, Non-Resizable)
   ========================================== */
.liquid-dock {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(10, 14, 24, 0.45);
  border: 0.5px solid rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  backdrop-filter: blur(32px) saturate(140%);
  -webkit-backdrop-filter: blur(32px) saturate(140%);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35), inset 0 0.5px 0 rgba(255, 255, 255, 0.3);
  z-index: 30;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  box-sizing: border-box;
  width: max-content !important;
  max-width: calc(100vw - 32px);
  overflow-x: auto;
  scrollbar-width: none;
  resize: none !important;
  user-select: none;
}

.liquid-dock.positioned {
  bottom: auto !important;
  transform: none !important;
}

.liquid-dock.dragging {
  cursor: grabbing !important;
  z-index: 100 !important;
  transition: none !important;
  transform: none !important;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.dock-drag-handle,
#liquid-dock .card-drag-handle {
  position: static !important;
  transform: none !important;
  writing-mode: horizontal-tb !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  cursor: grab;
  user-select: none;
  font-size: 14px;
  opacity: 0.6;
  color: var(--text-color);
  padding: 4px 6px;
  border-radius: 6px;
  margin-right: 2px;
  flex-shrink: 0;
  transition: opacity 0.2s, background-color 0.2s;
}

.dock-drag-handle:hover,
#liquid-dock .card-drag-handle:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
  transform: none !important;
}

.dock-drag-handle:active,
#liquid-dock .card-drag-handle:active {
  transform: scale(0.95) !important;
  cursor: grabbing;
}

.dock-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 0.5px solid rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  text-decoration: none;
  font-weight: 700;
  font-size: calc(var(--custom-font-size, 16px) * 0.82);
  position: relative;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.dock-item:hover {
  transform: translateY(-4px) scale(1.1);
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.dock-item .dock-tooltip {
  position: absolute;
  top: -30px;
  opacity: 0;
  transform: translateY(4px);
  transition: all 0.15s ease;
  pointer-events: none;
  background: rgba(10, 14, 22, 0.9);
  color: #FFFFFF;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
  border: 0.5px solid rgba(255, 255, 255, 0.15);
}

.dock-item:hover .dock-tooltip {
  opacity: 1;
  transform: translateY(0);
}

.dock-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 0.5px dashed rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.6);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dock-add-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
  border-color: var(--accent-color);
  transform: scale(1.08);
}

/* Dock Manager List in Settings */
.dock-links-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  max-height: 220px;
  overflow-y: auto;
}

.dock-link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 0.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  gap: 8px;
}

.dock-link-badge {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  flex-shrink: 0;
}

.dock-link-info {
  flex: 1;
  min-width: 0;
}

.dock-link-title {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dock-link-url {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.45);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dock-link-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* Modal Inputs & Light Theme Adaptation */
.dock-modal-input,
.custom-panel-input {
  width: 100%;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  border: 0.5px solid rgba(255, 255, 255, 0.2);
  color: var(--text-color);
  font-size: calc(var(--custom-font-size, 16px) * 0.82);
  transition: all 0.2s ease;
}

.dock-modal-input:focus,
.custom-panel-input:focus {
  border-color: var(--accent-color);
  background: rgba(255, 255, 255, 0.12);
}

.dock-modal-input::placeholder,
.custom-panel-input::placeholder {
  color: var(--text-color);
  opacity: 0.45;
}

body.light-theme .dock-modal-input,
body.light-theme .custom-panel-input {
  background: rgba(0, 0, 0, 0.04);
  border: 0.5px solid rgba(0, 0, 0, 0.15);
  color: #1C1C1E;
}

body.light-theme .dock-modal-input:focus,
body.light-theme .custom-panel-input:focus {
  background: #FFFFFF;
  border-color: var(--accent-color);
  color: #1C1C1E;
}

body.light-theme .dock-modal-input::placeholder,
body.light-theme .custom-panel-input::placeholder {
  color: rgba(28, 28, 30, 0.45);
}



/* Hotkey binding rows */
.hotkey-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 0.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}
.hotkey-label {
  font-size: 12px;
  font-weight: 500;
  flex: 1;
  min-width: 0;
}
.hotkey-bind-btn {
  min-width: 120px;
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 0.5px solid rgba(255, 255, 255, 0.18);
  color: var(--text-color);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  transition: background 0.15s, border-color 0.15s;
}
.hotkey-bind-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}
.hotkey-bind-btn.listening {
  border-color: var(--accent-color, #0A84FF);
  background: rgba(10, 132, 255, 0.2);
  animation: pulse-bind 1s ease infinite;
}
@keyframes pulse-bind {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
body.light-theme .hotkey-row {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.1);
}
body.light-theme .hotkey-bind-btn {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.12);
  color: #1C1C1E;
}

/* Custom user widget card */
.user-custom-card {
  min-width: 200px;
  min-height: 80px;
  max-width: 420px;
}
.user-custom-card .card-body {
  padding: 12px 14px;
  overflow: auto;
  max-height: 320px;
}


/* Hotkey binding rows */
.hotkey-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 0.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  flex-shrink: 0;
}
.hotkey-label { font-size: 12px; font-weight: 500; flex: 1; min-width: 0; }
.hotkey-bind-btn {
  min-width: 130px; padding: 5px 10px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.1); border: 0.5px solid rgba(255, 255, 255, 0.18);
  color: var(--text-color); font-size: 11px; font-weight: 600; cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.hotkey-bind-btn:hover { background: rgba(255, 255, 255, 0.16); }
.hotkey-bind-btn.listening {
  border-color: var(--accent-color, #0A84FF);
  background: rgba(10, 132, 255, 0.2);
  animation: pulse-bind 1s ease infinite;
}
@keyframes pulse-bind { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }
body.light-theme .hotkey-row { background: rgba(0, 0, 0, 0.04); border-color: rgba(0, 0, 0, 0.1); }
body.light-theme .hotkey-bind-btn { background: rgba(0, 0, 0, 0.06); border-color: rgba(0, 0, 0, 0.12); color: #1C1C1E; }

.user-custom-card { min-width: 180px; min-height: 100px; max-width: 480px; display: flex; flex-direction: column; }
.user-custom-card > .card-drag-handle {
  position: absolute; top: 6px; left: 50%; transform: translateX(-50%); z-index: 25; opacity: 0.4;
}
.user-custom-card:hover > .card-drag-handle { opacity: 0.9; }
.user-custom-card .card-body.user-custom-body {
  padding: 28px 14px 14px; overflow: auto; max-height: 360px; position: relative; flex: 1;
}
.user-custom-card .user-custom-del {
  position: absolute; top: 6px; right: 8px; z-index: 26; opacity: 0.5; cursor: pointer;
  font-size: 12px; padding: 2px 6px; border-radius: 6px;
}
.user-custom-card:hover .user-custom-del { opacity: 0.9; }
.user-custom-card .user-custom-del:hover { background: rgba(255,80,80,0.3); }

.card-builder-content {
  width: min(920px, 94vw); max-height: min(88vh, 720px);
  display: flex; flex-direction: column; padding: 16px 18px 18px; position: relative; z-index: 1;
}
.card-builder-body {
  display: grid; grid-template-columns: 120px 1fr 180px; gap: 12px;
  min-height: 320px; flex: 1; overflow: hidden; margin-bottom: 12px;
}
.card-builder-toolbox, .card-builder-props {
  background: rgba(0,0,0,0.2); border: 0.5px solid rgba(255,255,255,0.1);
  border-radius: 12px; padding: 10px; overflow-y: auto;
}
body.light-theme .card-builder-toolbox, body.light-theme .card-builder-props {
  background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.1);
}
.toolbox-title { font-size: 11px; font-weight: 700; opacity: 0.7; margin-bottom: 8px; }
.toolbox-item {
  display: block; width: 100%; margin-bottom: 6px; padding: 8px 6px; border-radius: 8px;
  border: 0.5px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.08);
  color: var(--text-color); font-size: 12px; cursor: pointer; text-align: center;
}
.toolbox-item:hover { background: rgba(255,255,255,0.14); }
body.light-theme .toolbox-item { background: rgba(0,0,0,0.05); border-color: rgba(0,0,0,0.12); color: #1C1C1E; }
.card-builder-canvas-wrap { display: flex; flex-direction: column; min-height: 0; }
.card-builder-canvas-hint { font-size: 11px; opacity: 0.55; margin-bottom: 6px; }
.card-builder-canvas {
  flex: 1; min-height: 280px; position: relative; background: rgba(0,0,0,0.25);
  border: 1.5px dashed rgba(255,255,255,0.2); border-radius: 14px; overflow: hidden;
}
body.light-theme .card-builder-canvas { background: rgba(255,255,255,0.5); border-color: rgba(0,0,0,0.15); }
.builder-el {
  position: absolute; cursor: move; user-select: none; padding: 4px 6px;
  border: 1px solid transparent; border-radius: 6px; box-sizing: border-box;
  max-width: calc(100% - 8px); color: var(--text-color);
}
.builder-el.selected { border-color: var(--accent-color, #0A84FF); box-shadow: 0 0 0 1px rgba(10,132,255,0.4); }
.builder-el-heading { font-size: 16px; font-weight: 700; }
.builder-el-text { font-size: 13px; line-height: 1.4; white-space: pre-wrap; }
.builder-el-link {
  display: inline-block; padding: 6px 12px; border-radius: 8px;
  background: rgba(10,132,255,0.35); color: #fff !important; font-size: 12px; font-weight: 600; text-decoration: none;
}
.builder-el-image img { max-width: 100%; max-height: 120px; border-radius: 6px; display: block; pointer-events: none; }
.builder-el-divider { height: 2px; width: 80%; background: rgba(255,255,255,0.25); padding: 0; }
body.light-theme .builder-el-divider { background: rgba(0,0,0,0.2); }
.builder-props-field { margin-bottom: 8px; }
.builder-props-field label { display: block; font-size: 10px; opacity: 0.65; margin-bottom: 3px; }
.builder-props-field input {
  width: 100%; padding: 5px 8px; border-radius: 6px; border: 0.5px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.25); color: var(--text-color); font-size: 12px;
}
body.light-theme .builder-props-field input { background: #fff; border-color: rgba(0,0,0,0.15); color: #1C1C1E; }
.builder-props-actions { display: flex; gap: 6px; margin-top: 8px; }


/* Prefer single-line labels */
.control-label > span,
.panel-section-title,
.hotkey-label,
.dock-link-title,
.dock-link-url,
.segmented-btn {
  white-space: nowrap;
}
.control-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Custom card: body clear of drag handle */
.user-custom-card {
  min-width: 180px;
  min-height: 100px;
  max-width: 480px;
  display: flex;
  flex-direction: column;
}
.user-custom-card > .card-drag-handle {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  opacity: 0.45;
}
.user-custom-card:hover > .card-drag-handle { opacity: 0.95; }
.user-custom-card .card-body.user-custom-body {
  padding: 30px 14px 14px;
  overflow: auto;
  max-height: 360px;
  position: relative;
  flex: 1;
  box-sizing: border-box;
}
.user-custom-card .user-custom-del {
  position: absolute;
  top: 6px;
  right: 8px;
  z-index: 26;
  opacity: 0.5;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 6px;
}
.user-custom-card:hover .user-custom-del { opacity: 0.95; }
.user-custom-card .user-card-html-root {
  position: relative;
  z-index: 1;
}

.card-code-editor-content {
  width: min(560px, 94vw);
  max-height: min(88vh, 720px);
  overflow-y: auto;
  padding: 16px 18px 18px;
}


/* Never wrap small action buttons */
.custom-btn,
.custom-btn.sm,
.custom-btn.xs,
.custom-btn.secondary-btn,
.custom-btn.theme-btn,
.custom-btn.del-btn,
.dock-link-actions .custom-btn,
.hotkey-bind-btn {
  white-space: nowrap !important;
  flex-shrink: 0;
  word-break: keep-all;
}

.dock-link-actions {
  flex-shrink: 0;
  white-space: nowrap;
}

.control-group.flex-row {
  flex-wrap: nowrap;
  gap: 8px;
}

/* Control panel fixed — not draggable */
.control-panel {
  position: fixed !important;
  top: 76px !important;
  right: 24px !important;
  left: auto !important;
  bottom: auto !important;
  transform: none !important;
  cursor: default !important;
  resize: none !important;
}
.control-panel .card-drag-handle,
.control-panel-drag-handle {
  display: none !important;
  pointer-events: none !important;
}

/* Custom / note / generic card drag handle: ALWAYS 90deg, never 0deg */
.draggable-card > .card-drag-handle,
.user-custom-card > .card-drag-handle,
.note-card > .card-drag-handle {
  transform: translateX(-50%) rotate(90deg) !important;
}
.draggable-card:hover > .card-drag-handle,
.user-custom-card:hover > .card-drag-handle,
.note-card:hover > .card-drag-handle {
  transform: translateX(-50%) rotate(90deg) !important;
  opacity: 0.95;
}
.draggable-card > .card-drag-handle:hover,
.user-custom-card > .card-drag-handle:hover,
.note-card > .card-drag-handle:hover {
  transform: translateX(-50%) rotate(90deg) scale(1.1) !important;
}
.draggable-card > .card-drag-handle:active,
.user-custom-card > .card-drag-handle:active,
.note-card > .card-drag-handle:active {
  transform: translateX(-50%) rotate(90deg) scale(0.95) !important;
}

/* Sandboxed custom card iframe */
.user-custom-card .user-custom-frame {
  width: 100%;
  border: 0;
  background: transparent;
  display: block;
  min-height: 64px;
  max-height: 320px;
  border-radius: 10px;
}


/* ========== User Custom Card — full liquid glass ========== */
.user-custom-card.liquid-glass,
.liquid-glass.user-custom-card {
  /* Inherit / reinforce glass material on the ENTIRE card shell */
  border-radius: var(--radius, 22px) !important;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, calc(var(--opacity, 0.12) * 1.5)) 0%,
    rgba(255, 255, 255, calc(var(--opacity, 0.12) * 0.7)) 100%
  ) !important;
  -webkit-backdrop-filter: blur(var(--blur, 36px)) saturate(var(--saturate, 180%)) contrast(var(--contrast, 108%)) hue-rotate(var(--hue-rotate, 0deg)) url(#liquid-refraction) !important;
  backdrop-filter: blur(var(--blur, 36px)) saturate(var(--saturate, 180%)) contrast(var(--contrast, 108%)) hue-rotate(var(--hue-rotate, 0deg)) url(#liquid-refraction) !important;
  border: 1px solid rgba(255, 255, 255, var(--border-opacity, 0.16)) !important;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.42),
    0 4px 14px rgba(0, 0, 0, 0.2),
    inset 0 1px 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -1px 2px 0 rgba(0, 0, 0, 0.25) !important;
  overflow: hidden;
  min-width: 180px;
  min-height: 100px;
  max-width: 520px;
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  isolation: isolate;
}

.user-custom-card > .card-drag-handle {
  position: absolute !important;
  top: 8px !important;
  left: 50% !important;
  transform: translateX(-50%) rotate(90deg) !important;
  z-index: 30;
  opacity: 0.45;
  width: 28px;
  height: 20px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  cursor: grab;
  pointer-events: auto;
}

.user-custom-card:hover > .card-drag-handle {
  opacity: 0.95;
  transform: translateX(-50%) rotate(90deg) !important;
}

.user-custom-card > .card-drag-handle:hover {
  transform: translateX(-50%) rotate(90deg) scale(1.1) !important;
}

.user-custom-card > .card-drag-handle:active {
  transform: translateX(-50%) rotate(90deg) scale(0.95) !important;
  cursor: grabbing;
}

.user-custom-card .user-custom-del {
  position: absolute;
  top: 8px;
  right: 10px;
  z-index: 30;
  opacity: 0.5;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--text-color);
  background: transparent;
  border: none;
}

.user-custom-card:hover .user-custom-del { opacity: 0.95; }
.user-custom-card .user-custom-del:hover { background: rgba(255, 80, 80, 0.28); }

/* Content area: transparent so liquid glass shows through the whole card */
.user-custom-card .card-body.user-custom-body,
.user-custom-card .user-custom-body {
  padding: 32px 14px 14px !important;
  margin: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 48px;
  max-height: 360px;
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  color: inherit;
}

.user-custom-card .user-custom-frame {
  width: 100% !important;
  border: 0 !important;
  background: transparent !important;
  display: block;
  min-height: 48px;
  max-height: 320px;
  border-radius: 10px;
  /* Let parent glass remain visible around content */
  color-scheme: normal;
}

.user-custom-card .note-resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 22px;
  height: 22px;
  cursor: nwse-resize;
  z-index: 30;
  background: transparent;
}

/* Equidistant guide badge readability */
.equidistant-badge {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}


/* Continuous liquid glass — no mid-card seam */
.user-custom-card.liquid-glass {
  /* Single continuous surface */
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, calc(var(--opacity, 0.12) * 1.5)) 0%,
    rgba(255, 255, 255, calc(var(--opacity, 0.12) * 0.7)) 100%
  ) !important;
  -webkit-backdrop-filter: blur(var(--blur, 36px)) saturate(var(--saturate, 180%)) contrast(var(--contrast, 108%)) hue-rotate(var(--hue-rotate, 0deg)) url(#liquid-refraction) !important;
  backdrop-filter: blur(var(--blur, 36px)) saturate(var(--saturate, 180%)) contrast(var(--contrast, 108%)) hue-rotate(var(--hue-rotate, 0deg)) url(#liquid-refraction) !important;
  /* Avoid nested stacking that can split the blur sample */
  isolation: auto !important;
  overflow: hidden;
}

.user-custom-card .user-custom-body,
.user-custom-card .card-body.user-custom-body {
  background: transparent !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  /* no second glass layer */
  border-radius: 0 !important;
  margin: 0 !important;
  padding: 32px 16px 16px !important;
}

.user-custom-card .user-card-html-root {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  position: relative;
  z-index: 1;
  min-height: 24px;
}

/* Hide any legacy visual iframe if present */
.user-custom-card iframe.user-custom-frame {
  display: none !important;
}

/* Credit Button - Fixed at bottom center, cannot be removed */
.credit-button-container {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 12px 20px 8px 20px;
  pointer-events: none;
}

.credit-button {
  pointer-events: auto;
  display: inline-block;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  color: var(--text-color);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  white-space: nowrap;
}

.credit-button:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.credit-button:active {
  transform: translateY(0);
}

/* Light theme adjustments for credit button */
body.light-theme .credit-button {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

body.light-theme .credit-button:hover {
  background: rgba(0, 0, 0, 0.1);
  border-color: rgba(0, 0, 0, 0.2);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* Mobile responsiveness for credit button */
/* ==========================================
   Responsive Design - All Devices
   Desktop, Mobile, Smartwatch Optimization
   ========================================== */

/* Base responsive adjustments */
@media (max-width: 1440px) {
  .control-panel {
    width: 400px;
    max-width: calc(100vw - 48px);
  }
}

/* Tablet & Large Mobile */
@media (max-width: 1024px) {
  .control-panel {
    top: 70px;
    right: 16px;
    width: 360px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 86px);
    padding: 18px;
  }
  
  #clock-card {
    width: 320px !important;
    padding: 14px 20px !important;
  }
  
  .time-display {
    font-size: calc(var(--custom-font-size, 16px) * 3);
  }
  
  #search-card {
    width: 90%;
    max-width: 500px;
    left: 5% !important;
  }
}

/* Mobile Landscape & Portrait */
@media (max-width: 768px) {
  /* Control Panel - Full screen modal style with proper containment */
  .control-panel {
    top: 64px !important;
    right: 0 !important;
    left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: calc(100vh - 72px) !important;
    height: calc(100vh - 72px) !important;
    border-radius: 24px 24px 0 0 !important;
    padding: 16px !important;
    animation: appleSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto !important;
    overflow-x: hidden !important;
    box-sizing: border-box;
  }
  
  @keyframes appleSlideUp {
    from {
      opacity: 0;
      transform: translateY(20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  .settings-trigger {
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    z-index: 1000;
  }
  
  /* Clock - Center and scale down significantly */
  #clock-card {
    top: 10% !important;
    width: 280px !important;
    min-width: 200px !important;
    padding: 12px 16px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
  }
  
  .time-display {
    font-size: calc(var(--custom-font-size, 16px) * 2) !important;
    text-align: center;
  }
  
  .date-display {
    font-size: calc(var(--custom-font-size, 16px) * 0.7) !important;
    text-align: center;
    margin-top: 4px !important;
  }
  
  /* Search bar - Compact and positioned below clock */
  #search-card {
    width: calc(100% - 40px) !important;
    max-width: 400px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    top: calc(10% + 130px) !important;
    min-height: 44px !important;
  }
  
  #search-card .card-body {
    padding: 6px 10px !important;
  }
  
  .search-wrapper {
    padding: 6px 10px !important;
    border-radius: 12px !important;
  }
  
  .search-input-box {
    font-size: calc(var(--custom-font-size, 16px) * 0.85) !important;
    min-height: 18px !important;
  }
  
  .search-icon,
  .clear-search-btn {
    font-size: 12px !important;
  }
  
  /* Show drag handle on mobile for full drag control */
  #search-card .card-drag-handle,
  .search-wrapper .card-drag-handle {
    display: flex !important;
    align-items: center;
    justify-content: center;
  }
  
  /* Segmented nav - Compact */
  .settings-segmented-nav {
    gap: 4px;
    margin-bottom: 16px;
  }
  
  .segmented-btn {
    font-size: 12px;
    padding: 8px 10px;
  }
  
  /* Sliders - Larger touch targets */
  .custom-slider {
    height: 8px;
    margin: 12px 0 8px;
  }
  
  .custom-slider-thumb {
    width: 22px;
    height: 22px;
    top: -7px;
  }
  
  /* Color inputs - Side by side stack on mobile */
  .control-group.flex-row {
    flex-direction: column;
    gap: 12px;
  }
  
  /* Fix toggle switch on mobile - Proper sizing and alignment */
  .control-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 12px;
  }
  
  .custom-toggle {
    width: 51px;
    height: 31px;
    flex-shrink: 0;
    margin-left: auto;
  }
  
  .custom-toggle::after {
    width: 27px;
    height: 27px;
    top: 2px;
    left: 2px;
  }
  
  .custom-toggle.active::after {
    transform: translateX(20px);
  }
  
  /* Ensure all sections fit within viewport */
  .settings-tab-content {
    padding-bottom: 20px;
  }
  
  .panel-section-title {
    font-size: 13px;
    margin-bottom: 10px;
    margin-top: 8px;
  }
  
  .control-group {
    margin-bottom: 12px;
  }
  
  /* Hide less important elements on small screens */
  .panel-section-title {
    font-size: 13px;
    margin-bottom: 8px;
  }
  
  .control-label {
    font-size: 13px;
  }
}

/* Small Mobile (iPhone SE, etc.) */
@media (max-width: 414px) {
  .control-panel {
    padding: 14px !important;
    max-height: calc(100vh - 64px) !important;
    height: calc(100vh - 64px) !important;
    overflow-y: auto !important;
  }
  
  #clock-card {
    top: 8% !important;
    width: 240px !important;
    padding: 10px 12px !important;
  }
  
  .time-display {
    font-size: calc(var(--custom-font-size, 16px) * 1.6) !important;
  }
  
  .date-display {
    font-size: calc(var(--custom-font-size, 16px) * 0.65) !important;
  }
  
  #search-card {
    top: calc(8% + 100px) !important;
    width: calc(100% - 32px) !important;
    max-width: 320px !important;
  }
  
  .segmented-btn {
    font-size: 11px;
    padding: 6px 8px;
  }
  
  .custom-dropdown-trigger {
    padding: 8px 10px;
    font-size: 13px;
  }
  
  /* Fix toggle switch on small mobile - Proper sizing */
  .control-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 8px;
  }
  
  .custom-toggle {
    width: 44px;
    height: 26px;
    flex-shrink: 0;
    margin-left: auto;
  }
  
  .custom-toggle::after {
    width: 22px;
    height: 22px;
    top: 2px;
    left: 2px;
  }
  
  .custom-toggle.active::after {
    transform: translateX(18px);
  }
}

/* Smartwatch & Very Small Screens */
@media (max-width: 200px), (max-height: 300px) {
  /* Ultra compact mode for watches */
  body {
    overflow: hidden !important;
  }
  
  .settings-trigger {
    width: 32px;
    height: 32px;
    top: 8px;
    right: 8px;
  }
  
  .control-panel {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 100vh !important;
    top: 0 !important;
    right: 0 !important;
    border-radius: 0 !important;
    padding: 10px !important;
  }
  
  .panel-header {
    margin-bottom: 8px;
  }
  
  .panel-title {
    font-size: 12px;
  }
  
  .panel-close-btn {
    width: 24px;
    height: 24px;
    font-size: 14px;
  }
  
  .settings-segmented-nav {
    margin-bottom: 8px;
  }
  
  .segmented-btn {
    font-size: 9px;
    padding: 4px 6px;
    flex: 1;
  }
  
  .control-group {
    margin-bottom: 8px;
  }
  
  .control-label {
    font-size: 10px;
    margin-bottom: 4px;
  }
  
  .custom-slider {
    height: 6px;
    margin: 6px 0 4px;
  }
  
  .custom-slider-thumb {
    width: 14px;
    height: 14px;
    top: -4px;
  }
  
  .custom-dropdown-trigger {
    padding: 6px 8px;
    font-size: 11px;
  }
  
  .val-badge {
    font-size: 9px;
    padding: 2px 4px;
  }
  
  .color-hex-row {
    gap: 4px;
  }
  
  .color-input-native {
    width: 24px;
    height: 24px;
  }
  
  .custom-editable {
    font-size: 11px;
  }
  
  .custom-btn {
    font-size: 11px;
    padding: 6px 10px;
  }
  
  .custom-dropzone {
    padding: 10px;
    font-size: 10px;
  }
  
  /* Hide clock and search on watch - too small */
  #clock-card,
  #search-card {
    display: none !important;
  }
  
  /* Show only essential controls in panel */
  .settings-tab-content {
    padding: 0;
  }
  
  .panel-section-title {
    font-size: 11px;
    margin-bottom: 6px;
  }
}

/* Landscape orientation optimization */
@media (max-height: 500px) and (orientation: landscape) {
  .control-panel {
    max-height: calc(100vh - 60px) !important;
    overflow-y: auto;
    overflow-x: hidden;
  }
  
  #clock-card {
    top: 10% !important;
    width: 260px !important;
    padding: 10px 14px !important;
  }
  
  .time-display {
    font-size: calc(var(--custom-font-size, 16px) * 1.8) !important;
  }
  
  #search-card {
    top: calc(10% + 100px) !important;
    width: calc(100% - 40px) !important;
    max-width: 350px !important;
  }
  
  /* Stack settings vertically in landscape */
  .control-group.flex-row {
    flex-direction: column;
    gap: 8px;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .custom-slider {
    touch-action: pan-y pinch-zoom;
  }
  
  .custom-slider-thumb {
    width: 24px;
    height: 24px;
    top: -9px;
  }
  
  .segmented-btn,
  .custom-btn,
  .custom-dropdown-trigger,
  .settings-trigger {
    min-height: 44px; /* Apple HIG minimum touch target */
  }
  
  .custom-toggle {
    min-height: 32px;
    min-width: 52px;
  }
  
  /* Improve drag handles for touch */
  .card-drag-handle {
    min-width: 48px;
    min-height: 44px;
  }
}

/* High DPI / Retina displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .liquid-glass {
    --blur: 40px;
    --border-opacity: 0.18;
  }
}

/* Dark mode preference */
@media (prefers-color-scheme: dark) {
  body:not(.light-theme) {
    --text-color: #FFFFFF;
    --bg-color: #000000;
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 768px) {
  .credit-button-container {
    padding: 8px 12px 6px 12px;
  }
  
  .credit-button {
    font-size: 11px;
    padding: 8px 16px;
  }
  
  /* Perbesar drag handle untuk mobile */
  .draggable-card .card-drag-handle,
  .note-card .card-drag-handle,
  #liquid-dock .card-drag-handle,
  #search-card .card-drag-handle,
  .search-wrapper .card-drag-handle {
    width: 48px;
    height: 36px;
    opacity: 0.6;
  }
  
  .draggable-card .card-drag-handle:active,
  .note-card .card-drag-handle:active,
  #liquid-dock .card-drag-handle:active,
  #search-card .card-drag-handle:active,
  .search-wrapper .card-drag-handle:active {
    opacity: 1;
  }
  
  /* Perbesar resize handle untuk mobile */
  .clock-resize-handle,
  .search-resize-handle,
  .note-resize-handle {
    min-width: 44px;
    min-height: 44px;
  }
  
  /* Pastikan elemen card lebih mudah di-drag di mobile */
  .draggable-card {
    touch-action: none;
  }
  
  /* Optimalkan untuk layar sentuh */
  .liquid-glass {
    -webkit-tap-highlight-color: transparent;
  }
}
