/* ============================================================
   KlikDRAW — Design System & Styles
   ============================================================ */

/* ---- Google Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400;500;600;700&family=Inter:wght@300;400;500;600;700&family=Fira+Code:wght@400;500&display=swap');

/* ---- CSS Custom Properties ---- */
:root {
  color-scheme: light dark;

  /* Canvas */
  --canvas-bg: #ffffff;
  --canvas-grid: rgba(0, 0, 0, 0.08);

  /* UI Chrome */
  --ui-bg: rgba(255, 255, 255, 0.92);
  --ui-bg-solid: #ffffff;
  --ui-border: rgba(0, 0, 0, 0.08);
  --ui-shadow: 0 2px 16px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);
  --ui-shadow-hover: 0 4px 24px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.06);

  /* Text */
  --text-primary: #1b1b1f;
  --text-secondary: #5c5c66;
  --text-tertiary: #9e9ea8;

  /* Accent */
  --accent: #6965db;
  --accent-hover: #5b57d1;
  --accent-bg: rgba(105, 101, 219, 0.1);
  --accent-light: rgba(105, 101, 219, 0.15);

  /* Interactive */
  --btn-hover: rgba(0, 0, 0, 0.05);
  --btn-active: rgba(105, 101, 219, 0.12);

  /* Danger */
  --danger: #e03131;

  /* Misc */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

[data-theme="dark"] {
  --canvas-bg: #121212;
  --canvas-grid: rgba(255, 255, 255, 0.06);

  --ui-bg: rgba(30, 30, 30, 0.92);
  --ui-bg-solid: #1e1e1e;
  --ui-border: rgba(255, 255, 255, 0.08);
  --ui-shadow: 0 2px 16px rgba(0, 0, 0, 0.32), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --ui-shadow-hover: 0 4px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.06);

  --text-primary: #e8e8e8;
  --text-secondary: #a0a0ab;
  --text-tertiary: #6c6c78;

  --accent: #a5a3ff;
  --accent-hover: #b8b6ff;
  --accent-bg: rgba(165, 163, 255, 0.12);
  --accent-light: rgba(165, 163, 255, 0.18);

  --btn-hover: rgba(255, 255, 255, 0.06);
  --btn-active: rgba(165, 163, 255, 0.16);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-ui);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--canvas-bg);
  color: var(--text-primary);
}

/* ---- Canvas ---- */
#drawing-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ============================================================
   Toolbar (Left Side)
   ============================================================ */
#toolbar {
  position: fixed;
  top: 50%;
  left: 16px;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 6px;
  background: var(--ui-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--ui-shadow);
  z-index: 100;
  transition: box-shadow 0.2s ease, top 0.3s cubic-bezier(0.4, 0, 0.2, 1), bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1), left 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s ease, gap 0.3s ease;
}

#toolbar:hover {
  box-shadow: var(--ui-shadow-hover);
}

.tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.tool-btn:hover {
  background: var(--btn-hover);
  color: var(--text-primary);
}

.tool-btn.active {
  background: var(--accent-bg);
  color: var(--accent);
}

.tool-btn svg {
  width: 20px;
  height: 20px;
}

.tool-btn .shortcut-hint {
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-size: 8px;
  font-weight: 600;
  color: var(--text-tertiary);
  pointer-events: none;
  opacity: 0.6;
}

.tool-divider {
  width: 24px;
  height: 1px;
  background: var(--ui-border);
  margin: 4px auto;
}

/* ============================================================
   Top Bar (Actions)
   ============================================================ */
#top-bar {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  background: var(--ui-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-md);
  box-shadow: var(--ui-shadow);
  z-index: 100;
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.action-btn:hover {
  background: var(--btn-hover);
  color: var(--text-primary);
}

.action-btn.active {
  color: var(--accent);
}

.action-btn:disabled {
  opacity: 0.35;
  pointer-events: none;
}

.action-btn svg {
  width: 18px;
  height: 18px;
}

.action-divider {
  width: 1px;
  height: 20px;
  background: var(--ui-border);
  margin: 0 4px;
}

/* Brand logo in top-left */
#brand {
  position: fixed;
  top: 16px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--ui-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-md);
  box-shadow: var(--ui-shadow);
  z-index: 100;
  font-weight: 700;
  font-size: 15px;
  color: var(--accent);
  letter-spacing: -0.3px;
  user-select: none;
}

#brand .brand-icon {
  width: 22px;
  height: 22px;
}

