/* Modern Design System for TikZ Studio */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-surface-hover: #f1f5f9;
  --color-border: #e2e8f0;
  --color-border-hover: #cbd5e1;
  
  --color-text-main: #0f172a;
  --color-text-muted: #64748b;
  --color-text-subtle: #94a3b8;
  
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-primary-light: #eef2ff;
  --color-primary-border: #c7d2fe;
  
  --color-secondary: #0ea5e9;
  --color-success: #10b981;
  --color-danger: #ef4444;
  --color-warning: #f59e0b;
  
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

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

/* App Header & Navigation */
.app-header {
  background-color: #ffffff;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.4rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
}

.brand-icon {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, #4f46e5 0%, #3730a3 100%);
  color: #ffffff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.25);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text-main);
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.brand-subtitle {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  list-style: none;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-md);
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--color-text-muted);
  transition: all 0.15s ease;
}

.nav-item a:hover {
  color: var(--color-text-main);
  background-color: var(--color-surface-hover);
}

.nav-item.active a {
  color: var(--color-primary);
  background-color: var(--color-primary-light);
  font-weight: 600;
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.45rem;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
  font-size: 0.725rem;
  font-weight: 500;
  color: #475569;
}

/* Main Container Layouts */
.main-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  flex: 1;
  width: 100%;
}

/* Action Toolbar */
.toolbar-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0.5rem 0.85rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  box-shadow: var(--shadow-sm);
}

.toolbar-title-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.toolbar-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text-main);
  letter-spacing: -0.01em;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.scale-control-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--color-surface-hover);
  padding: 0.2rem 0.45rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.scale-input {
  width: 48px;
  padding: 0.15rem 0.35rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #ffffff;
  font-weight: 600;
  font-size: 0.825rem;
  text-align: center;
  color: var(--color-text-main);
}

/* Modern Buttons */
.btn-modern {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.38rem 0.75rem;
  font-size: 0.825rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  line-height: 1.25;
}

.btn-modern:active {
  transform: scale(0.98);
}

.btn-modern-primary {
  background-color: var(--color-primary);
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.2);
}

.btn-modern-primary:hover {
  background-color: var(--color-primary-hover);
  color: #ffffff;
}

.btn-modern-secondary {
  background-color: #ffffff;
  border-color: var(--color-border);
  color: var(--color-text-main);
}

.btn-modern-secondary:hover {
  background-color: var(--color-surface-hover);
  border-color: var(--color-border-hover);
}

.btn-modern-danger {
  background-color: #fee2e2;
  border-color: #fecaca;
  color: #b91c1c;
}

.btn-modern-danger:hover {
  background-color: #fecaca;
  color: #991b1b;
}

.btn-modern-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

.btn-modern-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Modern Two-Column Layout */
.studio-grid {
  display: grid;
  grid-template-columns: 460px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

@media (max-width: 1100px) {
  .studio-grid {
    grid-template-columns: 1fr;
  }
}

/* Left Panel - Modern Tabs/Accordion */
.studio-sidebar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.sidebar-tab-header {
  display: flex;
  background: #f8fafc;
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
  scrollbar-width: thin;
}

.tab-btn {
  padding: 0.5rem 0.85rem;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--color-text-muted);
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: var(--color-text-main);
  background: rgba(0, 0, 0, 0.02);
}

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  background: #ffffff;
}

.tab-panel-content {
  padding: 0.85rem;
  max-height: 520px;
  overflow-y: auto;
}

/* Card Sections Inside Controls */
.control-card {
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  transition: border-color 0.15s ease;
}

.control-card:hover {
  border-color: var(--color-border-hover);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.control-card:hover img {
  transform: scale(1.03);
}

.control-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.control-card-title {
  font-size: 0.825rem;
  font-weight: 700;
  color: var(--color-text-main);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Form Styles */
.form-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.45rem;
  font-size: 0.825rem;
}

.form-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.input-modern {
  padding: 0.25rem 0.45rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.825rem;
  color: var(--color-text-main);
  background: #ffffff;
  transition: all 0.15s ease;
}

.input-modern:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.coord-box {
  display: inline-flex;
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.35rem;
  font-size: 0.825rem;
  gap: 0.15rem;
  color: var(--color-text-muted);
}

.coord-box input {
  width: 36px;
  border: none;
  background: transparent;
  text-align: center;
  font-weight: 600;
  font-size: 0.825rem;
  color: var(--color-text-main);
  padding: 0;
}

.coord-box input:focus {
  outline: none;
  background: var(--color-primary-light);
  border-radius: 2px;
}

.select-modern {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #ffffff;
  font-size: 0.825rem;
  color: var(--color-text-main);
  cursor: pointer;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: var(--color-text-main);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--color-primary);
}

/* Preset buttons */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.preset-card-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #ffffff;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-card-btn:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  transform: translateY(-1px);
}

