:root {
    --bg: #d9d9d4;
    --surface: #eeeeea;
    --surface-light: #f8f8f5;
    --surface-dark: #232323;
    --surface-dark-2: #2d2d2d;
    --surface-dark-3: #383838;

    --text: #202020;
    --text-soft: #555550;
    --muted: #777772;

    --text-light: #f4f4ef;
    --text-light-soft: #b8b8b2;

    --border: #b9b9b3;
    --border-light: #d2d2cc;
    --border-dark: #444444;

    --accent: #316f88;
    --accent-light: #d8e8ee;

    --success: #69b97b;

    --sidebar-width: 300px;
    --tool-width: 280px;

    --radius: 5px;
}


/* =========================================================
   RESET
========================================================= */

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;

    background: var(--bg);
    color: var(--text);

    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    line-height: 1.5;
}

button,
input,
select {
    font: inherit;
}

button {
    color: inherit;
}

a {
    color: inherit;
}


/* =========================================================
   SCROLLBARS
========================================================= */

* {
    scrollbar-width: thin;
    scrollbar-color: #666 transparent;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: #666;
    border-radius: 10px;
}


/* =========================================================
   TOP BAR
========================================================= */

.topbar {
    min-height: 70px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 24px;

    padding: 0 22px;

    background: #191919;
    color: var(--text-light);

    border-bottom: 1px solid #3b3b3b;

    position: sticky;
    top: 0;
    z-index: 100;
}

.brand-area {
    display: flex;
    align-items: baseline;
    gap: 14px;
}

.brand {
    color: #ffffff;

    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.03em;

    text-decoration: none;
}

.brand-description {
    color: #969696;
    font-size: 0.78rem;
}

