/**
 * Vector Studio - Dockable Right Panels Stylesheet (Adobe Illustrator CC Workspace Architecture)
 */

#right-panels-dock {
  display: flex;
  width: 320px;
  height: 100%;
  background-color: var(--bg-panel);
  border-left: 1px solid var(--border-app);
  flex-shrink: 0;
  z-index: 90;
  position: relative;
  transition: width 0.15s ease;
}

#right-panels-dock.dock-collapsed {
  width: 40px;
}

#right-panels-dock.dock-collapsed .panels-main-column {
  display: none;
}

/* Main Left Column inside Right Dock (Header + Subtabs + Scrollable Content) */
.panels-main-column {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
  min-width: 0;
  overflow: hidden;
  background-color: var(--bg-panel);
}

/* Workspace Category Header & Search */
.dock-workspace-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px 6px;
  background-color: var(--bg-panel-header);
  border-bottom: 1px solid var(--border-app);
  flex-shrink: 0;
}

.dock-group-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.dock-active-group-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-bright);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dock-active-group-title::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent);
}

.dock-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.dock-search-wrap input {
  width: 100%;
  height: 24px;
  padding: 0 24px 0 8px;
  font-size: 11px;
  background-color: var(--bg-canvas);
  border: 1px solid var(--border-control);
  border-radius: 4px;
  color: var(--text-main);
}

.dock-search-wrap input:focus {
  border-color: var(--accent);
  outline: none;
}

.dock-search-clear {
  position: absolute;
  right: 6px;
  font-size: 10px;
  color: var(--text-dim);
  cursor: pointer;
  display: none;
}

/* Sub-Tabs Bar (Illustrator Tab Group Pills) */
.dock-subtabs-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 5px 8px;
  background-color: #1e1e1e;
  border-bottom: 1px solid var(--border-app);
  flex-shrink: 0;
}

.dock-subtab-pill {
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-dim);
  background-color: var(--bg-control);
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  user-select: none;
  transition: all 0.12s;
}

.dock-subtab-pill:hover {
  color: var(--text-bright);
  background-color: var(--bg-control-hover);
}

.dock-subtab-pill.active {
  color: #ffffff;
  background-color: rgba(13, 153, 255, 0.22);
  border-color: var(--accent);
  font-weight: 600;
}

/* Panel Tab Strip on the far right (7 Scientific Groups) */
.panel-tab-strip {
  display: flex;
  flex-direction: column;
  width: 40px;
  background-color: #1b1b1b;
  border-left: 1px solid var(--border-app);
  padding: 6px 0;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
  user-select: none;
}

.rail-group-btn {
  width: 32px;
  height: 36px;
  border-radius: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.12s ease;
  position: relative;
  padding: 0;
}

.rail-group-btn:hover {
  color: var(--text-bright);
  background-color: var(--bg-control);
}

.rail-group-btn.active {
  color: var(--accent);
  background-color: rgba(13, 153, 255, 0.16);
  border-color: rgba(13, 153, 255, 0.45);
}

.rail-group-btn.active::before {
  content: '';
  position: absolute;
  left: -4px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background-color: var(--accent);
}

.rail-group-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.rail-group-label {
  font-size: 7.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  line-height: 1;
}

.rail-divider {
  width: 22px;
  height: 1px;
  background-color: var(--border-app);
  margin: 2px 0;
}

/* Panel Body Container */
.panels-content-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  background-color: var(--bg-panel);
}

/* Accordion Section */
.panel-section {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border-app);
}

.panel-section.group-hidden {
  display: none !important;
}

.panel-section.highlight > .panel-header {
  background-color: rgba(13, 153, 255, 0.14);
  border-left: 3px solid var(--accent);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 28px;
  padding: 0 10px;
  background-color: var(--bg-panel-header);
  cursor: pointer;
  user-select: none;
}

.panel-header:hover {
  background-color: var(--bg-control);
}

.panel-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.panel-header-icon {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  cursor: pointer;
  transition: transform 0.15s;
}

.panel-section.collapsed .panel-header-icon {
  transform: rotate(-90deg);
}

.panel-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-section.collapsed .panel-body {
  display: none;
}

/* Selection Status Banner in Properties */
.selection-status-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  background-color: var(--bg-canvas);
  border: 1px solid var(--border-control);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}

