#main-content > .tool-page.svg-editor {
    max-width: none;
    width: 100%;
    padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px));
    box-sizing: border-box;
}

.svg-editor {
    max-width: none;
}

.svg-editor.is-max {
    position: fixed;
    inset: 0;
    z-index: 800;
    max-width: none;
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 8px;
    overflow: hidden;
    background: var(--bg);
    display: flex;
    flex-direction: column;
}

body.svg-max {
    overflow: hidden;
}

.svg-editor.is-max .workspace__title,
.svg-editor.is-max .ocr-section__lead {
    display: none;
}

.svg-editor.is-max .svg-app {
    flex: 1;
    min-height: 0;
    height: auto;
    margin: 0;
}

.svg-app {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    padding: 8px;
    height: calc(100vh - 220px);
    min-height: 560px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.svg-app__top,
.svg-ico-row,
.svg-time__bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.svg-app__status {
    min-height: 1.2em;
    margin: 0;
    color: var(--error);
    font-size: 13px;
}

.svg-app__main {
    display: flex;
    flex: 1;
    min-height: 0;
    gap: 8px;
}

.svg-rail {
    width: 44px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: auto;
    min-height: 0;
}

.svg-ico {
    width: 16px;
    height: 16px;
    display: block;
}

.svg-stage {
    position: relative;
    flex: 1;
    min-width: 0;
    min-height: 0;
    height: auto;
    border-radius: 12px;
    background: #1b2433;
    overflow: hidden;
}

.svg-tool,
.svg-op,
.svg-node-act,
.svg-mini {
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    border-radius: 8px;
    padding: 6px 8px;
    font: 600 12px/1.2 Inter, sans-serif;
    cursor: pointer;
}

.svg-tool.is-active,
.svg-op.is-on {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
}

.svg-tool:hover,
.svg-op:hover,
.svg-node-act:hover,
.svg-mini:hover {
    border-color: var(--blue);
}

.svg-mini {
    padding: 4px 6px;
}

.svg-ruler {
    position: absolute;
    z-index: 3;
    background: #121826;
    color: #9aa6bd;
    font: 10px/1 Inter, sans-serif;
    overflow: hidden;
    pointer-events: none;
}

.svg-ruler--corner {
    top: 0;
    left: 0;
    width: 22px;
    height: 22px;
    z-index: 4;
}

.svg-ruler--x {
    top: 0;
    left: 22px;
    right: 0;
    height: 22px;
}

.svg-ruler--y {
    top: 22px;
    left: 0;
    bottom: 0;
    width: 22px;
}

.svg-ruler span {
    position: absolute;
    white-space: nowrap;
}

.svg-ruler--x span {
    top: 4px;
    transform: translateX(-50%);
}

.svg-ruler--y span {
    left: 2px;
    transform: translateY(-50%);
}

.svg-stage__view {
    position: absolute;
    left: 22px;
    top: 22px;
    right: 0;
    bottom: 0;
    overflow: hidden;
    touch-action: none;
    cursor: crosshair;
}

.svg-stage__view[data-tool="select"],
.svg-stage__view[data-tool="nodes"] {
    cursor: default;
}

.svg-stage__view[data-tool="hand"],
.svg-stage__view.is-space {
    cursor: grab;
}

#svg-camera {
    transform-origin: 0 0;
    width: max-content;
    background: repeating-conic-gradient(#eceff4 0% 25%, #fff 0% 50%) 0 0 / 16px 16px;
}

#svg-doc {
    display: block;
    overflow: hidden;
}

#svg-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.svg-box {
    position: absolute;
    border: 1px solid #027ff6;
    box-sizing: border-box;
}

.svg-handle,
.svg-node,
.svg-hnd {
    position: absolute;
    width: 8px;
    height: 8px;
    margin: -4px 0 0 -4px;
    background: #fff;
    border: 1px solid #027ff6;
    pointer-events: auto;
    box-sizing: border-box;
}

.svg-handle[data-handle="rot"] {
    border-radius: 50%;
    background: #027ff6;
}

.svg-hnd {
    border-radius: 50%;
    background: #027ff6;
}

.svg-node {
    width: 9px;
    height: 9px;
    margin: -5px 0 0 -5px;
    background: #fff;
}

.svg-node.is-on {
    background: #027ff6;
}

.svg-marquee {
    position: absolute;
    border: 1px dashed #027ff6;
    background: rgba(2, 127, 246, 0.12);
}

.svg-side {
    width: 280px;
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 4px;
}

.svg-panel {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    background: var(--bg);
}

