/* --- Design System & CSS Variables --- */
:root {
    --bg-main: #0b0f19;
    --bg-card: rgba(17, 24, 39, 0.75);
    --bg-card-hover: rgba(26, 36, 57, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-glow: rgba(139, 92, 246, 0.3);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --primary: #8b5cf6;       /* Violet */
    --primary-glow: rgba(139, 92, 246, 0.5);
    --secondary: #06b6d4;     /* Cyan */
    --secondary-glow: rgba(6, 182, 212, 0.5);
    --accent: #f43f5e;        /* Rose red for alerts */
    
    --panel-padding: 1.25rem;
    --border-radius: 12px;
    --transition-speed: 0.3s;
    
    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* --- Base Resets & Layout --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    overflow-x: hidden;
}

body.dark-theme {
    background-image: 
        radial-gradient(at 0% 0%, rgba(139, 92, 246, 0.08) 0px, transparent 50%),
        radial-gradient(at 50% 0%, rgba(6, 182, 212, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.03) 0px, transparent 50%);
    background-attachment: fixed;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    padding: 0.75rem;
}

/* --- Header Styling --- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 0.75rem;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 1.75rem;
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary-glow);
}

.logo-text h1 {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.logo-text span {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: block;
    margin-top: -2px;
}

.mode-selector {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.25rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all var(--transition-speed);
}

.nav-btn:hover {
    color: var(--text-primary);
}

.nav-btn.active {
    background: var(--primary);
    color: var(--text-primary);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.ncert-tag {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #10b981;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* --- Layout Grid --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 360px 1fr 340px;
    gap: 0.75rem;
    flex: 1;
    min-height: 0; /* Important for flex-child scrolling */
}

/* --- Cards Standard --- */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--panel-padding);
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    transition: border-color var(--transition-speed);
    overflow: hidden;
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

/* --- Sidebar Styling --- */
.sidebar {
    gap: 1.25rem;
    overflow-y: auto;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.section-title {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.select-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.select-group label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

select {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.6rem;
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-speed);
}

select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.25);
}

/* --- Toggle Switches --- */
.toggle-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.4rem 0;
}

.toggle-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.15);
    transition: .3s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--primary);
}

input:checked + .slider:before {
    transform: translateX(18px);
}

/* --- Chemical Legend --- */
.legend-card {
    margin-top: auto;
}

.legend-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    font-size: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 6px rgba(0,0,0,0.5);
}

/* --- Viewport Layout Section --- */
.viewport-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 0;
}

.viewports-wrapper {
    display: grid;
    gap: 0.75rem;
    flex: 1;
    position: relative;
    min-height: 0;
    width: 100%;
}

.viewports-wrapper.cols-1 {
    grid-template-columns: 1fr;
}

.viewports-wrapper.cols-2 {
    grid-template-columns: 1fr 1fr;
}

.viewports-wrapper.cols-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.viewports-wrapper.cols-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.viewports-wrapper.cols-5,
.viewports-wrapper.cols-6 {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: auto auto;
}

.viewport-card {
    flex: 1;
    position: relative;
    padding: 0; /* Custom container */
    background: radial-gradient(circle at center, rgba(17, 24, 39, 0.4) 0%, rgba(2, 6, 23, 0.95) 100%);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.viewport-header {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    right: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
    pointer-events: none;
}

.viewport-badge {
    padding: 0.35rem 0.8rem;
    border-radius: 6px;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid var(--border-color);
}

.viewport-badge.primary {
    background: rgba(139, 92, 246, 0.15);
    color: var(--primary);
    border-color: rgba(139, 92, 246, 0.3);
    text-shadow: 0 0 6px rgba(139, 92, 246, 0.3);
}

.viewport-badge.secondary {
    background: rgba(6, 182, 212, 0.15);
    color: var(--secondary);
    border-color: rgba(6, 182, 212, 0.3);
    text-shadow: 0 0 6px rgba(6, 182, 212, 0.3);
}

.reset-camera-btn {
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: all var(--transition-speed);
}

.reset-camera-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.canvas-container {
    width: 100%;
    height: 100%;
    position: relative;
    cursor: grab;
}

.canvas-container:active {
    cursor: grabbing;
}

/* --- Canvas Floating Labels Overlay --- */
.canvas-labels-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.floating-label {
    position: absolute;
    transform: translate(-50%, -50%);
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    pointer-events: none;
    transition: opacity 0.15s;
}

/* --- Vertical Divider / Mirror Plane --- */
.viewports-divider {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 2px;
    background: linear-gradient(to bottom, transparent, var(--border-color) 20%, var(--border-color) 80%, transparent);
    position: relative;
    flex-shrink: 0;
}

.divider-text {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.75rem;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    padding: 4px 6px;
    border-radius: 50%;
    color: var(--text-muted);
    z-index: 10;
    transition: all var(--transition-speed);
}

/* Mirror Plane Glowing State */
.viewports-divider.mirror-plane {
    background: linear-gradient(to bottom, transparent, rgba(6, 182, 212, 0.1) 10%, rgba(6, 182, 212, 0.6) 50%, rgba(6, 182, 212, 0.1) 90%, transparent);
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.3);
}