.preset-card-btn strong {
  font-size: 0.825rem;
  color: var(--color-text-main);
}

.preset-card-btn span {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  margin-top: 0.15rem;
}

.preset-filter-bar {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.preset-filter-btn {
  padding: 0.25rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 500;
  border-radius: 9999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.preset-filter-btn.active,
.preset-filter-btn:hover {
  background: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
}

.preset-badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  font-size: 0.65rem;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Canvas Viewport */
.canvas-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 0.85rem;
}

.canvas-header {
  padding: 0.5rem 0.85rem;
  background: #ffffff;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.canvas-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-main);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.canvas-hud {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--color-text-muted);
  background: #f1f5f9;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  border: 1px solid #e2e8f0;
}

.canvas-stage-wrapper {
  position: relative;
  background: #ffffff;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.5rem;
  min-height: 520px;
  background-image: radial-gradient(#e2e8f0 1px, transparent 1px);
  background-size: 20px 20px;
  overflow: auto;
}

.canvas-stage {
  position: relative;
  width: 600px;
  height: 580px;
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
}

.canvas-stage canvas {
  position: absolute;
  top: 0;
  left: 0;
}

/* LaTeX Output Code Block */
.code-card {
  background: #0f172a;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid #1e293b;
}

.code-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.85rem;
  background: #1e293b;
  border-bottom: 1px solid #334155;
}

.code-card-title {
  font-size: 0.825rem;
  font-weight: 600;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.code-badge {
  background: #334155;
  color: #94a3b8;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-sm);
  font-size: 0.725rem;
  font-family: var(--font-mono);
}

.code-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #334155;
  color: #f8fafc;
  border: 1px solid #475569;
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-copy:hover {
  background: #475569;
  color: #ffffff;
}

.code-viewport {
  padding: 1rem 1.25rem !important;
  max-height: 280px;
  overflow: auto;
  background: #0f172a !important;
  font-family: 'JetBrains Mono', 'Fira Code', var(--font-mono), monospace !important;
  font-size: 0.85rem !important;
  line-height: 1.65 !important;
  letter-spacing: 0.015em;
  color: #f8fafc !important;
  text-shadow: none !important;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-sizing: border-box;
}

.code-viewport.code-font-lg {
  font-size: 0.95rem !important;
  line-height: 1.7 !important;
}

.code-viewport.code-font-sm {
  font-size: 0.775rem !important;
  line-height: 1.55 !important;
}

.code-viewport pre,
.code-viewport pre[class*="language-"],
.latex-editor-container pre,
#tikz-output-code,
pre#tikz-output-code {
  margin: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  color: #f8fafc !important;
  text-shadow: none !important;
  font-family: 'JetBrains Mono', 'Fira Code', var(--font-mono), monospace !important;
  font-size: inherit !important;
  line-height: inherit !important;
  white-space: pre !important;
  word-break: normal !important;
  word-wrap: normal !important;
  user-select: text;
  -webkit-user-select: text;
}

.code-viewport pre.line-numbers {
  padding-left: 0 !important;
}

.code-viewport code,
.code-viewport code[class*="language-"] {
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: #f8fafc !important;
  text-shadow: none !important;
  font-family: inherit !important;
  font-size: inherit !important;
  line-height: inherit !important;
  display: block !important;
  white-space: pre !important;
}

.code-viewport #answer,
#answer,
span#answer {
  display: inline !important;
  color: #f8fafc !important;
  text-shadow: none !important;
  font-family: inherit !important;
  font-size: inherit !important;
  line-height: inherit !important;
  background: transparent !important;
  font-weight: 400 !important;
}

