body {
    padding: 20px;
}

.code-area {
    display: flex;
    /* 70pxは、ヘッダー分 */
    height: calc(100vh - 70px);
    box-sizing: border-box;
}

.code-output,
.step {
    flex: 1;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    padding: 10px;
    overflow: hidden;
}

/* 左側（コードと出力） */
.code-output {
    border-right: 1px solid #ccc;
}

/* エディタ部分 */
.editor {
    flex: 0 0 55%;
    display: flex;
    overflow: hidden;
    border: 1px solid #ccc;
    height: 55%;
    box-sizing: border-box;
}

/* 行番号とtextarea */
#line-numbers {
    background-color: #f0f0f0;
    text-align: right;
    padding: 5px;
    user-select: none;
    overflow-y: auto;
    white-space: pre;
    color: #999;
    font-size: 16px;
    line-height: 1.4em;
}

#code {
    flex: 1;
    resize: none;
    border: none;
    padding: 5px;
    font-size: 16px;
    line-height: 1.4em;
    overflow: auto;
    text-wrap: nowrap;
}

/* 出力エリア */
#output {
    flex: 1;
    margin-top: 10px;
    padding: 10px;
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    overflow: auto;
    white-space: pre-wrap;
}

/* 実行ステップ */
.step {
    overflow: auto;
    background-color: #fafafa;
    border-left: 1px solid #ccc;
}

#trace {
    overflow: auto;
    padding: 10px;
}

/* 表テーブル（既存のtrace-tableにも効く） */
#trace table {
    border-collapse: collapse;
    width: max-content;
    /* 横幅が必要なら広がる */
    table-layout: fixed;
}

/* セル共通 */
#trace th,
#trace td {
    border: 1px solid #ccc;
    padding: 6px 12px;
    text-align: center;
    background-color: white;
}

/* ヘッダー行を固定 */
#trace thead th {
    position: sticky;
    top: 0;
    background-color: #f0f0f0;
    z-index: 2;
}

/* 最左列（ステップ列）を固定 */
#trace th:first-child,
#trace td:first-child {
    position: sticky;
    left: 0;
    background-color: #f8f8f8;
    z-index: 1;
}

/* ヘッダーの左上セルは上書きして最前面に */
#trace thead th:first-child {
    z-index: 3;
    background-color: #e8e8e8;
}

#trace .changed {
    font-weight: bold;
    color: #d00000;
    background-color: #fff0f0;
}

h3 {
    background-color: #1565c0;
    color: white;
    margin: 0;
    padding: 0;
    font-size: 18px;
}

.insert-button {
    padding: 4px 8px;
    margin-right: 3px;
    color: black;
    background-color: var(--primary-light-2);
}