.tb-heading h1 { margin-top: 10px; }
.tb-heading .page-heading__description { max-width: 62ch; }

.tb-modes {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
}
.tb-modes a {
    display: grid;
    min-width: 65px;
    min-height: 40px;
    place-items: center;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--muted);
    font-size: .84rem;
    font-weight: 750;
}
.tb-modes a:hover { color: var(--text); background: #222c3b; }
.tb-modes a[aria-current="page"] { color: var(--accent); border-color: #a8dce140; background: #243c44; }

.tb-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(285px, 24%);
    align-items: start;
    gap: 16px;
}
.tb-main, .tb-sidebar { display: grid; gap: 12px; min-width: 0; }
.tb-stage {
    position: relative;
    overflow: hidden;
    height: clamp(390px, 57vh, 650px);
    background: radial-gradient(ellipse at center, #19253b, #080e1b 70%);
}
.tb-stage #tb-canvas, .tb-stage #tb-canvas canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}
.tb-stage canvas:focus-visible { outline-offset: -4px; }
.tb-legend {
    position: absolute;
    z-index: 2;
    inset: 12px auto auto 12px;
    display: flex;
    gap: 12px;
    padding: 7px 10px;
    background: #11151ee8;
    font-size: .72rem;
    pointer-events: none;
}
.tb-legend span:nth-child(1) { color: #8ddcff; }
.tb-legend span:nth-child(2) { color: #ffc58e; }
.tb-legend span:nth-child(3) { color: #c7a5ff; }
.tb-body-label {
    position: absolute;
    z-index: 1;
    color: #e4edfa;
    font-size: .7rem;
    line-height: 1.2;
    white-space: nowrap;
    text-shadow: 0 1px 5px #08101f, 0 0 8px #08101f;
    pointer-events: none;
    user-select: none;
    transform: translate(5px, -50%);
}

.tb-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 10px;
    font-size: .8rem;
}
.tb-actions label {
    display: flex;
    flex: 0 1 auto;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    color: var(--muted);
}
.tb-actions input { width: 105px; }
.tb-actions output { min-width: 3ch; text-align: right; }
.tb-actions input, .tb-field input[type="range"] { accent-color: var(--accent); }
.tb-actions button:disabled { opacity: .55; cursor: default; }
.tb-time { color: var(--muted); white-space: nowrap; }
.tb-time strong, .tb-actions output, .tb-events strong { color: var(--text); }
.tb-note, .tb-events { color: var(--muted); font-size: .8rem; line-height: 1.55; }
.tb-events, .tb-status { padding: 12px 14px; }
.tb-events ul { margin: 8px 0 0; padding-left: 20px; }
.tb-caption { margin-top: 16px; }

.tb-status {
    color: var(--accent);
    background: #121e26;
    font-size: .83rem;
    font-weight: 700;
    line-height: 1.45;
}
.tb-toast {
    position: fixed;
    z-index: 5;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: min(440px, calc(100vw - 32px));
    padding: 10px 16px;
    border-color: #ff687560;
    color: #f8e1e4;
    background: #241b24;
    box-shadow: 0 4px 20px #0005;
    font-size: .85rem;
    line-height: 1.45;
    text-align: center;
    pointer-events: none;
}
.tb-toast:empty { opacity: 0; }
.tb-editor, .tb-fields, .tb-presets { display: grid; gap: 9px; }
.tb-editor { padding: 15px; }
.tb-editor h2 { margin-top: 8px; font-size: 1.25rem; }
.tb-editor h2 + .tb-note { margin-top: 6px; }
.tb-editor h3 { margin-top: 6px; font-size: .84rem; }
.tb-row { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: 8px; }
.tb-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px;
    color: var(--muted);
    font-size: .77rem;
}
.tb-field output { color: var(--accent); }
.tb-field input { grid-column: 1 / -1; width: 100%; min-width: 0; margin: 0; }
.tb-field input[type="number"], .tb-presets select {
    min-height: 36px;
    padding: 6px 8px;
    border: 1px solid var(--glass-edge);
    border-radius: 6px;
    color: var(--text);
    background: #171d29;
    font-size: .8rem;
}
.tb-presets { margin-top: 5px; padding-top: 12px; border-top: 1px solid var(--line); }
.tb-presets label { font-size: .84rem; font-weight: 700; }
.tb-presets select { width: 100%; }

@media (max-width: 820px) {
    .tb-layout { grid-template-columns: minmax(0, 1fr); }
    .tb-stage { height: clamp(300px, 60vw, 470px); }
}
@media (max-width: 560px) {
    .tb-heading h1 { font-size: clamp(2rem, 8vw, 2.65rem); }
    .tb-actions label { flex: 1 1 100%; margin: 3px 0; }
    .tb-actions label input { flex: 1; }
}