.topbar-tools {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-wrapper {
    width: min(360px, 35vw);

    display: flex;
    align-items: center;

    background: #292929;

    border: 1px solid #454545;
    border-radius: var(--radius);

    transition: border-color 120ms ease;
}

.search-wrapper:focus-within {
    border-color: #777777;
}

.search-symbol {
    padding-left: 11px;

    color: #8d8d8d;

    font-size: 1rem;
    line-height: 1;
}

.search-input {
    width: 100%;

    padding: 9px 11px;

    color: #ffffff;
    background: transparent;

    border: 0;
    outline: 0;

    font-size: 0.85rem;
}

.search-input::placeholder {
    color: #777777;
}

.anthonycs-link {
    color: #b9b9b9;

    font-size: 0.82rem;

    text-decoration: none;

    transition: color 120ms ease;
}

.anthonycs-link:hover {
    color: #ffffff;
}


/* =========================================================
   APPLICATION SHELL
========================================================= */

.app {
    min-height: calc(100vh - 70px);

    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}


/* =========================================================
   SIDEBAR
========================================================= */

.sidebar {
    min-height: calc(100vh - 70px);

    display: flex;
    flex-direction: column;

    background: var(--surface-dark);
    color: var(--text-light);

    border-right: 1px solid #111111;

    position: sticky;
    top: 70px;

    height: calc(100vh - 70px);
}

.sidebar-scroll {
    flex: 1;

    overflow-y: auto;

    padding: 18px 11px 30px;
}

.navigation-group {
    margin-bottom: 27px;
}

.navigation-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 10px;

    margin: 0 9px 8px;

    color: #858585;

    font-family:
        "SFMono-Regular",
        Consolas,
        "Liberation Mono",
        monospace;

    font-size: 0.64rem;
    font-weight: 700;

    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.nav-item {
    width: 100%;
    min-height: 40px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 12px;

    padding: 9px 11px;

    background: transparent;
    color: var(--text-light);

    border: 1px solid transparent;
    border-radius: 4px;

    text-align: left;

    cursor: pointer;

    transition:
        background 120ms ease,
        border-color 120ms ease,
        transform 120ms ease;
}

.nav-item:hover {
    background: var(--surface-dark-2);
    border-color: var(--border-dark);
}

.nav-item.active {
    background: var(--surface-dark-3);
    border-color: #5b5b5b;
}

.nav-item:active {
    transform: translateY(1px);
}

.nav-name {
    min-width: 0;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    font-size: 0.86rem;
}

.nav-type {
    flex: 0 0 auto;

    color: #838383;

    font-family:
        "SFMono-Regular",
        Consolas,
        "Liberation Mono",
        monospace;

    font-size: 0.59rem;

    letter-spacing: 0.06em;
}

.nav-item.hidden {
    display: none;
}


/* =========================================================
   SIDEBAR FOOTER
========================================================= */

.sidebar-footer {
    min-height: 48px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 16px;

    padding: 0 18px;

    color: #858585;
    background: #1c1c1c;

    border-top: 1px solid #3a3a3a;

    font-family:
        "SFMono-Regular",
        Consolas,
        "Liberation Mono",
        monospace;

    font-size: 0.65rem;
}

.sidebar-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-light {
    width: 6px;
    height: 6px;

    background: var(--success);
    border-radius: 50%;
}

.version {
    color: #676767;
}


/* =========================================================
   WORKSPACE
========================================================= */

.workspace {
    min-width: 0;
    padding: 28px;
}

.workspace-header {
    min-height: 130px;

    display: flex;
    align-items: flex-end;
    justify-content: space-between;

    gap: 24px;

    padding-bottom: 22px;

    border-bottom: 1px solid var(--border);
}

.workspace-title-area {
    min-width: 0;
}

.topic-category {
    margin: 0 0 7px;

    color: var(--muted);

    font-family:
        "SFMono-Regular",
        Consolas,
        "Liberation Mono",
        monospace;

    font-size: 0.67rem;

    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.workspace-header h1 {
    margin: 0;

    font-size: clamp(2.4rem, 5vw, 4.6rem);
    font-weight: 700;

    letter-spacing: -0.06em;
    line-height: 0.95;
}

.topic-summary {
    max-width: 700px;

    margin: 13px 0 0;

    color: var(--text-soft);

    font-size: 0.96rem;
    line-height: 1.55;
}

.topic-meta {
    flex: 0 0 auto;

    padding-bottom: 5px;
}

.meta-item {
    display: inline-block;

    padding: 6px 9px;

    color: var(--text-soft);
    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 3px;

    font-family:
        "SFMono-Regular",
        Consolas,
        "Liberation Mono",
        monospace;

    font-size: 0.65rem;
}


/* =========================================================
   TOPIC TABS
========================================================= */

.topic-tabs {
    min-height: 54px;

    display: flex;
    align-items: flex-end;
    gap: 3px;

    overflow-x: auto;

    border-bottom: 1px solid var(--border);
}

.topic-tab {
    flex: 0 0 auto;

    padding: 17px 15px 13px;

    color: #74746f;
    background: transparent;

    border: 0;
    border-bottom: 2px solid transparent;

    font-size: 0.8rem;
    font-weight: 600;

    cursor: pointer;

    transition:
        color 120ms ease,
        border-color 120ms ease,
        background 120ms ease;
}

.topic-tab:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.18);
}

.topic-tab.active {
    color: var(--text);
    border-bottom-color: var(--text);
}


/* =========================================================
   WORKSPACE LAYOUT
========================================================= */

.workspace-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--tool-width);

    gap: 18px;

    margin-top: 20px;
}


/* =========================================================
   MAIN PANEL
========================================================= */

.main-panel {
    min-width: 0;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: var(--radius);

    overflow: hidden;

    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.6) inset,
        0 1px 2px rgba(0, 0, 0, 0.07);
}