/* ============================================================
   Style Panel (Right Side Sidebar)
   ============================================================ */
#style-panel {
  position: fixed;
  top: 50%;
  right: 16px;
  left: auto;
  transform: translateY(-50%) translateX(20px);
  display: none;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--ui-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--ui-shadow);
  z-index: 100;
  width: 260px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#style-panel.visible {
  display: flex;
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* Minimized State (Desktop) */
#style-panel.minimized {
  transform: translateY(-50%) translateX(calc(100% - 56px));
}

#style-panel.minimized .icon-collapse {
  transform: rotate(180deg);
}

#style-panel.minimized .style-panel-title,
#style-panel.minimized .style-columns,
#style-panel.minimized .style-divider-h,
#style-panel.minimized #image-options,
#style-panel.minimized #pencil-options,
#style-panel.minimized #text-options {
  opacity: 0;
  pointer-events: none;
}

/* Transitions for contents when minimizing */
#style-panel .style-panel-title,
#style-panel .style-columns,
#style-panel .style-divider-h,
#style-panel #image-options,
#style-panel #pencil-options,
#style-panel #text-options {
  transition: opacity 0.15s ease;
}

/* Style Panel Header */
.style-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--ui-border);
  margin-bottom: 4px;
}

.style-panel-title {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.style-minimize-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.style-minimize-btn:hover {
  background: var(--btn-hover);
  color: var(--text-primary);
}

.style-minimize-btn svg {
  width: 14px;
  height: 14px;
  transition: transform 0.3s ease;
}

.style-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  margin-left: auto;
}

.style-action-btn:hover {
  background: var(--btn-hover);
  color: var(--accent);
  border-color: var(--accent);
}

.style-action-btn svg {
  width: 14px;
  height: 14px;
}

/* Stack sections vertically in the side panel */
#style-panel .style-columns {
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

#style-panel .style-divider-v {
  display: none;
}

/* Horizontal divider between rows */
.style-divider-h {
  height: 1px;
  background: var(--ui-border);
  width: 100%;
  margin: 2px 0;
  display: block;
}

.style-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.style-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
}

.style-row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

/* Color Swatches */
.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: padding-box;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  flex-shrink: 0;
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.color-swatch.transparent-swatch {
  background: linear-gradient(45deg, #ccc 25%, transparent 25%),
              linear-gradient(-45deg, #ccc 25%, transparent 25%),
              linear-gradient(45deg, transparent 75%, #ccc 75%),
              linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
}

.style-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.color-hex-badge {
  font-size: 10px;
  font-family: var(--font-code, monospace);
  color: var(--text-secondary);
  background: var(--ui-border);
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 500;
  letter-spacing: 0.2px;
}

/* Eyedropper (Penyedot Warna) */
.eyedropper-btn {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 1px solid var(--ui-border);
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  flex-shrink: 0;
  position: relative;
}

.eyedropper-btn:hover {
  transform: scale(1.15);
  border-color: var(--accent);
  color: var(--accent);
  background: var(--btn-hover);
}

.eyedropper-btn svg {
  width: 13px;
  height: 13px;
}

.eyedropper-btn.active {
  border-color: var(--accent);
  background: var(--accent-light, rgba(99, 102, 241, 0.2));
  color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.color-swatch.custom-swatch {
  border: 2px solid var(--ui-border);
  position: relative;
}
.color-swatch.custom-swatch::after {
  content: '';
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

/* Style Options (stroke width, etc.) */
.style-option {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-ui);
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.style-option:hover {
  background: var(--btn-hover);
  border-color: var(--text-tertiary);
}

.style-option.active {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}

.style-option svg {
  width: 18px;
  height: 18px;
}

/* Opacity Slider */
.opacity-control {
  display: flex;
  align-items: center;
  gap: 10px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 4px;
  background: var(--ui-border);
  border-radius: 2px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--ui-bg-solid);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  background: var(--accent);
}

/* Number Input Control */
.number-control {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--btn-bg);
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  padding: 4px 8px;
  width: fit-content;
  transition: all 0.15s ease;
}

.number-control:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.number-input {
  width: 45px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  outline: none;
  text-align: right;
  -moz-appearance: textfield; /* Hide arrows in Firefox */
}

/* Hide arrows in Chrome/Safari/Edge */
.number-input::-webkit-outer-spin-button,
.number-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.unit-label {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
}

/* Switches & Toggles */
.opacity-value {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 36px;
}

/* Horizontal sections layout */
.style-columns {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.style-columns > .style-section {
  flex: 0 0 auto;
}

.style-divider-v {
  width: 1px;
  background: var(--ui-border);
  align-self: stretch;
  min-height: 32px;
}

/* ============================================================
   Zoom Controls (Bottom Left)
   ============================================================ */
#zoom-controls {
  position: fixed;
  bottom: 16px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px;
  background: var(--ui-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--ui-shadow);
  z-index: 100;
}

#zoom-level {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 40px;
  text-align: center;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.15s ease;
}

#zoom-level:hover {
  background: var(--btn-hover);
}

.zoom-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.zoom-btn:hover {
  background: var(--btn-hover);
  color: var(--text-primary);
}

.zoom-btn svg {
  width: 16px;
  height: 16px;
}

/* ============================================================
   Export Panel
   ============================================================ */
#export-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  display: none;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  background: var(--ui-bg-solid);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--ui-shadow-hover);
  z-index: 200;
  min-width: 300px;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#export-panel.visible {
  display: flex;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.export-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.close-btn:hover {
  background: var(--btn-hover);
  color: var(--text-primary);
}

.export-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.export-btn:hover {
  background: var(--btn-hover);
  border-color: var(--accent);
}

.export-btn svg {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

/* Backdrop for export panel */
#export-backdrop {
  display: none;
}

#export-panel.visible ~ #export-backdrop,
.export-backdrop-active {
  display: block;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 199;
}

/* ============================================================
   Toast Notification
   ============================================================ */
#toast {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 20px;
  background: var(--ui-bg-solid);
  color: var(--text-primary);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--ui-shadow);
  font-size: 13px;
  font-weight: 500;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   Text Editor (Overlay)
   ============================================================ */
