/* Style variables & Design system */
:root {
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Outfit', sans-serif;

  /* Theme color defaults: Dark mode */
  --bg-app: #080b11;
  --bg-panel: rgba(15, 22, 38, 0.7);
  --bg-card: rgba(26, 36, 57, 0.55);
  --border-color: rgba(255, 255, 255, 0.07);
  --border-focus: rgba(99, 102, 241, 0.4);
  
  --text-main: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-primary: #6366f1; /* Indigo */
  --accent-primary-hover: #4f46e5;
  --accent-secondary: #06b6d4; /* Cyan */
  --accent-secondary-hover: #0891b2;
  --accent-warn: #eab308; /* Amber */
  --accent-danger: #ef4444; /* Red */
  --accent-danger-hover: #dc2626;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.15), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 15px rgba(99, 102, 241, 0.25);
  
  --blur-val: 12px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

/* Light Theme overrides */
body.light-theme {
  --bg-app: #f1f5f9;
  --bg-panel: rgba(255, 255, 255, 0.75);
  --bg-card: rgba(241, 245, 249, 0.85);
  --border-color: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(99, 102, 241, 0.6);
  
  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --accent-primary: #4f46e5;
  --accent-primary-hover: #3730a3;
  --shadow-glow: 0 0 15px rgba(99, 102, 241, 0.15);
}

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

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-body);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* App Layout Container */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* Header */
.app-header {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background-color: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(var(--blur-val));
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-header-sidebar {
  display: none; /* Shown on mobile */
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
}

.logo {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
}

.logo-accent {
  color: var(--accent-primary);
  text-shadow: 0 0 8px rgba(99, 102, 241, 0.3);
}

.subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 400;
  margin-right: auto;
  margin-left: 20px;
  padding-left: 20px;
  border-left: 1px solid var(--border-color);
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
}

.btn-icon:hover {
  color: var(--text-main);
  background-color: var(--border-color);
  transform: scale(1.05);
}

.coffee-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.coffee-link:hover {
  color: #FF5E5B;
  border-color: #FF5E5B;
  transform: scale(1.05);
}

.coffee-icon {
  font-size: 14px;
}


.sun-icon {
  display: none;
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.moon-icon {
  display: block;
  width: 20px;
  height: 20px;
  fill: currentColor;
}

body.light-theme .sun-icon {
  display: block;
}

body.light-theme .moon-icon {
  display: none;
}

/* Main Workspace Grid */
.app-main-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 60px);
  transition: grid-template-columns 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-main-grid.sidebar-collapsed {
  grid-template-columns: 0px 1fr !important;
}

/* Left Sidebar Panel */
.left-panel {
  background-color: var(--bg-panel);
  border-right: 1px solid var(--border-color);
  backdrop-filter: blur(var(--blur-val));
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  height: 100%;
  max-height: 100%;
  overflow-y: auto;
  min-width: 0;
  box-sizing: border-box;
  scrollbar-width: auto;
  scrollbar-color: rgba(255, 255, 255, 0.25) rgba(0, 0, 0, 0.15);
  transition: padding 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease, border-color 0.3s ease;
}

.app-main-grid.sidebar-collapsed .left-panel {
  padding-left: 0 !important;
  padding-right: 0 !important;
  opacity: 0;
  pointer-events: none;
  border-right-color: transparent;
  visibility: hidden;
  overflow: hidden;
}

/* Sidebar Panel Header */
.sidebar-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.sidebar-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-main);
  text-transform: uppercase;
}

.sidebar-panel-title svg {
  color: var(--accent-primary);
}

