#palette button {
    margin: 5px;
}

.palette-block-button-active {
    outline: 2px solid #ffb300;
    outline-offset: 1px;
}

.palette-preview {
    position: relative;
    margin-top: 8px;
    margin-bottom: 14px;
    background: linear-gradient(135deg, #f7fbff, #edf4fb);
    border: 1px solid #d7e3f0;
    border-radius: 12px;
    padding: 8px 34px 8px 10px;
    color: #28415b;
    line-height: 1.45;
}

.palette-preview-close {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: rgba(22, 50, 79, 0.08);
    color: #28415b;
    font-size: 14px;
    line-height: 20px;
    cursor: pointer;
}

.palette-preview-hidden {
    display: none;
}

.palette-preview pre {
    margin: 4px 0;
    background: #16324f;
    color: #f5fbff;
    border-radius: 8px;
    padding: 6px 8px;
    overflow-x: auto;
}

.sample-buttons {
    display: inline-flex;
    gap: 4px;
    margin-left: 6px;
    vertical-align: middle;
}

.sample-buttons button {
    font-size: 12px;
    padding: 3px 8px;
}

/* ★左右レイアウト */
.dncl-main {
    display: flex;
    gap: 20px;
    margin: 20px 5px;
}

/* 左 */
.dncl-left {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.program-view-switch {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.program-view-button {
    border: 1px solid #d0d9e8;
    background: #f4f7fc;
    color: #2f4460;
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 13px;
    cursor: pointer;
}

.program-view-button-active {
    background: #3d5a80;
    border-color: #3d5a80;
    color: #ffffff;
}

.program-panel-hidden {
    display: none;
}

/* 右 */
.dncl-right {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.run-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.run-buttons button {
    font-size: 13px;
    padding: 5px 8px;
}

/* workspace */
#workspace {
    border: 2px dashed #ccc;
    padding: 10px 0px 10px 10px;
    max-height: 70vh;
    overflow-x: auto;
    overflow-y: scroll;
    white-space: nowrap;
    background-color: var(--primary-light-2);
    scrollbar-color: var(--primary);
}

#workspace::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

#workspace::-webkit-scrollbar-track {
    border-radius: 999px;
}

#workspace::-webkit-scrollbar-thumb {
    background-color: var(--primary-light-2);
    border-radius: 999px;
    border: 2px solid var(--primary);
}

#workspace::-webkit-scrollbar-corner {
    background: var(--primary-light-2);
}

#workspace-panel {
    user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
}

#workspace-panel input,
#workspace-panel textarea {
    user-select: text;
    -webkit-user-select: text;
}