.selection-status-type {
  font-size: 9px;
  color: var(--text-dim);
  font-weight: 400;
}

/* Properties Grid Form */
.prop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.prop-col {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 4px;
  min-width: 0;
}

.prop-label {
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
}

.prop-section-title {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-top: 4px;
  padding-bottom: 3px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.prop-input-wrap {
  display: flex;
  align-items: center;
  background-color: var(--bg-control);
  border: 1px solid var(--border-control);
  border-radius: 3px;
  padding: 0 5px;
  height: 24px;
  min-width: 0;
}

.prop-input-wrap:focus-within {
  border-color: var(--border-focus);
}

.prop-input-wrap span.unit {
  font-size: 9px;
  color: var(--text-muted);
  margin-right: 3px;
  margin-left: 2px;
  flex-shrink: 0;
}

.prop-input-wrap input {
  background: transparent;
  border: none;
  color: var(--text-main);
  width: 100%;
  font-size: 11px;
  padding: 0;
  min-width: 0;
}

.prop-input-wrap input:focus {
  outline: none;
}

/* Transform Matrix Grid */
.transform-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

/* Quick Actions Grid in Properties */
.quick-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.quick-actions-grid .btn {
  font-size: 10px;
  padding: 4px 6px;
  height: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* Color Input Chip */
.inline-color-input {
  width: 24px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border-control);
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}

.inline-color-input::-webkit-color-swatch-wrapper {
  padding: 1px;
}

.inline-color-input::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

/* Layers Panel Tree (Expandable Hierarchy) */
.layers-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
}

.layers-tree {
  display: flex;
  flex-direction: column;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border-control);
  background-color: var(--bg-canvas);
  border-radius: 4px;
}

.layer-item, .layer-child-item {
  display: flex;
  align-items: center;
  height: 26px;
  padding: 0 6px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-main);
  font-size: 11px;
  gap: 5px;
  user-select: none;
}

.layer-child-item {
  height: 24px;
  padding-left: 20px;
  font-size: 10.5px;
  background-color: rgba(0, 0, 0, 0.18);
}

.layer-item:hover, .layer-child-item:hover {
  background-color: var(--bg-control);
}

.layer-item.selected, .layer-child-item.selected {
  background-color: rgba(13, 153, 255, 0.25);
  color: var(--text-bright);
}

.layer-expand-btn {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: var(--text-dim);
  cursor: pointer;
  flex-shrink: 0;
}

.layer-expand-btn:hover {
  color: var(--text-bright);
}

.layer-icon-btn {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  cursor: pointer;
  flex-shrink: 0;
  font-size: 11px;
}

.layer-icon-btn:hover {
  color: var(--text-bright);
}

.layer-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.25);
}

.layer-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-target-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid var(--text-dim);
  flex-shrink: 0;
}

.layer-item.selected .layer-target-indicator,
.layer-child-item.selected .layer-target-indicator {
  background-color: var(--accent);
  border-color: var(--accent);
}

/* Appearance Panel */
.appearance-toolbar {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.appearance-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border-control);
  border-radius: 4px;
  background-color: var(--bg-canvas);
  padding: 5px;
}

.appearance-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  background-color: var(--bg-control);
  border-radius: 3px;
  font-size: 11px;
  gap: 6px;
  border: 1px solid transparent;
}

.appearance-item:hover {
  background-color: var(--bg-control-hover);
}

.appearance-item.active {
  border-color: var(--accent);
  background-color: rgba(13, 153, 255, 0.12);
}

/* Swatches Grid */
.swatches-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
  padding: 5px;
  background-color: var(--bg-canvas);
  border: 1px solid var(--border-control);
  border-radius: 4px;
  max-height: 170px;
  overflow-y: auto;
}

.swatch-item {
  aspect-ratio: 1;
  border-radius: 2px;
  border: 1px solid rgba(255,255,255,0.12);
  cursor: pointer;
  transition: transform 0.1s;
}

.swatch-item:hover {
  transform: scale(1.18);
  z-index: 2;
  border-color: #ffffff;
  box-shadow: 0 0 4px rgba(0,0,0,0.6);
}

