.rd-page {
    max-width: 1760px;
}

.rd-page h1,
.rd-page .rd-intro,
.rd-page .rd-equations,
.rd-page .rd-info-grid {
    max-width: none;
}

.rd-intro {
    max-width: 1120px;
}

.rd-equations {
    max-width: 1120px;
    margin-bottom: 24px;
}

.rd-layout {
    display: grid;
    grid-template-columns: minmax(320px, 360px) minmax(640px, 1fr) minmax(360px, 440px);
    align-items: flex-start;
    gap: 28px;
}

.rd-controls {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.rd-sidebar {
    align-self: flex-start;
}

.canvas-wrapper,
.rd-main-column {
    display: contents;
}

.rd-workbench-row {
    display: contents;
}

.rd-stage-column {
    min-width: 0;
}

.rd-section {
    border: 1px solid var(--text-color);
    background: #fff;
    overflow: hidden;
}

.rd-info-card {
    border: 1px solid var(--text-color);
    background: #fff;
    overflow: hidden;
}

.rd-panel {
    width: 100%;
}

.rd-panel-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.rd-panel-summary::-webkit-details-marker {
    display: none;
}

.rd-panel-summary::marker {
    content: "";
}

.rd-panel-summary::before {
    content: "▸";
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1;
    transition: transform 120ms ease;
}

.rd-panel-summary:focus-visible {
    outline: 1px solid var(--text-color);
    outline-offset: -1px;
}

.rd-panel[open] > .rd-panel-summary::before {
    transform: rotate(90deg);
}

.rd-panel-summary h3 {
    margin: 0;
}

.rd-panel-body {
    padding: 0 14px 14px;
}

.rd-button-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.rd-tool-grid,
.rd-style-toolbar,
.rd-mask-tool-grid {
    margin-bottom: 10px;
}

.rd-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.rd-chip-row .preset-btn,
.rd-tool-grid .preset-btn,
.rd-style-toolbar .preset-btn,
.rd-mask-tool-grid .preset-btn {
    margin: 0;
}

.preset-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.rd-preset-row {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
}

.preset-btn.active {
    background: var(--text-color);
    color: var(--bg-color);
}

.rd-inline-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.rd-inline-toggle input {
    cursor: pointer;
}

.rd-select-group {
    margin-top: 12px;
}

.rd-select-group select {
    width: 100%;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: 6px 8px;
    border: 1px solid var(--text-color);
    background: #fff;
}

.rd-subnote {
    display: block;
    font-size: 0.78rem;
    color: #555;
    line-height: 1.4;
}

.rd-code-box {
    margin-top: 12px;
    min-height: 74px;
}

.rd-file-row input[type="file"] {
    width: 100%;
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.rd-upload-label {
    display: block;
    margin-bottom: 6px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.rd-stage {
    width: 100%;
}

.rd-canvas-shell {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background: #111;
    border: 1px solid var(--text-color);
    overflow: hidden;
}

.rd-canvas-shell canvas,
.rd-style-map-shell canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    border: 0;
}

#rdCanvas,
#rdOverlay,
#styleMapCanvas,
#styleMapOverlay,
#maskEditorCanvas,
#maskEditorOverlay {
    image-rendering: pixelated;
}

#rdCanvas,
#styleMapCanvas,
#maskEditorCanvas {
    background: #111;
}

#rdOverlay,
#styleMapOverlay,
#maskEditorOverlay {
    background: transparent;
    pointer-events: none;
}

.rd-mask-editor-shell {
    position: relative;
    width: 100%;
    max-width: 280px;
    aspect-ratio: 1;
    margin: 12px 0;
    border: 1px solid var(--text-color);
    background: #111;
    overflow: hidden;
}

.rd-mask-editor-shell canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    border: 0;
}

.rd-stage-label {
    position: absolute;
    top: 14px;
    left: 14px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--text-color);
    padding: 7px 10px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1.35;
}

.rd-stage-hint {
    max-width: 100%;
    margin: 12px 0 0;
    font-size: 0.92rem;
}

.rd-under-panels {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 18px;
}

.rd-under-panel {
    min-width: 0;
}

.rd-kf-workbench {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.rd-kf-panel {
    min-width: 0;
}

.rd-style-map-shell {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background: #111;
    border: 1px solid var(--text-color);
    overflow: hidden;
    margin: 12px 0;
}

.rd-guide-shell {
    width: 100%;
    margin: 12px 0;
    border: 1px solid var(--text-color);
    background: #f3f3f3;
}

#kfGuideCanvas {
    display: block;
    width: 100%;
    height: auto;
}

.rd-guide-selection {
    margin: 0 0 12px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.45;
}

.rd-style-readouts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.rd-style-readout {
    border: 1px solid var(--text-color);
    padding: 8px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1.45;
    background: #f9f9f9;
}

.rd-style-readout.active {
    background: #111;
    color: #fff;
}

.rd-style-readout .slot-name {
    display: inline-block;
    font-weight: bold;
    margin-bottom: 4px;
}

.rd-style-readout[data-slot-color="red"] .slot-name {
    color: #ef464e;
}

.rd-style-readout[data-slot-color="green"] .slot-name {
    color: #31b460;
}

.rd-style-readout[data-slot-color="blue"] .slot-name {
    color: #4674ff;
}

.rd-style-slot-btn[data-style-slot="1"] {
    border-color: #ef464e;
}

.rd-style-slot-btn[data-style-slot="2"] {
    border-color: #31b460;
}

.rd-style-slot-btn[data-style-slot="3"] {
    border-color: #4674ff;
}

.rd-info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 22px;
    max-width: 1120px;
}

.rd-info-card ul {
    margin: 0;
    padding-left: 18px;
}

.rd-info-card li {
    margin-bottom: 8px;
}

@media (max-width: 1320px) {
    .rd-layout {
        grid-template-columns: minmax(300px, 340px) minmax(560px, 1fr) minmax(320px, 400px);
    }

    .rd-controls {
        min-width: 0;
    }
}

@media (max-width: 1180px) {
    .rd-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 980px) {
    .rd-under-panels,
    .rd-style-readouts,
    .rd-info-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .rd-canvas-shell,
    .rd-style-map-shell,
    .rd-guide-shell,
    .rd-mask-editor-shell {
        width: 100%;
    }
}
