/* Tokens and components follow the Audio Workbench desktop theme:
   Roboto Mono only, flat surfaces, 1 px rules, teal for the one thing that is active. */
:root {
    --canvas: #15161c;
    --panel: #262832;
    --well: #14151b;
    --raise: #30323d;
    --line: #3b3e4a;
    --line-2: #31333e;
    --fg: #eef0f3;
    --fg-2: #d2d6dd;
    --dim: #a6abb5;
    --teal: #1de9b6;
    --teal-ink: #05261d;
    --teal-a: #1de9b61f;
    --amber: #ffb000;
    /* Pink marks a name that stands for a file or asset (a sample), the way teal marks what is active. */
    --pink: #ff6fb5;
    --pink-a: #ff6fb51f;
    /* A waveform, used as a mask so it takes the colour of whatever draws it. */
    --waveform: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M3 10v4M7.5 6v12M12 3v18M16.5 7v10M21 10v4'/%3E%3C/svg%3E");
    --tomato: #ff5a4f;
    --mono: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --t-head: 17px;
    --t-sec: 15px;
    --t-body: 14px;
    --t-small: 13px;
    --t-badge: 12px;
    --ctl-h: 36px;
    --r: 5px;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--canvas);
    color: var(--fg);
    font-family: var(--mono);
    font-size: var(--t-body);
    line-height: 1.45;
}

button,
input,
select {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 2px;
}

.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ---- Layout ---------------------------------------------------------------------------- */

.app {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 10px 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 8px;
    text-decoration: none;
}

/* The brand lockup from the Sigilgraph site: the one place Montserrat is used. */
.brand h1 {
    margin: 0;
    display: flex;
    flex-direction: column;
    line-height: 1;
    font-family: "Montserrat", sans-serif;
    white-space: nowrap;
}

.brand .wordmark {
    font-size: 1.35rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    color: #fff;
}

.brand .tagline {
    margin-top: 3px;
    font-size: 0.6rem;
    font-weight: 500;
    letter-spacing: 0.4em;
    color: var(--teal);
}

.sp {
    flex: 1;
}

.work {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 6px var(--sidebar-width, 360px);
    min-height: 0;
    position: relative;
}
.disclaimer-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 16px;
    background: #1b1d24;
    border-bottom: 1px solid var(--line);
    font-size: var(--t-small);
    color: var(--fg-2);
    line-height: 1.35;
    flex-shrink: 0;
    animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.disclaimer-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 7px;
    border-radius: 3px;
    background: #ffb0001a;
    border: 1px solid #ffb0004d;
    color: var(--amber);
    font-size: var(--t-badge);
    font-weight: 500;
    white-space: nowrap;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.disclaimer-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.disclaimer-dismiss {
    background: none;
    border: none;
    color: var(--dim);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    line-height: 1;
    transition: color 0.15s ease, background 0.15s ease;
    flex-shrink: 0;
}

.disclaimer-dismiss:hover {
    color: var(--fg);
    background: var(--raise);
}


.resizer {
    width: 6px;
    background: var(--canvas);
    border-left: 1px solid var(--line-2);
    border-right: 1px solid var(--line);
    cursor: col-resize;
    user-select: none;
    touch-action: none;
    transition: background 0.15s ease;
    z-index: 10;
}

.resizer:hover,
.resizer:focus-visible,
.resizer.resizing {
    background: var(--teal);
    border-color: var(--teal);
    outline: none;
}

/* The editor and the keyboard under it share the left column; the editor takes whatever the keyboard leaves. */
.code {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
}

.editor {
    flex: 1;
    min-height: 0;
    min-width: 0;
    background: var(--well);
}

/* ---- Controls strip (Sigilgraph mode) ---------------------------------------------------------
   Sits in the keyboard's place under the editor; with both, the controls are above the keys. The widgets run left to right in the
   order the snippet declared them and wrap onto a second row when the column is narrow. */

.ctl {
    flex: none;
    background: var(--panel);
    border-top: 1px solid var(--line);
}

.ctl-h {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 36px;
    padding: 4px 12px;
}

.ctl-h h2 {
    margin: 0;
    font-size: var(--t-small);
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--dim);
    white-space: nowrap;
}

