@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/inter-400.ttf") format("truetype");
}
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/inter-500.ttf") format("truetype");
}
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("../fonts/inter-600.ttf") format("truetype");
}
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/inter-700.ttf") format("truetype");
}
:root {
    font-family: "Inter", system-ui, sans-serif;
    color: #253a3b;
    background: #f6f8f7;
    font-size: 14px;
    --green: #167563;
    --line: #dce5e1;
}
* {
    box-sizing: border-box;
}
body {
    margin: 0;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
button,
input,
select {
    font: inherit;
}
button {
    cursor: pointer;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: white;
    padding: 8px 12px;
    color: inherit;
}
button:hover {
    background: #edf4f1;
    border-color: #9abdb0;
}
button:disabled {
    opacity: 0.4;
    cursor: default;
}
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid #70b8a3;
    outline-offset: 2px;
}
.primary {
    background: var(--green);
    color: white;
    border-color: var(--green);
}
.primary:hover {
    background: #105b4c;
}
.project-bar {
    min-height: 83px;
    flex-wrap: wrap;
    flex-shrink: 0;
    padding: 18px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.project-bar input {
    display: block;
    border: 0;
    background: transparent;
    font-size: 20px;
    font-weight: 600;
    width: min(320px, 75vw);
    padding: 0;
}
.project-bar #save-status {
    display: block;
    color: #86968e;
    font-size: 11px;
    margin-top: 6px;
}
.run-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    align-items: center;
}
.run-actions label {
    font-size: 11px;
    color: #72867b;
}
.chart-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.icon-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.icon-label svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
#zoom-label {
    min-width: 42px;
    text-align: center;
    font-size: 12px;
}
select {
    padding: 7px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: white;
    color: #475f53;
}
main {
    display: grid;
    grid-template-columns: minmax(360px, 1fr) 345px;
    flex: 1;
    min-height: 0;
    border-top: 1px solid var(--line);
}
.palette {
    padding: 26px 20px;
    background: #fff;
    overflow: auto;
    border-right: 1px solid var(--line);
}
.eyebrow {
    font-size: 10px;
    letter-spacing: 1.6px;
    color: #7c9487;
    font-weight: 700;
}
h2 {
    font-size: 18px;
    margin: 10px 0;
}
p {
    line-height: 1.7;
    color: #74847d;
    font-size: 12px;
}
.palette p {
    margin-bottom: 19px;
}
#symbols,
#loop-tools {
    display: grid;
    gap: 7px;
}
.symbol-tool {
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    padding: 9px 11px;
    font-size: 12px;
}
.symbol-tool svg {
    width: 33px;
    height: 25px;
    flex-shrink: 0;
}
.tip {
    border-top: 1px solid var(--line);
    margin-top: 25px;
    padding-top: 20px;
    font-size: 12px;
}
.example-label {
    display: grid;
    gap: 8px;
    font-size: 11px;
    color: #6e8276;
}
.workspace {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}
.canvas-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: #fafcfb;
    border-bottom: 1px solid var(--line);
    font-size: 10px;
    letter-spacing: 1.2px;
}
.canvas-toolbar small {
    letter-spacing: 0;
    color: #8b9c93;
    margin-left: 12px;
}
.canvas-toolbar button {
    padding: 3px 8px;
    border: 0;
    background: transparent;
}
.canvas-toolbar div {
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0;
}
#canvas-scroll {
    overflow: auto;
    flex: 1;
    background-image: radial-gradient(#d7e1dc 1px, transparent 1px);
    background-size: 20px 20px;
    cursor: grab;
    min-height: 0;
    touch-action: none;
    overscroll-behavior: contain;
}
.structured-chart {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: max-content;
}
.symbol-tool,
.node {
    touch-action: none;
    user-select: none;
}
.symbol-tool {
    cursor: grab;
}
.loose-node {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 210px;
    z-index: 3;
}
.loose-caption {
    font-size: 10px;
    color: #8b7660;
    padding: 6px 0;
}
.connect-handle {
    padding: 4px 9px;
    border-radius: 12px;
    font-size: 10px;
    color: #167563;
    cursor: crosshair;
    touch-action: none;
}
.connecting .insert,
.drop-target {
    background: #167563;
    color: white;
    box-shadow: 0 0 0 5px #16756330;
}
.panning,
.panning * {
    cursor: grabbing !important;
    user-select: none;
}
.drag-ghost {
    position: fixed !important;
    z-index: 100;
    pointer-events: none;
    opacity: 0.8;
    margin: 0;
}
.connection-preview {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99;
    pointer-events: none;
}
.dropping .insert {
    box-shadow: 0 0 0 5px #16756320;
}
.dialog-actions {
    flex-wrap: wrap;
}
#chart {
    width: max-content;
    min-width: 100%;
    position: relative;
    min-height: 100%;
    padding: 60px 280px 250px;
    display: flex;
    align-items: center;
    flex-direction: column;
    transform-origin: top left;
}
.terminal {
    background: #dfefe6;
    border: 1.5px solid #77aa91;
    color: #396b53;
    border-radius: 30px;
    padding: 10px 43px;
    font-size: 12px;
    font-weight: 600;
}
.sequence {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 190px;
}
.connector {
    height: 40px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.connector:before {
    content: "";
    height: 100%;
    border-left: 1.5px solid #a5b9ae;
    position: absolute;
}
.connector:after {
    content: "";
    position: absolute;
    bottom: 0;
    border: 4px solid transparent;
    border-top-color: #a5b9ae;
    transform: translateY(4px);
}
.insert {
    z-index: 1;
    border: 1px solid #c3d5cb;
    width: 20px;
    height: 20px;
    padding: 0;
    border-radius: 50%;
    background: #f8fbf9;
    color: #7b9d8a;
    font-size: 15px;
    line-height: 16px;
}
.insert.selected {
    background: var(--green);
    color: white;
    box-shadow: 0 0 0 4px #dcefe6;
}
.node {
    position: relative;
    border: 0;
    background: transparent !important;
    padding: 0;
    width: 190px;
    height: 64px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.node svg {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: visible;
}
.node span {
    position: relative;
    font-size: 11px;
    max-width: 142px;
    max-height: 48px;
    overflow: hidden;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.35;
}
.node.decision {
    height: 88px;
    width: 210px;
}
.node.active svg {
    filter: drop-shadow(0 0 5px #e3a20d);
}
.node.active {
    outline: 3px solid #e3a20d;
    outline-offset: 4px;
    border-radius: 8px;
}
.branches {
    display: flex;
    position: relative;
    border-top: 1.5px solid #a5b9ae;
    border-bottom: 1.5px solid #a5b9ae;
    margin: 20px 15px 0;
    gap: 25px;
}
.branch {
    display: flex;
    align-items: center;
    flex-direction: column;
    position: relative;
    min-width: 205px;
}
.branches::before {
    content: "";
    position: absolute;
    left: 50%;
    top: -21px;
    height: 20px;
    border-left: 1.5px solid #a5b9ae;
}
.branch > .sequence {
    flex: 1;
}
.branch > .sequence > .connector:last-child {
    flex: 1;
    min-height: 40px;
}
.branch-label {
    font-size: 10px;
    background: #f3f7f4;
    padding: 3px 9px;
    border-radius: 12px;
    margin-top: -11px;
    color: #688774;
}
.loop-tools-heading {
    margin-top: 22px;
    font-size: 10px;
    letter-spacing: 1px;
    color: #688774;
}
.palette .loop-tools-help {
    font-size: 11px;
    margin: 8px 0 12px;
}
.loop-diagram {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 70px 35px;
}
.loop-entry {
    height: 20px;
    width: 1px;
}
.loop-tail {
    width: 1px;
    height: 20px;
    border-left: 1.5px solid #829d8e;
}
.loop-wires {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
}
.loop-wires text {
    fill: #527260;
    font-size: 10px;
}
.loop-diagram > .node,
.loop-statements {
    z-index: 1;
}
#name-form label {
    display: block;
    margin: 20px 0 8px;
}
#chart-name {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
}
#name-error {
    color: #b42318;
}
.inspector {
    border-left: 1px solid var(--line);
    background: #fff;
    overflow: auto;
    min-width: 0;
    min-height: 0;
}
.tabs {
    display: flex;
    border-bottom: 1px solid var(--line);
    padding: 0 18px;
    gap: 23px;
}
.tabs button {
    border: 0;
    border-radius: 0;
    padding: 17px 0;
    color: #899a8f;
    font-size: 12px;
}
.tabs .active {
    color: var(--green);
    border-bottom: 2px solid var(--green);
}
.panel-heading {
    flex-wrap: wrap;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 17px 18px;
    font-size: 10px;
    color: #86978c;
}
.code-size-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-right: auto;
}
#code-size {
    min-width: 30px;
    text-align: center;
}
#pseudocode {
    font-size: var(--code-size, 14px);
    line-height: 1.8;
}
.panel-heading span {
    margin-right: auto;
}
.panel-heading button {
    font-size: 10px;
    padding: 4px 8px;
}
pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font:
        11px/2 "Inter",
        sans-serif;
    padding: 15px 22px;
    color: #3d6959;
    margin: 0;
}
.code-note {
    padding: 24px;
    font-size: 11px;
    line-height: 1.6;
    color: #9aa99f;
}
#console-panel {
    padding: 18px;
}
#console {
    min-height: 150px;
    font:
        12px/1.8 "Inter",
        sans-serif;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.log {
    padding: 6px 0;
    border-bottom: 1px solid #f0f4f1;
}
.log.error {
    color: #b14848;
}
.log.document {
    background: #fff7df;
    padding: 12px;
    border-left: 3px solid #c5a150;
    margin-top: 8px;
}
h3 {
    font-size: 11px;
    letter-spacing: 0.5px;
    margin: 26px 0 12px;
}
#variables,
#database {
    font:
        11px/1.8 "Inter",
        sans-serif;
    color: #718777;
    overflow-wrap: anywhere;
}
.value-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid #eef3ef;
    padding: 5px;
}
#input-form {
    padding: 15px 0;
}
#input-form label {
    display: block;
    margin-bottom: 8px;
}
#input-form input {
    width: 100%;
    padding: 9px;
    margin-bottom: 8px;
    border: 1px solid var(--line);
    border-radius: 5px;
}
dialog {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 28px;
    width: min(500px, 95vw);
    box-shadow: 0 20px 90px #173a3030;
}
dialog::backdrop {
    background: #183c3455;
    backdrop-filter: blur(2px);
}
#fields label {
    display: grid;
    gap: 7px;
    margin: 18px 0;
    font-size: 12px;
}
#fields input,
#fields select {
    width: 100%;
    padding: 10px;
    border: 1px solid #cbd9d0;
    border-radius: 6px;
}
.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 25px;
}
.danger {
    margin-right: auto;
    color: #a75454;
}
#edit-error {
    color: #b14848;
}
#toast {
    position: fixed;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    background: #213f34;
    color: white;
    padding: 12px 22px;
    border-radius: 8px;
    z-index: 10;
    font-size: 12px;
}
#help-dialog p {
    font-size: 13px;
}
.field-help code {
    font-size: 11px;
}
[hidden] {
    display: none !important;
}
@media (max-width: 1100px) {
    main {
        grid-template-columns: 190px minmax(320px, 1fr) 280px;
    }
    .palette {
        padding: 22px 12px;
    }
}
@media (max-width: 800px) {
    .project-bar {
        padding: 16px;
        flex-wrap: wrap;
    }
    .project-bar input {
        width: 290px;
    }
    main {
        flex: none;
        height: auto;
        grid-template-columns: 140px minmax(220px, 1fr);
    }
    .inspector {
        grid-column: 1/-1;
        min-height: 260px;
        border-top: 1px solid var(--line);
    }
    .workspace {
        height: 650px;
    }
    .palette {
        height: 650px;
    }
    .tip {
        display: none;
    }
    .run-actions {
        flex-wrap: wrap;
    }
    .symbol-tool {
        padding: 7px;
        font-size: 11px;
        gap: 6px;
    }
    .symbol-tool svg {
        width: 25px;
    }
}