.viewports-divider.mirror-plane .divider-text {
    background: var(--bg-main);
    border-color: var(--secondary);
    color: var(--secondary);
    box-shadow: 0 0 12px var(--secondary-glow);
    border-radius: 6px;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    padding: 4px 8px;
}

/* --- Quick Tips Bar --- */
.tips-bar {
    padding: 0.65rem 1rem;
    flex-direction: row;
    align-items: center;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.text-gradient {
    background: linear-gradient(135deg, var(--primary) 30%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* --- Right Sidebar: Explanation Panel --- */
.explanation-panel {
    gap: 1.25rem;
    overflow: hidden;
}

.explanation-panel .card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.formula-badge {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.2px;
}

.info-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.metric-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    border-radius: 8px;
    text-align: center;
}

.metric-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.metric-value {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 0.15rem;
}

.scrollable-info {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding-right: 0.25rem;
    flex: 1;
}

.info-block h3 {
    font-family: var(--font-heading);
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--secondary);
    margin-bottom: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.info-block p {
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.45;
}

.info-block p.text-secondary {
    font-size: 0.8rem;
}

.ligands-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.25rem;
}

.ligands-list li {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    background: rgba(255,255,255,0.02);
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.03);
}

.ligands-list li span:first-child {
    font-weight: 600;
    color: var(--text-primary);
}

.ligands-list li span:last-child {
    color: var(--text-secondary);
}

.important-notes {
    background: rgba(244, 63, 94, 0.08);
    border: 1px solid rgba(244, 63, 94, 0.2);
    padding: 0.75rem;
    border-radius: 8px;
    margin-top: auto;
}

.important-notes h3 {
    color: var(--accent);
}

.important-notes p {
    color: var(--text-primary);
    font-size: 0.78rem;
}

/* --- Quiz Mode Custom Layout --- */
.quiz-grid {
    grid-template-columns: 280px 1fr 360px;
}

.single-viewport {
    flex: 1;
}

.progress-bar-container {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.progress-track {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(95deg, var(--primary), var(--secondary));
    border-radius: 3px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 6px var(--primary-glow);
}

.quiz-score-card {
    background: radial-gradient(circle at center, rgba(139, 92, 246, 0.1) 0%, rgba(0, 0, 0, 0.3) 100%);
    border: 1px solid var(--border-color-glow);
    padding: 1.5rem 1rem;
    border-radius: var(--border-radius);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    box-shadow: inset 0 0 20px rgba(139, 92, 246, 0.05);
}

.score-number {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary);
    text-shadow: 0 0 15px var(--primary-glow);
    line-height: 1;
}

.score-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- Action Buttons --- */
.action-btn {
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    border: none;
    color: var(--text-primary);
    padding: 0.75rem 1.25rem;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all var(--transition-speed);
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3);
}

.action-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.45);
}

.action-btn:active:not(:disabled) {
    transform: translateY(1px);
}

.action-btn:disabled {
    background: #1f2937;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

.restart-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    box-shadow: none;
    font-size: 0.85rem;
    padding: 0.6rem 1rem;
}

.restart-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

/* --- Quiz Question Layout --- */
.quiz-question-card {
    justify-content: space-between;
}

.question-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1rem 0;
}

.question-text {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-primary);
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.option-card {
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--border-color);
    padding: 0.85rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s ease;
}

.option-card:hover {
    background: rgba(255,255,255,0.03);
    border-color: rgba(255, 255, 255, 0.2);
}

.option-card.selected {
    background: rgba(139, 92, 246, 0.1);
    border-color: var(--primary);
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.15);
}

.option-marker {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.option-card.selected .option-marker {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--text-primary);
}

/* Answer Feedback states */
.option-card.correct {
    background: rgba(16, 185, 129, 0.15) !important;
    border-color: #10b981 !important;
    color: #a7f3d0;
}

.option-card.correct .option-marker {
    background: #10b981 !important;
    border-color: #10b981 !important;
    color: white;
}

.option-card.wrong {
    background: rgba(244, 63, 94, 0.15) !important;
    border-color: var(--accent) !important;
    color: #fecdd3;
    opacity: 0.8;
}

.option-card.wrong .option-marker {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
    color: white;
}

/* --- Feedback Panel --- */
.feedback-container {
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border-color);
    padding: 0.85rem;
    border-radius: 8px;
    display: flex;
    gap: 0.75rem;
    animation: slideUp 0.3s ease;
}