/* Gradient Ramp & Presets */
.gradient-ramp-bar {
  height: 22px;
  width: 100%;
  border-radius: 4px;
  border: 1px solid var(--border-control);
  cursor: pointer;
  position: relative;
  background: linear-gradient(90deg, #0d99ff 0%, #a855f7 100%);
}

.gradient-presets-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}

.gradient-preset-chip {
  height: 22px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.18);
  cursor: pointer;
  transition: transform 0.1s;
}

.gradient-preset-chip:hover {
  transform: scale(1.1);
  border-color: #ffffff;
}

/* Pathfinder & Align Grids */
.pathfinder-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.pathfinder-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 36px;
  background-color: var(--bg-control);
  border: 1px solid var(--border-control);
  border-radius: 3px;
  cursor: pointer;
  color: var(--text-main);
  font-size: 9px;
  gap: 2px;
  transition: all 0.1s;
}

.pathfinder-btn:hover {
  background-color: var(--bg-control-hover);
  border-color: var(--accent);
  color: var(--text-bright);
}

.align-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}

.align-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  background-color: var(--bg-control);
  border: 1px solid var(--border-control);
  border-radius: 3px;
  cursor: pointer;
  color: var(--text-main);
  font-size: 12px;
}

.align-btn:hover {
  background-color: var(--bg-control-hover);
  border-color: var(--accent);
  color: var(--text-bright);
}

/* Pill Buttons for Stroke Weight / Presets */
.preset-pills-row {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}

.preset-pill-btn {
  flex: 1;
  min-width: 28px;
  height: 20px;
  font-size: 9.5px;
  background-color: var(--bg-control);
  border: 1px solid var(--border-control);
  color: var(--text-dim);
  border-radius: 3px;
  cursor: pointer;
  padding: 0 4px;
}

.preset-pill-btn:hover, .preset-pill-btn.active {
  background-color: rgba(13, 153, 255, 0.2);
  border-color: var(--accent);
  color: #ffffff;
}

/* History List */
.history-list {
  display: flex;
  flex-direction: column;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border-control);
  border-radius: 3px;
  background-color: var(--bg-canvas);
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  gap: 6px;
  cursor: pointer;
  font-size: 11px;
  border-bottom: 1px solid var(--border-app);
}

.history-item:hover {
  background-color: var(--bg-control);
}

.history-item.active {
  background-color: var(--bg-control-active);
  font-weight: 600;
  color: var(--accent);
}

.history-item.future {
  color: var(--text-muted);
  font-style: italic;
}

/* Artboards Panel */
.artboards-toolbar {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
  align-items: center;
}

.artboards-list {
  display: flex;
  flex-direction: column;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border-control);
  border-radius: 4px;
  background-color: var(--bg-canvas);
}

.artboard-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 6px;
  font-size: 11px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  user-select: none;
}

.artboard-item:hover {
  background-color: var(--bg-control);
}

.artboard-item.active {
  background-color: rgba(13, 153, 255, 0.25);
  color: var(--text-bright);
  font-weight: 600;
}

.artboard-item.hidden-ab {
  opacity: 0.48;
}

.artboard-item .ab-eye,
.artboard-item .ab-lock {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 3px;
}

.artboard-item .ab-eye:hover,
.artboard-item .ab-lock:hover {
  background-color: rgba(255,255,255,0.1);
}

.artboard-item .artboard-num {
  min-width: 16px;
  height: 16px;
  border-radius: 3px;
  background: rgba(13, 153, 255, 0.2);
  color: #38bdf8;
  font-size: 9.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.artboard-item .artboard-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artboard-item .artboard-dims {
  font-size: 9.5px;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* Brushes & Styles & Symbols Grid */
.styles-grid, .symbols-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border-control);
  border-radius: 4px;
  background-color: var(--bg-canvas);
}

.style-chip, .symbol-card {
  height: 44px;
  border: 1px solid var(--border-control);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  text-align: center;
  transition: transform 0.1s, border-color 0.1s;
}

.style-chip:hover, .symbol-card:hover, .symbol-card.active, .style-chip.active {
  border-color: var(--accent);
  transform: scale(1.04);
}

.brush-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-bottom: 1px solid var(--border-app);
  cursor: pointer;
  border-radius: 3px;
}

.brush-item:hover, .brush-item.active {
  background-color: var(--bg-control);
  border-left: 2px solid var(--accent);
}

