:root {
    --aiw-app-bg: #f1f5f9;
    --aiw-surface: #ffffff;
    --aiw-surface-soft: #f8fafc;
    --aiw-text: #1f2937;
    --aiw-muted: #6b7280;
    --aiw-border: #e5e7eb;
    --aiw-radius: 18px;
    --aiw-gap: 24px;
    --aiw-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.aiw-body {
    background: var(--aiw-app-bg);
    min-height: 100vh;
    color: var(--aiw-text);
}

.aiw-header {
    background: transparent;
}

    .aiw-header .container-xxl,
    .aiw-main .container-xxl {
        max-width: 1500px;
    }

.aiw-project-row {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    align-items: center;
    column-gap: 20px;
    width: 100%;
    margin-top: 8px;
}

.aiw-project-label {
    margin: 0;
    white-space: nowrap;
    text-align: right;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.2;
    color: var(--aiw-text);
}

.aiw-projname-input {
    min-width: 200px;
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    background: #fff;
    color: var(--aiw-text);
    padding: 10px 18px;
    font-size: 20px;
    font-weight: 500;
    line-height: 1.2;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.aiw-project-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.aiw-main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.aiw-main-inner {
    flex: 1 1 auto;
    padding-top: 4px;
    padding-bottom: 28px;
}

.aiw-layout {
    display: grid;
    grid-template-columns: 350px minmax(0, 1fr) 350px;
    gap: var(--aiw-gap);
    align-items: stretch;
    min-height: 0;
}

    .aiw-panel,
    .aiw-card,
    .aiw-layout > section {
        min-height: 0;
        height: 100%;
    }

.aiw-card {
    border-radius: var(--aiw-radius);
    border: 1px solid var(--aiw-border);
    background: var(--aiw-surface);
    box-shadow: var(--aiw-shadow);
    height: calc(100vh - 190px);
    min-height: 0;
    overflow: hidden;
}

    .aiw-card .card-body {
        display: flex;
        flex-direction: column;
        height: 100%;
        min-height: 0;
        color: black;
    }

.aiw-scroll {
    max-height: 600px;
    flex: 1 1 auto;
    overflow: auto;
    min-height: 0;
    padding-right: 4px;
}

.aiw-scroll2 {
    max-height: 800px;
    flex: 1 1 auto;
    overflow: auto;
    min-height: 0;
    padding-right: 4px;
}

.aiw-sticky-bottom {
    position: sticky;
    bottom: 0;
    background: var(--aiw-surface);
    border-top: 1px solid var(--aiw-border);
    padding-top: 16px;
}

.aiw-source-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.aiw-chat-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.aiw-chat-scroll-outer {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.aiw-chat-scroll {
    flex: 1 1 auto;
    min-height: 0;
}

.aiw-chat-history {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 8px 4px 28px 4px;
}

.aiw-chat-input {
    margin-top: 16px;
}

.aiw-chat-field {
    position: relative;
    width: 100%;
    min-width: 0;
}

.aiw-textarea {
    border-radius: 16px;
    border: 1px solid var(--aiw-border);
    background: #fff;
    min-height: 60px;
    resize: none;
    padding: 14px 110px 16px 14px;
}

.has-bottom-bar .aiw-textarea {
    padding-bottom: 72px;
}

.aiw-chat-field-model {
    position: absolute;
    left: 12px;
    bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: calc(100% - 130px);
    z-index: 2;
    pointer-events: none;
}

    .aiw-chat-field-model .aiw-llm-label,
    .aiw-chat-field-model .aiw-llm-select {
        pointer-events: auto;
    }

.aiw-chat-field-actions {
    position: absolute;
    right: 10px;
    bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    pointer-events: none;
}

    .aiw-chat-field-actions .aiw-chat-icon-btn {
        pointer-events: auto;
    }

.aiw-chat-icon-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 12px;
    border: 1px solid var(--aiw-border);
    background: #f8fafc;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

    .aiw-chat-icon-btn:hover {
        background: #eef2f7;
    }

#aiwPanelPinned .aiw-pinned-card-body {
    padding: 1.5rem 1rem;
}

.aiw-pinned-scroll,
.aiw-pinned-list {
    min-height: 0;
}

.briefing-row {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    align-items: center;
    column-gap: 18px;
}

.briefing-label {
    width: auto;
    min-width: 0;
    font-weight: 600;
    margin-bottom: 0;
}

.briefing-content {
    flex: initial;
    min-width: 0;
}

@media (max-width: 1399.98px) {
    .aiw-layout {
        grid-template-columns: 270px minmax(0, 1fr) 270px;
    }
}

@media (max-width: 1199.98px) {
    .aiw-layout {
        grid-template-columns: 260px minmax(0, 1fr);
    }

    #aiwPanelPinned {
        grid-column: 1 / -1;
    }
}

@media (max-width: 991.98px) {
    .aiw-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .aiw-card {
        height: auto;
        min-height: 420px;
    }

    .aiw-panel {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .aiw-project-row {
        grid-template-columns: 1fr;
        row-gap: 10px;
    }

    .aiw-project-label {
        text-align: left;
        font-size: 18px;
    }

    #aiwPanelPinned {
        grid-column: auto;
    }

    .briefing-row {
        grid-template-columns: 1fr;
        row-gap: 8px;
    }
}

.briefing-table-wrap {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    max-height: 600px;
    overflow-y: scroll;
    overflow-x: hidden;
    scrollbar-gutter: stable;
    border: 1px solid #000;
}

.briefing-table {
    width: 100%;
    table-layout: fixed; /* 欄寬固定分配，避免亂撐開 */
    margin-bottom: 0;
}

    .briefing-table thead th {
        background: #2f343a;
        color: #fff;
        border-color: #000;
        white-space: normal; /* 表頭可換行 */
        word-break: break-word;
        overflow-wrap: break-word;
        text-align: center;
        vertical-align: middle;
        position: sticky; /* 表頭固定 */
        top: 0;
        z-index: 2;
    }

    .briefing-table th,
    .briefing-table td {
        border-color: #000;
        word-break: break-word;
        overflow-wrap: break-word;
        white-space: normal; /* 允許換行 */
        vertical-align: middle;
    }

        .briefing-table th:nth-child(1),
        .briefing-table td:nth-child(1) {
            width: 30%;
        }

        .briefing-table th:nth-child(2),
        .briefing-table td:nth-child(2) {
            width: 20%;
        }

        .briefing-table th:nth-child(3),
        .briefing-table td:nth-child(3) {
            width: 50%;
        }

.time-cell {
    white-space: normal;
    word-break: break-word;
}

.param-cell .btn {
    margin: 2px 0;
}

.briefing-btn-group {
    width: 100%;
}

.briefing-btn {
    width: 100%;
    white-space: normal; /* 按鈕文字可換行 */
    word-break: break-word;
}
