* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
}

body {
    background: #18191d;
    color: #e8e8e3;
    font-family: Arial, Helvetica, sans-serif;
}

* {
    scrollbar-color: #555a68 #202127;
    scrollbar-width: thin;
}

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

::-webkit-scrollbar-track {
    background: #202127;
}

::-webkit-scrollbar-thumb {
    border: 2px solid #202127;
    border-radius: 999px;
    background: #555a68;
}

::-webkit-scrollbar-thumb:hover {
    background: #6f7484;
}

button,
input,
textarea {
    font: inherit;
}

button {
    border: 1px solid #4a4d59;
    border-radius: 4px;
    background-color: #2b2d35;
    color: #f2f2ee;
    min-height: 28px;
    padding: 4px 9px;
    cursor: pointer;
}

button:hover:not(:disabled) {
    background-color: #3a3d47;
    border-color: #6f7484;
}

button:disabled {
    color: #7f8492;
    cursor: default;
}

button.red {
    background-color: #4a2438;
    border-color: #8b3b63;
}

button.run-button.is-ready,
button.run-button.is-running {
    background-color: #244a34;
    border-color: #3d7550;
    color: #f2fff5;
}

button.run-button.is-running {
    box-shadow: inset 0 0 0 1px rgba(80, 250, 123, 0.22);
}

button.stop-button.is-running {
    background-color: #4a2438;
    border-color: #8b3b63;
    color: #fff3fa;
}

button.assemble-button.is-assembled:disabled {
    border-color: #343741;
    background-color: #24262d;
    color: #7f8492;
}

button.yellow {
    background-color: #4b4322;
    border-color: #82733a;
}

input {
    width: 90px;
    min-height: 28px;
    border: 1px solid #505364;
    border-radius: 4px;
    background: #202127;
    color: #f2f2ee;
    padding: 3px 6px;
}

.lmcContainer {
    height: 100vh;
    min-width: 0;
    display: grid;
    grid-template-rows: 42px minmax(0, 1fr) 176px 24px;
    grid-template-columns: 46px clamp(150px, 16vw, 220px) minmax(230px, 1fr) 126px minmax(300px, 380px);
    grid-template-areas:
        "header header header header header"
        "activity sidebar editor compiled debug"
        "activity sidebar terminal terminal debug"
        "status status status status status";
    background: #1d1f24;
}

.app-menubar {
    grid-area: header;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 12px;
    border-bottom: 1px solid #343741;
    background: #202127;
}

.app-brand {
    font-size: 14px;
    font-weight: 700;
    min-width: 172px;
    white-space: nowrap;
}

.app-menu {
    display: flex;
    align-self: stretch;
    gap: 2px;
    flex: 1;
}

.desktop-shell .app-menu {
    display: none;
}

.desktop-shell .app-brand {
    flex: 1;
}

.menu-group {
    position: relative;
    display: flex;
    align-items: stretch;
}

.menu-trigger,
.menu-popover button {
    border-color: transparent;
    background: transparent;
}

.menu-trigger {
    min-height: 0;
    padding: 0 10px;
}