/* Syntax tokens inside LaTeX viewer */
.code-viewport .token-cmd { color: #a5b4fc !important; font-weight: 600; text-shadow: none !important; }
.code-viewport .token-brace { color: #cbd5e1 !important; text-shadow: none !important; }
.code-viewport .token-pkg { color: #38bdf8 !important; text-shadow: none !important; }
.code-viewport .token-body { color: #34d399 !important; text-shadow: none !important; }
.code-viewport .token-opt { color: #7dd3fc !important; text-shadow: none !important; }
.code-viewport .token-coord { color: #fbbf24 !important; text-shadow: none !important; }
.code-viewport .token-math { color: #4ade80 !important; text-shadow: none !important; }
.code-viewport .token-comment,
.code-viewport .token.comment { color: #94a3b8 !important; font-style: italic; text-shadow: none !important; }

/* Modern Footer */
.app-footer {
  margin-top: auto;
  background: #ffffff;
  border-top: 1px solid var(--color-border);
  padding: 0.85rem 1.25rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-nav {
  display: flex;
  gap: 1.5rem;
}

.footer-nav a {
  color: var(--color-text-muted);
}

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

/* Toast Notifications */
.toast-notice {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #ffffff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.toast-notice.show {
  opacity: 1;
  transform: translateY(0);
}

/* Timeline Custom Styles */
.timeline-grid {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .timeline-grid {
    grid-template-columns: 1fr;
  }
}

.event-chip {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.35rem 0.6rem;
  margin-bottom: 0.35rem;
  font-size: 0.825rem;
  width: 100%;
}

.event-chip-info {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.event-year-badge {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-family: var(--font-mono);
}

.btn-delete-chip {
  background: none;
  border: none;
  color: var(--color-text-subtle);
  cursor: pointer;
  padding: 0.15rem;
  border-radius: var(--radius-sm);
}

.btn-delete-chip:hover {
  color: var(--color-danger);
  background: #fee2e2;
}

/* Modern Accordion Styles */
#example2 {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  height: auto !important;
}

#example2 > li {
  border-bottom: 1px solid var(--color-border);
}

#example2 > li:last-child {
  border-bottom: none;
}

#example2 > li > a {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem !important;
  font-weight: 600 !important;
  font-size: 0.875rem !important;
  color: var(--color-text-main) !important;
  background: #f8fafc !important;
  background-image: none !important;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
  height: auto !important;
  width: auto !important;
  box-sizing: border-box;
}

#example2 > li > a:hover {
  background: #f1f5f9 !important;
  color: var(--color-primary) !important;
}

#example2 > li > a.opened {
  background: #eef2ff !important;
  background-image: none !important;
  color: var(--color-primary) !important;
  border-left: 4px solid var(--color-primary);
}

#example2 > li > a.closed {
  background: #f8fafc !important;
  background-image: none !important;
  color: var(--color-text-main) !important;
  border-left: 4px solid transparent;
}

#example2 > li > ul {
  background: #ffffff;
  padding: 0;
  margin: 0;
}

#example2 > li > ul > li {
  padding: 0.85rem !important;
  height: auto !important;
  max-height: 480px;
  overflow-y: auto;
  border-left: none !important;
  border-right: none !important;
}

/* Accordion Form Layout */
.form-section {
  margin-bottom: 0.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--color-border);
}

.form-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.form-section-title {
  font-size: 0.825rem;
  font-weight: 700;
  color: var(--color-text-main);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.item-card {
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.5rem;
  transition: all 0.15s ease;
}

.item-card:hover {
  border-color: var(--color-border-hover);
  background: #f1f5f9;
}

.item-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
  font-weight: 600;
  font-size: 0.825rem;
}

.options-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
  padding: 0.35rem 0.5rem;
  background: var(--color-surface-hover);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  font-size: 0.78rem;
}

/* Base style for all control labels in options-row */
.options-row label,
.options-row .checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

/* ==========================================================================
   Focus Mode Elements & Modern Options Chips
   ========================================================================== */

/* 1. Show Toggle Chip (Label 1) */
.options-row > label:nth-of-type(1),
main:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(1) > ul#example2:nth-of-type(1) > li:nth-of-type(2) > ul:nth-of-type(1) > li:nth-of-type(1) > form#Retangularform:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(3) > label:nth-of-type(1) {
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  background: #ffffff;
  border: 1px solid #d1d5db;
  color: var(--color-text-main);
  font-weight: 600;
}

.options-row > label:nth-of-type(1):hover,
main:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(1) > ul#example2:nth-of-type(1) > li:nth-of-type(2) > ul:nth-of-type(1) > li:nth-of-type(1) > form#Retangularform:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(3) > label:nth-of-type(1):hover {
  background: #f0fdf4;
  border-color: #10b981;
}

.options-row > label:nth-of-type(1):has(input:checked),
.options-row > label:nth-of-type(1).is-checked {
  background: #ecfdf5;
  border-color: #6ee7b7;
  color: #065f46;
}

/* 2. Mouse Draw Toggle Chip (Label 2) */
.options-row > label:nth-of-type(2),
main:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(1) > ul#example2:nth-of-type(1) > li:nth-of-type(2) > ul:nth-of-type(1) > li:nth-of-type(1) > form#Retangularform:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(3) > label:nth-of-type(2) {
  padding: 0.22rem 0.65rem;
  border-radius: 9999px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #4338ca;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.08);
}

.options-row > label:nth-of-type(2):hover,
main:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(1) > ul#example2:nth-of-type(1) > li:nth-of-type(2) > ul:nth-of-type(1) > li:nth-of-type(1) > form#Retangularform:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(3) > label:nth-of-type(2):hover {
  background: #e0e7ff;
  border-color: #818cf8;
  color: #3730a3;
  transform: translateY(-1px);
}