.ctl-hint {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--t-small);
    color: var(--dim);
}

.ctl-src {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--t-small);
    color: var(--dim);
    white-space: nowrap;
}

.ctl-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 6px 4px;
    padding: 0 12px 12px;
}

.ctl-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 76px;
    padding: 6px 8px;
    border: 1px solid var(--line-2);
    border-radius: var(--r);
    background: var(--well);
}

.fader-item {
    min-width: 132px;
}

.ctl-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--t-small);
    color: var(--fg-2);
}

.ctl-val {
    font-size: var(--t-small);
    color: var(--teal);
    font-variant-numeric: tabular-nums;
}

.out-item .ctl-val {
    color: var(--dim);
}

.dial {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: ns-resize;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    outline: none;
}

.dial:focus-visible {
    box-shadow: 0 0 0 2px var(--teal);
}

.dial svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke-linecap: round;
}

.dial-track {
    stroke: var(--line);
    stroke-width: 4;
}

.dial-fill {
    stroke: var(--teal);
    stroke-width: 4;
}

.dial-hand {
    stroke: var(--fg);
    stroke-width: 2.5;
}

.fader {
    width: 116px;
    height: 48px;
    margin: 0;
    background: transparent;
    accent-color: var(--teal);
    cursor: pointer;
}

/* ---- Keyboard ---------------------------------------------------------------------------- */

.keys {
    flex: none;
    background: var(--panel);
    border-top: 1px solid var(--line);
}

.keys-h {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 36px;
    padding: 4px 12px;
}

.keys-h h2 {
    margin: 0;
    font-size: var(--t-small);
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--dim);
    white-space: nowrap;
}

.keys-hint {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--t-small);
    color: var(--dim);
}

.keys-hint code {
    color: var(--teal);
}

.mini {
    flex: none;
    width: 28px;
    height: 28px;
    padding: 0;
    display: inline-grid;
    place-items: center;
    border-radius: var(--r);
    border: 1px solid var(--line);
    background: #1b1c22;
    color: var(--fg-2);
}

.mini:hover:not(:disabled) {
    border-color: var(--dim);
    color: var(--fg);
}

.mini:disabled {
    color: #5e626c;
    border-color: var(--line-2);
    cursor: default;
}

.oct {
    min-width: 2.5em;
    text-align: center;
    font-size: var(--t-small);
    color: var(--fg-2);
}

.piano {
    position: relative;
    height: 112px;
    margin: 0 12px 12px;
    border-radius: 0 0 var(--r) var(--r);
    user-select: none;
    -webkit-user-select: none;
    /* Dragging across the keys is a glissando, not a scroll or a zoom. */
    touch-action: none;
    outline: none;
}

.piano:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 3px;
}

.wk,
.bk {
    position: absolute;
    top: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 6px;
    font-size: var(--t-badge);
    cursor: pointer;
}

.wk {
    bottom: 0;
    background: var(--fg-2);
    border: 1px solid var(--well);
    border-radius: 0 0 4px 4px;
    color: #5e626c;
}

.bk {
    height: 62%;
    z-index: 1;
    background: #1b1c22;
    border: 1px solid #000;
    border-radius: 0 0 3px 3px;
    color: var(--dim);
}

.wk.down {
    background: var(--teal);
    color: var(--teal-ink);
}

.bk.down {
    background: var(--teal);
    border-color: var(--teal);
    color: var(--teal-ink);
}

/* Letters on the keys are labels; clicks belong to the key under them. */
.lbl {
    pointer-events: none;
}

.side {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 14px 16px;
    background: var(--panel);
    border-left: 1px solid var(--line);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--raise) transparent;
}

.status {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 28px;
    padding: 0 16px;
    font-size: var(--t-small);
    background: var(--panel);
    border-top: 1px solid var(--line);
    white-space: nowrap;
    overflow: hidden;
}

.status > span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
}

.status .ok {
    color: var(--teal);
}

.status .error {
    color: var(--amber);
}

.status .keys {
    display: flex;
    gap: 18px;
}

.status .dim,
.status .keys {
    color: var(--dim);
}

/* ---- Components (same names as the theme mock) ----------------------------------------- */

