:root {
  /* Dark theme by default - much easier on the eyes */
  --bg-primary: #1e2227;
  --bg-secondary: #282c34;
  --bg-tertiary: #3a3f47;
  --text-primary: #e6e8ea;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --border-color: #404854;
  --border-focus: #6366f1;
  --shadow: 0 4px 15px rgba(0,0,0,0.25);
  --shadow-hover: 0 8px 30px rgba(0,0,0,0.35);
  --success-bg: #1f2937;
  --success-text: #34d399;
  --success-border: #065f46;
  --error-bg: #1f1414;
  --error-text: #fca5a5;
  --error-border: #7f1d1d;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
}

/* Removed light theme - dark is better for eyes */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
header {
  background: var(--bg-primary);
  padding: 24px;
  border-radius: 12px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s ease;
}

header:hover {
  box-shadow: var(--shadow-hover);
}

header h1 {
  color: var(--text-primary);
  font-size: 2.2em;
  font-weight: 600;
  letter-spacing: -0.02em;
}

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

.examples label {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.9em;
}

.examples select {
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 200px;
}

.examples select:hover {
  border-color: var(--accent);
}

.examples select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(77, 171, 247, 0.1);
}

/* Split view layout */
.split-view {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  height: calc(100vh - 160px);
}

.editor-panel, .form-panel {
  background: var(--bg-primary);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
}

.editor-panel:hover, .form-panel:hover {
  box-shadow: var(--shadow-hover);
}

.panel-header {
  background: var(--bg-secondary);
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-header h2 {
  color: var(--text-primary);
  font-size: 1.2em;
  font-weight: 600;
}

.panel-badge {
  background: var(--accent);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8em;
  font-weight: 500;
}

/* Editor */
#editor {
  flex: 1;
  min-height: 0;
  position: relative;
}

.status {
  padding: 12px 24px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  font-size: 0.9em;
  font-family: ui-monospace, 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  transition: all 0.3s ease;
}

.status.success {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-border);
}

.status.error {
  background: var(--error-bg);
  color: var(--error-text);
  border-color: var(--error-border);
}

/* Form container */
#form-container {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

.placeholder {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 60px 20px;
  font-size: 1.1em;
}

/* Form sections */
.form-section {
  margin-bottom: 24px;
}

.form-section h3 {
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border-color);
  font-size: 1.1em;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-icon {
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.8em;
}

/* Form fields */
.form-field {
  margin-bottom: 16px;
  position: relative;
}

.form-field.error input,
.form-field.error select {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.05);
}

.form-field.error input:focus,
.form-field.error select:focus {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.validation-error {
  color: #ef4444;
  font-size: 0.85em;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.validation-error::before {
  content: "⚠️";
  font-size: 0.9em;
}

.form-field label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.95em;
}

.form-field input, 
.form-field select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: all 0.2s ease;
  font-family: inherit;
}

/* Simple checkbox fix */
.form-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  padding: 0;
  margin-right: 8px;
  accent-color: var(--accent);
}

.form-field input:hover, 
.form-field select:hover {
  border-color: var(--accent);
}

.form-field input:focus, 
.form-field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(77, 171, 247, 0.1);
  transform: translateY(-1px);
}

.form-field select {
  cursor: pointer;
}

.form-field.computed {
  opacity: 0.8;
}

.form-field.computed input {
  background: var(--bg-secondary);
  cursor: not-allowed;
  font-family: ui-monospace, 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
}

/* Calculated values */
.calculated-values {
  background: var(--bg-secondary);
  padding: 20px;
  border-radius: 12px;
  margin-top: 24px;
  border: 1px solid var(--border-color);
}

