:root {
    --page-pad: 28px;
    --shell-pad: 18px;
    --bg-top: #d8d3cf;
    --bg-bottom: #f2efeb;
    --shell: rgba(247, 244, 240, 0.88);
    --sidebar: #f1eeea;
    --panel: #fffdfa;
    --panel-soft: #f7f4ef;
    --line: #e6e0d9;
    --line-strong: #d9d2ca;
    --text: #2f313c;
    --muted: #8b8993;
    --blue: #79a7f2;
    --blue-deep: #5d89db;
    --orange: #f3a13b;
    --green: #62c78a;
    --shadow-lg: 0 28px 60px rgba(104, 92, 82, 0.14);
    --shadow-md: 0 14px 32px rgba(104, 92, 82, 0.09);
    --shadow-sm: 0 8px 18px rgba(104, 92, 82, 0.06);
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: light;
}

body {
    position: relative;
    min-height: 100vh;
    margin: 0;
    padding: var(--page-pad);
    background: linear-gradient(180deg, var(--bg-top) 0%, #e8e3de 28%, var(--bg-bottom) 100%);
    color: var(--text);
    font-family: "Avenir Next", "SF Pro Display", "Segoe UI", sans-serif;
    line-height: 1.5;
}

body::before,
body::after {
    content: "";
    position: fixed;
    border-radius: 999px;
    filter: blur(12px);
    pointer-events: none;
    z-index: 0;
}

body::before {
    top: 72px;
    left: 48px;
    width: 220px;
    height: 220px;
    background: rgba(121, 167, 242, 0.18);
}

body::after {
    right: 60px;
    bottom: 80px;
    width: 260px;
    height: 260px;
    background: rgba(243, 161, 59, 0.12);
}

button,
input,
select,
textarea,
output {
    font: inherit;
    color: inherit;
}

button,
input,
select,
textarea {
    border: 1px solid var(--line);
    border-radius: 18px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
}

input,
select,
textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.92);
    padding: 14px 16px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

button {
    padding: 14px 20px;
    border: 0;
    background: linear-gradient(135deg, var(--blue), #8db5fb);
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.01em;
    box-shadow: 0 12px 24px rgba(121, 167, 242, 0.3);
    cursor: pointer;
}

button:hover,
button:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 16px 30px rgba(121, 167, 242, 0.34);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
    outline: none;
    border-color: rgba(121, 167, 242, 0.55);
    box-shadow: 0 0 0 4px rgba(121, 167, 242, 0.14);
}

textarea {
    /* min-height: 120px; */
    resize: vertical;
}

#app,
#createCasePanel,
body>button {
    position: relative;
    z-index: 1;
}

#warning {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff200;
    font-size: 18px;
    line-height: 2;
    z-index: 9999999;
    background: rgba(0, 0, 0, 0.75);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-14px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.35s ease, transform 0.35s ease, visibility 0s linear 0.35s;
}

#warning.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s;
    animation: warningPop 0.3s ease;
}

@keyframes warningPop {
    0% {
        transform: translateY(-18px) scale(0.94);
    }

    65% {
        transform: translateY(0) scale(1.03);
    }

    100% {
        transform: translateY(0) scale(1);
    }
}

#app {
    display: grid;
    grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
    gap: 18px;
    width: 100%;
    min-height: calc(100vh - (var(--page-pad) * 2));
    min-height: calc(100dvh - (var(--page-pad) * 2));
    padding: var(--shell-pad);
    background: var(--shell);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 34px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(16px);
    align-items: start;
    overflow: visible;
}

#caseList {
    position: relative;
    align-self: start;
    height: calc(100vh - (var(--page-pad) * 2) - (var(--shell-pad) * 2));
    height: calc(100dvh - (var(--page-pad) * 2) - (var(--shell-pad) * 2));
    min-height: 0;
    max-height: calc(100vh - (var(--page-pad) * 2) - (var(--shell-pad) * 2));
    max-height: calc(100dvh - (var(--page-pad) * 2) - (var(--shell-pad) * 2));
    overflow-y: auto;
    margin: 0;
    padding: 84px 12px 12px;
    background: linear-gradient(180deg, #f3f0ec 0%, #ece8e4 100%);
    border-radius: 28px;
}

#caseList::before {
    content: "案件清單";
    position: absolute;
    top: 26px;
    left: 22px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--muted);
}

