:root {
    --bg-color: #0d0f17;
    --panel-bg: rgba(23, 27, 42, 1);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #f0f2f5;
    --text-secondary: #a0aec0;
    --accent-color: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --primary-btn: #2563eb;
    --primary-btn-hover: #1d4ed8;
    --secondary-btn: rgba(255, 255, 255, 0.1);
    --secondary-btn-hover: rgba(255, 255, 255, 0.2);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    display: flex;
    height: 100vh;
    width: 100vw;
}

#ui-container {
    width: 500px;
    height: 100%;
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 2rem;
    z-index: 10;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    overflow-y: auto;
}

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

.header-title-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.header-tools {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.tooltip-container {
    position: relative;
    margin-top: 5px;
}

.info-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px; /* Small pill badge style */
    padding: 0.25rem 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    transition: all 0.2s;
}

.info-btn:hover {
    color: white;
    border-color: white;
    background: rgba(255, 255, 255, 0.1);
}

.tooltip-content {
    display: none;
    position: absolute;
    right: 0;
    top: 35px;
    width: 435px;
    background: rgba(15, 20, 30, 0.95);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    z-index: 100;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
}

.tooltip-content strong {
    color: #e2e8f0;
}

.tooltip-container:hover .tooltip-content {
    display: block;
}

.explanation-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

h1 {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
    background: linear-gradient(90deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-family: 'Space Mono', monospace;
}

.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

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

.control-group label {
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    justify-content: space-between;
}

.control-group.active-control {
    background: rgba(59, 130, 246, 0.05);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.speed-readout {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.speed-readout .label {
    font-weight: 600;
    font-size: 0.95rem;
}

.speed-readout .math-val {
    font-family: 'Space Mono', monospace;
    font-size: 1.1rem;
}

.highlight {
    color: #60a5fa;
    text-shadow: 0 0 10px rgba(96, 165, 250, 0.3);
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-top: 1.5rem;
    padding-bottom: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: var(--text-primary);
    cursor: pointer;
    margin-top: -7px;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    transition: transform 0.1s;
}

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

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

input[type=range]:disabled::-webkit-slider-thumb {
    background: #4b5563;
    box-shadow: none;
    cursor: not-allowed;
}

.bias-values {
    display: flex;
    justify-content: space-between;
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
    color: #93c5fd;
    margin-top: 0.5rem;
}

.actions {
    display: flex;
    gap: 1rem;
}

.btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.primary {
    background-color: var(--primary-btn);
    color: white;
    box-shadow: 0 4px 14px var(--accent-glow);
}

.primary:hover {
    background-color: var(--primary-btn-hover);
    transform: translateY(-1px);
}

.secondary {
    background-color: var(--secondary-btn);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.note {
    color: #6b7280;
    font-size: 0.75rem;
    font-style: italic;
}

.measurement-panel {
    background: rgba(20, 25, 40, 0.6);
    padding: 1rem 1.25rem;
    border-radius: 8px;
    border: 1px solid rgba(100, 200, 255, 0.2);
    margin-top: 0;
}

.log-header {
    font-size: 0.75rem;
    margin-bottom: 0.75rem;
    color: #e2e8f0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
}

.log-line {
    font-family: 'Space Mono', monospace;
    font-size: 0.70rem;
    color: #f8fafc;
    white-space: normal;
    line-height: 1.4;
    margin-bottom: 0.5rem;
}

.log-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.offset-log {
    color: #93c5fd;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
}

#canvas-container {
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Custom Scrollbar for UI */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Modal Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(13, 15, 23, 0.85);
    backdrop-filter: blur(0px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 1250px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(255, 255, 255, 0.02);
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.modal-header h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.75rem;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

.close-btn:hover {
    color: white;
}

.modal-body {
    padding: 2.5rem;
    overflow-y: auto;
    max-height: 80vh;
}

.modal-body p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 2rem;
    font-size: 1.05rem;
}

.solutions-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.solutions-table th, .solutions-table td {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.solutions-table th {
    color: #93c5fd;
    font-weight: 600;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.solutions-table td {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    vertical-align: top;
}

.solutions-table td strong {
    color: var(--text-primary);
}

.solutions-table td em {
    color: #f87171;
    font-style: normal;
    font-weight: 600;
}