/* ブロック */
.block {
    position: relative;
    background: var(--block-bg, #f3f6fb);
    color: #ffffff;
    border: 1px solid var(--block-border, #cfdceb);
    padding: 1px 20px 1px 8px;
    margin: 0;
    border-radius: 0 9px 9px 0;
    box-shadow: 0 2px 8px rgba(39, 64, 96, 0.08);
    transition: box-shadow 0.15s ease;
    width: fit-content;
    white-space: nowrap;
}

.block.step-active {
    box-shadow: 0 0 0 3px rgba(255, 235, 59, 0.95), 0 0 18px rgba(255, 235, 59, 0.6);
    filter: brightness(2.00);
    color: var(--text);

    input, select {
        color: var(--text);
    }
}

.protro-intro {
    margin: 0 auto 18px;
    padding: 0 10px;
    max-width: 1100px;
}

.protro-lead {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 14px;
    margin: 0 0 12px;
}

.protro-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.protro-link-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px 12px;
}

.protro-link-card h4 {
    margin: 0 0 6px;
}

.protro-link-card p {
    margin: 0 0 10px;
}

.protro-benefits {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 10px 12px;
}

.protro-benefits h4 {
    margin: 0 0 8px;
}

.protro-benefits ul {
    margin: 0;
    padding-left: 1.2em;
}

.protro-benefits li {
    margin: 0 0 10px;
}

@media (max-width: 768px) {
    .protro-links {
        grid-template-columns: 1fr;
    }
}

/* 種類ごとの淡い色 */
.block[data-type="assign"] {
    --block-bg: #4e79a7;
    --block-border: #3f668f;
}

.block[data-type="print"] {
    --block-bg: #59a14f;
    --block-border: #4b8a43;
}

.block[data-type="if"],
.block[data-type="ifelse"] {
    --block-bg: #8f63b8;
    --block-border: #7b53a2;
}

.block[data-type="for"] {
    --block-bg: #e08b34;
    --block-border: #c8792b;
}

.block[data-type="while"] {
    --block-bg: #d97a2b;
    --block-border: #bf6924;
}

.block[data-type="array"] {
    --block-bg: #c05a7a;
    --block-border: #aa4d6b;
}

.array-control-panel {
    border: 1px solid #d7e3f0;
    background: linear-gradient(135deg, #f7fbff, #edf4fb);
    border-radius: 12px;
    padding: 8px 10px;
    margin-bottom: 10px;
    color: #28415b;
}

.array-control-panel-title {
    font-weight: 700;
    margin-right: 10px;
}

.array-control-panel button {
    font-size: 12px;
    padding: 3px 10px;
    margin: 2px;
    border-radius: 8px;
    border: 1px solid #d0d9e8;
    background: #f4f7fc;
    color: #2f4460;
    cursor: pointer;
}

.array-control-panel button:hover {
    filter: brightness(0.98);
}

.array-control-panel button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.share-dialog {
    border: none;
    border-radius: 14px;
    padding: 14px 14px 12px;
    width: min(720px, 92vw);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
}

.share-dialog::backdrop {
    background: rgba(0, 0, 0, 0.35);
}

.share-url-input {
    width: 100%;
    box-sizing: border-box;
    margin-top: 6px;
    padding: 10px 10px;
    border: 1px solid #d0d9e8;
    border-radius: 10px;
    font-family: "Courier New", monospace;
    color: var(--text);
}

.share-dialog-buttons {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.block[data-type="expr"],
.block[data-type="floor"],
.block[data-type="ceil"],
.block[data-type="round"] {
    --block-bg: #2f9a9a;
    --block-border: #288484;
}

.block[data-type="random"] {
    --block-bg: #b3922f;
    --block-border: #9a7d27;
}

.block:hover {
    filter: saturate(1.1) brightness(0.9);
    box-shadow: 0 4px 11px rgba(39, 64, 96, 0.13);
}

/* ネスト */
.children {
    margin-left: 12px;
    border-left: 2px dashed rgba(70, 92, 118, 0.28);
    padding-left: 7px;

}

.children::after {
    content: "";
    display: block;
    height: 4px;
}

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

.array2d-body {
    margin-top: 6px;
}

.array2d-rows {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.array2d-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.array2d-row-items {
    display: inline-flex;
    align-items: center;
    gap: 0;
}

.array2d-bracket {
    font-weight: 700;
    color: rgba(255, 255, 255, 0.95);
}

.array2d-comma {
    color: rgba(255, 255, 255, 0.92);
    margin: 0 2px;
}

.array2d-row-controls {
    display: inline-flex;
    gap: 2px;
    margin-left: 6px;
}

.array2d-col-controls {
    display: inline-flex;
    gap: 2px;
    margin-top: 4px;
    margin-left: 14px;
}

.array2d-row-controls button,
.array2d-col-controls button {
    font-size: 11px;
    padding: 2px 6px;
}

.array2d-cell {
    width: 3ch;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.18);
    border-radius: 6px;
    padding: 3px 6px;
    font-family: "Courier New", monospace;
    color: var(--text);
}

.array2d-warning {
    margin-top: 6px;
    font-size: 12px;
    color: #4d3c12;
    background: rgba(255, 243, 201, 0.85);
    border: 1px solid rgba(240, 216, 137, 0.9);
    border-radius: 10px;
    padding: 6px 8px;
    display: inline-block;
}

.array2d-warning:empty {
    display: none;
}

.assign-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.block[data-type="assign"] .assign-inline {
    width: 100%;
}

.block[data-type="assign"] .expr-zone {
    display: inline-flex;
    align-items: center;
    flex: 1;
    gap: 6px;
    margin-left: 0;
    padding-left: 0;
    border-left: none;
    width: 100%;
    min-width: 120px;
    min-height: 28px;
    padding-right: 10px;
    border: 1px dashed rgba(255, 255, 255, 0.7);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.12);
}

.block[data-type="assign"] .expr-zone::after {
    display: none;
}

.block[data-type="assign"] .expr-zone .placeholder {
    display: block;
    width: 100%;
    white-space: nowrap;
    font-size: 11px;
}

.block[data-type="assign"] .assign-value {
    flex: 1;
    width: 100%;
    min-width: 0;
    background: transparent;
    color: inherit;
    border: none;
    outline: none;
}

/* else */
.else-area {
    margin-top: 4px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px dashed rgba(255, 255, 255, 0.45);
    border-radius: 8px;
    padding: 6px;
}

/* 入力 */
input,
select {
    width: 66px;
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 7px;
    padding: 3px 6px;
    outline: none;
}

input::placeholder {
    color: rgba(255, 255, 255, 0.78);
}

/* 削除 */
.delete-btn {
    position: absolute;
    top: 1px;
    right: 4px;
    cursor: pointer;
    color: inherit;
    opacity: 0.72;
    line-height: 1;
}

.delete-btn:hover {
    opacity: 1;
}

/* コード */
pre {
    background: #111;
    color: #0f0;
    padding: 10px;
}

.vars-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
    margin-bottom: 8px;
}

.vars-empty {
    width: 100%;
    background: linear-gradient(135deg, #f4f7fb, #e9eef5);
    color: #567;
    border: 1px dashed #b8c4d6;
    border-radius: 12px;
    padding: 14px;
}

.var-card {
    display: inline-block;
    width: fit-content;
    max-width: 100%;
    background: linear-gradient(135deg, #ffffff, #f3f7fb);
    border: 1px solid #d8e1ee;
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: 0 6px 18px rgba(31, 53, 86, 0.08);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.var-card-array {
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
}

.var-card-active {
    border-color: #ffb300;
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.22), 0 10px 24px rgba(255, 193, 7, 0.18);
    transform: translateY(-1px);
}

.var-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.var-name {
    color: #16324f;
    font-weight: 700;
    font-family: "Poppins", sans-serif;
}

.var-kind {
    color: #4f6b88;
    background: #e7eef7;
    border-radius: 999px;
    font-size: 12px;
    padding: 3px 8px;
}

.var-value {
    display: inline-block;
    color: #1e2b3c;
    background: #eef3f8;
    border-radius: 10px;
    padding: 10px 12px;
    font-family: "Courier New", monospace;
    white-space: pre-wrap;
    word-break: break-word;
    max-width: min(36ch, 100%);
}

.array-var {
    display: inline-block;
    min-width: max-content;
}

.array-var-table {
    border-collapse: separate;
    border-spacing: 0;
}

.array-var-cell {
    padding: 8px 10px;
    text-align: center;
    border-right: 1px solid #d7e3f0;
    white-space: nowrap;
}

.array-var-index-row .array-var-cell {
    background: #4f6b88;
    color: #e7eef7;
    font-size: 12px;
    font-weight: 700;
}

.array-var-row-index-cell,
.array-var-corner-cell {
    background: #4f6b88;
    color: #e7eef7;
    font-size: 12px;
    font-weight: 700;
}

.array-var-corner-cell {
    min-width: 2ch;
}

.array-var-value-row .array-var-cell {
    background: #eef3f8;
    color: #1e2b3c;
    font-family: "Courier New", monospace;
}

.array-var-cell-highlight {
    box-shadow: inset 0 0 0 2px rgba(255, 193, 7, 0.85);
    background: #fff2b8 !important;
    color: #5a4200 !important;
}

.array-var-index-row .array-var-cell:first-child {
    border-top-left-radius: 3px;
    border-bottom-left-radius: 3px;
}

.array-var-index-row .array-var-cell:last-child {
    border-right: none;
    border-top-right-radius: 3px;
    border-bottom-right-radius: 3px;
}

.array-var-value-row .array-var-cell:first-child {
    border-top-left-radius: 3px;
    border-bottom-left-radius: 3px;
}

.array-var-value-row .array-var-cell:last-child {
    border-right: none;
    border-top-right-radius: 3px;
    border-bottom-right-radius: 3px;
}

.step-explanation {
    background: linear-gradient(135deg, #fff9e8, #fff3c9);
    color: #4d3c12;
    border: 1px solid #f0d889;
    border-radius: 12px;
    padding: 9px 11px;
    line-height: 1.6;
    box-shadow: 0 6px 18px rgba(157, 124, 20, 0.08);
    margin-bottom: 10px;
    white-space: pre-wrap;
}


/* ★スマホ対応 */
@media (max-width: 800px) {
    .dncl-main {
        flex-direction: column;
    }
}

/* ★追加：プレースホルダー */
.placeholder {
    color: rgba(240, 240, 240, 0.55);
    font-size: 12px;
}

/* 配列全体 */
.array-items {
    display: inline-flex;
    flex-wrap: nowrap;
    align-items: center;
}

/* 各要素 */
.array-item {
    display: inline-flex;
    align-items: center;
}

.array-item:not(:last-child)::after {
    content: ",";
    margin: 0 6px;
}

/* 入力 */
.array-items input {
    width: auto;
    min-width: 20px;
}

/* ＋ボタン */
.add-item {
    font-size: 12px;
    padding: 1px 6px;
    margin-left: 4px;
    border: 1px solid rgba(78, 102, 130, 0.2);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    color: inherit;
}

.quiz-blank-active {
    outline: 2px solid #ffb300;
    outline-offset: 2px;
}

.quiz-choices-bar {
    position: sticky;
    bottom: 0;
    margin: 10px 5px 0;
    padding: 10px 12px;
    border: 1px solid #d7e3f0;
    border-radius: 12px;
    background: linear-gradient(135deg, #ffffff, #f7fbff);
}

.quiz-mode header {
    display: none;
}

.quiz-question-title {
    font-size: 14px;
    font-weight: 800;
    color: #16324f;
    margin-bottom: 8px;
    line-height: 1.35;
}

.quiz-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.quiz-actions-label {
    font-size: 12px;
    color: #516b86;
}

.quiz-actions-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.quiz-actions-buttons button {
    border: 1px solid #d0d9e8;
    background: #f4f7fc;
    color: #2f4460;
    border-radius: 10px;
    padding: 6px 10px;
    font-size: 14px;
    cursor: pointer;
}

.quiz-choices-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 2px 0 8px;
    min-width: 0;
}

.quiz-choices-label {
    font-size: 12px;
    color: #516b86;
    white-space: nowrap;
}

.quiz-choices {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x mandatory;
    min-width: 0;
}

.quiz-blank {
    min-width: 3.8em;
    padding: 4px 10px;
    margin: 0 2px;
    border: 2px solid #ffb300;
    border-radius: 10px;
    background: #fff8e1;
    color: #2f4460;
    font-weight: 800;
    font-size: 15px;
    text-align: center;
    cursor: pointer;
    font: inherit;
}

.quiz-blank-pulse {
    animation: quizBlankPulse 1.35s ease-in-out infinite;
}

@keyframes quizBlankPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 179, 0, 0.0);
        background: #fff8e1;
    }

    50% {
        box-shadow: 0 0 0 8px rgba(255, 179, 0, 0.18);
        background: #ffe57b;
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 179, 0, 0.0);
        background: #fff8e1;
    }
}