#caseList::after {
    content: "Case Board";
    position: absolute;
    top: 46px;
    left: 22px;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text);
}

#caseList li {
    position: relative;
    margin-bottom: 10px;
    padding: 16px 18px;
    border: 1px solid rgba(217, 210, 202, 0.95);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

#caseList li:hover {
    transform: translateY(-2px);
    border-color: rgba(121, 167, 242, 0.4);
    box-shadow: 0 16px 30px rgba(104, 92, 82, 0.1);
}

#caseList li:last-child {
    margin-bottom: 0;
}

#caseList li::before {
    content: "";
    position: absolute;
    top: 20px;
    right: 18px;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--blue);
    box-shadow: 0 0 0 6px rgba(121, 167, 242, 0.12);
}

#caseList li:nth-child(3n + 2)::before {
    background: var(--orange);
    box-shadow: 0 0 0 6px rgba(243, 161, 59, 0.14);
}

#caseList li:nth-child(3n)::before {
    background: var(--green);
    box-shadow: 0 0 0 6px rgba(98, 199, 138, 0.15);
}

#caseList li span {
    display: block;
}

#caseList li span.title {
    padding-right: 24px;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.35;
    color: var(--text);
}

#caseList li span.serial {
    margin-top: 6px;
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}

.caseDetail {
    display: grid;
    grid-template-rows: auto auto;
    gap: 18px;
    height: auto;
    align-self: start;
    min-width: 0;
    min-height: 0;
    padding: 0;
    background: transparent;
    border-radius: 28px;
    overflow: visible;
}

#caseDetailThreadPanel,
#caseMessageThreadPanel,
#createCasePanel {
    border: 1px solid rgba(230, 224, 217, 0.95);
    border-radius: 28px;
    background: var(--panel);
    box-shadow: var(--shadow-md);
}

#caseDetailThreadPanel {
    position: relative;
    min-height: 0;
    padding: 72px 24px 20px;
    overflow: hidden;
}

#caseDetailThreadPanel::before {
    content: "案件摘要";
    position: absolute;
    top: 22px;
    left: 24px;
    font-size: 25px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text);
}

#caseDetailThreadPanel::after {
    content: "Overview";
    position: absolute;
    top: 28px;
    right: 24px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: var(--muted);
    text-transform: uppercase;
}

#caseDetailThreadContainer {
    display: grid;
    grid-template-rows: auto auto auto auto;
    align-content: start;
    gap: 12px;
    margin: 0;
    padding: 0;
    overflow: visible;
}

#caseDetailThreadContainer li {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: linear-gradient(180deg, #fcfbf9 0%, var(--panel-soft) 100%);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--muted);
}

#caseDetailThreadContainer li:nth-child(-n + 2) {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 16px;
}

#caseDetailThreadContainer li:nth-child(-n + 2) span {
    min-width: 0;
    margin: 0;
}

#caseDetailThreadContainer li:nth-child(3) {
    padding-bottom: 12px;
}

#caseDetailThreadContainer li span {
    display: block;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.6;
    letter-spacing: 0;
    color: var(--text);
}

#caseDetailTitleOutput {
    font-size: 24px;
    font-weight: 800;
    line-height: 1.3;
}

#caseDetailSerialOutput {
    color: var(--blue-deep);
    font-family: "SF Mono", "SFMono-Regular", ui-monospace, monospace;
    font-size: 14px;
    letter-spacing: 0.02em;
}

#caseDetailContentOutput {
    max-height: clamp(82px, 14vh, 132px);
    padding-right: 8px;
    overflow-y: auto;
}

#caseDetailDeptOutput {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

#caseDetailDeptOutput .dept {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    margin-right: 5px;
    border-radius: 999px;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}



#caseMessageThreadPanel {
    display: grid;
    grid-template-rows: auto auto auto;
    min-height: 0;
    overflow: visible;
}

#caseMessageThreadPanel>h3 {
    margin: 0;
    padding: 24px 28px 18px;
    border-bottom: 1px solid var(--line);
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.03em;
}

#caseMessageThreadContainer {
    display: grid;
    align-content: start;
    gap: 12px;
    min-height: 0;
    margin: 0;
    padding: 20px 24px;
    overflow: visible;
    background: linear-gradient(180deg, rgba(121, 167, 242, 0.05) 0%, rgba(255, 255, 255, 0) 20%);
}

