:root {
    --bg-color: #ffffff;
    --sidebar-bg: #fafafa;
    --text-main: #111827;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --border-color: #e5e7eb;
    --accent: #0d9488;        /* teal accent */
    --accent-hover: #0f766e;
    --warn: #d97706;          /* amber highlight */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', 'Roboto', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.top-nav {
    height: 60px;
    background-color: #ffffff;
    color: #111827;
    display: flex;
    align-items: center;
    padding: 0 20px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
}

.nav-brand {
    font-size: 1.2rem;
    font-weight: 600;
    margin-right: 30px;
    color: #111827;
}

.nav-links {
    display: flex;
    gap: 10px;
}

.nav-btn {
    background: transparent;
    color: #4b5563;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    transition: 0.2s;
}

.nav-btn.active {
    background: var(--primary);
    color: white;
}

.nav-btn:hover:not(.active) {
    background: #f3f4f6;
    color: #111827;
}

.pages-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.page {
    display: none;
    width: 100%;
    height: 100%;
}

.page.active-page {
    display: block;
}

.learn-container {
    padding: 40px;
    max-width: 1100px;
    margin: 0 auto;
    overflow-y: auto;
    height: 100%;
}

.learn-grid {
    display: flex;
    flex-direction: column;
    gap: 30px;
    margin-top: 20px;
}

.learn-section {
    background: #ffffff;
    padding: 25px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.static-heap-demo {
    margin-top: 20px;
    padding: 20px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px dashed #cbd5e1;
    display: flex;
    justify-content: center;
    overflow-x: auto;
}

.learn-container h1 {
    margin-bottom: 20px;
    color: #0f172a;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 15px;
}

.learn-read-more-btn {
    background-color: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
    padding: 10px 24px;
    font-size: 1.05rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 15px 0;
}

.learn-read-more-btn:hover {
    background-color: var(--primary);
    color: white;
}

.learn-container p {
    font-size: 1.1rem;
    line-height: 1.6;
    color: #334155;
}

.learn-container h3 {
    margin-top: 15px;
    margin-bottom: 10px;
    color: #1e293b;
}

.video-wrapper {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    width: 100%;
    background: #0f172a;
}

.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

.sidebar {
    width: 380px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px;
    z-index: 10;
    overflow-y: auto;
}

header h2 {
    font-size: 1.5rem;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-tabs {
    display: flex;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 10px;
    color: #64748b;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.95rem;
    transition: 0.2s;
}

.tab-btn.active {
    color: #3b82f6;
    border-bottom: 3px solid #3b82f6;
    margin-bottom: -2px;
}

.tab-btn:hover:not(.active) {
    color: #1e293b;
}

.tab-pane {
    display: none;
}

.tab-pane.active-pane {
    display: block;
}

.right-toolbar {
    width: 85px;
    background-color: var(--sidebar-bg);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 0;
    gap: 12px;
    z-index: 10;
    overflow-y: auto;
    overflow-x: hidden;
}

.right-toolbar::-webkit-scrollbar {
    width: 4px;
}

.right-toolbar::-webkit-scrollbar-track {
    background: transparent;
}

.right-toolbar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.right-toolbar::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.toolbar-title {
    font-size: 0.75rem;
    font-weight: bold;
    color: #94a3b8;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.quiz-lives {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
    font-size: 1.5rem;
    z-index: 50;
    background: #ffffff;
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.quiz-heart {
    transition: transform 0.2s;
}

.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    color: #64748b;
    cursor: pointer;
    font-size: 0.65rem;
    gap: 6px;
    padding: 10px 4px;
    border-radius: 8px;
    width: 65px;
    transition: all 0.2s;
}

.tool-btn svg {
    width: 22px;
    height: 22px;
}

.tool-btn:hover:not(.active) {
    background-color: #f1f5f9;
    color: #3b82f6;
}

.tool-btn.active {
    background-color: #eff6ff;
    color: #3b82f6;
    border: 1px solid #bfdbfe;
    font-weight: bold;
}

.toolbar-divider {
    width: 60%;
    border: 0;
    border-top: 2px solid var(--border-color);
    margin: 5px 0;
}

.floating-table {
    position: absolute;
    top: 20px;
    right: 100px;
    width: 300px;
    min-width: 250px;
    min-height: 150px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    resize: both;
}

.floating-table.hidden {
    display: none;
}

.table-header {
    background: #1e293b;
    color: white;
    padding: 10px 15px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    flex-shrink: 0;
}

.close-float-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 5px;
    transition: 0.2s;
}

.close-float-btn:hover {
    color: #ef4444;
}

.table-header:active {
    cursor: grabbing;
}

.table-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    padding: 10px;
}