.options-row > label:nth-of-type(2):has(input:checked),
.options-row > label:nth-of-type(2).is-checked,
.options-row > label:nth-of-type(2).is-drawing-active,
main:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(1) > ul#example2:nth-of-type(1) > li:nth-of-type(2) > ul:nth-of-type(1) > li:nth-of-type(1) > form#Retangularform:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(3) > label:nth-of-type(2):has(input:checked) {
  background: #4f46e5 !important;
  border-color: #4338ca !important;
  color: #ffffff !important;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.4) !important;
}

.options-row > label:nth-of-type(2):has(input:checked) input,
.options-row > label:nth-of-type(2).is-checked input {
  accent-color: #ffffff;
}

/* 3, 4, 5. Point Selector Chips (All, Pt 1, Pt 2) */
.options-row > label:nth-of-type(3),
.options-row > label:nth-of-type(4),
.options-row > label:nth-of-type(5) {
  padding: 0.16rem 0.45rem;
  border-radius: 4px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--color-text-muted);
  font-size: 0.72rem;
  font-weight: 500;
}

.options-row > label:nth-of-type(3):hover,
.options-row > label:nth-of-type(4):hover,
.options-row > label:nth-of-type(5):hover {
  background: #ffffff;
  color: var(--color-text-main);
  border-color: var(--color-border);
}

.options-row > label:nth-of-type(3):has(input:checked),
.options-row > label:nth-of-type(4):has(input:checked),
.options-row > label:nth-of-type(5):has(input:checked),
.options-row > label:nth-of-type(3).is-checked,
.options-row > label:nth-of-type(4).is-checked,
.options-row > label:nth-of-type(5).is-checked {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #4f46e5;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* Target Inputs 3, 4, 5 */
.options-row > label:nth-of-type(3) > input#retangular_1:nth-of-type(1),
.options-row > label:nth-of-type(4) > input#RP1_1:nth-of-type(1),
.options-row > label:nth-of-type(5) > input#RP2_1:nth-of-type(1),
main:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(1) > ul#example2:nth-of-type(1) > li:nth-of-type(2) > ul:nth-of-type(1) > li:nth-of-type(1) > form#Retangularform:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(3) > label:nth-of-type(3) > input#retangular_1:nth-of-type(1),
main:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(1) > ul#example2:nth-of-type(1) > li:nth-of-type(2) > ul:nth-of-type(1) > li:nth-of-type(1) > form#Retangularform:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(3) > label:nth-of-type(4) > input#RP1_1:nth-of-type(1),
main:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(1) > ul#example2:nth-of-type(1) > li:nth-of-type(2) > ul:nth-of-type(1) > li:nth-of-type(1) > form#Retangularform:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(3) > label:nth-of-type(5) > input#RP2_1:nth-of-type(1) {
  accent-color: #4f46e5;
  width: 13px;
  height: 13px;
  cursor: pointer;
  margin: 0;
}

/* 6. Dash Toggle Chip (Label 6) */
.options-row > label:nth-of-type(6),
main:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(1) > ul#example2:nth-of-type(1) > li:nth-of-type(2) > ul:nth-of-type(1) > li:nth-of-type(1) > form#Retangularform:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(3) > label:nth-of-type(6) {
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  background: #ffffff;
  border: 1px dashed #cbd5e1;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.options-row > label:nth-of-type(6):hover,
main:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(1) > ul#example2:nth-of-type(1) > li:nth-of-type(2) > ul:nth-of-type(1) > li:nth-of-type(1) > form#Retangularform:nth-of-type(1) > div:nth-of-type(2) > div:nth-of-type(3) > label:nth-of-type(6):hover {
  border-color: #a855f7;
  color: #7e22ce;
  background: #faf5ff;
}

.options-row > label:nth-of-type(6):has(input:checked),
.options-row > label:nth-of-type(6).is-checked {
  background: #faf5ff;
  border-color: #d8b4fe;
  color: #7e22ce;
  font-weight: 600;
}

/* Active card drawing highlight */
.item-card.is-active-drawing {
  border-color: #6366f1 !important;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25), 0 4px 12px rgba(99, 102, 241, 0.1) !important;
  background: #fdfefe !important;
}

/* ==========================================================================
   Canvas Drawing Quick Toolbar & Guide Banner
   ========================================================================== */

.canvas-draw-toolbar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  background: #f8fafc;
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.tool-btn:hover {
  background: #f1f5f9;
  color: var(--color-text-main);
  border-color: #cbd5e1;
}

.tool-btn.active {
  background: #4f46e5;
  color: #ffffff;
  border-color: #4338ca;
  box-shadow: 0 1px 3px rgba(79, 70, 229, 0.3);
}

.tool-btn.active svg {
  stroke: #ffffff;
}

.tool-btn-snap {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: #f0fdf4;
  color: #166534;
  border-color: #bbf7d0;
}

.tool-btn-snap:hover {
  background: #dcfce7;
  color: #15803d;
}

.toolbar-separator {
  width: 1px;
  height: 20px;
  background: var(--color-border);
  margin: 0 0.25rem;
}