.panel-titlebar {
    min-height: 38px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;

    padding: 0 14px;

    color: #53534f;
    background: #d0d0cb;

    border-bottom: 1px solid var(--border);

    font-family:
        "SFMono-Regular",
        Consolas,
        "Liberation Mono",
        monospace;

    font-size: 0.66rem;

    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.panel-indicator {
    color: #8b8b85;
}


/* =========================================================
   TOPIC CONTENT
========================================================= */

.topic-content {
    max-width: 1040px;

    padding: 30px;
}

.topic-content > :first-child {
    margin-top: 0;
}

.topic-content h2 {
    margin: 34px 0 12px;

    font-size: 1.4rem;
    font-weight: 700;

    letter-spacing: -0.025em;
}

.topic-content h3 {
    margin: 27px 0 10px;

    font-size: 1.05rem;
}

.topic-content p {
    max-width: 850px;

    margin: 0 0 20px;

    color: #3f3f3a;

    font-size: 0.98rem;
    line-height: 1.75;
}

.topic-content ul,
.topic-content ol {
    max-width: 850px;

    margin: 0 0 22px;
    padding-left: 24px;
}

.topic-content li {
    margin: 7px 0;

    color: #3f3f3a;

    font-size: 0.95rem;
    line-height: 1.6;
}

.topic-content a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.topic-content strong {
    font-weight: 700;
}


/* =========================================================
   INFORMATION GRID
========================================================= */

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));

    gap: 10px;

    margin: 24px 0 28px;
}

.info-card {
    min-height: 96px;

    display: flex;
    flex-direction: column;
    justify-content: space-between;

    padding: 14px;

    background: var(--surface-light);

    border: 1px solid var(--border-light);
    border-radius: 4px;
}

.info-card-label {
    color: var(--muted);

    font-family:
        "SFMono-Regular",
        Consolas,
        "Liberation Mono",
        monospace;

    font-size: 0.63rem;

    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.info-card-value {
    margin-top: 12px;

    font-size: 0.96rem;
    font-weight: 700;
}


/* =========================================================
   CONTENT BLOCKS
========================================================= */

.note {
    margin: 22px 0;
    padding: 14px 16px;

    color: #394e58;
    background: var(--accent-light);

    border-left: 3px solid var(--accent);
}

.note p {
    margin: 0;
}

.definition {
    margin: 20px 0;
    padding: 16px;

    background: #e5e5e0;

    border: 1px solid #c8c8c2;
    border-radius: 4px;
}

.definition-title {
    display: block;

    margin-bottom: 7px;

    color: var(--muted);

    font-family:
        "SFMono-Regular",
        Consolas,
        "Liberation Mono",
        monospace;

    font-size: 0.64rem;

    letter-spacing: 0.08em;
    text-transform: uppercase;
}


/* =========================================================
   CODE
========================================================= */

.code-block {
    margin: 22px 0;

    overflow-x: auto;

    background: #1f1f1f;
    color: #ededE7;

    border: 1px solid #101010;
    border-radius: 4px;
}

.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;

    padding: 8px 12px;

    color: #959595;
    background: #292929;

    border-bottom: 1px solid #393939;

    font-family:
        "SFMono-Regular",
        Consolas,
        "Liberation Mono",
        monospace;

    font-size: 0.64rem;
}

.code-block pre {
    margin: 0;
    padding: 18px;

    overflow-x: auto;
}

.code-block code {
    font-family:
        "SFMono-Regular",
        Consolas,
        "Liberation Mono",
        monospace;

    font-size: 0.84rem;
    line-height: 1.65;
}


/* =========================================================
   PRACTICE
========================================================= */

.practice-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;

    margin: 0 0 24px;
}

.practice-tag {
    padding: 5px 8px;

    color: #555550;
    background: #e4e4df;

    border: 1px solid #cacac4;
    border-radius: 3px;

    font-family:
        "SFMono-Regular",
        Consolas,
        "Liberation Mono",
        monospace;

    font-size: 0.62rem;
}

.checklist {
    list-style: none;

    padding-left: 0 !important;
}

.checklist li {
    position: relative;

    padding-left: 25px;
}

.checklist li::before {
    content: "□";

    position: absolute;
    left: 0;

    color: #777772;

    font-family: monospace;
}


/* =========================================================
   RESOURCE LINKS
========================================================= */

.resource-list {
    display: grid;
    gap: 9px;

    margin-top: 18px;
}