#toast-container {
    position: fixed;
    bottom: 20px;
    right: 120px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
}

.toast {
    background-color: #ef4444;
    color: white;
    padding: 14px 20px;
    border-radius: 4px;
    font-weight: 500;
    max-width: 400px;
    font-size: 0.95rem;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: #ffffff;
    color: #111827;
    padding: 25px;
    border-radius: 4px;
    width: 320px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-content h3 {
    margin: 0;
    color: #f8fafc;
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-content input {
    background: #0f172a;
    border: 1px solid #475569;
    color: white;
    padding: 12px;
    font-size: 1.1rem;
    border-radius: 8px;
    outline: none;
}

.modal-content input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

.modal-btn {
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: 0.2s;
}

.modal-btn.secondary-btn {
    background: #475569;
    color: white;
}

.modal-btn.secondary-btn:hover {
    background: #64748b;
}

.modal-btn.primary-btn {
    background: #3b82f6;
    color: white;
}

.modal-btn.primary-btn:hover {
    background: #2563eb;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

label {
    font-size: 0.9rem;
    font-weight: 600;
}

input:not([type="range"]),
select {
    padding: 5px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.85rem;
}

input[type="range"] {
    width: 100%;
    margin-top: 5px;
    cursor: pointer;
}

button {
    background-color: var(--primary);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s, box-shadow 0.15s;
    border: none;
    padding: 7px 12px;
    border-radius: 4px;
    letter-spacing: 0.01em;
    font-size: 0.82rem;
}

button:hover:not(:disabled) {
    background-color: var(--primary-hover);
}

button:disabled {
    background-color: #cbd5e1;
    cursor: not-allowed;
}

#next-btn,
#custom-next-btn,
#anim-next-btn {
    background-color: var(--accent);
    margin-top: 10px;
}

#next-btn:hover:not(:disabled),
#custom-next-btn:hover:not(:disabled),
#anim-next-btn:hover:not(:disabled) {
    background-color: var(--accent-hover);
}

#next-iter-btn,
#custom-next-iter-btn,
#anim-next-iter-btn {
    background-color: #8b5cf6;
    margin-top: 5px;
}

#next-iter-btn:hover:not(:disabled),
#custom-next-iter-btn:hover:not(:disabled),
#anim-next-iter-btn:hover:not(:disabled) {
    background-color: #7c3aed;
}

#prev-btn,
#custom-prev-btn,
#anim-prev-btn {
    background-color: #64748b;
    margin-top: 5px;
}

#prev-btn:hover:not(:disabled),
#custom-prev-btn:hover:not(:disabled),
#anim-prev-btn:hover:not(:disabled) {
    background-color: #475569;
}

.secondary-btn {
    background-color: #64748b;
}

.secondary-btn:hover:not(:disabled) {
    background-color: #475569;
}

.input-with-toggle {
    display: flex;
    gap: 10px;
    align-items: center;
}

.input-with-toggle input[type="number"],
.input-with-toggle select {
    flex: 1;
}

.input-with-toggle label {
    font-size: 0.85rem;
    font-weight: normal;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.explanation-panel {
    flex: 1;
    min-height: 180px;
    background-color: var(--bg-color);
    border-radius: 8px;
    padding: 15px;
    border: 1px solid var(--border-color);
    overflow-y: auto;
    font-size: 0.9rem;
    line-height: 1.55;
    transition: all 0.3s ease;
}

.explanation-panel h3 {
    margin-bottom: 10px;
    font-size: 1.1rem;
}

#explanation-text,
#custom-explanation-text,
#anim-explanation-text {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--border-color);
}

@keyframes trap-flash {
    0% {
        background-color: var(--bg-color);
        border-color: var(--border-color);
    }

    10% {
        background-color: #fef2f2;
        border-color: #ef4444;
        box-shadow: inset 0 0 20px rgba(239, 68, 68, 0.3);
    }

    100% {
        background-color: var(--bg-color);
        border-color: var(--border-color);
        box-shadow: none;
    }
}

.explanation-panel.trap-active {
    animation: trap-flash 0.8s ease 1;
    border-color: #ef4444 !important;
}

.dist-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-top: 10px;
}

.dist-table th,
.dist-table td {
    border: 1px solid var(--border-color);
    padding: 6px;
    text-align: left;
}

.dist-table th {
    background-color: #f1f5f9;
    font-weight: 600;
}

.dist-table tr.highlight-row {
    background-color: #dcfce7;
    transition: background-color 0.3s;
}