.tpg {
    display: flex;
    gap: 6px;
    align-items: center;
}

.tp {
    --s: 36px;
    width: var(--s);
    height: var(--s);
    flex: none;
    padding: 0;
    border-radius: 6px;
    background: #1b1c22;
    border: 1px solid var(--line);
    color: var(--fg-2);
    display: inline-grid;
    place-items: center;
}

.tp svg {
    width: calc(var(--s) * 0.48);
    height: calc(var(--s) * 0.48);
}

.tp:hover:not(:disabled) {
    border-color: var(--dim);
    color: var(--fg);
}

.tp.play {
    color: var(--teal);
}

.tp[aria-pressed="true"] {
    background: var(--teal-a);
    border-color: var(--teal);
    color: var(--teal);
}

.tp:disabled {
    color: #5e626c;
    border-color: var(--line-2);
    cursor: default;
}

.btn {
    height: var(--ctl-h);
    padding: 0 14px;
    border-radius: var(--r);
    border: 1.5px solid var(--teal);
    background: none;
    color: var(--teal);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
    flex: none;
    text-decoration: none;
}

.btn:hover {
    background: var(--teal-a);
}

.btn.ghost {
    border-color: var(--line);
    color: var(--fg);
}

.btn.ghost:hover {
    border-color: var(--dim);
    background: none;
}

.btn[disabled] {
    background: var(--raise);
    border-color: var(--raise);
    color: var(--dim);
    cursor: default;
}

.btn.ic {
    width: var(--ctl-h);
    padding: 0;
}

.btn.bare {
    border-color: transparent;
    color: var(--fg-2);
}

.btn.bare:hover {
    background: var(--raise);
    color: var(--fg);
}

.btn[aria-disabled="true"] {
    color: #5e626c;
    pointer-events: none;
}

.sel {
    height: var(--ctl-h);
    min-width: 0;
    background: var(--well) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23a6abb5' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 0 34px 0 12px;
    appearance: none;
    outline: 0;
    cursor: pointer;
}

.sel:focus {
    border-color: var(--teal);
}

.sel option {
    background: var(--panel);
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: var(--ctl-h);
    color: var(--fg-2);
    white-space: nowrap;
    cursor: pointer;
}

.switch input {
    appearance: none;
    flex: none;
    margin: 0;
    width: 36px;
    height: 20px;
    border-radius: 10px;
    background: var(--well);
    border: 1.5px solid #7d828e;
    position: relative;
    cursor: pointer;
    transition: background 0.15s;
}

.switch input::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #9ca1ab;
    transition: transform 0.15s;
}

.switch input:checked {
    background: var(--teal);
    border-color: var(--teal);
}

.switch input:checked::after {
    transform: translateX(16px);
    background: var(--teal-ink);
}

.badge {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 7px;
    border-radius: 4px;
    border: 1px solid var(--teal);
    color: var(--teal);
    font-size: var(--t-badge);
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge.n {
    border-color: var(--line);
    color: var(--fg-2);
}

.sec {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.sec-h {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 26px;
}

.sec-h h2 {
    margin: 0;
    font-size: var(--t-sec);
    font-weight: 500;
    white-space: nowrap;
}

.sec-h::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
    order: 1;
}

.sec-h > .end {
    order: 2;
    font-size: var(--t-small);
    color: var(--dim);
}

.wave {
    height: 150px;
    background: var(--well);
    border: 1px solid var(--line);
    border-radius: var(--r);
    overflow: hidden;
}

.wave.notes {
    height: 130px;
}

.wave canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.plain {
    margin: 0;
    color: var(--fg-2);
}

.plain.dim {
    color: var(--dim);
    font-size: var(--t-small);
}

.kv {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.kv li {
    display: contents;
}

.kv li > * {
    padding: 7px 0;
    border-bottom: 1px solid var(--line-2);
    min-width: 0;
}

.kv li:last-child > * {
    border-bottom: 0;
}

.kv .k {
    color: var(--fg);
    white-space: nowrap;
}

.kv .val {
    color: var(--dim);
    font-size: var(--t-small);
    text-align: right;
}

.problems {
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--t-small);
}

.problems li {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid var(--line-2);
    color: var(--fg-2);
    overflow-wrap: anywhere;
}

.problems li:last-child {
    border-bottom: 0;
}

.problems .at {
    color: var(--amber);
}

.problems .warning .at {
    color: var(--dim);
}

/* ---- Samples ----------------------------------------------------------------------------- */

.wf {
    display: inline-block;
    flex: none;
    width: 16px;
    height: 16px;
    background-color: var(--pink);
    -webkit-mask: var(--waveform) center / contain no-repeat;
    mask: var(--waveform) center / contain no-repeat;
}

.samples {
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--t-small);
}

