:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --bg-color: #f8fafc;
    --sidebar-bg: #ffffff;
    --sidebar-text: #1e293b;
    --border-color: #e2e8f0;
    --accent-color: #818cf8;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.2);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius: 12px;
}

[data-theme="dark"] {
    --primary-color: #6366f1;
    --bg-color: #0f172a;
    --sidebar-bg: #1e293b;
    --sidebar-text: #f1f5f9;
    --border-color: #334155;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --shadow: 0 10px 15px -3px rgb(0 0 0 / 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--sidebar-text);
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar Styling */
.sidebar {
    width: 380px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 24px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.05);
}

header h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    margin-bottom: 4px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 24px;
}

.control-group {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.control-group h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    margin-bottom: 12px;
}

.input-field {
    margin-bottom: 12px;
}

.input-field label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 6px;
}

.input-field input,
.input-field select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9375rem;
    transition: all 0.2s;
    background: white;
}

.input-field input:focus,
.input-field select:focus,
.custom-select:focus-within {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.custom-select {
    position: relative;
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-size: 0.9375rem;
    transition: all 0.2s;
}

.selected-option {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    line-height: 1.2;
}

.selected-option::after {
    content: '▼';
    font-size: 0.7rem;
    color: #94a3b8;
    margin-left: 12px;
    flex-shrink: 0;
}

.options-container {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
    z-index: 1000;
    max-height: 250px;
    overflow-y: auto;
}

.options-container.hidden {
    display: none;
}

.option {
    padding: 10px 12px;
    transition: background 0.1s;
    line-height: 1.2;
}

.option:hover {
    background-color: #f1f5f9;
}

/* Clean and reliable subscript/superscript styling */
.custom-select sub,
.custom-select sup {
    font-size: 0.7em;
    line-height: 1;
    position: relative;
}

.custom-select sup {
    vertical-align: top;
    top: 0.2em;
    /* Sits slightly above center */
}

.custom-select sub {
    vertical-align: bottom;
}

.selected-option,
.option {
    display: block;
    /* Back to standard block flow used for text */
    padding: 10px 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.selected-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    /* Move padding to inner span */
}

.selected-option-text {
    flex: 1;
    padding: 10px 12px;
}

.input-with-button {
    display: flex;
    gap: 8px;
}

.row {
    display: flex;
    gap: 8px;
}

.row input {
    flex: 1;
    min-width: 0;
}

.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    margin-top: 8px;
}

.checkbox-field input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
}

.vector-input {
    margin-top: 12px;
    margin-bottom: 12px;
}

.vector-input label {
    display: block;
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 4px;
}

.hidden {
    display: none;
}

.link-container {
    margin-top: 8px;
    font-size: 0.8125rem;
}

.external-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.external-link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Main Content Styling */
.main-content {
    flex: 1;
    padding: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% 50%, #f1f5f9 0%, #e2e8f0 100%);
    position: relative;
}

.plot-card {
    width: 100%;
    max-width: 1000px;
    height: 600px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
}

#plot-container {
    flex: 1;
    width: 100%;
    height: 100%;
}

/* Buttons */
.primary-btn {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, background-color 0.2s;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

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

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

.secondary-btn {
    padding: 8px 16px;
    background-color: #f1f5f9;
    color: #475569;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background-color: #e2e8f0;
}

.secondary-btn-full {
    width: 100%;
    margin-top: 12px;
    padding: 10px;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 24px;
}

.status-message {
    position: absolute;
    bottom: 24px;
    right: 24px;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 100;
}

.status-message.error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    opacity: 1;
}

.status-message.success {
    background-color: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
    opacity: 1;
}

/* Polar Navigation */
.nav-links {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 24px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 10px;
}

.nav-link {
    flex: 1;
    text-align: center;
    text-decoration: none;
    color: #64748b;
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

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

.nav-link.active {
    background: white;
    color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Mode Table Styling */
.mode-table-container {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 8px;
    background: white;
}

.mode-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.mode-table th,
.mode-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
}

.mode-table th {
    background-color: #f8fafc;
    position: sticky;
    top: 0;
    font-weight: 600;
    color: #64748b;
    z-index: 5;
}

.mode-table tr:hover {
    background-color: #f1f5f9;
    cursor: pointer;
}

.mode-table tr.selected {
    background-color: #eef2ff;
}

.mode-table input[type="checkbox"] {
    cursor: pointer;
}