.btn-collapse-sidebar {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-collapse-sidebar:hover {
  color: var(--text-main);
  border-color: var(--accent-primary);
  background: var(--border-color);
}

.btn-fold-panel {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-fold-panel:hover {
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  background: var(--border-color);
}

/* Sidebar Toggle Button in Toolbar */
.btn-sidebar-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-sidebar-toggle:hover {
  color: var(--text-main);
  border-color: var(--text-secondary);
  background-color: var(--border-color);
}

.app-main-grid.sidebar-collapsed .btn-sidebar-toggle,
.btn-sidebar-toggle.active {
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  background-color: rgba(99, 102, 241, 0.12);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.2);
}

.left-panel::-webkit-scrollbar {
  width: 10px; /* Clearly visible width */
}
.left-panel::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 5px;
}
.left-panel::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.25); /* High contrast thumb */
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: padding-box;
  transition: background-color 0.2s;
}
.left-panel::-webkit-scrollbar-thumb:hover {
  background-color: var(--accent-primary); /* High visibility glow on hover */
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.control-group h3 {
  font-family: var(--font-display);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  font-weight: 700;
}

/* Preset Buttons Grid */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:hover:not(:disabled) {
  background-color: var(--border-color);
  border-color: var(--text-secondary);
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

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

.btn-preset {
  font-weight: 400;
  text-align: left;
  justify-content: flex-start;
  padding: 8px 12px;
}

/* Drawing tools button bar */
.tool-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.btn-tool {
  justify-content: center;
  font-weight: 600;
  position: relative;
}

.btn-tool.active {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #ffffff;
  box-shadow: var(--shadow-glow);
}

.btn-tool.active:hover {
  background-color: var(--accent-primary-hover);
  border-color: var(--accent-primary-hover);
}

.indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.outer-dot {
  background-color: var(--accent-secondary);
  box-shadow: 0 0 6px var(--accent-secondary);
}

.btn-tool.active .outer-dot {
  background-color: #ffffff;
  box-shadow: 0 0 6px #ffffff;
}

.hole-dot {
  background-color: var(--accent-warn);
  box-shadow: 0 0 6px var(--accent-warn);
}

.btn-tool.active .hole-dot {
  background-color: #ffffff;
  box-shadow: 0 0 6px #ffffff;
}

.action-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 8px;
}

.btn-danger {
  background-color: var(--accent-danger);
  border-color: var(--accent-danger);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background-color: var(--accent-danger-hover);
  border-color: var(--accent-danger-hover);
}

.btn-danger-outline {
  border-color: var(--accent-danger);
  color: var(--accent-danger);
  background: transparent;
}

.btn-danger-outline:hover {
  background-color: rgba(239, 68, 68, 0.08);
}

/* Slider Controls */
.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.badge {
  font-family: var(--font-display);
  background-color: var(--accent-primary);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  box-shadow: var(--shadow-glow);
}

.slider-wrapper {
  padding: 4px 0;
}

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

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-primary);
  transition: transform 0.1s ease;
}

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

/* Visualizations check lists */
.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-color: var(--bg-card);
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: color 0.2s ease;
}

.toggle-item:hover {
  color: var(--text-main);
}

.toggle-item input[type="checkbox"] {
  display: none;
}

.checkbox-custom {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--text-muted);
  border-radius: 4px;
  display: inline-block;
  position: relative;
  transition: all 0.2s ease;
}

.checkbox-custom.small {
  width: 14px;
  height: 14px;
}

.toggle-item input[type="checkbox"]:checked + .checkbox-custom {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.4);
}

.toggle-item input[type="checkbox"]:checked + .checkbox-custom::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1px;
  width: 4px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox-custom.small::after {
  left: 3px !important;
  top: 0px !important;
  width: 3px !important;
  height: 7px !important;
}

.inline-toggle {
  margin-right: 15px;
  font-size: 12px;
}

/* Vertices Accordion lists */
.coords-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.accordion {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}

.accordion-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.accordion-header {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  background-color: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid transparent;
  transition: background-color 0.2s ease;
}

.accordion-header:hover {
  background-color: rgba(255, 255, 255, 0.04);
}

.accordion-item.expanded .accordion-header {
  border-bottom-color: var(--border-color);
}

.coords-count {
  font-family: var(--font-display);
  font-size: 11px;
  background-color: rgba(255, 255, 255, 0.07);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-secondary);
}

.accordion-content {
  display: none;
  max-height: 200px;
  overflow-y: auto;
}

.accordion-item.expanded .accordion-content {
  display: block;
}

.coords-list {
  list-style: none;
}

.coords-list li {
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-display);
  font-size: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.coords-list li:last-child {
  border-bottom: none;
}

.coord-text {
  color: var(--text-secondary);
}

.btn-delete-pt {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: color 0.1s ease;
}

.btn-delete-pt:hover {
  color: var(--accent-danger);
}

.empty-list-msg {
  padding: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* Holes Accordion list inner structures */
.hole-section {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 6px;
}
.hole-section:last-child {
  border-bottom: none;
}

.hole-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px 4px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent-warn);
}

/* Right Display Panel: Canvas & Properties */
.canvas-and-results {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

/* Canvas Wrapper */
.canvas-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: var(--bg-app);
}

.canvas-toolbar {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-color);
  background-color: rgba(255, 255, 255, 0.01);
}

.coords-display {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--text-secondary);
}