.samples li {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid var(--line-2);
}

.samples li:last-child {
    border-bottom: 0;
}

.samples .pick {
    padding: 0;
    border: 0;
    background: none;
    color: var(--pink);
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.samples .pick:hover {
    text-decoration: underline;
}

.samples .meta {
    color: var(--dim);
    white-space: nowrap;
}

.samples .rm {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: var(--r);
    background: none;
    color: var(--dim);
}

.samples .rm:hover {
    background: var(--raise);
    color: var(--fg);
}

.samples .tag {
    padding: 1px 6px;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--dim);
    font-size: var(--t-badge);
    white-space: nowrap;
}

.sample-add {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.sample-add .btn {
    cursor: pointer;
}

.plain code {
    color: var(--pink);
    font-size: inherit;
}

/* Shown while files are dragged over the page; it lets the drop through to the window underneath. */
.drop-overlay {
    position: fixed;
    inset: 12px;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border: 2px dashed var(--pink);
    border-radius: 8px;
    background: #14151bd9;
    color: var(--pink);
    font-size: var(--t-head);
    pointer-events: none;
}

.drop-overlay .wf {
    width: 28px;
    height: 28px;
}

body.dragging-files .drop-overlay {
    display: flex;
}

/* Sample names in the editor's suggestion list: Monaco's File icon becomes the waveform and the name turns pink.
   The name already carries its quotes, which is what tells it apart from code. */
.monaco-editor .suggest-widget .monaco-list-row .codicon-symbol-file::before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    background-color: var(--pink);
    -webkit-mask: var(--waveform) center / contain no-repeat;
    mask: var(--waveform) center / contain no-repeat;
}

.monaco-editor .suggest-widget .monaco-list-row:has(.codicon-symbol-file) .label-name,
.monaco-editor .suggest-widget .monaco-list-row:has(.codicon-symbol-file) .label-name .highlight {
    color: var(--pink);
}

/* ---- Boot -------------------------------------------------------------------------------- */

.boot {
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--dim);
    font-size: var(--t-small);
}

.boot-bar {
    width: 200px;
    height: 2px;
    background: var(--raise);
}

.boot-bar > div {
    height: 100%;
    width: var(--blazor-load-percentage, 0%);
    background: var(--teal);
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "");
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 8px 16px;
    background: var(--panel);
    border-top: 1px solid var(--amber);
    color: var(--fg);
    font-size: var(--t-small);
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 16px;
    top: 8px;
}

/* ---- Narrow screens ---------------------------------------------------------------------- */

@media (max-width: 900px) {
    .app {
        height: auto;
        min-height: 100vh;
    }

    .work {
        grid-template-columns: minmax(0, 1fr);
    }

    .resizer {
        display: none;
    }

    /* The editor's base rule is flex: 1, whose zero basis beats a height in a column that has no height of its own,
       so without "flex: none" the editor collapses to a few pixels and only the sidebar shows. */
    .editor {
        flex: none;
        height: 60vh;
        min-height: 280px;
    }

    .side {
        border-left: 0;
        border-top: 1px solid var(--line);
    }

    .status .keys {
        display: none;
    }
}

@media (max-width: 560px) {
    .bar .badge,
    .bar .btn.ghost {
        display: none;
    }
}

/* ---- Offer to switch to Sigilgraph mode ---------------------------------------------------- */

.offer {
    flex: none;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 36px;
    padding: 4px 12px;
    background: var(--teal-a);
    border-bottom: 1px solid var(--line);
    font-size: var(--t-small);
    color: var(--fg-2);
}

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