.feedback-container.correct-panel {
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.05);
}

.feedback-container.wrong-panel {
    border-color: rgba(244, 63, 94, 0.3);
    background: rgba(244, 63, 94, 0.05);
}

.feedback-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.correct-panel .feedback-icon {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.wrong-panel .feedback-icon {
    background: rgba(244, 63, 94, 0.15);
    color: var(--accent);
}

.feedback-text h4 {
    font-family: var(--font-heading);
    font-size: 0.88rem;
    font-weight: 700;
}

.correct-panel h4 {
    color: #10b981;
}

.wrong-panel h4 {
    color: var(--accent);
}

.feedback-text p {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
    line-height: 1.4;
}

.quiz-question-card .card-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 0.75rem;
    display: flex;
    justify-content: flex-end;
}

.next-btn {
    width: 100%;
}

/* --- Common UI states --- */
.hidden {
    display: none !important;
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* --- Animations --- */
@keyframes pulse-animation {
    0% {
        transform: scale(1);
        text-shadow: 0 0 10px var(--primary-glow);
    }
    50% {
        transform: scale(1.05);
        text-shadow: 0 0 20px var(--primary-glow);
    }
    100% {
        transform: scale(1);
        text-shadow: 0 0 10px var(--primary-glow);
    }
}

.pulse-animation {
    animation: pulse-animation 3s infinite ease-in-out;
}

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

/* --- Responsive Adjustments --- */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 250px 1fr;
    }
    .explanation-panel {
        grid-column: span 2;
        max-height: 300px;
    }
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }
    .sidebar, .viewport-section, .explanation-panel {
        grid-column: span 1;
    }
    .viewports-wrapper {
        flex-direction: column;
        height: 600px;
    }
    .viewports-divider {
        width: 100%;
        height: 2px;
        flex-direction: row;
        margin: 0.5rem 0;
    }
    .app-header {
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
    }
}

/* --- Master Tables Layout & Design --- */
.tables-grid {
    flex: 1;
    min-height: 0;
    margin-bottom: 0.25rem;
}

.presets-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: rgba(10, 15, 28, 0.4);
}

.presets-table th,
.presets-table td {
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.presets-table th {
    background-color: rgba(139, 92, 246, 0.1);
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
}

.presets-table tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

.presets-table tr:last-child td {
    border-bottom: none;
}

.formula-font {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1rem;
    color: var(--secondary) !important;
}

.table-action-btn {
    background: var(--primary);
    color: var(--text-primary) !important;
    border: none;
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 700;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px var(--primary-glow);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 120px;
}

.table-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.table-action-btn.soon {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-color);
    box-shadow: none;
    cursor: not-allowed;
}

.table-action-btn.soon:hover {
    transform: none;
    box-shadow: none;
}

/* Soon toast for stereoisomers */
.ncert-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #0f172a;
    border: 1px solid var(--border-color);
    color: #ffffff;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    font-weight: 600;
    font-size: 0.9rem;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
}

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

/* Plane of Symmetry Viewport Badges */
.pos-badge {
    position: absolute;
    bottom: 12px;
    left: 12px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: var(--font-heading);
    backdrop-filter: blur(8px);
    z-index: 10;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

.pos-badge.active-pos {
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid rgba(16, 185, 129, 0.45);
    color: #10b981;
}

.pos-badge.no-pos {
    background: rgba(244, 63, 94, 0.15);
    border: 1px solid rgba(244, 63, 94, 0.4);
    color: #f43f5e;
}

/* Glassmorphic Settings Modal Popover */
.settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.25s ease;
}

.settings-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Directory Table styling */
.directory-table {
    border-collapse: separate;
    border-spacing: 0 6px; /* spacing between rows to look like buttons */
    width: 100%;
    margin-bottom: 0.5rem;
}

.directory-table tr {
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px; /* rounded pill card style */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.directory-table tr td {
    padding: 8px 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(0, 0, 0, 0.2);
    vertical-align: middle;
}

.directory-table tr td:first-child {
    border-left: 1px solid rgba(255, 255, 255, 0.03);
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.directory-table tr td:last-child {
    border-right: 1px solid rgba(255, 255, 255, 0.03);
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

.directory-table tr:hover {
    background: rgba(255, 255, 255, 0.07);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15); /* primary glow */
    border-color: rgba(139, 92, 246, 0.3);
}

.directory-table tr.active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.22) 0%, rgba(99, 102, 241, 0.22) 100%) !important;
    border-color: var(--primary) !important;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.3) !important;
}

.directory-table tr.active td {
    color: #fff !important;
    font-weight: 600;
}

.directory-table td, .directory-table th {
    padding: 6px 8px;
}