.menu-popover {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 20;
    display: none;
    min-width: 190px;
    padding: 6px;
    border: 1px solid #3b3e49;
    border-radius: 6px;
    background: #252832;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

.menu-group:hover .menu-popover,
.menu-group:focus-within .menu-popover {
    display: block;
}

.menu-popover button {
    display: block;
    width: 100%;
    min-height: 28px;
    padding: 5px 10px;
    text-align: left;
}

.menu-separator {
    height: 1px;
    margin: 5px 4px;
    background: #3b3e49;
}

.run-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.toolbar-speed {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: 4px;
    color: #aeb4c2;
    font-size: 12px;
    white-space: nowrap;
}

.toolbar-speed button {
    width: 30px;
    height: 30px;
    min-height: 30px;
    padding: 0;
}

.activity-bar,
.side-panel,
.editor-pane,
.compiled-pane,
.debug-pane,
.terminal-pane {
    min-height: 0;
    border-right: 1px solid #343741;
    background: #22242b;
}

.activity-bar {
    grid-area: activity;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px 5px;
    background: #1a1c21;
}

.activity-button {
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    border-color: transparent;
    background: transparent;
    color: #aeb4c2;
    font-size: 18px;
}

.activity-button:hover:not(:disabled),
.activity-button.active {
    color: #f2f2ee;
    background: #30333d;
    border-color: #474b59;
}

.side-panel {
    grid-area: sidebar;
    padding: 10px;
    overflow: auto;
}

.side-view[hidden] {
    display: none;
}

.reference-view {
    display: grid;
    gap: 8px;
}

.reference-item {
    border: 1px solid #363946;
    border-radius: 6px;
    background: #252832;
    padding: 8px;
}

.reference-command {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    color: #f8f8f2;
    font-family: monospace;
}

.reference-command strong {
    color: #ff79c6;
}

.reference-command span {
    color: #8be9fd;
    font-size: 12px;
}

.reference-item p {
    margin: 6px 0;
    color: #c9ced8;
    font-size: 12px;
    line-height: 16px;
}

.reference-item code {
    display: block;
    color: #50fa7b;
    font-size: 12px;
    white-space: normal;
}

.editor-pane {
    grid-area: editor;
    background: #282a36;
}

.editor-header {
    height: 30px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    border-bottom: 1px solid rgba(52, 55, 65, 0.75);
}

.source-title {
    min-width: 0;
    margin-bottom: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-transform: none;
}

.compiled-pane {
    grid-area: compiled;
}

.compiled-pane,
.debug-pane {
    padding: 10px;
}

.terminal-pane {
    border-top: 1px solid #343741;
    border-right: 0;
    background: #15161a;
    padding: 8px 12px;
}

.status-bar {
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-top: 1px solid #343741;
    background: #22242b;
    color: #aeb4c2;
    font-family: monospace;
    font-size: 12px;
}

.hidden-file-input {
    display: none;
}

.panel-title {
    color: #aeb4c2;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.sidebar-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.sidebar-heading .panel-title {
    margin-bottom: 0;
}

.workspace-source {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 7px;
    color: #d2d5dd;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.workspace-source span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workspace-actions {
    display: flex;
    gap: 3px;
}

.workspace-actions button {
    width: 24px;
    height: 24px;
    min-height: 24px;
    padding: 0;
    color: #aeb4c2;
    background: transparent;
    border-color: transparent;
}

.workspace-actions button:hover {
    color: #f2f2ee;
    background: #30333d;
    border-color: #474b59;
}

.file-entry {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    border: 0;
    text-align: left;
    color: #d9dbdf;
    background: transparent;
    font-family: monospace;
    font-size: 13px;
    padding: 6px 8px;
    border-radius: 4px;
    min-height: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-entry span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-type-icon {
    flex: 0 0 14px;
    width: 14px;
    color: #8be9fd;
    text-align: center;
}

.example-entry .file-type-icon {
    color: #b9a4ff;
}

.file-entry.active {
    background: #343741;
}

.file-entry:hover {
    background: #30333d;
}

.workspace-files {
    display: grid;
    gap: 2px;
}

.section-toggle {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    min-height: 28px;
    padding: 4px 2px;
    border-color: transparent;
    background: transparent;
    color: #bfc4d0;
    font-size: 12px;
    font-weight: 700;
    text-align: left;
    text-transform: uppercase;
}

.section-toggle:hover:not(:disabled) {
    background: #30333d;
    border-color: transparent;
}

.section-toggle i {
    width: 12px;
    text-align: center;
}

.examples-title {
    margin-top: 18px;
}

.examples-list {
    display: grid;
    gap: 2px;
}

.examples-list[hidden] {
    display: none;
}

.editor {
    height: calc(100% - 30px);
}

.editor .CodeMirror {
    width: 100%;
    height: 100%;
    font-size: 14px;
}

.assemble_code {
    width: 100%;
    height: calc(100% - 27px);
    resize: none;
    font-family: monospace;
    font-size: 13px;
    line-height: 20px;
    color: #9fd8ce;
    background-color: #1f2228;
    border: 1px solid #343741;
    border-radius: 4px;
    padding: 8px;
}

.debug-pane {
    grid-area: debug;
}

.terminal-pane {
    grid-area: terminal;
}

.status-bar {
    grid-area: status;
}

.debug-pane {
    border-right: 0;
    overflow: hidden;
}

.register-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 10px;
}

.chip {
    background-color: #30333d;
    border: 1px solid #474b59;
    border-radius: 4px;
    color: #f5f5f1;
    min-width: 0;
    padding: 6px 8px;
    font-family: monospace;
    font-size: 13px;
}

.chip span {
    float: right;
    color: #50fa7b;
}

.pc-chip i {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-left: 4px;
    border-radius: 50%;
    background: #50fa7b;
    box-shadow: 0 0 0 2px rgba(80, 250, 123, 0.16);
}

.debug-io-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(120px, 1.25fr);
    gap: 8px;
    align-items: end;
    margin-bottom: 10px;
}

.output-chip {
    min-height: 46px;
    display: flex;
    align-items: center;
}

.output-chip span {
    float: none;
    min-width: 0;
    overflow: hidden;
    color: #50fa7b;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.input-row label,
.memory-header {
    display: block;
    color: #d2d5dd;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 6px;
}

.input-row div {
    display: flex;
    gap: 6px;
}

.input-row input {
    min-width: 0;
    width: 100%;
}

.memory-grid-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 8px;
    border: 1px solid #343741;
    border-radius: 6px;
    background: #1b1d24;
}

.debug-pane canvas {
    display: block;
    max-width: 100%;
    height: auto;
    border: 1px solid #444857;
    background: #20232b;
    cursor: pointer;
}

.memory-inspector {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 16px;
    row-gap: 4px;
    padding: 10px 12px;
    border: 1px solid #343741;
    border-radius: 4px;
    background: #202127;
}