.graph-container {
    flex: 1;
    position: relative;
    background-color: var(--bg-color);
}

.cy-instance {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.graph-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.85rem;
    pointer-events: none;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: #475569;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid transparent;
}

.legend-unvisited {
    background: #e2e8f0;
    border-color: #64748b;
}

.legend-in-queue {
    background: #e2e8f0;
    border-color: #f97316;
    box-shadow: 0 0 5px rgba(249, 115, 22, 0.5);
}

.legend-current {
    background: #3b82f6;
    border-color: #1e3a8a;
    animation: pulse-blue 1.5s infinite;
}

.legend-evaluating {
    background: transparent;
    border-top: 3px dashed #a855f7;
    border-radius: 0;
    height: 0;
    width: 20px;
}

.legend-finalized {
    background: #10b981;
    border-color: #059669;
}

@keyframes pulse-blue {
    0% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

.heap-tree {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px;
    min-width: max-content;
}

.heap-level {
    display: flex;
    justify-content: center;
    gap: 30px;
}

.heap-node {
    background: #f8fafc;
    border: 2px solid #3b82f6;
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 60px;
    position: relative;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.heap-node.min-element {
    border-color: #f59e0b;
    background: #fffbeb;
}

.heap-node .node-id {
    font-weight: bold;
    font-size: 1.1rem;
    color: #1e293b;
}

.heap-node .node-val {
    font-size: 0.85rem;
    color: #ef4444;
    font-family: monospace;
}

.math-status-bar {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.92);
    color: #f8fafc;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    z-index: 500;
    backdrop-filter: blur(6px);
    transition: opacity 0.3s;
    pointer-events: none;
    text-align: center;
    border: 1px solid #334155;
    white-space: nowrap;
}

.math-status-bar.hidden {
    opacity: 0;
    pointer-events: none;
}

.floating-code {
    position: absolute;
    top: 20px;
    right: 200px;
    width: 330px;
    background: #1e293b;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid #334155;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    resize: both;
    min-width: 280px;
    min-height: 200px;
}

.floating-code.hidden {
    display: none;
}

.code-header {
    background: #0f172a;
    color: white;
    padding: 10px 15px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    flex-shrink: 0;
}

.code-header:active {
    cursor: grabbing;
}

.code-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.code-line {
    font-family: 'Courier New', monospace;
    font-size: 0.88rem;
    color: #cbd5e1;
    padding: 5px 8px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
    display: block;
    margin-bottom: 3px;
}

.code-line.active-line {
    color: #3b82f6 !important;
    background: rgba(59, 130, 246, 0.12);
}

.visited-section {
    border-top: 1px solid #334155;
    padding: 12px 15px;
}

.visited-section strong {
    font-size: 0.8rem;
    color: #94a3b8;
    display: block;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#visited-nodes-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.quiz-error-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}

.quiz-error-modal.hidden {
    display: none;
}

.quiz-error-content {
    background: #1e293b;
    border: 2px solid #ef4444;
    color: white;
    padding: 30px;
    border-radius: 16px;
    max-width: 430px;
    width: 90%;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.quiz-error-content h3 {
    font-size: 1.4rem;
    margin-bottom: 15px;
    color: #ef4444;
}

#quiz-error-details {
    font-size: 1rem;
    color: #cbd5e1;
    line-height: 1.6;
    margin-bottom: 20px;
}

#quiz-error-close-btn {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

#quiz-error-close-btn:hover {
    background: #2563eb;
}

/* Home Page Styles */
.home-container {
    padding: 40px;
    max-width: 1200px;
    margin: 0 auto;
    overflow-y: auto;
    height: 100%;
}

.home-hero {
    text-align: center;
    margin-bottom: 40px;
    margin-top: 20px;
}

.home-hero h1 {
    font-size: 2.5rem;
    color: #0f172a;
    margin-bottom: 15px;
}

.home-hero p {
    font-size: 1.2rem;
    color: #475569;
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.6;
}

.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    padding-bottom: 40px;
}

.home-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 30px 20px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.home-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px rgba(0,0,0,0.1);
    border-color: #3b82f6;
}

.home-card-icon {
    font-size: 3.5rem;
}

.home-card h3 {
    font-size: 1.35rem;
    color: #1e293b;
}

.home-card p {
    color: #64748b;
    font-size: 0.95rem;
    line-height: 1.5;
    flex: 1;
}

button {
    background-color: var(--primary);
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    border: none;
    padding: 7px 12px;
    border-radius: 4px;
}

.button-group-academic {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f9fafb;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-top: 10px;
}

