:root {
  --primary: #4299e1; /* Blue 400 */
  --primary-dark: #3182ce; /* Blue 500 */
  --secondary: #718096; /* Gray 500 */
  --bg-app: #f4f7fa;
  --bg-panel: #ffffff;
  --text-main: #2d3748;
  --text-muted: #718096;
  --border: #e2e8f0;
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --header-height: 60px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-app);
  color: var(--text-main);
}

/* --- Dropdown Menus --- */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 0 12px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid #4a5568;
  background: #2d3748;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

.dropdown-trigger:hover {
  background: #4a5568;
  border-color: #718096;
}

.dropdown-trigger::after {
  content: '';
}

.dropdown-content {
  display: none;
  position: absolute;
  top: calc(100% - 4px); /* Slight overlap to prevent gap */
  right: 0;
  min-width: 220px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  z-index: 100;
  padding-top: 4px; 
}

.dropdown-content-inner {
  background-color: #2d3748;
  border-radius: 8px;
  border: 1px solid #4a5568;
  padding: 8px 0;
}

.dropdown-content.show {
  display: block;
}

.dropdown-item {
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: white;
  cursor: pointer;
  white-space: nowrap;
  font-size: 0.9rem;
  transition: background 0.1s;
}

.dropdown-item:hover {
  background-color: #4a5568;
}

.dropdown-item label {
  color: #a0aec0 !important;
  font-size: 0.75rem !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  margin: 0 !important;
}

.dropdown-item select {
  background: #1a202c !important;
  border: 1px solid #4a5568 !important;
  height: 28px !important;
  padding: 0 8px !important;
  font-size: 0.85rem !important;
  width: 120px;
}

.dropdown-divider {
  height: 1px;
  background: #4a5568;
  margin: 4px 0;
}

.dropdown-btn {
    width: 100%;
    text-align: left;
    background: transparent !important;
    border: none !important;
    height: auto !important;
    padding: 10px 16px !important;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem !important;
    color: white !important;
    border-radius: 0 !important;
}

.dropdown-btn:hover {
    background: #4a5568 !important;
}

#toolbar .icon-btn {
    background: transparent;
    border: 1px solid transparent;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

#toolbar .icon-btn:hover {
    background: #2d3748;
    border-color: #4a5568;
    transform: none;
}

#toolbar .icon-btn.active {
    background: #4a5568;
    border-color: #718096;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

/* --- Toolbar --- */
#toolbar {
  height: var(--header-height);
  background: #1a202c; /* Dark Slate */
  color: white;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  z-index: 20;
  overflow: visible;
}

#toolbar h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: #fff;
  white-space: nowrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#toolbar label {
  font-size: 0.85rem;
  color: #a0aec0;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Custom Selects and Buttons in Toolbar */
#toolbar select, 
#toolbar button {
  height: 36px;
  padding: 0 16px;
  border-radius: 6px;
  border: 1px solid #4a5568;
  font-size: 0.9rem;
  background: #2d3748;
  color: white;
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

#toolbar select:hover, 
#toolbar button:hover {
  background: #4a5568;
  border-color: #718096;
  transform: translateY(-1px);
}

#toolbar button:active {
  transform: translateY(0);
}

#toolbar .divider {
    background: #4a5568 !important;
}

#toolbar button.primary-btn {
    background: var(--primary);
    border-color: var(--primary-dark);
}

/* --- Modal --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #fff;
    padding: 0;
    border-radius: 12px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    border-radius: 12px 12px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.close-btn {
    background: transparent !important;
    border: none !important;
    color: var(--text-muted) !important;
    font-size: 1.5rem !important;
    cursor: pointer;
    line-height: 1;
    padding: 4px !important;
    height: auto !important;
}

.close-btn:hover {
    color: var(--text-main) !important;
}

#codePanel {
    margin: 0;
    padding: 24px;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.95rem;
    color: #2d3748;
    background: #ffffff;
    border: none;
    overflow-y: auto;
    line-height: 1.6;
    white-space: pre-wrap;
    flex: 1;
}

/* --- Main Layout --- */
#mainContainer {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

#blocklyDiv {
  flex: 1; /* Will grow */
  position: relative;
  background: white;
  box-shadow: inset -5px 0 10px rgba(0,0,0,0.02);
}

/* --- Sidebar --- */
#sidebar {
  flex: 0 0 450px;
  min-width: 350px;
  max-width: 50%;
  display: flex;
  flex-direction: column;
  background-color: #f7fafc;
  padding: 16px;
  gap: 16px;
  box-sizing: border-box;
  border-left: 1px solid var(--border);
  overflow-y: auto; 
}

/* Panels */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Panel Headers */
.panel h3 {
  margin: 0;
  padding: 12px 16px;
  font-size: 0.8rem;
  color: #4a5568;
  background: #edf2f7;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Specific Panel Tweaks */
.state-panel {
    flex: 1;
    min-height: 0; /* Important for flex-grow to work inside flex-column */
}

#lspPanel {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    background: white;
}

/* Task Description */
#taskDescription {
    padding: 20px;
    line-height: 1.6;
    color: #2d3748;
    font-size: 0.95rem;
}

/* --- Badges --- */
.badge {
  font-size: 0.75em;
  padding: 4px 10px;
  border-radius: 999px;
  background: #edf2f7;
  color: #718096;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.3s;
}
.badge.connected { background: #c6f6d5; color: #276749; box-shadow: 0 0 0 1px #9ae6b4; }
.badge.error { background: #fed7d7; color: #9b2c2c; box-shadow: 0 0 0 1px #feb2b2; }


/* Goal Tabs */
.goal-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

.tab-button {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    font-weight: 500;
}

.tab-button:hover {
    background: #edf2f7;
    color: var(--text-main);
}

.tab-button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary-dark);
    box-shadow: 0 2px 4px rgba(66, 153, 225, 0.3);
}