.quiz-blank::placeholder {
    color: rgba(47, 68, 96, 0.55);
    font-weight: 700;
}

.quiz-choice {
    scroll-snap-align: start;
    border: 1px solid #d0d9e8;
    background: #f4f7fc;
    color: #2f4460;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 14px;
    white-space: nowrap;
    cursor: pointer;
}

.quiz-cta {
    outline: 3px solid #ffb300;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(255, 179, 0, 0.18);
}

.quiz-cta-pulse {
    animation: quizCtaPulse 1.2s ease-in-out infinite;
}

@keyframes quizCtaPulse {
    0% {
        box-shadow: 0 0 0 4px rgba(255, 179, 0, 0.14);
    }

    50% {
        box-shadow: 0 0 0 7px rgba(255, 179, 0, 0.28);
    }

    100% {
        box-shadow: 0 0 0 4px rgba(255, 179, 0, 0.14);
    }
}

.quiz-result-dialog {
    border: 1px solid #d7e3f0;
    border-radius: 14px;
    padding: 16px;
    width: min(520px, 92vw);
}

.quiz-result-body {
    margin-top: 8px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.quiz-result-output {
    margin-top: 6px;
    background: #16324f;
    color: #f5fbff;
    border-radius: 10px;
    padding: 10px 12px;
    white-space: pre-wrap;
    font-size: 13px;
}

.quiz-result-buttons {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.question-panel {
    margin: 14px 5px 6px;
    padding: 12px 14px;
    border: 1px solid #d7e3f0;
    border-radius: 12px;
    background: linear-gradient(135deg, #ffffff, #f7fbff);
}

.question-panel-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.question-panel-label {
    font-size: 12px;
    color: #516b86;
    margin-bottom: 4px;
}

.question-panel-box {
    background: #ffffff;
    border: 1px solid #e3ebf5;
    border-radius: 10px;
    padding: 8px 10px;
    line-height: 1.55;
    white-space: pre-wrap;
}

.question-panel-result {
    margin-top: 8px;
    font-weight: 700;
}

@media (max-width: 900px) {
    .question-panel-grid {
        grid-template-columns: 1fr;
    }
}