.resource-link {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;

    padding: 13px 14px;

    color: var(--text) !important;
    background: var(--surface-light);

    border: 1px solid var(--border-light);
    border-radius: 4px;

    text-decoration: none !important;

    transition:
        background 120ms ease,
        border-color 120ms ease;
}

.resource-link:hover {
    background: #ffffff;
    border-color: #aaaaa5;
}

.resource-link span:last-child {
    color: var(--muted);
}


/* =========================================================
   HISTORY TIMELINE
========================================================= */

.timeline {
    position: relative;

    margin-top: 25px;
    padding-left: 28px;
}

.timeline::before {
    content: "";

    position: absolute;
    top: 7px;
    bottom: 8px;
    left: 7px;

    width: 1px;

    background: var(--border);
}

.timeline-item {
    position: relative;

    margin-bottom: 30px;
}

.timeline-item::before {
    content: "";

    position: absolute;
    top: 7px;
    left: -25px;

    width: 9px;
    height: 9px;

    background: var(--surface);
    border: 2px solid #686863;
    border-radius: 50%;
}

.timeline-period {
    display: block;

    margin-bottom: 5px;

    color: var(--muted);

    font-family:
        "SFMono-Regular",
        Consolas,
        "Liberation Mono",
        monospace;

    font-size: 0.64rem;

    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.timeline-item h3 {
    margin: 0 0 8px;
}


/* =========================================================
   FIGURE CARDS
========================================================= */

.figure-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));

    gap: 12px;

    margin-top: 22px;
}

.figure-card {
    padding: 17px;

    background: var(--surface-light);

    border: 1px solid var(--border-light);
    border-radius: 4px;
}

.figure-date {
    color: var(--muted);

    font-family:
        "SFMono-Regular",
        Consolas,
        "Liberation Mono",
        monospace;

    font-size: 0.63rem;
}

.figure-card h3 {
    margin: 7px 0 8px;
}

.figure-card p {
    margin: 0;

    font-size: 0.88rem;
    line-height: 1.6;
}


/* =========================================================
   RIGHT TOOL RAIL
========================================================= */

.tool-rail {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.tool-panel {
    overflow: hidden;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: var(--radius);

    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.55) inset,
        0 1px 2px rgba(0, 0, 0, 0.06);
}

.tool-panel-heading {
    padding: 9px 12px;

    color: #555550;
    background: #d0d0cb;

    border-bottom: 1px solid var(--border);

    font-family:
        "SFMono-Regular",
        Consolas,
        "Liberation Mono",
        monospace;

    font-size: 0.64rem;

    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tool-button {
    width: 100%;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 14px;

    padding: 12px;

    background: transparent;

    border: 0;
    border-bottom: 1px solid #ccccC6;

    text-align: left;

    cursor: pointer;
}

.tool-button:last-child {
    border-bottom: 0;
}

.tool-button:hover {
    background: #e3e3de;
}

.topic-information {
    margin: 0;
    padding: 8px 12px;
}

.topic-information > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;

    gap: 15px;

    padding: 9px 0;

    border-bottom: 1px solid #d2d2cc;
}

.topic-information > div:last-child {
    border-bottom: 0;
}

.topic-information dt {
    color: var(--muted);

    font-family:
        "SFMono-Regular",
        Consolas,
        "Liberation Mono",
        monospace;

    font-size: 0.62rem;

    text-transform: uppercase;
}

.topic-information dd {
    margin: 0;

    color: #444440;

    font-size: 0.77rem;
    text-align: right;
}

.tool-copy {
    margin: 0;
    padding: 14px;

    color: var(--muted);

    font-size: 0.79rem;
    line-height: 1.6;
}


/* =========================================================
   MODAL
========================================================= */

.modal {
    position: fixed;
    inset: 0;

    z-index: 1000;

    display: none;
    align-items: center;
    justify-content: center;

    padding: 28px;
}

.modal.open {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;

    background: rgba(0, 0, 0, 0.72);
}

