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

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: #0f1117;
    color: #e2e8f0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Header ── */
header {
    background: #1a1d2e;
    border-bottom: 1px solid #2d3148;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

nav {
    max-width: 900px;
    margin: 0 auto;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-logo {
    color: #7c83f7;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 600;
}
.nav-logo:hover { color: #a5abff; }

.nav-profile {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.avatar svg { width: 34px; height: 34px; border-radius: 50%; display: block; }

.profile-info {
    display: flex;
    flex-direction: column;
}
.profile-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: #e2e8f0;
}
.profile-sub {
    font-size: 0.75rem;
    color: #94a3b8;
}

/* ── Main ── */
main {
    flex: 1;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ── Hero ── */
.hero {
    text-align: center;
    padding: 2.5rem 0 2.5rem;
}

.hero-avatar svg {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto 1rem;
    display: block;
    border: 3px solid #2d3148;
}

.hero h1 {
    font-size: 2.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #7c83f7, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.4rem;
}

.hero-sub {
    color: #94a3b8;
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.hero-stats {
    display: inline-flex;
    align-items: center;
    gap: 1.5rem;
    background: #1a1d2e;
    border: 1px solid #2d3148;
    border-radius: 12px;
    padding: 0.8rem 2rem;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.stat-num {
    font-size: 1.4rem;
    font-weight: 700;
    color: #7c83f7;
}
.stat-label {
    font-size: 0.75rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.stat-div {
    width: 1px;
    height: 30px;
    background: #2d3148;
}

/* ── Sections ── */
.section { margin-bottom: 2.5rem; }

.section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #2d3148;
}

/* ── Labs Grid ── */
.labs-grid {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.lab-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    background: #1a1d2e;
    border: 1px solid #2d3148;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, transform 0.15s, background 0.2s;
}

.lab-card:hover {
    border-color: #7c83f7;
    background: #1e2240;
    transform: translateX(4px);
}

.lab-number {
    font-size: 1.3rem;
    font-weight: 800;
    color: #7c83f7;
    min-width: 2rem;
    text-align: center;
}

.lab-info { flex: 1; }

.lab-info h3 {
    font-size: 0.98rem;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 0.15rem;
}

.lab-info p {
    font-size: 0.85rem;
    color: #94a3b8;
}

.lab-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.3rem;
}

.lab-arrow {
    color: #4a5080;
    font-size: 1.1rem;
    transition: color 0.2s;
}
.lab-card:hover .lab-arrow { color: #7c83f7; }

/* ── Status badge ── */
.status-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.status-badge.done {
    background: #0f2a1a;
    color: #4ade80;
    border: 1px solid #166534;
}

/* ── DL cards ── */
.dl-card { border-color: #2d2040; }
.dl-card:hover { border-color: #a78bfa; background: #1e1a30; }
.dl-num { color: #a78bfa; }
.dl-badge {
    background: #2a1d40;
    color: #a78bfa;
    border-color: #5b3d7a;
}

/* ── Lab Detail ── */
.lab-detail { padding-bottom: 3rem; }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: #7c83f7;
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    transition: color 0.2s;
}
.back-link:hover { color: #a5abff; }

.lab-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #2d3148;
}

.lab-header-top {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.lab-badge {
    display: inline-block;
    background: #2a2d50;
    color: #7c83f7;
    border: 1px solid #3d4175;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.2rem 0.65rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.lab-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: #e2e8f0;
    margin-bottom: 0.35rem;
}

.lab-desc {
    color: #94a3b8;
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.author-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.75rem;
}
.author-avatar svg { width: 32px; height: 32px; border-radius: 50%; display: block; }
.author-name {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: #c4c9ff;
}
.author-sub {
    display: block;
    font-size: 0.75rem;
    color: #94a3b8;
}

/* ── Lab Content ── */
.lab-content h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #c4c9ff;
    margin: 1.6rem 0 0.5rem;
}

.lab-content p {
    color: #94a3b8;
    line-height: 1.7;
    margin-bottom: 0.6rem;
}

.lab-content ol, .lab-content ul {
    color: #94a3b8;
    line-height: 1.8;
    padding-left: 1.5rem;
    margin-bottom: 0.6rem;
}

.lab-content a { color: #7c83f7; }
.lab-content a:hover { color: #a5abff; }

.lab-content pre {
    background: #12141f;
    border: 1px solid #2d3148;
    border-radius: 10px;
    padding: 1.1rem 1.4rem;
    overflow-x: auto;
    margin: 0.75rem 0;
}

.lab-content code {
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    color: #a5f3a5;
    line-height: 1.7;
}

/* ── Footer ── */
footer {
    text-align: center;
    padding: 1.25rem;
    color: #4a5080;
    font-size: 0.82rem;
    border-top: 1px solid #1e2235;
}

/* ── RLE Demo ── */
.rle-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 1rem 0;
}

.rle-form label {
    font-size: 0.85rem;
    color: #94a3b8;
    font-weight: 600;
}

.rle-form textarea {
    background: #12141f;
    border: 1px solid #2d3148;
    border-radius: 10px;
    padding: 0.9rem 1.1rem;
    color: #e2e8f0;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.92rem;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}
.rle-form textarea:focus { border-color: #7c83f7; }

.rle-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.rle-btn {
    background: #1a1d2e;
    border: 1px solid #2d3148;
    color: #e2e8f0;
    border-radius: 8px;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.rle-btn:hover { border-color: #7c83f7; color: #a5abff; }
.rle-btn.active {
    background: linear-gradient(135deg, #7c83f7, #a78bfa);
    border-color: transparent;
    color: #0f1117;
}

.rle-error {
    color: #f87171;
    font-size: 0.9rem;
    margin: 0.5rem 0;
}

.rle-result {
    background: #12141f;
    border: 1px solid #2d3148;
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    margin: 1rem 0;
}

.rle-result-label {
    display: block;
    font-size: 0.78rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.3rem;
}

.rle-result-value {
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.95rem;
    color: #a5f3a5;
    word-break: break-all;
    line-height: 1.6;
}

.rle-result-arrow {
    text-align: center;
    color: #4a5080;
    font-size: 1.2rem;
    margin: 0.5rem 0;
}

.rsa-key {
    font-size: 0.7rem;
    max-height: 120px;
    overflow-y: auto;
    color: #c4c9ff;
}

.dh-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem;
}

.dh-grid label {
    font-size: 0.8rem;
    color: #94a3b8;
    font-weight: 600;
    display: block;
    margin-bottom: 0.35rem;
}

.dh-grid input[type="number"] {
    width: 100%;
    background: #12141f;
    border: 1px solid #2d3148;
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    color: #e2e8f0;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.92rem;
    outline: none;
    transition: border-color 0.2s;
}
.dh-grid input[type="number"]:focus { border-color: #7c83f7; }

.dh-match-ok {
    color: #4ade80;
    font-size: 0.9rem;
    margin: 0.5rem 0;
}

/* ── Select dropdown ── */
.bool-select {
    width: 100%;
    background: #12141f;
    border: 1px solid #2d3148;
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    color: #e2e8f0;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.92rem;
    outline: none;
    transition: border-color 0.2s;
    cursor: pointer;
}
.bool-select:focus { border-color: #7c83f7; }

/* ── Text input ── */
.rle-form input[type="text"] {
    background: #12141f;
    border: 1px solid #2d3148;
    border-radius: 8px;
    padding: 0.7rem 1rem;
    color: #e2e8f0;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}
.rle-form input[type="text"]:focus { border-color: #7c83f7; }

/* ── Turing Machine tape ── */
.tm-steps {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 1rem 0;
    max-height: 460px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.tm-step {
    background: #12141f;
    border: 1px solid #2d3148;
    border-radius: 10px;
    padding: 0.85rem 1.1rem;
}

.tm-step-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
    flex-wrap: wrap;
}

.tm-step-num {
    font-size: 0.72rem;
    color: #4a5080;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tm-state {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.55rem;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.tm-state-right { background: #1d2a4a; color: #7ca8f7; }
.tm-state-carry { background: #4a2a1d; color: #f7a87c; }
.tm-state-done  { background: #1d4a2a; color: #4ade80; }

.tm-action {
    font-size: 0.8rem;
    color: #94a3b8;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

.tm-tape {
    display: flex;
    gap: 2px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.tm-cell {
    min-width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #2d3148;
    border-radius: 4px;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    color: #c4c9ff;
    background: #0f1117;
    flex-shrink: 0;
}

.tm-cell-active {
    border-color: #7c83f7;
    background: #1e2240;
    color: #fff;
    box-shadow: 0 0 0 1px #7c83f7;
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .hero h1 { font-size: 1.6rem; }
    .hero-stats { gap: 1rem; padding: 0.7rem 1.2rem; }
    .lab-card { padding: 0.85rem; }
    .profile-info { display: none; }
    .dh-grid { grid-template-columns: 1fr; }
}

/* ── Web Forms controls ── */
input[type="text"], input[type="number"], select, textarea {
    background: #12141f;
    border: 1px solid #2d3148;
    border-radius: 8px;
    padding: 0.6rem 0.9rem;
    color: #e2e8f0;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.92rem;
    outline: none;
    transition: border-color 0.2s;
}
input[type="text"]:focus, input[type="number"]:focus, select:focus, textarea:focus {
    border-color: #7c83f7;
}

input[type="submit"], input[type="button"] {
    background: #1a1d2e;
    border: 1px solid #2d3148;
    color: #e2e8f0;
    border-radius: 8px;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
    font-family: 'Segoe UI', system-ui, sans-serif;
}
input[type="submit"]:hover, input[type="button"]:hover {
    border-color: #7c83f7;
    color: #a5abff;
}
input[type="submit"].primary, input[type="button"].primary {
    background: linear-gradient(135deg, #7c83f7, #a78bfa);
    border-color: transparent;
    color: #0f1117;
}

.field-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.9rem;
}
.field-row label {
    font-size: 0.8rem;
    color: #94a3b8;
    font-weight: 600;
}

.dh-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem;
    margin-bottom: 0.9rem;
}
@media (max-width: 600px) {
    .dh-grid { grid-template-columns: 1fr; }
}

.demo-form {
    margin: 1rem 0;
}

.button-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.result-box {
    background: #12141f;
    border: 1px solid #2d3148;
    border-radius: 10px;
    padding: 1.1rem 1.4rem;
    margin: 1rem 0;
}
.result-label {
    display: block;
    font-size: 0.78rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.3rem;
}
.result-value {
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.92rem;
    color: #a5f3a5;
    word-break: break-all;
    line-height: 1.6;
}
.result-arrow {
    text-align: center;
    color: #4a5080;
    font-size: 1.2rem;
    margin: 0.4rem 0;
}
.error-msg {
    color: #f87171;
    font-size: 0.9rem;
    margin: 0.5rem 0;
}
.success-msg {
    color: #4ade80;
    font-size: 0.9rem;
    margin: 0.5rem 0;
}

/* ── Turing tape (Web Forms) ── */
.tm-steps {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 1rem 0;
    max-height: 460px;
    overflow-y: auto;
    padding-right: 0.25rem;
}
.tm-step {
    background: #12141f;
    border: 1px solid #2d3148;
    border-radius: 10px;
    padding: 0.85rem 1.1rem;
}
.tm-step-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
    flex-wrap: wrap;
}
.tm-step-num {
    font-size: 0.72rem;
    color: #4a5080;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.tm-state {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.55rem;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.tm-state-right { background: #1d2a4a; color: #7ca8f7; }
.tm-state-carry { background: #4a2a1d; color: #f7a87c; }
.tm-state-done  { background: #1d4a2a; color: #4ade80; }
.tm-action {
    font-size: 0.8rem;
    color: #94a3b8;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}
.tm-tape {
    display: flex;
    gap: 2px;
    overflow-x: auto;
    padding-bottom: 2px;
}
.tm-cell {
    min-width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #2d3148;
    border-radius: 4px;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    color: #c4c9ff;
    background: #0f1117;
    flex-shrink: 0;
}
.tm-cell-active {
    border-color: #7c83f7;
    background: #1e2240;
    color: #fff;
    box-shadow: 0 0 0 1px #7c83f7;
}

.rsa-key {
    font-size: 0.7rem;
    max-height: 120px;
    overflow-y: auto;
    color: #c4c9ff;
}