.brush-preview-stroke {
  flex: 1;
  height: 14px;
  background-repeat: no-repeat;
  background-position: center;
}

/* Navigator Panel */
.navigator-wrapper {
  position: relative;
  width: 100%;
  height: 150px;
  background-color: var(--bg-canvas);
  border: 1px solid var(--border-control);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#navigator-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#navigator-viewport-rect {
  position: absolute;
  border: 2px solid #ff0055;
  background-color: rgba(255, 0, 85, 0.12);
  cursor: grab;
  pointer-events: auto;
}

#navigator-viewport-rect:active {
  cursor: grabbing;
}

/* Color Guide Harmonies & Tints */
.color-guide-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.tint-shade-row {
  display: flex;
  height: 20px;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border-control);
}

.tint-shade-chip {
  flex: 1;
  height: 100%;
  cursor: pointer;
}

.tint-shade-chip:hover {
  transform: scale(1.1);
  z-index: 2;
}

/* CSS Properties & Doc Info */
.css-code-box {
  width: 100%;
  height: 130px;
  background-color: #0b0c0e;
  color: #5af78e;
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 11px;
  padding: 8px;
  border: 1px solid var(--border-control);
  border-radius: 4px;
  resize: vertical;
  white-space: pre;
}

.doc-info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.doc-info-table td {
  padding: 4px 2px;
  border-bottom: 1px solid var(--border-app);
}

.doc-info-table td:last-child {
  text-align: right;
  color: var(--text-bright);
  font-weight: 500;
}

/* Actions Panel */
.action-item {
  transition: background-color 0.1s;
  border-radius: 3px;
}

.action-item:hover {
  background-color: var(--bg-hover);
}

.action-item.active {
  background-color: var(--bg-selected) !important;
  color: #ffffff;
}

/* Glyphs Panel */
.glyph-cell {
  background: var(--bg-panel);
  border: 1px solid var(--border-app);
  transition: all 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.glyph-cell:hover {
  background-color: var(--accent) !important;
  color: #ffffff;
  transform: scale(1.15);
  z-index: 2;
}

/* OpenType Panel */
.opentype-btn-grid button.active {
  background-color: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

/* Target Fill/Stroke Toggle in Color & Swatches */
.paint-target-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  background-color: var(--bg-canvas);
  padding: 3px;
  border-radius: 4px;
  border: 1px solid var(--border-control);
}

.paint-target-btn {
  flex: 1;
  height: 22px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 3px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.paint-target-btn.active {
  background-color: var(--bg-control);
  border-color: var(--accent);
  color: var(--text-bright);
}

/* ========================================================================= */
/* Adobe Illustrator CC Right-Click Context Menu                             */
/* ========================================================================= */
.ai-context-menu {
  position: fixed;
  z-index: 15000;
  min-width: 215px;
  background-color: #26272b;
  border: 1px solid #444750;
  border-radius: 6px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.72), 0 0 0 1px rgba(255, 255, 255, 0.06);
  padding: 5px 0;
  user-select: none;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 11.5px;
  color: #e2e8f0;
}

.ai-ctx-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  cursor: pointer;
  transition: background-color 0.08s ease;
  gap: 14px;
}

.ai-ctx-item:hover {
  background-color: var(--accent);
  color: #ffffff;
}

.ai-ctx-item:hover .ai-ctx-shortcut,
.ai-ctx-item:hover .ai-ctx-arrow {
  color: rgba(255, 255, 255, 0.9);
}

.ai-ctx-item.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.ai-ctx-shortcut {
  font-size: 10px;
  color: #94a3b8;
  font-family: 'JetBrains Mono', Consolas, monospace;
}

.ai-ctx-arrow {
  font-size: 10px;
  color: #94a3b8;
  margin-left: auto;
}

.ai-ctx-divider {
  height: 1px;
  background-color: #3a3d45;
  margin: 4px 0;
}

.ai-ctx-submenu {
  display: none;
  position: absolute;
  left: 100%;
  top: -5px;
  min-width: 205px;
  background-color: #26272b;
  border: 1px solid #444750;
  border-radius: 6px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.72);
  padding: 5px 0;
  z-index: 15001;
}

.ai-ctx-submenu.flip-left {
  left: auto;
  right: 100%;
}