.memory-inspector .panel-title {
    grid-column: 1 / -1;
    margin-bottom: 4px;
}

.inspect-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 0;
    color: #aeb4c2;
    font-family: monospace;
    font-size: 12px;
}

.inspect-row strong {
    color: #f2f2ee;
    font-weight: 700;
    text-align: right;
}

.inspect-source {
    grid-column: 1 / -1;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #343741;
    color: #c9ced8;
    font-family: monospace;
    font-size: 12px;
    line-height: 16px;
    overflow-wrap: anywhere;
}

.checks-panel {
    margin-top: 0;
}

.checks-panel button {
    margin-bottom: 8px;
}

.checks-output {
    min-height: 38px;
    border: 1px solid #343741;
    border-radius: 4px;
    background: #202127;
    color: #aeb4c2;
    padding: 8px;
    font-family: monospace;
    font-size: 12px;
    line-height: 17px;
    overflow-wrap: anywhere;
}

.checks-pass {
    border-color: #3d7550;
    color: #50fa7b;
}

.checks-fail {
    border-color: #8b3b63;
    color: #ff79c6;
}

.check-row + .check-row {
    margin-top: 6px;
}

.check-pass {
    color: #50fa7b;
}

.check-fail {
    color: #ff79c6;
}

.check-row strong {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #f2f2ee;
}

.check-pass strong {
    color: #50fa7b;
}

.check-fail strong {
    color: #ff79c6;
}

.terminal-output {
    height: calc(100% - 22px);
    overflow: auto;
    font-family: monospace;
    font-size: 13px;
    line-height: 19px;
    white-space: pre-wrap;
}

.terminal-line {
    color: #e8e8e3;
}

.terminal-icon {
    width: 14px;
    text-align: center;
}

.terminal-grey {
    color: #8e95a4;
}

.terminal-white {
    color: #e8e8e3;
}

.terminal-cyan {
    color: #8be9fd;
}

.terminal-success {
    color: #50fa7b;
}

.terminal-error {
    color: #ff79c6;
}

.highlighted-line {
    background-color: rgba(255,255,255,0.07 ) !important;
}

.diagnostic-gutter {
    width: 18px;
}

.breakpoint-gutter {
    width: 18px;
}

.breakpoint-marker {
    width: 11px;
    height: 11px;
    margin-top: 4px;
    margin-left: 3px;
    border-radius: 50%;
    background: #ff5555;
    box-shadow: 0 0 0 2px rgba(255, 85, 85, 0.22);
}

.diagnostic-marker {
    width: 14px;
    height: 14px;
    margin-top: 2px;
    border-radius: 50%;
    background: #ff79c6;
    color: #1d1f24;
    font-size: 10px;
    font-weight: 700;
    line-height: 14px;
    text-align: center;
}

.diagnostic-line {
    background-color: rgba(255, 121, 198, 0.12) !important;
}

.diagnostic-widget {
    margin: 2px 0 4px 34px;
    padding: 4px 8px;
    border-left: 2px solid #ff79c6;
    background: #332630;
    color: #ffd6e9;
    font-family: monospace;
    font-size: 12px;
}

.tooltip {
    position: fixed;
    background: rgba(20, 21, 27, 0.92);
    color: #e8e8e3;
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid #656a78;
    font-size: 12px;
    display: none;
    pointer-events: none;
    font-family: monospace;
    z-index: 100;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    background: rgba(10, 11, 15, 0.62);
}

.modal-backdrop[hidden] {
    display: none;
}

.modal-card {
    width: min(440px, calc(100vw - 32px));
    border: 1px solid #474b59;
    border-radius: 6px;
    background: #22242b;
    padding: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.modal-card h2 {
    margin: 0 0 8px;
    font-size: 16px;
    color: #f2f2ee;
}

.modal-card p {
    margin: 0 0 12px;
    color: #c9ced8;
    font-size: 13px;
    line-height: 18px;
    white-space: pre-line;
}

.modal-card input {
    width: 100%;
    margin-bottom: 14px;
}

.modal-card input[hidden] {
    display: none;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.modal-actions button.primary {
    border-color: #5d7a65;
    background: #2f5b3a;
}

@media (max-width: 900px) {
    .lmcContainer {
        height: auto;
        min-height: 100vh;
        grid-template-columns: 46px minmax(0, 1fr);
        grid-template-rows: auto auto minmax(420px, 1fr) 160px auto 150px 24px;
        grid-template-areas:
            "header header"
            "activity sidebar"
            "editor editor"
            "compiled compiled"
            "debug debug"
            "terminal terminal"
            "status status";
    }

    .app-menubar {
        flex-wrap: wrap;
        min-height: 42px;
        padding: 8px 12px;
    }

    .side-panel {
        min-height: 120px;
        max-height: 220px;
    }

    .debug-pane {
        border-top: 1px solid #343741;
    }

    .terminal-pane {
        min-height: 150px;
    }
}