#text-editor {
  font-family: 'Caveat', cursive;
  caret-color: var(--accent);
}

/* ============================================================
   Scrollbar
   ============================================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-tertiary);
  border-radius: 3px;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  #toolbar {
    top: calc(62px + env(safe-area-inset-top));
    bottom: auto;
    left: 12px;
    right: 12px;
    transform: none;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: none;
    justify-content: flex-start;
    padding: 6px 10px;
    gap: 4px;
    scrollbar-width: none;
  }

  #toolbar::-webkit-scrollbar {
    display: none;
  }

  /* Keep toolbar position static even if style panel is open */
  body.style-panel-open #toolbar {
    top: calc(62px + env(safe-area-inset-top));
    bottom: auto;
    left: 12px;
    right: 12px;
    transform: none;
    flex-direction: row;
  }

  .tool-btn,
  .tool-divider {
    flex-shrink: 0;
  }

  .tool-divider {
    width: 1px;
    height: 24px;
    margin: 0 4px;
  }

  #brand {
    padding: 6px 10px;
    font-size: 13px;
  }

  #style-panel {
    top: auto;
    bottom: calc(8px + env(safe-area-inset-bottom));
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    transform: translateY(20px);
    max-height: 50vh;
    overflow-y: auto;
  }

  #style-panel.visible {
    transform: translateY(0);
  }

  #style-panel.minimized {
    transform: translateY(calc(100% - 44px));
  }

  #style-panel.minimized .icon-collapse {
    transform: rotate(-90deg);
  }

  #style-panel .icon-collapse {
    transform: rotate(90deg);
  }

  #style-panel.drawing-active {
    opacity: 0.12 !important;
    pointer-events: none;
    transition: opacity 0.15s ease;
  }

  #style-panel .style-columns {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px 16px;
    justify-content: center;
    align-items: flex-start;
  }

  #style-panel .style-divider-v {
    display: none;
  }

  #top-bar {
    top: calc(12px + env(safe-area-inset-top));
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    max-width: calc(100vw - 24px);
  }
}