.coord-val {
  color: var(--accent-secondary);
  font-weight: 500;
}

.canvas-controls {
  display: flex;
  align-items: center;
}

.btn-small {
  padding: 6px 12px;
  font-size: 11px;
  border-radius: 4px;
}

.canvas-viewport-container {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  outline: none;
}

#viewport-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* Centered Canvas Instructions Overlay */
.canvas-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(8, 11, 17, 0.4);
  backdrop-filter: blur(4px);
  z-index: 5;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.overlay-card {
  background-color: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
}

.draw-icon {
  width: 48px;
  height: 48px;
  color: var(--accent-primary);
  margin-bottom: 4px;
}

.overlay-card h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
}

.overlay-card p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.shortcuts {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  background-color: rgba(0, 0, 0, 0.15);
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.shortcuts div {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
}

.shortcuts span {
  font-family: var(--font-display);
  background-color: var(--border-color);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-main);
  font-size: 11px;
}

/* Calculated Results Dashboard */
.results-dashboard {
  background-color: var(--bg-panel);
  border-bottom: 1px solid var(--border-color); /* Divider below the panel */
  backdrop-filter: blur(var(--blur-val));
  padding: 8px 18px; /* Very compact vertical spacing */
  z-index: 10;
  order: -1; /* Shifts the panel to the top of the vertical flex container */
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr); /* 5 columns yields exactly 2 rows for 10 cards */
  gap: 8px; /* Compact gap */
}

@media (max-width: 1200px) {
  .results-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 900px) {
  .results-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .app-main-grid {
    grid-template-columns: 320px 1fr;
  }
}

.result-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 12px; /* Sleek, minimal padding */
  display: flex;
  flex-direction: column;
  gap: 2px; /* Very tight spacing */
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.result-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow);
}

.result-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-secondary);
  font-weight: 600;
}

.result-value {
  font-family: var(--font-display);
  font-size: 24px; /* Perfectly readable but space-saving */
  font-weight: 700;
  color: var(--text-main); /* Theme-adaptive color (black in daytime, white in night) */
}

.result-desc {
  display: none; /* Hide description to make the cards extremely short */
}

/* Accent result cards for Principal axes properties */
.result-card.accent-card {
  border-left: 3px solid var(--accent-primary);
}

.result-card.accent-card:hover {
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.08);
}

/* Close button for Welcome Screen overlay */
.btn-close-overlay {
  position: absolute;
  top: 14px;
  right: 18px;
  background: none;
  border: none;
  font-family: var(--font-display);
  font-size: 26px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.btn-close-overlay:hover {
  color: var(--text-main);
  background-color: var(--border-color);
}

/* Floating HUD Summary Card */
.canvas-hud {
  position: absolute;
  top: 60px;
  right: 16px;
  background-color: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  width: 360px;
  backdrop-filter: blur(var(--blur-val));
  box-shadow: var(--shadow-lg);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.hud-title {
  font-family: var(--font-display);
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent-primary);
  font-weight: 700;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 6px;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
}

.hud-label {
  color: var(--text-secondary);
  font-weight: 500;
}

.hud-value {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text-main);
  text-align: right;
}

/* Manual coordinate entry styles */
.manual-input-container {
  background-color: var(--bg-card);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 6px 0;
}

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

.manual-input-row {
  display: flex;
  gap: 8px;
}

.manual-input-row input {
  width: 60px;
  flex: 1;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 6px 8px;
  font-family: var(--font-display);
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s;
}

.manual-input-row input:focus {
  border-color: var(--accent-primary);
}

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

.btn-primary:hover:not(:disabled) {
  background-color: var(--accent-primary-hover);
  border-color: var(--accent-primary-hover);
}

/* Preset Configuration Modal styles */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(8, 11, 17, 0.7);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.modal-card {
  background-color: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 30px;
  width: 420px;
  max-width: 90%;
  box-shadow: var(--shadow-lg);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--text-main);
}

.modal-card h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-primary);
  margin-bottom: 5px;
  margin-top: 0;
}

.modal-choices {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-choices h3 {
  font-family: var(--font-display);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  font-weight: 600;
  margin: 10px 0 2px 0;
}

.modal-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  margin: 4px 0;
}

.modal-divider::before,
.modal-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-color);
}

.modal-divider span {
  padding: 0 10px;
}

