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

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #f0fdfa;
    /* Teal-50 */
    color: #334155;
    /* Slate-700 */
}

.container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 450px 1fr;
    gap: 0;
    overflow: hidden;
    background: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin: 20px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    /* Slate-200 */
}

.footer {
    background: transparent;
    padding: 10px 20px;
    text-align: center;
    font-size: 0.85em;
    color: #64748b;
    /* Slate-500 */
    border-top: none;
    margin-bottom: 10px;
}

.footer a {
    color: #0d9488;
    /* Teal-600 */
    text-decoration: none;
    font-weight: 500;
}

.footer a:hover {
    text-decoration: underline;
    color: #0f766e;
    /* Teal-700 */
}

.left-panel,
.right-panel {
    background: white;
    overflow-y: auto;
    height: 100%;
}

.left-panel {
    border-right: 1px solid #e2e8f0;
    padding: 0;
    background: #f8fafc;
    /* Slate-50 */
}

.right-panel {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    background: white;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
    background: white;
    padding: 0 16px;
    gap: 16px;
}

.tab-button {
    padding: 16px 4px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    color: #64748b;
    transition: all 0.2s;
}

.tab-button:hover {
    color: #334155;
}

.tab-button.active {
    color: #0d9488;
    /* Teal-600 */
    border-bottom-color: #0d9488;
}

.tab-content {
    display: none;
    padding: 24px;
}

.tab-content.active {
    display: block;
}

/* Sections */
.section {
    margin-bottom: 24px;
}

.section-title {
    font-size: 0.75em;
    font-weight: 700;
    color: #64748b;
    /* Slate-500 */
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
}

.control-group {
    margin-bottom: 16px;
}

.mode-buttons {
    display: flex;
    gap: 8px;
    background: #e2e8f0;
    padding: 4px;
    border-radius: 8px;
}

.mode-btn {
    flex: 1;
    padding: 8px 16px;
    font-size: 0.9em;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn:hover {
    color: #334155;
}

.mode-btn.active {
    background: white;
    color: #0d9488;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

label {
    display: block;
    font-weight: 500;
    color: #475569;
    /* Slate-600 */
    margin-bottom: 8px;
    font-size: 0.9em;
}

label .value {
    color: #0d9488;
    font-weight: 600;
    background: #f0fdfa;
    padding: 2px 6px;
    border-radius: 4px;
}

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

.slider-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    color: #64748b;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.slider-btn:hover {
    color: #0d9488;
    border-color: #0d9488;
    background: #f0fdfa;
}

input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #0d9488;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.1s;
}

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

input[type="number"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9em;
    background: white;
    transition: border-color 0.2s;
}

input[type="number"]:focus {
    outline: none;
    border-color: #0d9488;
}

select {
    width: 100%;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9em;
    background: white;
    cursor: pointer;
    color: #334155;
}

.buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

button {
    width: 100%;
    padding: 12px 20px;
    font-size: 0.95em;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

button:active:not(:disabled) {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: #0d9488;
    /* Teal-600 */
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #0f766e;
    /* Teal-700 */
}

.btn-secondary {
    background: white;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.btn-secondary:hover:not(:disabled) {
    background: #f8fafc;
    border-color: #cbd5e1;
}

/* Results box */
.result-box {
    background: white;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    margin-bottom: 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.result-label {
    font-size: 0.75em;
    color: #64748b;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.result-value {
    font-size: 1.25em;
    font-weight: 600;
    color: #0f172a;
    /* Slate-900 */
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* Matrix section title with inline tabs */
.section-title-with-tabs {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
}

.section-title-text {
    font-size: 0.75em;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.matrix-tabs-inline {
    display: flex;
    gap: 4px;
    background: #f1f5f9;
    padding: 2px;
    border-radius: 6px;
}

.matrix-tab-button {
    padding: 4px 12px;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
    color: #64748b;
    transition: all 0.2s;
}

.matrix-tab-button:hover {
    color: #334155;
    background: rgba(255, 255, 255, 0.5);
}

.matrix-tab-button.active {
    color: #0d9488;
    background: white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.matrix-tab-content {
    display: none;
}

.matrix-tab-content.active {
    display: block;
}

/* Visual Matrix */
.matrix-visual {
    display: grid;
    gap: 3px;
    padding: 20px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    overflow-x: auto;
}

.matrix-axis-label-bottom {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    text-align: left;
    letter-spacing: 0.5px;
}

.matrix-visual-row {
    display: flex;
    gap: 4px;
    align-items: center;
}

.matrix-visual-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    font-weight: 500;
    color: #94a3b8;
    width: 24px;
    text-align: right;
    flex-shrink: 0;
}

.matrix-visual-label.current-position {
    font-size: 14px;
    color: #0f172a;
    font-weight: 700;
}

.matrix-visual-cell {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.matrix-visual-cell.valid {
    background: #ccfbf1;
    /* Teal-100 */
    border: 1px solid #99f6e4;
    /* Teal-200 */
}

.matrix-visual-cell.invalid {
    background: #f1f5f9;
    /* Slate-100 */
    border: 1px solid #e2e8f0;
    /* Slate-200 */
}

.matrix-visual-cell.hidden {
    background: transparent;
    border: none;
    visibility: hidden;
    cursor: default;
}

.matrix-visual-cell.selected.valid {
    background: #14b8a6;
    /* Teal-500 */
    border-color: #0d9488;
    /* Teal-600 */
    box-shadow: 0 0 0 2px #ccfbf1;
}

.matrix-visual-cell.selected.invalid {
    background: #94a3b8;
    /* Slate-400 */
    border-color: #64748b;
}

.matrix-visual-cell.valid:hover {
    background: #5eead4;
    /* Teal-300 */
    transform: scale(1.1);
    z-index: 10;
}

.end-marker {
    font-size: 10px;
    color: white;
    font-weight: bold;
    pointer-events: none;
}

.end-marker.finish-flag {
    font-size: 14px;
    color: #0f766e;
    visibility: visible;
}

.matrix-visual-header {
    display: flex;
    gap: 4px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

.matrix-visual-header-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    font-weight: 500;
    color: #94a3b8;
    min-width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.matrix-visual-header-label.current-position {
    color: #0f172a;
    font-weight: 700;
}

.matrix-visual-header-label.highlighted-valid {
    color: #10b981;
    /* Emerald-500 */
    border-bottom: 2px solid #10b981;
    font-weight: 700;
    background: #ecfdf5;
}

.matrix-visual-header-label.highlighted-invalid {
    color: #ef4444;
    /* Red-500 */
    border-bottom: 2px solid #ef4444;
    font-weight: 700;
    background: #fef2f2;
}

/* Text Matrix */
.matrix {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    line-height: 1.4;
    white-space: pre;
    color: #334155;
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    overflow-x: auto;
}

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

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

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        margin: 0;
        border-radius: 0;
        border: none;
    }

    .left-panel {
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        max-height: 50vh;
    }
}