.modal-window {
    position: relative;
    z-index: 1;

    width: min(1200px, 96vw);
    height: min(820px, 92vh);

    display: flex;
    flex-direction: column;

    background: var(--surface);

    border: 1px solid #62625e;
    border-radius: 6px;

    overflow: hidden;

    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.55);
}

.modal-header {
    min-height: 70px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;

    padding: 12px 17px;

    background: #202020;
    color: #ffffff;

    border-bottom: 1px solid #444444;
}

.modal-label {
    color: #8e8e8e;

    font-family:
        "SFMono-Regular",
        Consolas,
        "Liberation Mono",
        monospace;

    font-size: 0.61rem;

    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.modal-header h2 {
    margin: 2px 0 0;

    font-size: 1.35rem;
}

.close-button {
    width: 38px;
    height: 38px;

    color: #cccccc;
    background: #303030;

    border: 1px solid #505050;
    border-radius: 4px;

    font-size: 1.5rem;
    line-height: 1;

    cursor: pointer;
}

.close-button:hover {
    color: #ffffff;
    background: #3d3d3d;
}

.compiler-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;

    padding: 9px 13px;

    background: #d1d1cc;

    border-bottom: 1px solid var(--border);

    font-size: 0.75rem;
}

.compiler-toolbar label {
    color: var(--muted);

    font-family:
        "SFMono-Regular",
        Consolas,
        "Liberation Mono",
        monospace;

    font-size: 0.62rem;

    text-transform: uppercase;
}

.compiler-toolbar select {
    padding: 5px 8px;

    background: #f5f5f1;

    border: 1px solid #aaaaa5;
    border-radius: 3px;
}

.compiler-frame {
    flex: 1;

    width: 100%;

    border: 0;
}


/* =========================================================
   EMPTY SEARCH STATE
========================================================= */

.search-empty {
    display: none;

    padding: 12px;

    color: #8d8d8d;

    font-size: 0.75rem;
}


/* =========================================================
   RESPONSIVE — TABLET
========================================================= */

@media (max-width: 1100px) {
    :root {
        --sidebar-width: 250px;
    }

    .workspace-layout {
        grid-template-columns: 1fr;
    }

    .tool-rail {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}


/* =========================================================
   RESPONSIVE — SMALL TABLET
========================================================= */

@media (max-width: 800px) {
    .topbar {
        align-items: stretch;
        flex-direction: column;

        padding: 13px 15px;
    }

    .brand-description {
        display: none;
    }

    .topbar-tools {
        width: 100%;
    }

    .search-wrapper {
        width: 100%;
    }

    .app {
        display: block;
    }

    .sidebar {
        position: static;

        width: 100%;
        height: auto;
        min-height: 0;

        border-right: 0;
        border-bottom: 1px solid #111111;
    }

    .sidebar-scroll {
        max-height: 310px;
    }

    .sidebar-footer {
        display: none;
    }

    .workspace {
        padding: 20px;
    }

    .workspace-header {
        min-height: 0;

        align-items: flex-start;
        flex-direction: column;

        padding: 25px 0 18px;
    }

    .topic-meta {
        padding-bottom: 0;
    }

    .tool-rail {
        grid-template-columns: 1fr;
    }

    .info-grid,
    .figure-grid {
        grid-template-columns: 1fr;
    }
}


/* =========================================================
   RESPONSIVE — MOBILE
========================================================= */

@media (max-width: 520px) {
    .topbar-tools {
        align-items: stretch;
        flex-direction: column;
        gap: 9px;
    }

    .anthonycs-link {
        align-self: flex-end;
    }

    .workspace {
        padding: 14px;
    }

    .workspace-header h1 {
        font-size: 2.6rem;
    }

    .topic-content {
        padding: 20px;
    }

    .topic-tab {
        padding-left: 11px;
        padding-right: 11px;

        font-size: 0.74rem;
    }

    .modal {
        padding: 8px;
    }

    .modal-window {
        width: 100%;
        height: 96vh;
    }
}