/* --- Blockly Overrides --- */
.blocklyHtmlInput {
    font-family: 'Fira Code', 'Consolas', monospace !important;
    min-width: 100px;
}

.blocklyText {
    font-family: 'Fira Code', 'Consolas', monospace !important;
}

/* --- Proof State (Internal Content) --- */

.proof-section {
    margin-bottom: 16px;
    border-radius: 8px;
    overflow: hidden; /* For the border-left to look integrated */
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.proof-section h4 {
    margin: 0;
    padding: 8px 12px;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.math-content {
    padding: 12px 14px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #1a202c;
    background: rgba(255,255,255,0.7);
}

/* Hypotheses */
.proof-section.hypotheses {
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-left: 4px solid #4ade80;
}
.proof-section.hypotheses h4 { color: #166534; background: rgba(74, 222, 128, 0.15); }

/* Goal */
.proof-section.goal {
    background-color: #eff6ff;
    border: 1px solid #bfdbfe;
    border-left: 4px solid #60a5fa;
}
.proof-section.goal h4 { color: #1e40af; background: rgba(96, 165, 250, 0.15); }

/* Error */
.proof-section.error-state {
    background-color: #fff5f5;
    border: 1px solid #feb2b2;
    border-left: 4px solid #f56565;
}
.proof-section.error-state h4 { color: #9b2c2c; background: rgba(245, 101, 101, 0.1); }
.error-content { white-space: pre-wrap; word-break: break-word; color: #742a2a; }

/* Success */
.proof-section.success-state {
    background-color: #f0fff4;
    border: 1px solid #9ae6b4;
    border-left: 4px solid #48bb78;
    text-align: center;
    padding: 24px;
}
.proof-section.success-state h4 { 
    color: #22543d; 
    background: transparent; 
    font-size: 1.1rem; 
    margin-bottom: 8px; 
    padding: 0;
}

/* Spinner */
.state-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 150px;
    color: #a0aec0;
}
.spinner {
   width: 32px;
   height: 32px;
   border: 3px solid #e2e8f0;
   border-top-color: var(--primary);
   border-radius: 50%;
   margin-bottom: 12px;
   animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Math Keywords */
.math-keyword { font-weight: bold; color: #805ad5; }

/* Scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e0 transparent;
}

/* --- Resizer --- */
#resizer {
  width: 5px;
  background: transparent;
  cursor: col-resize;
  z-index: 20;
  transition: background 0.2s;
  flex: 0 0 auto; /* Prevent shrinking */
}

#resizer:hover, #resizer.resizing {
  background: #4299e1; /* Highlight on hover/drag */
}

/* --- Interactive Tags & Tooltips (VS Code Integration) --- */

.interactive-tag {
    cursor: pointer;
    border-bottom: 1px solid transparent;
    transition: all 0.1s ease;
    padding: 0 1px;
    border-radius: 2px;
    position: relative;
}

.interactive-tag:hover {
    background-color: rgba(66, 153, 225, 0.1);
    border-bottom-color: var(--primary);
    color: var(--primary-dark);
}

.interactive-tag.loading {
    animation: pulse-bg 1s infinite alternate;
}

@keyframes pulse-bg {
    from { background-color: transparent; }
    to { background-color: rgba(66, 153, 225, 0.2); }
}

.lean-tooltip {
    z-index: 1000;
    background: #2d3748;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    max-width: 300px;
    pointer-events: auto;
    font-family: 'Fira Code', 'JetBrains Mono', monospace;
    line-height: 1.4;
    border: 1px solid #4a5568;
    animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Specific styling for nested tags inside tooltips */
.lean-tooltip .interactive-tag {
    color: #90cdf4; /* Light blue for symbols in dark tooltip */
}

/* --- Panel Toggles --- */
.panel-toggle {
    background: transparent !important;
    border: none !important;
    color: #a0aec0 !important;
    padding: 4px !important;
    height: auto !important;
    font-size: 0.8rem !important;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    transition: transform 0.2s, color 0.2s;
}
.panel-toggle:hover {
    color: #4a5568 !important;
    background: #edf2f7 !important;
}

/* --- Math Toolbar --- */
#mathToolbar {
    background: #edf2f7;
    border-bottom: 1px solid var(--border);
    padding: 8px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.symbol-group {
    display: flex;
    gap: 4px;
}

#mathToolbar button {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.1s;
    color: #2d3748;
}

#mathToolbar button:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary-dark);
}

#mathToolbar .divider {
    width: 1px;
    height: 24px;
    background: #cbd5e0;
}

/* --- Tabular Proof Highlighting --- */
.tabular-status-red {
    filter: drop-shadow(0 0 5px rgba(255, 0, 0, 0.8)) !important;
}
.tabular-status-green {
    filter: drop-shadow(0 0 5px rgba(0, 255, 0, 0.8)) !important;
}
.tabular-status-orange {
    filter: drop-shadow(0 0 5px rgba(255, 165, 0, 0.8)) !important;
}


/* Hide content when collapsed */
.panel.collapsed .panel-content {
    display: none !important;
}

/* Adjust flex when state panel is collapsed */
.panel.state-panel.collapsed {
    flex: 0 0 auto !important; /* Don't take up space */
    min-height: auto !important;
}