.download-btn-group {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.tool-btn-download {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
  font-weight: 600;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
}

.tool-btn-download:hover {
  background: #dbeafe;
  color: #1e40af;
  border-color: #93c5fd;
}

.tool-btn-download svg {
  stroke: #1d4ed8;
}

.tool-btn-options {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  padding: 0.25rem 0.35rem;
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tool-btn-options:hover {
  background: #dbeafe;
  color: #1e40af;
  border-color: #93c5fd;
}

.png-options-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 250px;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  padding: 0.75rem;
  z-index: 100;
}

.png-opt-header {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text-main);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid #f1f5f9;
}

.png-opt-row {
  margin-bottom: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.png-opt-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.png-opt-select {
  font-size: 0.75rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  color: var(--color-text-main);
  outline: none;
}

.png-opt-select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.png-export-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #f8fafc;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
  border: 1px solid #334155;
  z-index: 9999;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.png-export-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Drawing Guide Assistant Banner */
.drawing-guide-banner {
  padding: 0.45rem 0.85rem;
  background: #eef2ff;
  border-bottom: 1px solid #c7d2fe;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  animation: guideSlideDown 0.2s ease;
}

.guide-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  background: #4f46e5;
  color: #ffffff;
  border-radius: 4px;
}

.guide-text {
  font-size: 0.78rem;
  font-weight: 600;
  color: #3730a3;
  flex: 1;
}

.guide-cancel-btn {
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #4338ca;
  background: #ffffff;
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.guide-cancel-btn:hover {
  background: #e0e7ff;
  color: #312e81;
}

.curve-step-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: #e0e7ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.curve-step-chip.completed {
  background: #dcfce7;
  color: #15803d;
  border-color: #86efac;
}

.curve-step-chip.active {
  background: #4f46e5;
  color: #ffffff;
  border-color: #4338ca;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
  font-weight: 700;
}

@keyframes guideSlideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Canvas-First Direct Drawing & Floating Confirmation Overlays
   ========================================================================== */

/* Hierarchy Clarification Banner in Left Column */
.sidebar-role-banner {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.85rem;
  box-shadow: var(--shadow-sm);
}

.sidebar-role-banner .role-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 0.25rem;
}

.sidebar-role-banner .role-title svg {
  color: #4f46e5;
}

.sidebar-role-banner .role-desc {
  font-size: 0.74rem;
  line-height: 1.4;
  color: var(--color-text-muted);
}

.sidebar-role-banner .role-desc strong {
  color: #4338ca;
}

/* Floating On-Canvas Final Confirmation Card */
.shape-confirm-card {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 320px;
  max-width: calc(100% - 28px);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-md);
  box-shadow: 0 16px 36px -8px rgba(15, 23, 42, 0.22), 0 4px 12px -2px rgba(15, 23, 42, 0.08);
  padding: 0.85rem;
  z-index: 30;
  animation: confirmFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

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

.confirm-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 0.55rem;
}

.confirm-title-area {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.confirm-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  background: #e0e7ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
}

.confirm-coords {
  font-family: 'JetBrains Mono', monospace, monospace;
  font-size: 0.75rem;
  font-weight: 600;
  color: #1e293b;
}