.ai-ctx-item.has-submenu:hover > .ai-ctx-submenu {
  display: block;
}

/* Layer Eye / Lock / Group Toggle Button Refinements */
.layer-eye,
.layer-lock,
.child-eye,
.child-lock {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  flex-shrink: 0;
  transition: background-color 0.1s, transform 0.1s;
}

.layer-eye:hover,
.layer-lock:hover,
.child-eye:hover,
.child-lock:hover {
  background-color: rgba(255, 255, 255, 0.14);
  transform: scale(1.1);
}

.layer-eye.hidden-layer,
.child-eye.hidden-node {
  opacity: 0.45;
}

.layer-lock.locked,
.child-lock.locked {
  color: #f59e0b;
}

.artboard-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.artboard-item:hover {
  background-color: var(--bg-control-hover);
}

.artboard-item.active {
  background-color: rgba(13, 153, 255, 0.2);
  border-left: 3px solid var(--accent);
  color: #ffffff;
}

.artboard-num {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  background: var(--bg-control);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
}

.artboard-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artboard-dims {
  font-size: 10px;
  color: var(--text-dim);
  font-family: monospace;
}

/* ========================================================================= */
/* GROUP 8: VECTOR TEMPLATES LIBRARY PANEL & FULL-SCREEN GALLERY MODAL       */
/* ========================================================================= */

.tpl-panel-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tpl-search-box {
  position: relative;
  display: flex;
  align-items: center;
  background-color: var(--bg-canvas);
  border: 1px solid var(--border-control);
  border-radius: 4px;
  padding: 0 6px;
  height: 26px;
  transition: border-color 0.15s;
}

.tpl-search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(13, 153, 255, 0.25);
}

.tpl-search-icon {
  font-size: 11px;
  margin-right: 5px;
  opacity: 0.7;
}

.tpl-search-box input {
  flex: 1;
  background: transparent !important;
  border: none !important;
  color: var(--text-bright);
  font-size: 11px;
  outline: none;
  padding: 0;
  height: 100%;
}

.tpl-search-clear {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 4px;
}

.tpl-search-clear:hover {
  color: #ffffff;
}

.tpl-matching-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 54px;
  overflow-y: auto;
  padding: 2px 0;
}

.tpl-topic-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  font-size: 9.5px;
  background: rgba(13, 153, 255, 0.12);
  border: 1px solid rgba(13, 153, 255, 0.35);
  color: #7dd3fc;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}

.tpl-topic-pill:hover,
.tpl-topic-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.tpl-filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.tpl-filter-grid select,
.tpl-topic-nav-row select {
  width: 100%;
  height: 24px;
  font-size: 10.5px;
  background-color: var(--bg-canvas);
  border: 1px solid var(--border-control);
  color: var(--text-main);
  border-radius: 4px;
  padding: 0 4px;
}

.tpl-topic-nav-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tpl-stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-dim);
  padding: 2px 0;
}

.tpl-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  max-height: calc(100vh - 350px);
  min-height: 280px;
  overflow-y: auto;
  padding: 4px;
  background-color: var(--bg-canvas);
  border: 1px solid var(--border-control);
  border-radius: 5px;
}

.tpl-loading-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 36px 12px;
  color: var(--text-dim);
  font-size: 11px;
}

.tpl-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background-color: #1b1c20;
  border: 1px solid #32353e;
  border-radius: 6px;
  overflow: hidden;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
  cursor: pointer;
}

.tpl-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.55);
}

.tpl-card-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: radial-gradient(circle at center, #262932 0%, #14161b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 4px;
}

.tpl-card-thumb svg,
.tpl-card-thumb img {
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 3px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  transition: transform 0.2s ease;
  pointer-events: none;
}

.tpl-card:hover .tpl-card-thumb svg,
.tpl-card:hover .tpl-card-thumb img {
  transform: scale(1.04);
}