.calculated-values h4 {
  color: var(--text-primary);
  margin-bottom: 16px;
  font-size: 1.1em;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.calculated-values h4::before {
  content: "📊";
  font-size: 1.2em;
}

.calculated-value {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.calculated-value:hover {
  background: var(--bg-tertiary);
  margin: 0 -12px;
  padding: 12px;
  border-radius: 6px;
}

.calculated-value:last-child {
  border-bottom: none;
}

.calculated-value .name {
  font-weight: 500;
  color: var(--text-primary);
}

.calculated-value .value {
  font-family: ui-monospace, 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  background: var(--bg-primary);
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  font-weight: 600;
  color: var(--accent);
  min-width: 80px;
  text-align: right;
}

/* Responsive design */
@media (max-width: 768px) {
  .split-view {
    grid-template-columns: 1fr;
    height: auto;
  }
  
  .container {
    padding: 16px;
  }
  
  header {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }
  
  header h1 {
    font-size: 1.8em;
  }
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.form-field {
  animation: fadeIn 0.3s ease;
}

.calculated-value {
  animation: fadeIn 0.4s ease;
}

/* Loading states */
.status.loading {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  position: relative;
  overflow: hidden;
}

.status.loading::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(77, 171, 247, 0.2), transparent);
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/* Highlighting System */
.highlight-primary {
  background: rgba(99, 102, 241, 0.15) !important;
  border: 2px solid var(--accent) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.highlight-dependency {
  background: rgba(52, 211, 153, 0.12) !important;
  border: 2px solid #34d399 !important;
  transform: translateY(-1px);
}

.highlight-dependent {
  background: rgba(251, 191, 36, 0.12) !important;
  border: 2px solid #fbbf24 !important;
  transform: translateY(-1px);
}

.form-field.highlighting, 
.calculated-value.highlighting {
  transition: all 0.2s ease;
  cursor: pointer;
}

.form-field.highlighting:hover, 
.calculated-value.highlighting:hover {
  transform: translateY(-2px);
}

/* Dependency relationship indicators */
.highlight-primary::before {
  content: "🎯";
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--accent);
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7em;
  z-index: 10;
}

.highlight-dependency::before {
  content: "⬅️";
  position: absolute;
  top: -8px;
  right: -8px;
  background: #34d399;
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7em;
  z-index: 10;
}

.highlight-dependent::before {
  content: "➡️";
  position: absolute;
  top: -8px;
  right: -8px;
  background: #fbbf24;
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7em;
  z-index: 10;
}

/* Progressive Form Styles - Hide progress indicator */
.progress-indicator {
  display: none;
}

.progress-steps {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.progress-steps::before {
  content: "";
  position: absolute;
  top: 20px;
  left: 24px;
  right: 24px;
  height: 2px;
  background: var(--border-color);
  z-index: 1;
}

.progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 2;
  min-width: 120px;
}

.step-number {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  margin-bottom: 8px;
  transition: all 0.3s ease;
}

.step-label {
  font-size: 0.9em;
  text-align: center;
  color: var(--text-secondary);
  transition: all 0.3s ease;
}

.progress-step.active .step-number {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.progress-step.active .step-label {
  color: var(--text-primary);
  font-weight: 500;
}

.progress-step.completed .step-number {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}

.progress-step.completed .step-number::before {
  content: "✓";
}

.progressive-stage {
  background: transparent;
  border-radius: 0;
  padding: 0;
  margin-bottom: 0;
  border: none;
  transition: opacity 0.3s ease, pointer-events 0s;
}

.stage-title {
  display: none;
}

.stage-icon {
  font-size: 1.4em;
}

.continue-btn {
  display: none;
}

.continue-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(77, 171, 247, 0.3);
}

.continue-btn:disabled {
  background: var(--bg-tertiary);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Tabbed Interface */
.tab-container {
  display: flex;
  flex: 1;
  min-height: 0;
}

.bookmark-tabs {
  width: 48px;
  background: var(--bg-secondary);
  padding: 20px 0;
  position: relative;
  border-right: 1px solid var(--border-color);
}

.bookmark-tab {
  width: 44px;
  height: 120px;
  margin-bottom: 10px;
  border-radius: 8px 0 0 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  background: var(--bg-tertiary);
  position: relative;
  left: 0;
  border: 1px solid var(--border-color);
  border-right: none;
}

.bookmark-tab.active {
  width: 52px;
  left: -8px;
  background: var(--bg-primary);
  box-shadow: 2px 0 8px rgba(0,0,0,0.1);
  z-index: 10;
  border-color: var(--accent);
}

.bookmark-tab:hover:not(.active) {
  left: -4px;
  background: var(--bg-primary);
  border-color: var(--border-focus);
}

.tab-icon {
  font-size: 24px;
  margin-bottom: 8px;
}

.tab-label {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.bookmark-tab.active .tab-label {
  color: var(--text-primary);
}

.tab-content {
  flex: 1;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tab-pane {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.tab-pane.active {
  display: flex;
}

.config-preview {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 20px;
  min-height: 200px;
}

.config-preview h3 {
  color: var(--text-primary);
  margin-bottom: 16px;
  font-size: 1.1em;
  font-weight: 600;
}

#display-config-editor {
  flex: 1;
  min-height: 300px;
  position: relative;
}

#config-preview-content {
  color: var(--text-secondary);
  font-style: italic;
}

/* Formatted Output Styles */
.output-badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.output-badge.success {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.output-badge.warning {
  background: #1f1a0d;
  color: #fbbf24;
  border: 1px solid #92400e;
}

.output-badge.danger {
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid var(--error-border);
}

.output-badge.info {
  background: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
  border: 1px solid #1e40af;
}

.output-progress {
  width: 100%;
  height: 20px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border-color);
}

.output-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 10px;
  transition: width 0.8s ease;
  position: relative;
}

.output-progress-bar.good {
  background: linear-gradient(90deg, var(--success-text), #10b981);
}

.output-progress-bar.fair {
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
}

.output-progress-bar.poor {
  background: linear-gradient(90deg, var(--error-text), #ef4444);
}

.output-progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.8em;
  font-weight: 600;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  z-index: 2;
}

.output-alert {
  padding: 16px 20px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
  margin: 8px 0;
}

.output-alert.success {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.output-alert.info {
  background: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
  border: 1px solid #1e40af;
}

.output-alert.warning {
  background: #1f1a0d;
  color: #fbbf24;
  border: 1px solid #92400e;
}

.output-alert.danger {
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid var(--error-border);
}

.output-alert-icon {
  font-size: 1.2em;
  flex-shrink: 0;
}

.output-currency {
  font-family: ui-monospace, 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  font-weight: 600;
  color: var(--accent);
}

.output-percentage {
  font-family: ui-monospace, 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  font-weight: 600;
  color: var(--accent);
}

.output-percentage::after {
  content: "%";
  margin-left: 1px;
}

.output-highlight {
  background: rgba(99, 102, 241, 0.15);
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 4px 8px;
  font-weight: 600;
}

/* Input Groups */
.input-group {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
  border: 1px solid var(--border-color);
}

.input-group h3 {
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border-color);
  font-size: 1.1em;
  font-weight: 600;
}