.stage-member-toolbar
{
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    background: var(--panel);
}

.stage-member-bar
{
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
}

.stage-member-chip
{
    display: inline-grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 6px;
    overflow: hidden;
    max-width: 260px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 10px;
    font: inherit;
    font-size: 12px;
    color: #526172;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: #f8fafc;
    cursor: pointer;
}

.stage-member-chip-wrap
{
    position: relative;
    display: inline-flex;
}

.stage-member-info-panel
{
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 30;
    display: none;
    width: min(420px, 70vw);
    max-height: 600px;
    overflow-y: auto;
    border: 1px solid rgba(18, 131, 116, 0.24);
    border-radius: 8px;
    padding: 14px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 18px 50px rgba(19, 41, 48, 0.18);
    backdrop-filter: blur(10px);
}

.stage-member-chip-wrap:hover .stage-member-info-panel,
.stage-member-chip-wrap:focus-within .stage-member-info-panel
{
    display: grid;
    gap: 12px;
}

.stage-member-chip-icon
{
    display: inline-grid;
    place-items: center;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    color: var(--accent-hover);
    background: #eef8f6;
}

.stage-member-chip-icon svg
{
    width: 12px;
    height: 12px;
    stroke-width: 2.4;
}

.stage-member-chip-label
{
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stage-member-chip:hover,
.stage-member-chip:focus
{
    border-color: #a7c9c4;
    color: var(--text);
    outline: none;
    background: #f1f8f6;
}

.stage-member-chip.active
{
    border-color: #8bcfc6;
    color: var(--accent-hover);
    background: #eef8f6;
}

.stage-member-chip[disabled]
{
    cursor: not-allowed;
    opacity: 0.6;
}

.stage-member-chip:empty::before
{
    content: "선택된 멤버 없음";
    color: var(--text-dim);
}

.stage-mode-bar
{
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-width: none;
    margin: 0;
    padding: 8px max(16px, calc((100% - 1100px) / 2)) 7px;
    border-bottom: 1px solid var(--border);
    background: #f4f8f7;
}

.stage-composer
{
    padding: 0;
    background: #ffffff;
}

.stage-composer .composer-wrap
{
    container-name: stage-composer;
    container-type: inline-size;
    max-width: none;
    grid-template-columns: minmax(0, 1fr);
    padding: 14px max(16px, calc((100% - 1100px) / 2)) 18px;
}

.stage-control-deck
{
    display: grid;
    grid-template-columns: 42px minmax(180px, 220px) minmax(180px, 250px) minmax(180px, 250px) auto;
    gap: 8px;
    align-items: center;
    justify-self: center;
    width: fit-content;
    max-width: 100%;
    border: 1px solid var(--stage-control-border);
    border-radius: 14px;
    padding: 8px;
    background: var(--stage-control-bg);
    box-shadow: 0 8px 22px var(--stage-control-shadow);
}

@media (min-width: 861px)
{
    .stage-composer.edit-mode .stage-control-deck,
    .stage-composer.review-mode .stage-control-deck
    {
        grid-template-columns: 42px minmax(180px, 220px) minmax(180px, 226px) minmax(180px, 226px) auto;
    }

    .stage-composer.free-chat-mode .stage-control-deck
    {
        grid-template-columns: 42px minmax(180px, 220px) minmax(180px, 274px) minmax(180px, 274px) auto;
    }
}

.stage-control-deck .stage-execution-dropdown
{
    --custom-dropdown-height: 42px;
    --custom-dropdown-border: transparent;
    --custom-dropdown-panel-border: var(--border);
    --custom-dropdown-radius: 999px;
    --custom-dropdown-padding-inline: 14px;
    --custom-dropdown-font-size: 14px;
    --custom-dropdown-background: var(--stage-control-inner);
}

.stage-control-deck .stage-execution-dropdown .custom-dropdown__panel
{
    top: auto;
    bottom: calc(100% + var(--custom-dropdown-panel-offset));
}

.stage-composer textarea
{
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 10px;
    font: inherit;
    color: var(--text);
    background: #ffffff;
}

.stage-composer textarea:focus
{
    border-color: #8bcfc6;
    box-shadow: 0 0 0 3px #d7f3ec;
    outline: none;
}

.stage-composer #stageExecutionRefreshBtn
{
    width: 42px;
    min-height: 42px;
    border: 0;
    border-radius: 999px;
    font-size: 0;
    color: #42625c;
    background: transparent;
}

.stage-composer #stageExecutionRefreshBtn svg
{
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

.stage-mode-btn
{
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 6px 10px 7px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: #42534f;
    background: transparent;
    cursor: pointer;
}

.stage-mode-btn:hover,
.stage-mode-btn:focus
{
    border-bottom-color: #8bcfc6;
    color: #263a36;
    background: #f4faf8;
    outline: none;
}

.stage-mode-btn.active
{
    border-bottom-color: #128374;
    color: #263a36;
    background: transparent;
}

.stage-draft-toolbar,
.stage-edit-toolbar,
.stage-review-toolbar,
.stage-free-chat-toolbar
{
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 42px;
    min-width: 0;
}

.stage-draft-toolbar[hidden],
.stage-edit-toolbar[hidden],
.stage-review-toolbar[hidden],
.stage-free-chat-toolbar[hidden]
{
    display: none;
}

.stage-draft-actions
{
    display: flex;
    gap: 6px;
    align-items: center;
}

.stage-draft-run-btn,
.stage-draft-options-btn,
.stage-edit-select-btn,
.stage-edit-run-btn,
.stage-review-card-btn
{
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    font-family: inherit;
    cursor: pointer;
}

.stage-draft-options-btn,
.stage-edit-select-btn
{
    border: 0;
    color: #42625c;
    background: transparent;
}

.stage-draft-run-btn,
.stage-edit-run-btn
{
    border: 0;
    color: #ffffff;
    background: var(--accent);
    box-shadow: 0 8px 18px rgba(18, 131, 116, 0.22);
}

.stage-draft-run-btn:hover,
.stage-edit-run-btn:hover
{
    background: var(--accent-hover);
}

.stage-draft-options-btn:hover,
.stage-draft-options-btn:focus,
.stage-edit-select-btn:hover,
.stage-edit-select-btn:focus
{
    color: #0f5f56;
    background: #eef8f6;
    outline: none;
}

.stage-draft-options-btn svg,
.stage-edit-select-btn svg
{
    width: 19px;
    height: 19px;
}

.stage-draft-run-btn svg,
.stage-edit-run-btn svg
{
    width: 20px;
    height: 20px;
}

.stage-draft-run-btn:disabled,
.stage-draft-options-btn:disabled,
.stage-edit-select-btn:disabled,
.stage-edit-run-btn:disabled,
.stage-review-card-btn:disabled
{
    opacity: 0.65;
    cursor: not-allowed;
}

.stage-edit-select-btn.active
{
    color: #0f5f56;
    background: #dff7f1;
}

.stage-edit-select-btn.selection-flash
{
    animation: stage-edit-selection-flash 520ms ease-out;
}

.stage-edit-select-btn.active::after
{
    content: "✓";
    position: absolute;
    top: 5px;
    right: 6px;
    color: #128374;
    font-size: 14px;
    font-weight: 900;
    line-height: 1;
    text-shadow: 0 1px 0 #ffffff, 1px 0 0 #ffffff;
    pointer-events: none;
}

@keyframes stage-edit-selection-flash
{
    0%
    {
        background: #dff7f1;
        box-shadow: 0 0 0 0 rgba(18, 131, 116, 0.32);
    }

    45%
    {
        background: #bff0e7;
        box-shadow: 0 0 0 6px rgba(18, 131, 116, 0.14);
    }

    100%
    {
        background: #dff7f1;
        box-shadow: 0 0 0 0 rgba(18, 131, 116, 0);
    }
}

.stage-free-chat-input,
.stage-review-input
{
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    justify-self: center;
    width: 100%;
    min-width: 0;
}

.stage-free-chat-input,
.stage-review-input
{
    grid-column: 1 / -1;
    width: min(900px, 100%);
}

.stage-directing-input,
.stage-refining-input
{
    position: relative;
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    justify-self: center;
    width: min(900px, 100%);
    min-width: 0;
}

.stage-directing-field
{
    position: relative;
    min-width: 0;
}

.stage-free-chat-input #stagePrompt,
.stage-free-chat-input #stageSendBtn
{
    grid-column: auto;
}

.stage-directing-input[hidden],
.stage-refining-input[hidden],
.stage-review-input[hidden],
.stage-free-chat-input[hidden]
{
    display: none;
}

.stage-execution-icon,
.stage-member-icon
{
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    color: var(--accent-hover);
    background: #eef8f6;
}

.stage-execution-icon svg,
.stage-member-icon svg
{
    width: 13px;
    height: 13px;
    stroke-width: 2.35;
}

#stagePrompt,
#stageReviewPrompt
{
    resize: none;
    height: 54px;
    min-height: 54px;
    max-height: 220px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
}

#stageReviewPrompt
{
    max-height: 160px;
    border-color: #cfe0dc;
    padding: 12px 14px;
    font-size: 14px;
    color: var(--text);
    background: #fbfdfc;
}

#stageDirectingPrompt,
#stageRefiningPrompt
{
    resize: none;
    height: 54px;
    min-height: 54px;
    max-height: 160px;
    border: 1px solid #cfe0dc;
    border-radius: 12px;
    padding: 12px 54px 12px 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: #fbfdfc;
    outline: none;
    scrollbar-width: none;
}

#stageDirectingPrompt::-webkit-scrollbar,
#stageRefiningPrompt::-webkit-scrollbar
{
    width: 0;
    height: 0;
}

#stageDirectingPrompt:focus,
#stageRefiningPrompt:focus,
#stageReviewPrompt:focus,
#stagePrompt:focus
{
    border-color: #8bcfc6;
    box-shadow: 0 0 0 3px #d7f3ec;
}

#stageSendBtn,
#stageReviewSendBtn
{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    min-width: 54px;
    height: 54px;
    border: 0;
    border-radius: 12px;
    padding: 0;
    color: #ffffff;
    background: var(--accent);
    cursor: pointer;
}

#stageSendBtn svg,
#stageReviewSendBtn svg
{
    width: 20px;
    height: 20px;
    stroke-width: 2.2;
}

#stageDirectingAddBtn,
#stageRefiningAddBtn
{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    min-width: 54px;
    height: 54px;
    border: 1px solid #a8ded8;
    border-radius: 12px;
    padding: 0;
    color: #0f5f56;
    background: #eef8f6;
    cursor: pointer;
}

#stageDirectingAddBtn svg,
#stageRefiningAddBtn svg
{
    width: 20px;
    height: 20px;
    stroke-width: 2.2;
}

#stageDirectingAddBtn:hover,
#stageRefiningAddBtn:hover
{
    border-color: #7fc8bf;
    background: #e2f3ef;
}

#stageSendBtn:hover,
#stageReviewSendBtn:hover
{
    background: var(--accent-hover);
}

#stageExecutionRefreshBtn:disabled,
#stageDirectingBoardBtn:disabled,
#stageRefiningBoardBtn:disabled,
#stageDirectingPrompt:disabled,
#stageRefiningPrompt:disabled,
#stageReviewPrompt:disabled,
#stagePrompt:disabled,
#stagePrompt[readonly],
#stageDirectingAddBtn:disabled,
#stageRefiningAddBtn:disabled,
#stageReviewSendBtn:disabled,
#stageSendBtn:disabled
{
    opacity: 0.65;
    cursor: not-allowed;
}

#stageSendBtn:disabled:hover,
#stageReviewSendBtn:disabled:hover
{
    background: var(--accent);
}

#stageExecutionRefreshBtn:disabled:hover
{
    border-color: var(--border);
    background: var(--panel-soft);
}

#stageDirectingAddBtn:disabled:hover,
#stageRefiningAddBtn:disabled:hover
{
    border-color: #a8ded8;
    background: #eef8f6;
}

@container stage-composer (max-width: 860px)
{
    .stage-control-deck,
    .stage-composer.edit-mode .stage-control-deck,
    .stage-composer.review-mode .stage-control-deck,
    .stage-composer.free-chat-mode .stage-control-deck
    {
        grid-template-columns: 42px minmax(0, 1fr);
        justify-self: stretch;
        width: auto;
    }

    .stage-execution-cache-dropdown,
    .stage-execution-member-dropdown
    {
        grid-column: 1 / -1;
    }

    .stage-draft-toolbar,
    .stage-edit-toolbar,
    .stage-review-toolbar,
    .stage-free-chat-toolbar,
    .stage-directing-input,
    .stage-refining-input,
    .stage-review-input,
    .stage-free-chat-input
    {
        grid-column: 1 / -1;
    }

    .stage-free-chat-input #stagePrompt
    {
        grid-column: 1 / 2;
    }
}