.preset-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.form-row input {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 8px 12px;
  font-family: var(--font-display);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.form-row input:focus {
  border-color: var(--accent-primary);
}

.btn-full {
  width: 100%;
}

/* Language Toggle Button */
.btn-lang-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  color: var(--accent-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 36px;
  text-align: center;
}

.btn-lang-toggle:hover {
  transform: scale(1.05);
  color: var(--accent-secondary-hover);
  background: var(--border-color);
}

/* Header Actions */
.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Manual Modal Styles */
.manual-modal .modal-card {
  max-width: 680px;
  max-height: 85vh;
  overflow-y: auto;
}

.manual-modal h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
}

.manual-modal h2::before {
  content: '📖';
}

.manual-section {
  margin-bottom: 24px;
}

.manual-section h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--accent-primary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.manual-section h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin: 14px 0 6px;
}

.manual-section p {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.manual-section ol,
.manual-section ul {
  padding-left: 20px;
  margin-bottom: 10px;
}

.manual-section li {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.manual-section table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 12px;
}

.manual-section td {
  padding: 8px 12px;
  font-size: 12px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  vertical-align: top;
}

.manual-section td:first-child {
  white-space: nowrap;
  color: var(--text-main);
  font-weight: 500;
  width: 40%;
}

.manual-section kbd {
  display: inline-block;
  padding: 2px 6px;
  font-size: 11px;
  font-family: var(--font-display);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--accent-secondary);
  box-shadow: 0 1px 0 var(--border-color);
}

.manual-section strong {
  color: var(--text-main);
}

/* Manual Modal Scrollbar */
.manual-modal .modal-card::-webkit-scrollbar {
  width: 6px;
}

.manual-modal .modal-card::-webkit-scrollbar-track {
  background: transparent;
}

.manual-modal .modal-card::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

/* Draw Node Hint */
.draw-node-hint {
  margin-left: 6px;
  font-size: 11px;
  color: var(--accent-primary);
  opacity: 0.8;
  animation: hintPulse 2s ease-in-out infinite;
}

.draw-node-hint.hidden {
  display: none;
}

@keyframes hintPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Draw Node Toggle Button */
.btn-draw-node {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  pointer-events: auto;
}

.btn-draw-node:hover {
  color: var(--text-main);
  border-color: var(--text-main);
  transform: scale(1.03);
}

.btn-draw-node.active {
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.1);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.25);
}

/* ==========================================================================
   Mobile Responsive & Collapsible Sidebar Styles (Phone-Friendly)
   ========================================================================== */

/* Mobile Backdrop Overlay */
.sidebar-backdrop {
  display: none;
}

@media (max-width: 768px) {
  .app-header {
    padding: 0 12px;
    height: 54px;
  }

  .subtitle {
    display: none;
  }

  .btn-header-sidebar {
    display: flex;
  }

  .header-actions {
    gap: 6px;
  }

  .coffee-link {
    padding: 4px 8px;
    font-size: 11px;
  }

  .app-main-grid {
    display: block;
    position: relative;
    height: calc(100vh - 54px);
  }

  .canvas-and-results {
    width: 100%;
    height: 100%;
  }

  .left-panel {
    position: fixed;
    top: 54px;
    left: 0;
    bottom: 0;
    width: 320px;
    max-width: 88vw;
    z-index: 500;
    transform: translateX(0); /* Visible & Open by default so user can set parameters! */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.6);
    border-right: 1px solid var(--border-color);
  }

  /* When the user manually clicks the Fold button on mobile */
  .left-panel.mobile-folded {
    transform: translateX(-100%) !important;
    box-shadow: none !important;
    pointer-events: none !important;
  }

  /* Mobile Backdrop (visible when panel is open, tap to fold) */
  .sidebar-backdrop {
    display: block;
    position: fixed;
    top: 54px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    z-index: 499;
    transition: opacity 0.3s ease;
  }

  .sidebar-backdrop.hidden {
    display: none !important;
  }

  .canvas-toolbar {
    padding: 0 10px;
    height: 42px;
    overflow-x: auto;
  }

  .draw-node-hint {
    display: none;
  }

  .canvas-controls {
    gap: 8px !important;
  }

  .btn-draw-node {
    bottom: 16px;
    right: 16px;
    padding: 6px 12px;
    font-size: 11px;
  }

  #axis-reversal-hud {
    top: 48px !important;
    left: 10px !important;
  }

  #ref-axes-note-panel {
    top: 48px !important;
    right: 10px !important;
    max-width: calc(100vw - 20px);
  }

  .results-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .result-card {
    padding: 4px 8px;
  }

  .result-value {
    font-size: 18px;
  }
}