code,
pre,
textarea {
    font-family: "Inter", sans-serif;
}
@media (max-width: 800px) {
    body {
        overflow: auto;
        height: auto;
        min-height: 100dvh;
    }
}
/* Arrow-based graph editor */
#chart {
    position: relative;
    padding: 0;
    display: block;
    min-width: 100%;
    min-height: 100%;
}
.graph-node {
    position: absolute;
    z-index: 2;
}
.graph-node .node {
    width: 100%;
    height: 100%;
    cursor: move;
}
.graph-node .node span {
    max-width: 142px;
    pointer-events: none;
}
.node-inlet {
    position: absolute;
    top: -13px;
    left: calc(50% - 6px);
    width: 12px;
    height: 12px;
    padding: 0;
    border-radius: 50%;
    border: 1.5px solid #829d8e;
    background: #fff;
    cursor: crosshair;
}
#graph-wires {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}
#graph-wires text {
    fill: #527260;
    font:
        400 10px Inter,
        sans-serif;
    pointer-events: none;
}
.edge-hit {
    cursor: pointer;
    pointer-events: stroke;
}
.edge-action {
    position: absolute;
    z-index: 3;
    width: 24px;
    height: 24px;
    padding: 0;
    border-radius: 50%;
    background: #f8fbf9;
    color: #167563;
    border: 1px solid #b0cbbb;
    font-size: 17px;
    line-height: 20px;
}
.edge-action:hover {
    background: #167563;
    color: #fff;
}
.linking .node-inlet,
.linking .edge-action {
    background: #167563;
    color: #fff;
    box-shadow: 0 0 0 4px #16756330;
}
.linking .edge-hit:hover {
    stroke: #16756350;
}
#connection-banner {
    background: #e5f2ec;
    padding: 10px 18px;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.unconnected {
    display: block;
    text-align: center;
    color: #a15a35;
    font-size: 10px;
    padding-top: 5px;
}
#symbol-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 20px 0;
}
.symbol-choice {
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: left;
}
.symbol-choice svg {
    width: 42px;
    height: 30px;
    flex-shrink: 0;
}
.link-existing {
    width: 100%;
    color: #167563;
    background: #edf6f1;
}
@media (max-width: 1100px) {
    main {
        grid-template-columns: minmax(320px, 1fr) 280px;
    }
}
@media (max-width: 800px) {
    main {
        grid-template-columns: minmax(0, 1fr);
    }
    .canvas-toolbar {
        gap: 8px;
        flex-wrap: wrap;
    }
    .canvas-toolbar > div {
        flex-wrap: wrap;
    }
    .workspace {
        height: 650px;
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    color: #e0eae6;
    background: #000000;
    --line: #333333;
    --green: #40e6a1;
}
[data-theme="dark"] :is(.inspector, dialog, button, select, input) {
    background: #0a0a0a;
    color: #e0eae6;
    border-color: var(--line);
}
[data-theme="dark"] button:hover {
    background: #202020;
    border-color: #40e6a1;
}
[data-theme="dark"]
    :is(
        .primary,
        .edge-action:hover,
        .linking .edge-action,
        .linking .node-inlet
    ) {
    background: #40e6a1;
    color: #102720;
}
[data-theme="dark"] #theme-toggle[aria-pressed="true"] {
    border-color: #40e6a1;
    background: #161616;
}
[data-theme="dark"]
    :is(
        p,
        .eyebrow,
        .code-note,
        .panel-heading,
        .run-actions label,
        #save-status,
        #variables,
        #database,
        .tabs button
    ) {
    color: #adbfba;
}
[data-theme="dark"] :is(#pseudocode, .tabs .active) {
    color: #9be0c6;
}
[data-theme="dark"] #canvas-scroll {
    background-color: #000000;
    background-image: none;
}
[data-theme="dark"] .node {
    color: #253a3b;
}
[data-theme="dark"] #graph-wires text {
    fill: #c3d5cb;
}
[data-theme="dark"]
    :is(.edge-action, .node-inlet, .link-existing, #connection-banner) {
    background: #141414;
    color: #a2e6cc;
}
[data-theme="dark"] :is(.log, .value-row) {
    border-color: var(--line);
}
[data-theme="dark"] .log.document {
    background: #241b08;
}
[data-theme="dark"] :is(.danger, .log.error, #edit-error, #name-error) {
    color: #ffaaa5;
}
[data-theme="dark"] .unconnected {
    color: #edbc94;
}