.confirm-close-btn {
  background: transparent;
  border: none;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0.2rem 0.35rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.confirm-close-btn:hover {
  background: #fee2e2;
  color: #dc2626;
}

.confirm-body {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 0.75rem;
}

.confirm-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.confirm-dim-pill {
  font-size: 0.72rem;
  font-weight: 600;
  color: #4338ca;
  background: #eef2ff;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  border: 1px solid #e0e7ff;
}

.confirm-hint {
  font-size: 0.68rem;
  color: var(--color-text-muted);
  font-style: italic;
}

.confirm-props-row,
.confirm-row-flex {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.confirm-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.confirm-field label {
  font-size: 0.68rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.confirm-input {
  width: 100%;
  padding: 0.3rem 0.5rem;
  font-size: 0.76rem;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: #0f172a;
}

.confirm-input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.quick-chip {
  padding: 0.12rem 0.38rem;
  font-size: 0.68rem;
  font-weight: 600;
  border-radius: 4px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  cursor: pointer;
  line-height: 1.2;
  transition: all 0.15s ease;
}

.quick-chip:hover {
  background: #e0e7ff;
  border-color: #a5b4fc;
  color: #4338ca;
}

.quick-chip:active {
  transform: scale(0.96);
}

.confirm-style-toggle {
  display: flex;
  background: #f1f5f9;
  border-radius: var(--radius-sm);
  padding: 2px;
  border: 1px solid #e2e8f0;
}

.style-toggle-btn {
  background: transparent;
  border: none;
  padding: 0.25rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #64748b;
  border-radius: calc(var(--radius-sm) - 2px);
  cursor: pointer;
  transition: all 0.15s ease;
}

.style-toggle-btn.active {
  background: #ffffff;
  color: #4338ca;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.confirm-color-swatches {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.color-swatch {
  width: 18px;
  height: 18px;
  border-radius: 9999px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s ease;
}

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

.color-swatch.active {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px #4f46e5;
  transform: scale(1.15);
}

.confirm-slot-select {
  padding: 0.3rem 0.4rem;
  font-size: 0.74rem;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: #1e293b;
  cursor: pointer;
}

.confirm-actions {
  display: flex;
  gap: 0.45rem;
  justify-content: flex-end;
}

.btn-confirm-discard {
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-confirm-discard:hover {
  background: #f1f5f9;
  color: #334155;
}

.btn-confirm-apply {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.9rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #ffffff;
  background: #4f46e5;
  border: 1px solid #4338ca;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.25);
  transition: all 0.15s ease;
}

.btn-confirm-apply:hover {
  background: #4338ca;
  transform: translateY(-1px);
}

/* Floating Selected Shape Actions Bar */
.shape-selected-card {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 9999px;
  padding: 0.4rem 0.85rem;
  color: #ffffff;
  box-shadow: 0 12px 28px -6px rgba(0, 0, 0, 0.35);
  z-index: 25;
  animation: selectedSlideUp 0.18s ease;
}

@keyframes selectedSlideUp {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.selected-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.selected-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  background: #4f46e5;
  color: #ffffff;
  padding: 0.15rem 0.45rem;
  border-radius: 9999px;
}

.selected-coords {
  font-family: monospace;
  font-size: 0.74rem;
  color: #cbd5e1;
}

.selected-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-selected-scroll {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-selected-scroll:hover {
  background: rgba(255, 255, 255, 0.25);
}

.btn-selected-delete {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-selected-delete:hover {
  background: rgba(239, 68, 68, 0.4);
  color: #ffffff;
}

.btn-selected-close {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  padding: 0 0.25rem;
}

.btn-selected-close:hover {
  color: #ffffff;
}

/* Secondary form item card highlight on sync */
.item-card.is-newly-synchronized {
  animation: syncCardGlow 2s ease;
}

@keyframes syncCardGlow {
  0% {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.35);
    background-color: #f5f3ff;
  }
  70% {
    border-color: #818cf8;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
    background-color: #f5f3ff;
  }
  100% {
    border-color: var(--color-border);
    box-shadow: var(--shadow-sm);
    background-color: var(--color-surface);
  }
}

/* Tool Confirm Mode Toggle Badge */
.tool-btn-confirm {
  font-weight: 600;
}

.badge-confirm-on {
  color: #059669;
  font-weight: 800;
}

.badge-confirm-off {
  color: #6b7280;
  font-weight: 700;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .header-container {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  
  .nav-links {
    justify-content: space-between;
    overflow-x: auto;
  }
  
  .toolbar-card {
    flex-direction: column;
    align-items: stretch;
  }
  
  .footer-inner {
    flex-direction: column;
    text-align: center;
  }
}

/* Floating Viewport Navigator Widget */
.canvas-floating-nav {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 3px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 3px 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  user-select: none;
}

.nav-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 5px;
  background: transparent;
  border: 1px solid transparent;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-icon-btn:hover {
  background: #f1f5f9;
  color: #1e293b;
  border-color: #cbd5e1;
}

.nav-icon-btn:active {
  background: #e2e8f0;
  transform: scale(0.95);
}

.nav-zoom-text {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 700;
  color: #334155;
  min-width: 42px;
  text-align: center;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}

.nav-zoom-text:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.nav-divider {
  width: 1px;
  height: 16px;
  background: #cbd5e1;
  margin: 0 2px;
}

/* Undo / Redo Controls & Disabled States */
.tool-btn:disabled,
.tool-btn[disabled],
.btn-modern:disabled,
.btn-modern[disabled],
.nav-icon-btn:disabled,
.nav-icon-btn[disabled] {
  opacity: 0.42 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  filter: grayscale(0.5);
  box-shadow: none !important;
}

.undo-redo-btn-group,
.undo-redo-group {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

/* ==========================================================================
   Color Palette & Custom Color Picker Component Styles
   ========================================================================== */

.color-picker-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #ffffff;
  border: 1px solid var(--color-border, #cbd5e1);
  border-radius: var(--radius-sm, 6px);
  padding: 0.2rem 0.45rem;
  font-size: 0.76rem;
  font-family: inherit;
  font-weight: 500;
  color: var(--color-text-main, #334155);
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.2;
  user-select: none;
}

.color-picker-trigger:hover {
  border-color: var(--color-primary, #4f46e5);
  background: #f8fafc;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.color-trigger-swatch {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
  display: inline-block;
  flex-shrink: 0;
}

.color-trigger-label {
  text-transform: capitalize;
  font-family: 'JetBrains Mono', monospace, sans-serif;
  font-size: 0.74rem;
}

.color-trigger-icon {
  color: var(--color-text-muted, #94a3b8);
  display: flex;
  align-items: center;
}

/* Floating Color Palette & Picker Popover */
.tikz-color-popover {
  position: absolute;
  z-index: 1050;
  width: 276px;
  background: #ffffff;
  border: 1px solid var(--color-border, #cbd5e1);
  border-radius: 10px;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.18), 0 8px 10px -6px rgba(15, 23, 42, 0.1);
  overflow: hidden;
  font-family: inherit;
  animation: popoverFadeIn 0.15s ease-out;
}

@keyframes popoverFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.color-popover-header {
  background: #f8fafc;
  border-bottom: 1px solid var(--color-border, #e2e8f0);
  padding: 0.5rem 0.65rem 0.4rem;
}

.color-popover-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.color-popover-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-main, #0f172a);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.color-popover-close-btn {
  border: none;
  background: transparent;
  font-size: 1.1rem;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  padding: 0 0.2rem;
  border-radius: 4px;
}

.color-popover-close-btn:hover {
  color: #0f172a;
  background: #e2e8f0;
}

.color-popover-tabs {
  display: flex;
  background: #e2e8f0;
  padding: 2px;
  border-radius: 6px;
  gap: 2px;
}

.color-tab-btn {
  flex: 1;
  padding: 0.25rem 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.color-tab-btn.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.color-popover-body {
  padding: 0.65rem;
  max-height: 290px;
  overflow-y: auto;
}

.palette-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.35rem;
}

.palette-swatches-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.35rem;
}

.palette-swatch-item {
  aspect-ratio: 1;
  width: 100%;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  padding: 0;
}

.palette-swatch-item:hover {
  transform: scale(1.12);
  z-index: 2;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2), inset 0 0 0 1px #fff;
}

.palette-swatch-item.active {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px var(--color-primary, #4f46e5);
}

.swatch-check {
  font-size: 0.65rem;
  font-weight: bold;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Custom Picker Tab */
.custom-picker-pane {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.custom-picker-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.custom-wheel-wrapper {
  position: relative;
  width: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  padding: 0.35rem;
  background: #f8fafc;
  cursor: pointer;
}

.native-color-input {
  width: 100%;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.native-color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.native-color-input::-webkit-color-swatch {
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 4px;
}

.custom-wheel-label {
  display: none;
}

.custom-color-preview-box {
  flex: 1;
  height: 38px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  transition: background-color 0.15s ease;
}

.preview-hex-tag {
  background: rgba(15, 23, 42, 0.75);
  color: #ffffff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.custom-inputs-group {
  display: flex;
  gap: 0.35rem;
}

.custom-input-field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.custom-input-field label {
  font-size: 0.62rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
}

.custom-input-field input {
  font-size: 0.72rem;
  padding: 0.2rem 0.35rem;
  font-family: 'JetBrains Mono', monospace;
  text-align: center;
}

.custom-input-field .rgb-num {
  width: 38px;
}

#custom-hex-input {
  width: 76px;
}

/* Popover Footer */
.color-popover-footer {
  background: #f8fafc;
  border-top: 1px solid var(--color-border, #e2e8f0);
  padding: 0.45rem 0.65rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.tikz-live-badge {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  overflow: hidden;
  max-width: 140px;
}

.tikz-badge-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: #475569;
}

.tikz-badge-code {
  font-size: 0.68rem;
  font-family: 'JetBrains Mono', monospace;
  background: #e2e8f0;
  color: #0f172a;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   COORDINATE STUDIO LAYERING SIDEBAR
   ========================================================================== */

.canvas-workspace-layout {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  position: relative;
  background: #ffffff;
  border-bottom: 1px solid var(--color-border);
  min-height: 580px;
  overflow: hidden;
}

.canvas-workspace-layout .canvas-stage-wrapper {
  flex: 1;
  min-width: 0;
  border-right: 1px solid var(--color-border);
  position: relative;
}

/* Layering Sidebar Container */
.layering-sidebar {
  width: 320px;
  min-width: 300px;
  max-width: 360px;
  flex-shrink: 0;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--color-border);
  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.18s ease;
  position: relative;
  z-index: 20;
}

.layering-sidebar.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  border-left: none;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

/* Sidebar Header */
.layering-sidebar-header {
  padding: 0.65rem 0.85rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.layering-sidebar-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-main);
  letter-spacing: -0.01em;
}

.layer-header-badge {
  font-size: 0.68rem;
  font-weight: 600;
  color: #4338ca;
  background: #e0e7ff;
  padding: 0.1rem 0.45rem;
  border-radius: 9999px;
  letter-spacing: normal;
}

.layering-header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.layer-header-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.layer-header-btn:hover {
  background: #f1f5f9;
  border-color: var(--color-border);
  color: var(--color-text-main);
}

/* Controls Bar (Search + Filter Pills) */
.layering-controls-bar {
  padding: 0.5rem 0.75rem;
  background: #ffffff;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.layer-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.layer-search-icon {
  position: absolute;
  left: 8px;
  pointer-events: none;
}

.layer-search-input {
  width: 100%;
  padding: 0.35rem 0.5rem 0.35rem 1.6rem;
  font-size: 0.75rem;
  font-family: var(--font-sans);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  color: var(--color-text-main);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.layer-search-input:focus {
  border-color: var(--color-primary);
  background: #ffffff;
}

.layer-filter-pills {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  overflow-x: auto;
}

.layer-pill {
  font-size: 0.68rem;
  font-weight: 500;
  padding: 0.15rem 0.45rem;
  border-radius: 9999px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: var(--color-text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.layer-pill:hover {
  background: #e2e8f0;
  color: var(--color-text-main);
}

.layer-pill.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #ffffff;
  font-weight: 600;
}

/* Scrollable Layer Stack Container */
.layer-list-scrollable {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 250px;
  background: #fafbfc;
}

/* Layer Card Item */
.layer-card-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.55rem;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}

.layer-card-item:hover {
  background: #f8fafc;
  border-color: var(--color-border-hover);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.layer-card-item.layer-selected {
  border-color: var(--color-primary);
  background: #f5f3ff;
  box-shadow: 0 0 0 1.5px rgba(79, 70, 229, 0.25);
}

.layer-card-item.layer-locked {
  background: #fffbeb;
  border-color: #fde68a;
}

.layer-card-item.layer-hidden {
  opacity: 0.55;
  background: #f1f5f9;
}

/* Drag & Drop Feedback */
.layer-card-item.dragging-layer {
  opacity: 0.35;
  border-style: dashed;
  border-color: var(--color-primary);
}

.layer-card-item.drag-over-top::before {
  content: '';
  position: absolute;
  top: -3px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-primary);
  border-radius: 2px;
  z-index: 10;
}

.layer-card-item.drag-over-bottom::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-primary);
  border-radius: 2px;
  z-index: 10;
}

/* Drag Grip */
.layer-grip-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  color: #94a3b8;
  padding: 0.15rem 0.1rem;
  flex-shrink: 0;
}

.layer-grip-handle:hover {
  color: var(--color-text-main);
}

.layer-grip-handle:active {
  cursor: grabbing;
}

/* Color Dot */
.layer-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

/* Layer Info Column */
.layer-info-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.layer-header-line {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  line-height: 1.2;
}

.layer-type-tag {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  background: #f1f5f9;
  color: #475569;
  flex-shrink: 0;
}

.layer-tag-line { background: #dbeafe; color: #1e40af; }
.layer-tag-curve { background: #fae8ff; color: #86198f; }
.layer-tag-rectangle { background: #fef3c7; color: #92400e; }
.layer-tag-circle { background: #dcfce7; color: #166534; }
.layer-tag-point { background: #ffe4e6; color: #9f1239; }
.layer-tag-axis { background: #f1f5f9; color: #334155; }

.layer-title-text {
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--color-text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-locked-badge {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #b45309;
  background: #fef3c7;
  padding: 0.05rem 0.25rem;
  border-radius: 3px;
  flex-shrink: 0;
}

.layer-desc-text {
  font-size: 0.675rem;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Layer Actions Group */
.layer-actions-group {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
}

.btn-layer-icon {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-layer-icon:hover:not(:disabled) {
  background: #e2e8f0;
  color: var(--color-text-main);
  border-color: #cbd5e1;
}

.btn-layer-icon.active-hidden {
  color: #94a3b8;
}

.btn-layer-icon.active-locked {
  color: #d97706;
}

/* Empty State */
.layers-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2.5rem 1rem;
  background: #ffffff;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  margin: auto 0;
}

/* Sidebar Footer */
.layering-sidebar-footer {
  padding: 0.5rem 0.75rem;
  background: #f8fafc;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.layer-zorder-hint {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.65rem;
  font-family: var(--font-mono);
  color: var(--color-text-subtle);
  user-select: none;
}

.layer-footer-btns {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.layer-footer-btn {
  flex: 1;
  padding: 0.25rem 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.layer-footer-btn:hover {
  background: #f1f5f9;
  border-color: var(--color-border-hover);
}

/* Responsive adjustment for Layering Sidebar */
@media (max-width: 1200px) {
  .canvas-workspace-layout {
    flex-direction: column;
  }
  .canvas-workspace-layout .canvas-stage-wrapper {
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }
  .layering-sidebar {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    border-left: none;
    max-height: 380px;
  }
  .layering-sidebar.collapsed {
    max-height: 0 !important;
  }
}