.tpl-card-badge-top {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(15, 23, 42, 0.84);
  backdrop-filter: blur(4px);
  color: #38bdf8;
  font-size: 8.5px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid rgba(56, 189, 248, 0.3);
  pointer-events: none;
  max-width: calc(100% - 8px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tpl-card-dims-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(15, 23, 42, 0.82);
  color: #cbd5e1;
  font-size: 8px;
  font-family: monospace;
  padding: 1px 4px;
  border-radius: 3px;
  pointer-events: none;
}

.tpl-card-hover-actions {
  position: absolute;
  inset: 0;
  background: rgba(10, 14, 24, 0.82);
  backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px;
  opacity: 0;
  transition: opacity 0.14s ease;
}

.tpl-card:hover .tpl-card-hover-actions {
  opacity: 1;
}

.tpl-act-btn {
  width: 100%;
  height: 22px;
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.12s;
}

.tpl-act-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.tpl-act-btn.primary:hover {
  background: #0284c7;
}

.tpl-act-btn.secondary {
  background: rgba(30, 41, 59, 0.92);
  color: #e2e8f0;
}

.tpl-act-btn.secondary:hover {
  background: #334155;
  border-color: #38bdf8;
  color: #ffffff;
}

.tpl-card-info {
  padding: 5px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.tpl-card-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-bright);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tpl-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-dim);
}

.tpl-palette-dots {
  display: inline-flex;
  gap: 2px;
}

.tpl-palette-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.tpl-pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
  padding-top: 2px;
}

.tpl-page-jump {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-dim);
}

.tpl-page-jump input {
  width: 46px;
  height: 20px;
  text-align: center;
  font-size: 10px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-control);
  color: var(--text-bright);
  border-radius: 3px;
  padding: 0 2px;
}

/* Full-Screen Template Gallery Modal */
.tpl-gallery-modal-dialog {
  width: 94vw;
  max-width: 1480px;
  height: 88vh;
  background-color: #1e1f23;
  border: 1px solid #3f424c;
  border-radius: 10px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tpl-gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background-color: #25262b;
  border-bottom: 1px solid #363942;
  gap: 14px;
  flex-wrap: wrap;
}

.tpl-gallery-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tpl-gallery-badge {
  background: linear-gradient(135deg, #0d99ff, #6366f1);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.tpl-gallery-brand h3 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  color: #f8fafc;
}

.tpl-gallery-top-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: flex-end;
}

.tpl-modal-search {
  width: 340px;
  height: 30px;
}

.tpl-modal-select {
  height: 30px;
  font-size: 11.5px;
  background-color: #16171a;
  border: 1px solid #3c3f4a;
  color: #e2e8f0;
  border-radius: 5px;
  padding: 0 8px;
}

.tpl-gallery-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.tpl-gallery-sidebar {
  width: 245px;
  background-color: #18191d;
  border-right: 1px solid #32353e;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.tpl-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  font-size: 10.5px;
  font-weight: 700;
  color: #94a3b8;
  border-bottom: 1px solid #2b2d36;
}

.tpl-sidebar-filter {
  padding: 6px 8px;
  border-bottom: 1px solid #2b2d36;
}

.tpl-sidebar-filter input {
  width: 100%;
  height: 25px;
  background: #101114;
  border: 1px solid #32353e;
  border-radius: 4px;
  color: #f8fafc;
  font-size: 11px;
  padding: 0 8px;
}

.tpl-sidebar-topics-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tpl-sidebar-topic-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 11px;
  color: #cbd5e1;
  cursor: pointer;
  transition: background-color 0.1s;
}

.tpl-sidebar-topic-item:hover {
  background-color: #262932;
  color: #ffffff;
}

.tpl-sidebar-topic-item.active {
  background-color: rgba(13, 153, 255, 0.22);
  border-left: 3px solid var(--accent);
  color: #38bdf8;
  font-weight: 600;
}

.tpl-sidebar-topic-num {
  font-family: monospace;
  font-size: 9.5px;
  color: #64748b;
  margin-right: 6px;
}

.tpl-sidebar-topic-count {
  font-size: 9.5px;
  color: #64748b;
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 5px;
  border-radius: 8px;
}

.tpl-gallery-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background-color: #141518;
}

.tpl-gallery-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background-color: #1b1c20;
  border-bottom: 1px solid #2b2d36;
  font-size: 11.5px;
  color: #cbd5e1;
}

.tpl-gallery-pagination {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tpl-modal-page-indicator {
  font-size: 11px;
  font-weight: 600;
  color: #38bdf8;
  padding: 0 6px;
}

.tpl-gallery-grid {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  align-content: start;
}