.code-line {
    display: block;
    padding: 0 8px;
    border-left: 3px solid var(--symbol-stroke);
    background: color-mix(in srgb, var(--symbol-fill) 35%, transparent);
    color: color-mix(in srgb, var(--symbol-stroke) 50%, #152622);
}
[data-theme="dark"] .code-line {
    background: #080808;
    border-color: var(--symbol-vivid);
    color: var(--symbol-vivid);
}

.file-actions,
.console-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.project-title {
    margin-right: auto;
}
.project-bar {
    padding: 14px 20px;
}
.project-bar input {
    width: min(260px, 75vw);
}
.workspace {
    position: relative;
}
.floating-zoom {
    position: absolute;
    right: 14px;
    bottom: 14px;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 2px 10px #0002;
}
.floating-zoom button {
    padding: 3px 8px;
    border: 0;
}
.floating-zoom #zoom-label {
    font-size: 10px;
    min-width: 34px;
}
#theme-toggle {
    display: flex;
    padding: 8px;
}
#theme-toggle svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}
#theme-toggle .sun-icon {
    display: none;
}
[data-theme="dark"] #theme-toggle .sun-icon {
    display: block;
}
[data-theme="dark"] #theme-toggle .moon-icon {
    display: none;
}
[data-theme="dark"] .floating-zoom {
    background: #0a0a0a;
}
#panel-resizer {
    background: var(--line);
    cursor: col-resize;
    touch-action: none;
    z-index: 6;
}
#panel-resizer:hover,
#panel-resizer:focus-visible {
    background: var(--green);
}
.resizing-panel,
.resizing-panel * {
    cursor: col-resize !important;
    user-select: none !important;
}
@media (min-width: 801px) {
    main {
        grid-template-columns: minmax(320px, 1fr) 6px var(--panel-width, 345px);
    }
    .inspector {
        border-left: 0;
    }
}
@media (max-width: 800px) {
    #panel-resizer {
        display: none;
    }
    .file-actions {
        flex-wrap: wrap;
    }
}