/* Quiz Edit/Save Button */
.quiz-edit-btn {
    background-color: #4b5563;
    color: white;
}
.quiz-edit-btn:hover:not(:disabled) {
    background-color: #374151;
}
.quiz-save-active {
    background-color: var(--accent) !important;
    color: white !important;
}
.quiz-save-active:hover:not(:disabled) {
    background-color: var(--accent-hover) !important;
}

/* Design Polish: Sidebar headings with teal accent bar */
.sidebar h2,
.sidebar header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    padding-bottom: 10px;
    border-bottom: 3px solid var(--accent);
    margin-bottom: 16px;
    letter-spacing: 0.02em;
}

.sidebar h3,
.explanation-panel h3 {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #9ca3af;
    margin-bottom: 10px;
}

/* Home card: left accent border on hover */
.home-card:hover {
    border-left: 3px solid var(--accent);
    padding-left: 17px;
}

/* Nav brand with teal dot */
.nav-brand::before {
    content: '▪';
    color: var(--accent);
    margin-right: 6px;
    font-size: 1rem;
}

/* Amber highlight for active algorithm state */
.explanation-panel strong[style*="#10b981"] {
    color: var(--accent) !important;
}

/* Quiz lives improved styling */
.quiz-heart {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 7px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: #f0fdf4;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ================================
   GOOGLE FONTS
================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ================================
   TOP NAV REFINEMENT
================================ */
.top-nav {
    border-bottom: 2px solid var(--border-color);
}

.nav-brand {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #111827;
}

.nav-btn {
    font-size: 0.8rem;
    padding: 5px 13px;
    letter-spacing: 0.02em;
}

/* ================================
   HOME PAGE DESIGN POLISH
================================ */
.home-hero h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #111827;
}

.home-hero p {
    font-size: 1rem;
    color: #6b7280;
    max-width: 580px;
    margin: 0 auto;
    line-height: 1.7;
}

/* Category label on home cards */
.home-card::before {
    content: attr(data-tag);
    display: inline-block;
    background: #f0fdf4;
    color: var(--accent);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 2px 7px;
    border-radius: 3px;
    border: 1px solid #d1fae5;
}

.home-card h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
}

.home-card p {
    font-size: 0.85rem;
    color: #6b7280;
    line-height: 1.55;
}

/* ================================
   SIDEBAR REFINEMENT
================================ */
.sidebar {
    border-right: 2px solid var(--border-color);
}

/* Control group labels */
.control-group label {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: #374151;
    text-transform: uppercase;
}

/* Explanation panel accent left bar */
.explanation-panel {
    border-left: 3px solid var(--accent);
    padding-left: 18px;
}

/* Algorithm State heading */
.explanation-panel h3 {
    color: var(--accent);
    font-size: 0.78rem;
}

/* ================================
   TABLE REFINEMENT
================================ */
.distances-table-container table {
    font-size: 0.8rem;
}

.distances-table-container th {
    background: #f9fafb;
    color: #374151;
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 6px 10px;
    border-bottom: 2px solid var(--border-color);
}

/* ================================
   BUTTON HOVER GLOW (subtle)
================================ */
button:hover:not(:disabled) {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

#next-btn:hover:not(:disabled),
#custom-next-btn:hover:not(:disabled),
#anim-next-btn:hover:not(:disabled) {
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ================================
   BUTTON GROUP ACADEMIC POLISH
================================ */
.button-group-academic {
    border-left: 3px solid var(--primary);
    background: #fafafa;
}

/* ================================
   GRAPH LEGEND STRIP
================================ */
.graph-legend {
    font-size: 0.72rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    font-weight: 600;
    color: #6b7280;
}

/* ================================
   MATH STATUS BAR
================================ */
.math-status-bar {
    font-family: 'Inter', monospace;
    letter-spacing: 0.01em;
    /* Overrides removed — the dark pill style at line ~835 is canonical */
}

/* ================================
   MODAL DIALOG POLISH
================================ */
.modal-content h3 {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* ================================
   FLOATING PANEL HEADERS
================================ */
.table-header {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 700;
    color: #4b5563;
    border-bottom: 2px solid var(--border-color);
}

/* ================================
   TOOLBAR BUTTON LABEL
================================ */
.tool-btn span {
    font-size: 0.6rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: 700;
}

/* ================================
   LEARN / READ MORE SECTION
================================ */
.learn-section h2 {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #111827;
    border-left: 3px solid var(--accent);
    padding-left: 10px;
    margin-bottom: 14px;
}

.learn-section p,
.learn-section li {
    font-size: 0.88rem;
    line-height: 1.7;
    color: #374151;
}