#caseMessageThreadContainer:empty::before {
    content: "選擇左側案件後，處理訊息會顯示在這裡。";
    display: block;
    padding: 16px 18px;
    border: 1px dashed var(--line-strong);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--muted);
}

#caseMessageThreadContainer li {
    position: relative;
    padding: 16px 18px 16px 22px;
    border: 1px solid rgba(232, 226, 219, 0.95);
    border-radius: 20px;
    background: #fff;
    box-shadow: var(--shadow-sm);
    line-height: 1.65;
    color: #4a4a54;
}

#caseMessageThreadContainer li::before {
    content: "";
    position: absolute;
    top: 16px;
    bottom: 16px;
    left: 0;
    width: 4px;
    border-radius: 999px;
}



#caseMessageThreadContainer li .name {
    display: inline-block;
    padding: 3px 6px;
    margin-right: 5px;
    color: #fff;
    border-radius: 10px;
}

#caseMessageThreadContainer li .time {
    color: #aaa;
}

.createMessagePanel {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    align-items: center;
    gap: 16px;
    padding: 20px 22px 22px;
    background: linear-gradient(180deg, #f5f1eb 0%, #efebe6 100%);
    border-top: 1px solid var(--line);
}

.createMessagePanel>h3 {
    padding: 0;
    white-space: nowrap;
    line-height: 1.3;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

#createMessageControl {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr) 150px;
    gap: 12px;
    align-items: stretch;
    padding: 0;
    border-radius: 0;
    background: transparent;
}

#createMessageSelect {
    min-width: 0;
}

#createMessageInput {
    height: 58px;
    min-height: 58px;
    padding-top: 16px;
    padding-bottom: 16px;
    resize: none;
}

#createMessageBtn {
    align-self: stretch;
}

#createCasePanel {
    position: relative;
    display: grid;
    gap: 16px;
    margin-top: 22px;
    padding: 78px 20px 20px;
    background: var(--panel);
}

#createCasePanel #closeBtn {
    position: absolute;
    top: 18px;
    right: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    background: linear-gradient(135deg, #EA4335, #E63221);
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(234, 67, 53, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#createCasePanel #closeBtn:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 24px rgba(234, 67, 53, 0.4);
}

#createCasePanel::before {
    content: "新增案件";
    position: absolute;
    top: 24px;
    left: 24px;
    font-size: 25px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text);
}



#createCasePanel>div {

    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: linear-gradient(180deg, #fcfbf9 0%, var(--panel-soft) 100%);
}

.createCaseSerialRow {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr) 170px;
    gap: 16px;
    align-items: center;
    max-width: none;
}

.createCaseFieldRow {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 16px;
    align-items: start;
}

.createCaseSerialRow h3,
.createCaseFieldRow h3,
#createCaseDeptTitle {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.4;
    color: var(--muted);
}

.createCaseFieldRow h3 {
    display: inline-flex;
    align-items: center;
    height: 100%;
}

#createCaseSerialOutput {
    display: flex;
    align-items: center;
    min-height: 54px;
    padding: 14px 16px;
    border: 1px dashed rgba(121, 167, 242, 0.45);
    border-radius: 18px;
    background: rgba(121, 167, 242, 0.06);
    color: var(--blue-deep);
    font-weight: 700;
    letter-spacing: 0.02em;
}

#createCaseSerialBtn {
    background: linear-gradient(135deg, var(--orange), #f6b25e);
    box-shadow: 0 12px 24px rgba(243, 161, 59, 0.28);
}

#createCaseSerialBtn:hover,
#createCaseSerialBtn:focus-visible {
    box-shadow: 0 16px 30px rgba(243, 161, 59, 0.34);
}

.createCaseDeptOptionList {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    grid-auto-flow: row;
    gap: 12px;
    margin: 14px 0 0;
    padding: 0;
    list-style: none;
}

.createCaseDeptOptionItem {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.84);
}

.createCaseDeptOptionItem:has(input:checked) {
    border-color: rgba(121, 167, 242, 0.42);
    background: rgba(121, 167, 242, 0.08);
    box-shadow: 0 10px 20px rgba(121, 167, 242, 0.1);
}

.createCaseDeptOptionItem input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--blue);
}

.createCaseDeptOptionItem label {
    font-weight: 600;
    cursor: pointer;
}