[data-symbol="start"],
[data-symbol="end"] {
    --symbol-vivid: #6ee7a0;
}
[data-symbol="declare"],
[data-symbol="assign"] {
    --symbol-vivid: #78a9ff;
}
[data-symbol="input"] {
    --symbol-vivid: #49d8ff;
}
[data-symbol="output"] {
    --symbol-vivid: #4ade80;
}
[data-symbol="if"] {
    --symbol-vivid: #ffd24a;
}
[data-symbol="document"] {
    --symbol-vivid: #ffad66;
}
[data-symbol="database"] {
    --symbol-vivid: #2dd4bf;
}
[data-symbol="comment"] {
    --symbol-vivid: #bdc6d3;
}
[data-theme="dark"] svg[data-symbol] > g {
    fill: var(--symbol-vivid);
    stroke: var(--symbol-vivid);
}
[data-theme="dark"] .node {
    color: #101010;
}
[data-theme="dark"] .inspector {
    background: #000;
}
[data-theme="dark"] dialog::backdrop {
    background: #000b;
    backdrop-filter: none;
}

:root:not([data-theme="dark"]) svg[data-symbol] > g {
    fill: color-mix(in srgb, var(--symbol-vivid) 70%, white);
    stroke: color-mix(in srgb, var(--symbol-vivid) 65%, #152622);
}
:root:not([data-theme="dark"]) .code-line {
    background: color-mix(in srgb, var(--symbol-vivid) 14%, white);
    border-color: var(--symbol-vivid);
    color: color-mix(in srgb, var(--symbol-vivid) 45%, #101820);
}
.project-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}
.toolbar-centre {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}
.toolbar-centre .project-title {
    margin: 0;
}
.project-bar > .run-actions {
    justify-self: end;
    flex-wrap: nowrap;
}
@media (max-width: 1200px) {
    .project-bar {
        display: flex;
        flex-wrap: wrap;
    }
    .toolbar-centre {
        order: -1;
        width: 100%;
    }
    .project-bar > .run-actions {
        margin-left: auto;
        flex-wrap: wrap;
    }
}
@media (max-width: 480px) {
    .toolbar-centre {
        flex-direction: column;
        gap: 10px;
    }
}