@media (max-width: 580px) {
  #brand,
  #zoom-controls,
  #btn-shortcuts,
  #btn-developer {
    display: none !important;
  }

  #top-bar {
    top: calc(6px + env(safe-area-inset-top));
    left: 8px;
    right: 8px;
    transform: none;
    padding: 4px 6px;
    gap: 1px;
    max-width: none;
    width: auto;
    justify-content: center;
  }

  .action-btn {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
  }

  .action-btn svg {
    width: 16px;
    height: 16px;
  }

  .action-divider {
    height: 16px;
    margin: 0 2px;
    flex-shrink: 0;
  }

  #toolbar {
    top: calc(48px + env(safe-area-inset-top));
    bottom: auto;
    left: 8px;
    right: 8px;
    transform: none;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 5px 6px;
    gap: 3px;
    border-radius: var(--radius-md);
  }

  body.style-panel-open #toolbar {
    top: calc(48px + env(safe-area-inset-top));
    bottom: auto;
    left: 8px;
    right: 8px;
    transform: none;
    flex-direction: row;
  }

  .tool-btn {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
  }

  .tool-btn svg {
    width: 18px;
    height: 18px;
  }

  .tool-btn .shortcut-hint {
    display: none !important;
  }

  .tool-divider {
    width: 1px;
    height: 20px;
    margin: 0 2px;
    flex-shrink: 0;
  }

  #style-panel {
    top: auto;
    bottom: calc(8px + env(safe-area-inset-bottom));
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    transform: translateY(20px);
    padding: 10px 12px;
    gap: 6px;
    border-radius: var(--radius-md);
    max-height: 50vh;
    overflow-y: auto;
  }

  #style-panel.visible {
    transform: translateY(0);
  }

  #style-panel.minimized {
    transform: translateY(calc(100% - 44px));
  }

  #style-panel.minimized .icon-collapse {
    transform: rotate(-90deg);
  }

  #style-panel .icon-collapse {
    transform: rotate(90deg);
  }

  #style-panel .style-columns {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px 12px;
    justify-content: flex-start;
    align-items: flex-start;
  }

  .style-section {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }

  .style-row {
    gap: 3px;
  }

  .color-swatch {
    width: 18px;
    height: 18px;
    border-radius: 4px;
  }

  .style-option {
    height: 28px;
    padding: 0 8px;
    font-size: 11px;
  }

  .style-option svg {
    width: 14px;
    height: 14px;
  }

  .opacity-control input[type="range"] {
    width: 70px;
  }

  .opacity-value {
    font-size: 11px;
    min-width: 28px;
  }

  .style-label {
    font-size: 10px;
    margin-bottom: 2px;
  }
}

/* ============================================================
   Accessibility
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

.visually-hidden {
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
  user-select: none;
}

/* ============================================================
   Keyboard Focus Styles
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus:not(:focus-visible) {
  outline: none;
}

/* ============================================================
   Developer Info Button (Bottom Right)
   ============================================================ */
#btn-developer {
  position: fixed;
  bottom: 20px;
  right: 70px;
  z-index: 100;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--ui-bg);
  backdrop-filter: blur(12px);
  box-shadow: var(--ui-shadow);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  text-decoration: none;
}

#btn-developer svg {
  width: 20px;
  height: 20px;
}

#btn-developer:hover {
  color: var(--accent);
  box-shadow: var(--ui-shadow-hover);
  transform: translateY(-1px);
}

/* ============================================================
   Keyboard Shortcuts Button (Bottom Right)
   ============================================================ */
#btn-shortcuts {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--ui-bg);
  backdrop-filter: blur(12px);
  box-shadow: var(--ui-shadow);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

#btn-shortcuts svg {
  width: 20px;
  height: 20px;
}

#btn-shortcuts:hover {
  color: var(--accent);
  box-shadow: var(--ui-shadow-hover);
  transform: translateY(-1px);
}

/* ============================================================
   Keyboard Shortcuts Modal
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.shortcuts-panel {
  background: var(--ui-bg-solid);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2), 0 0 0 1px var(--ui-border);
  width: 580px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(8px);
  transition: transform 0.25s ease;
}

.modal-overlay.visible .shortcuts-panel {
  transform: scale(1) translateY(0);
}

.shortcuts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--ui-border);
}

.shortcuts-header h2 {
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.shortcuts-header .close-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.shortcuts-header .close-btn svg {
  width: 16px;
  height: 16px;
}

.shortcuts-header .close-btn:hover {
  background: var(--btn-hover);
  color: var(--text-primary);
}

.shortcuts-body {
  display: flex;
  gap: 24px;
  padding: 16px 24px 24px;
}

.shortcuts-col {
  flex: 1;
}

.shortcuts-col h3 {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin: 12px 0 8px;
  padding-bottom: 4px;
}

.shortcuts-col h3:first-child {
  margin-top: 4px;
}

.shortcut-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
}

.shortcut-desc {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-primary);
}

kbd {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--btn-hover);
  border: 1px solid var(--ui-border);
  border-radius: 5px;
  padding: 2px 7px;
  min-width: 22px;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}

@media (max-width: 600px) {
  .shortcuts-body {
    flex-direction: column;
    gap: 8px;
  }
}
