::selection {
    color: white;
    background-color: #9a2b17;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    font-family: 'Geist Mono', monospace;
    background: #fdfdfd;
    overflow: hidden;
}

.container {
    /* Mobile-first: stack panel on bottom */
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

.panel {
    background: #f8f8f8;
    width: 100%;
    /* taller panel on mobile for more room */
    height: 320px;
    overflow-y: auto;
    padding: 12px;
    box-sizing: border-box;
    order: 1;
    flex-shrink: 0;
}

.diagram {
    flex: 1;
    position: relative;
    order: 0;
    min-height: 200px;
}

/* Desktop / larger screens: side-by-side layout */
@media (min-width: 769px) {
    .container {
        flex-direction: row;
        height: 100%;
    }

    .panel {
        width: 350px;
        height: auto;
        overflow-y: auto;
        order: 0;
        flex-shrink: 0;
    }

    .diagram {
        order: 1;
    }
}

h2 {
    margin-top: 0;
    margin-bottom: 12px;
}

fieldset {
    margin-bottom: 12px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
}

legend {
    font-weight: bold;
    color: #444;
}

label {
    display: inline-block;
    margin-right: 12px;
    margin-bottom: 6px;
    font-size: 0.9em;
    color: #444;
}

input[type="number"], input[type="range"] {
    font-family: 'Geist Mono', monospace;
    background: transparent;

.panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
    border: none;
    border-bottom: 3px solid #888;
    padding: 3px 4px;
    outline: none;
    width: 60px;
    color: #222;
    transition: all 0.2s;
}

input[type="number"]:focus, input[type="number"]:hover {
    border-bottom-color: #9a2b17;
    color: #222;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100px;
    height: 12px;
    border-radius: 6px;
    background: #ddd;
    cursor: pointer;
    margin-left: 4px;
    vertical-align: middle;
    border: none;
}

input[type="range"]:hover {
    background: #bbb;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #9a2b17;
    cursor: pointer;
    border: none;
}

input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #9a2b17;
    cursor: pointer;
    border: none;
}

button {
    font-family: 'Geist Mono', monospace;
    border: none;
    padding: 4px 10px;
    background: #9a2b17;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    transition: opacity 0.2s;
    margin-bottom: 6px;
}

button:hover {
    opacity: 0.8;
}

#canvas {
    border: 1px solid #ddd;
    width: 100%;
    /* For mobile: make SVG fill remaining viewport under the panel */
    height: calc(100vh - 320px);
    display: block;
}

@media (min-width: 769px) {
    #canvas { height: 100%; }
}

/* Collapse/expanded panel styles */
#togglePanel {
    width: 34px;
    height: 34px;
    background: #9a2b17; /* match app red */
    border-radius: 50%;
    border: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
    cursor: pointer;
    padding: 0;
    flex: 0 0 34px;
}

/* hide any text content and use pseudo-element for the icon */
#togglePanel { font-size: 0; }
#togglePanel::after {
    content: "+";
    font-size: 18px;
    color: #fff;
    line-height: 34px;
    display: block;
}
/* when expanded show a minus sign */
#togglePanel[aria-expanded="true"]::after { content: "\2212"; }

.panel h2 { margin: 0; font-size: 1.2em; }

/* When container has .collapsed, make panel small and hide form content */
.container.collapsed .panel {
    /* taller collapsed strip so title and controls are not cut off */
    height: 72px;
    overflow: hidden;
    padding: 6px 12px 6px 12px;
    display: flex;
    align-items: center;
}
.container.collapsed .panel fieldset {
    display: none;
}
.container.collapsed #canvas {
    height: calc(100vh - 72px);
}

/* When collapsed on mobile keep the title visible next to the red dot */
.container.collapsed .panel h2 {
    display: inline-block;
    margin-left: 8px;
    font-size: 1rem;
    line-height: 1;
    margin-top: -4px; /* lift title up slightly to remove top gap */
}

@media (min-width: 769px) {
    .container.collapsed .panel {
        width: 56px;
        /* center the small toggle vertically so it isn't cut off */
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 12px;
        /* make the lateral bar match panel color (very light grey) */
        background: #f8f8f8;
        /* stretch the collapsed lateral bar to the bottom of the viewport */
        height: 100vh;
    }
    /* ensure the toggle is centered and fully visible inside the bar */
    .container.collapsed .panel #togglePanel { margin: 0; }
    /* On desktop when collapsed hide the title and keep small circular toggle visible */
    .container.collapsed .panel h2 { display: none; }
    .container.collapsed #canvas { height: 100%; }
}

text {
    font-family: 'Geist Mono', monospace;
    pointer-events: none;
}