body>button {
    margin-top: 18px;
    margin-right: 10px;
}

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

#loginWithGoogleBtn,
#openCreateCasePanelBtn,
#topLoginGoogleBtn {
    background: linear-gradient(135deg, #EA4335, #E63221);
    color: #fff;
    border: 0;
    box-shadow: 0 12px 24px rgba(234, 67, 53, 0.28);
}

#loginWithGoogleBtn:hover,
#loginWithGoogleBtn:focus-visible,
#openCreateCasePanelBtn:hover,
#openCreateCasePanelBtn:focus-visible,
#topLoginGoogleBtn:hover,
#topLoginGoogleBtn:focus-visible {
    box-shadow: 0 16px 30px rgba(234, 67, 53, 0.34);
}

#openCreateCasePanelBtn {
    padding-top: 16px;
    padding-bottom: 16px;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 0.02em;
}

#openCreateCasePanelBtn:hover,
#openCreateCasePanelBtn:focus-visible {
    transform: translateY(-2px);
}

#logoutBtn,
#topLogoutBtn {
    background: linear-gradient(135deg, #737784, #8d93a3);
    box-shadow: 0 12px 24px rgba(102, 108, 123, 0.25);
}

#logoutBtn:hover,
#logoutBtn:focus-visible,
#topLogoutBtn:hover,
#topLogoutBtn:focus-visible {
    box-shadow: 0 16px 30px rgba(102, 108, 123, 0.34);
}

#topLoginGoogleBtn,
#topLogoutBtn {
    display: none;
}

#topLoginGoogleBtn.visiable,
#topLogoutBtn.visiable {
    display: inline-block;
}

#createCaseBtn {
    background: linear-gradient(135deg, var(--green), #87d3a4);
    box-shadow: 0 12px 24px rgba(98, 199, 138, 0.28);
}

.formActions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.formActions button:first-child {
    grid-column: 1 / -1;
}



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

::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;
    background: rgba(139, 137, 147, 0.35);
    background-clip: padding-box;
}

::-webkit-scrollbar-track {
    background: transparent;
}


#fixWindow {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    bottom: 0;
    padding: 20px 40px;
    background: rgba(100, 100, 100, 0.5);
    backdrop-filter: blur(8px);
    z-index: 99999;
    overflow-y: scroll;
}

#fixWindow.action {
    display: block;
}

@media (max-width: 1100px) {
    #caseDetailThreadContainer {
        grid-template-columns: 1fr;
    }

    .createMessagePanel {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    #createMessageControl {
        grid-template-columns: 1fr;
    }

    #createMessageBtn {
        min-height: 54px;
    }
}

@media (max-width: 900px) {
    :root {
        --page-pad: 18px;
        --shell-pad: 14px;
    }

    body {
        padding: var(--page-pad);
    }

    #app {
        grid-template-columns: 1fr;
        padding: var(--shell-pad);
        border-radius: 28px;
    }

    #caseList {
        height: clamp(220px, 32vh, 320px);
        height: clamp(220px, 32dvh, 320px);
        max-height: clamp(220px, 32vh, 320px);
        max-height: clamp(220px, 32dvh, 320px);
    }

    .caseDetail {
        min-height: auto;
    }
}

@media (max-width: 720px) {

    #caseDetailThreadPanel,
    #caseMessageThreadPanel,
    #createCasePanel {
        border-radius: 24px;
    }

    .createCaseSerialRow,
    .createCaseFieldRow {
        grid-template-columns: 1fr;
    }

    .createCaseDeptOptionList {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 560px) {
    :root {
        --page-pad: 14px;
    }

    body {
        padding: var(--page-pad);
    }

    #app {
        gap: 14px;
    }

    #caseList {
        padding-top: 76px;
    }

    #caseList::after,
    #caseDetailThreadPanel::after,
    #createCasePanel::after {
        display: none;
    }

    #caseDetailThreadPanel,
    #createCasePanel {
        padding-left: 18px;
        padding-right: 18px;
    }

    #caseMessageThreadPanel>h3,
    #caseMessageThreadContainer,
    .createMessagePanel {
        padding-left: 18px;
        padding-right: 18px;
    }

    .createCaseDeptOptionList {
        grid-template-columns: 1fr;
    }

    body>button {
        width: 100%;
        margin-right: 0;
    }
}