.svg-panel h2,
.svg-time h2 {
    margin: 0 0 8px;
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.svg-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0 0 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.svg-field--row,
.svg-field--inline {
    flex-direction: row;
    align-items: center;
    gap: 6px;
}

.svg-field input,
.svg-field select,
.svg-source textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: #111827;
    padding: 6px 8px;
    font: 13px/1.3 Inter, sans-serif;
}

.svg-field--inline input,
.svg-field--inline select,
.svg-field--row input[type="color"] {
    width: auto;
}

.svg-grid2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.svg-layers,
.svg-keys {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.svg-layer,
.svg-key {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid transparent;
}

.svg-layer.is-on,
.svg-key.is-on {
    border-color: var(--blue);
}

.svg-layer input[type="text"] {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    font: 12px/1.3 Inter, sans-serif;
    color: #111827;
}

.svg-layer button svg {
    width: 14px;
    height: 14px;
    display: block;
}

.svg-layer button,
.svg-key button {
    border: 0;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 12px;
}

.svg-time {
    border-top: 1px solid var(--border);
    padding-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 240px;
}

.svg-time__split {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(220px, 280px);
    gap: 8px;
    min-height: 0;
    overflow: auto;
}

.svg-rail,
.svg-side,
.svg-time,
.svg-time__split,
.svg-layers,
.svg-keys,
.svg-source textarea {
    scrollbar-width: thin;
    scrollbar-color: rgba(142, 202, 255, 0.7) transparent;
}

.svg-rail::-webkit-scrollbar,
.svg-side::-webkit-scrollbar,
.svg-time::-webkit-scrollbar,
.svg-time__split::-webkit-scrollbar,
.svg-layers::-webkit-scrollbar,
.svg-keys::-webkit-scrollbar,
.svg-source textarea::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.svg-rail::-webkit-scrollbar-track,
.svg-side::-webkit-scrollbar-track,
.svg-time::-webkit-scrollbar-track,
.svg-time__split::-webkit-scrollbar-track,
.svg-layers::-webkit-scrollbar-track,
.svg-keys::-webkit-scrollbar-track,
.svg-source textarea::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 999px;
}

.svg-rail::-webkit-scrollbar-thumb,
.svg-side::-webkit-scrollbar-thumb,
.svg-time::-webkit-scrollbar-thumb,
.svg-time__split::-webkit-scrollbar-thumb,
.svg-layers::-webkit-scrollbar-thumb,
.svg-keys::-webkit-scrollbar-thumb,
.svg-source textarea::-webkit-scrollbar-thumb {
    background: rgba(142, 202, 255, 0.55);
    border: 2px solid transparent;
    background-clip: padding-box;
    border-radius: 999px;
}

.svg-rail::-webkit-scrollbar-thumb:hover,
.svg-side::-webkit-scrollbar-thumb:hover,
.svg-time::-webkit-scrollbar-thumb:hover,
.svg-time__split::-webkit-scrollbar-thumb:hover,
.svg-layers::-webkit-scrollbar-thumb:hover,
.svg-keys::-webkit-scrollbar-thumb:hover,
.svg-source textarea::-webkit-scrollbar-thumb:hover {
    background: #8ecaff;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.svg-tl {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.svg-tl__row {
    display: grid;
    grid-template-columns: 22px 22px 88px minmax(0, 1fr);
    align-items: center;
    gap: 4px;
    background: transparent;
    border: 0;
    padding: 0;
}

.svg-tl__row input[type="text"] {
    width: 88px;
    flex: none;
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #0c0e16;
    color: #eef1f8;
}

.svg-tl__track {
    position: relative;
    flex: none;
    height: 22px;
    border-radius: 6px;
    background: #0c0e16;
    border: 1px solid var(--border);
}

.svg-tl__play {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    margin-left: -1px;
    background: #027ff6;
    pointer-events: none;
}

.svg-tl__track .svg-tl__key {
    position: absolute;
    top: 4px;
    width: 12px;
    height: 12px;
    margin-left: -6px;
    padding: 0;
    border: 0;
    background: #8ecaff;
    transform: rotate(45deg);
    cursor: pointer;
}

.svg-tl__track .svg-tl__key.is-on {
    background: #fff;
}

.svg-time input[type="range"] {
    width: 100%;
    margin: 8px 0;
}

.svg-source textarea {
    min-height: 180px;
    font-family: ui-monospace, monospace;
}

@media (max-width: 980px) {
    .svg-app {
        height: auto;
    }

    .svg-app__main {
        flex-direction: column;
    }

    .svg-rail {
        width: auto;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .svg-stage {
        min-height: 420px;
    }

    .svg-side {
        width: auto;
        max-height: none;
    }
}
