:root {
    --bg: #202124;
    --panel: #ffffff;
    --text: #17202a;
    --muted: #5f6b7a;
    --line: #d9e0e7;
    --bot: #ffffff;
    --user: #ddf5cf;
    --user-text: #17202a;
    --accent: #1f7a5c;
    --accent-dark: #155b44;
    --error: #b42318;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "PingFang SC", "Microsoft YaHei", Arial, Helvetica, sans-serif;
    color: var(--text);
    background: var(--bg);
}

.test-mode-banner {
    position: fixed;
    z-index: 20;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: fit-content;
    max-width: calc(100vw - 32px);
    border: 1px solid #f4bf50;
    border-radius: 999px;
    padding: 7px 14px;
    background: #fff8e6;
    color: #7a4b00;
    font-size: 13px;
    font-weight: 800;
    box-shadow: 0 8px 24px rgba(23, 32, 42, 0.16);
}

.control-page,
.finish-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: #000;
}

.cover-page {
    min-height: 100svh;
    display: grid;
    padding: 0;
    background: #000;
    color: #fff;
    overflow-x: hidden;
}

.cover-stage {
    width: 100vw;
    min-height: 100svh;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    align-items: center;
    justify-items: center;
    padding: 0 0 18px;
}

.cover-art {
    position: relative;
    width: min(100vw, calc((100svh - 54px) * 16 / 9));
    aspect-ratio: 16 / 9;
}

.cover-desktop-art {
    transform: none;
}

.cover-image {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

.cover-hotspot {
    appearance: none;
    background: transparent;
    border: 0;
    padding: 0;
    position: absolute;
    left: 42.25%;
    top: 60.1%;
    width: 15.6%;
    height: 7.8%;
    border-radius: 999px;
    cursor: pointer;
    text-decoration: none;
}

.cover-hotspot:hover,
.cover-hotspot:active {
    background: transparent;
}

.cover-version {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.cover-hotspot:focus-visible {
    outline: 3px solid #6aa8ff;
    outline-offset: 4px;
}

.cover-tools {
    width: min(100vw, calc((100svh - 54px) * 16 / 9));
    display: flex;
    justify-content: flex-end;
    padding: 8px 22px 0;
}

.randomizer-entry {
    color: rgba(255, 255, 255, 0.62);
    font-size: 13px;
    text-decoration: none;
}

.randomizer-entry:hover {
    color: #fff;
}

.control-panel,
.finish-panel {
    width: min(720px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 32px;
    box-shadow: 0 18px 48px rgba(255, 255, 255, 0.08);
}

h1 {
    margin: 0 0 24px;
    font-size: 28px;
    line-height: 1.2;
}

.condition-form {
    display: grid;
    gap: 22px;
}

.step-label {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 14px;
    font-weight: 700;
}

.selection-summary {
    margin: -10px 0 22px;
    color: var(--muted);
}

.preset-summary {
    margin: -8px 0 22px;
    padding: 12px 14px;
    border: 1px solid #cfe1d9;
    border-radius: 8px;
    background: #f4fbf8;
    color: var(--accent-dark);
    font-weight: 700;
}

.helper-text {
    margin: -8px 0 22px;
    color: var(--muted);
    line-height: 1.7;
}

.inline-link {
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
}

.inline-link:hover {
    color: var(--accent-dark);
}

.randomizer-panel {
    width: min(860px, 100%);
}

.random-result {
    min-height: 78px;
    margin-bottom: 18px;
    padding: 18px;
    border: 1px solid #cfe1d9;
    border-radius: 8px;
    background: #f4fbf8;
    display: grid;
    gap: 6px;
    align-content: center;
}

.random-result strong {
    font-size: 24px;
    color: var(--accent-dark);
}

.random-result span {
    color: var(--text);
    font-size: 16px;
}

.randomizer-actions {
    justify-content: flex-start;
    margin-bottom: 22px;
}

.condition-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 22px;
    font-size: 14px;
}

.condition-table th,
.condition-table td {
    border: 1px solid var(--line);
    padding: 10px 12px;
    text-align: left;
}

.condition-table th {
    background: #f5f7f9;
}

fieldset {
    margin: 0;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

legend {
    padding: 0 8px;
    font-weight: 700;
}

label {
    display: block;
    margin-top: 12px;
    color: var(--text);
}

.text-input {
    width: 100%;
    min-height: 46px;
    margin-top: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 14px;
    color: var(--text);
    background: #fff;
    font: inherit;
}

.text-input:focus {
    border-color: var(--accent);
    outline: 3px solid rgba(31, 122, 92, 0.14);
}

button,
.button-link {
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
}

button:hover,
.button-link:hover {
    background: var(--accent-dark);
}

.secondary-button {
    width: fit-content;
    min-height: 40px;
    margin: -8px 0 22px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 16px;
    background: #fbfcfd;
    color: var(--text);
    font: inherit;
    font-weight: 700;
}

.secondary-button:hover {
    background: #f4f6f8;
}

.secondary-button.compact {
    min-height: 34px;
    margin: 0;
    padding: 0 12px;
    font-size: 14px;
}

.form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.secondary-link {
    color: var(--muted);
    font-weight: 700;
    text-decoration: none;
}

.secondary-link:hover {
    color: var(--text);
}

.error {
    color: var(--error);
    font-weight: 700;
}

.chat-page {
    min-height: 100svh;
    overflow: hidden;
    display: grid;
    place-items: center;
    padding: 20px;
    background: #eef1f5;
}

.phone-device {
    position: relative;
    width: min(402px, calc(100vw - 32px));
    height: min(852px, calc(100svh - 32px));
    padding: 8px;
    border-radius: 38px;
    background: #111318;
    box-shadow:
        0 22px 48px rgba(23, 32, 42, 0.24),
        inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.phone-device::before {
    content: "";
    position: absolute;
    z-index: 4;
    top: 18px;
    left: 50%;
    width: 82px;
    height: 6px;
    transform: translateX(-50%);
    border-radius: 999px;
    background: rgba(17, 19, 24, 0.42);
}

.phone-device::after {
    content: none;
}

.chat-shell {
    position: relative;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    background: var(--panel);
    border-radius: 30px;
    overflow: hidden;
    box-shadow: none;
}

.chat-header {
    border-bottom: 1px solid var(--line);
    padding: 28px 14px 10px;
    display: grid;
    grid-template-columns: 42px 1fr 64px;
    align-items: center;
    background: rgba(250, 251, 253, 0.96);
}

.chat-header h1 {
    margin: 0;
    font-size: 18px;
    text-align: center;
}

.header-title p {
    margin: 2px 0 0;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

.header-title span {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 6px;
    border-radius: 50%;
    background: #4db36a;
}

.back-button,
.finish-button {
    min-height: 34px;
    padding: 0;
    background: transparent;
    color: var(--text);
}

.back-button {
    font-size: 36px;
    font-weight: 300;
}

.finish-button {
    font-size: 14px;
    font-weight: 700;
    border: 1px solid var(--line);
}

.finish-button[hidden] { display: none; }

.back-button:hover,
.finish-button:hover {
    background: #f4f6f8;
}

.chat-log {
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: linear-gradient(180deg, #f8f9fb 0%, #ffffff 100%);
    scrollbar-width: none;
}

.chat-log::-webkit-scrollbar {
    display: none;
}

.message-row {
    display: grid;
    align-items: center;
    gap: 10px;
}

.message-row.grouped {
    margin-top: -8px;
}

.message-row.bot {
    grid-template-columns: 36px minmax(0, 1fr);
}

.message-row.user {
    grid-template-columns: minmax(0, 1fr) 36px;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 800;
    border: 1px solid var(--line);
}

.avatar-spacer {
    width: 32px;
    height: 32px;
}

.avatar.bot {
    background: radial-gradient(circle at center, #eef6ff 0%, #eef6ff 48%, #ffffff 49%);
    color: #2b5c9e;
}

.avatar.user {
    background: #f0f1f4;
    color: #5a6472;
}

.message-content {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.message-row.bot .message-content {
    justify-items: start;
}

.message-row.user .message-content {
    justify-items: end;
}

.message {
    max-width: min(292px, 100%);
    border-radius: 12px;
    padding: 11px 13px;
    line-height: 1.55;
    font-size: 14px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    box-shadow: 0 2px 10px rgba(23, 32, 42, 0.08);
}

.message.bot {
    background: var(--bot);
    color: var(--text);
    border: 1px solid #e5e8ec;
    border-top-left-radius: 5px;
}

.message.user {
    background: var(--user);
    color: var(--user-text);
    border: 1px solid #ccebbd;
    border-top-right-radius: 5px;
}

.message-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.stage-label {
    display: inline-flex;
    width: fit-content;
    border-radius: 6px;
    padding: 4px 7px;
    font-size: 11px;
    color: #2f3440;
    background: #e9edf4;
}

.stage-label.opening,
.stage-label.advice-reinforcement {
    background: #dbe8ff;
}

.stage-label.acknowledgement,
.stage-label.emotional-support {
    background: #eee7ff;
}

.stage-label.problem-inquiry {
    background: #fff1a8;
}

.stage-label.problem-analysis {
    background: #ffe1cf;
}

.stage-label.advice {
    background: #d8f4da;
}

.stage-label.gain-frame {
    background: #ffd7e0;
}

.stage-label.loss-frame {
    background: #ffd2c7;
}

.stage-label.clarification {
    background: #e7edf3;
}

.finish-cta-row {
    display: grid;
    gap: 9px;
    margin: 2px 0 4px 46px;
    padding: 13px;
    border: 1px solid #cfe1d9;
    border-radius: 12px;
    background: #f4fbf8;
}

.finish-cta-row p {
    margin: 0;
    color: var(--accent-dark);
    font-size: 13px;
    line-height: 1.45;
}

.finish-cta-button {
    width: 100%;
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 15px;
    font-weight: 800;
}

.finish-cta-button:hover {
    background: var(--accent-dark);
}

.typing-indicator {
    width: fit-content;
    min-width: 38px;
    padding: 8px 10px;
}

.typing-indicator span {
    display: inline-block;
    width: 5px;
    height: 5px;
    margin: 0 1px;
    border-radius: 50%;
    background: var(--muted);
    animation: pulse 1s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.3s;
}

.pending-retry-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 10px 18px 16px 72px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--muted);
    font-size: 13px;
}

.pending-retry-row button {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 0 14px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

@keyframes pulse {
    0%,
    80%,
    100% {
        opacity: 0.35;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

.chat-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px 12px 14px;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
}

.chat-form input {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 999px;
    min-height: 38px;
    padding: 0 13px;
    font-size: 14px;
    background: #fbfcfd;
}

.chat-form input:focus {
    outline: 3px solid rgba(31, 122, 92, 0.18);
    border-color: var(--accent);
}

.chat-status {
    grid-column: 1 / -1;
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}
.chat-status[hidden] { display: none; }
@media (max-width: 360px) {
    .chat-form { gap: 6px; padding-left: 8px; padding-right: 8px; }
    .chat-form input { padding-left: 9px; padding-right: 9px; }
    .chat-form button[type="submit"] { padding-left: 12px; padding-right: 12px; }
}

.finish-panel p {
    margin: 0 0 24px;
    color: var(--muted);
}

.chat-transcript-panel {
    margin: 0 0 24px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafb;
    overflow: hidden;
}

.transcript-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    background: #fff;
}

.transcript-header h2 {
    margin: 0;
    font-size: 18px;
}

.transcript-list {
    max-height: 420px;
    overflow-y: auto;
    display: grid;
    gap: 12px;
    padding: 16px;
}

.transcript-item {
    display: grid;
    gap: 6px;
}

.transcript-item strong {
    color: var(--muted);
    font-size: 13px;
}

.transcript-item p {
    width: fit-content;
    max-width: 92%;
    margin: 0;
    border: 1px solid #e5e8ec;
    border-radius: 10px;
    padding: 10px 12px;
    background: #fff;
    color: var(--text);
    white-space: pre-wrap;
    line-height: 1.55;
}

.transcript-item.user {
    justify-items: end;
}

.transcript-item.user p {
    background: var(--user);
    border-color: #ccebbd;
}

.frame-check-form {
    display: grid;
    gap: 20px;
}

.survey-page {
    min-height: 100vh;
    padding: 32px 20px;
    background: #eef1f5;
}

.survey-panel {
    width: min(820px, 100%);
    margin: 0 auto;
    padding: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 18px 48px rgba(23, 32, 42, 0.1);
}

.survey-intro,
.section-note {
    margin: 0 0 14px;
    color: var(--muted);
    line-height: 1.7;
}

.survey-form {
    display: grid;
    gap: 20px;
}

.survey-form fieldset {
    display: grid;
    gap: 18px;
}

.survey-question {
    padding-bottom: 16px;
    border-bottom: 1px solid #edf0f3;
}

.survey-question:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.survey-question p,
.survey-input-label {
    display: block;
    margin: 0 0 10px;
    color: var(--text);
    font-weight: 600;
    line-height: 1.65;
}

.required-mark {
    color: var(--error);
    font-size: 13px;
    font-weight: 500;
}

.item-code {
    display: inline-block;
    min-width: 38px;
    margin-right: 4px;
    color: var(--accent-dark);
    font-size: 13px;
    font-weight: 800;
}

.choice-row {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
}

.choice-row label {
    margin: 0;
}

.likert-question .likert-scale {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}

.likert-question .likert-scale label {
    display: block;
    margin: 0;
}

.likert-question .likert-scale input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.likert-question .likert-scale span {
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 6px;
    display: grid;
    place-items: center;
    background: #fbfcfd;
    color: var(--text);
    font-weight: 700;
}

.likert-question .likert-scale input:checked + span {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.likert-question .likert-scale input:focus-visible + span {
    outline: 3px solid rgba(31, 122, 92, 0.2);
    outline-offset: 2px;
}

@media (max-width: 560px) {
    .survey-page {
        padding: 14px;
    }

    .survey-panel {
        padding: 22px 16px;
    }

    .likert-question .likert-scale {
        gap: 5px;
    }

    .likert-question .likert-scale span {
        min-height: 36px;
        font-size: 13px;
    }
}

.frame-check-form fieldset {
    display: grid;
    gap: 18px;
}

.likert-item p {
    margin: 0 0 10px;
    color: var(--text);
    line-height: 1.6;
}

.likert-scale {
    display: grid;
    grid-template-columns: repeat(7, minmax(34px, 1fr));
    gap: 8px;
}

.likert-scale label {
    margin: 0;
}

.likert-scale input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.likert-scale span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
}

.likert-scale input:checked + span {
    border-color: var(--accent);
    background: #e8f5ef;
    color: var(--accent-dark);
}

.likert-scale input:focus-visible + span {
    outline: 3px solid rgba(31, 122, 92, 0.18);
}

.scale-anchors {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: var(--muted);
    font-size: 14px;
}

.home-indicator {
    display: none;
}

@media (min-width: 900px) {
    .chat-log,
    .chat-form,
    .chat-header {
        padding-left: 14px;
        padding-right: 14px;
    }
}

@media (max-width: 560px) {
    .cover-stage {
        min-height: 100svh;
        padding: 0 0 14px;
    }

    .cover-art {
        width: 100vw;
    }

    .cover-tools {
        width: 100%;
        justify-content: flex-end;
        padding: 8px 16px 0;
    }

    .randomizer-entry {
        min-height: 38px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        color: rgba(255, 255, 255, 0.74);
        font-size: 13px;
    }

    .control-panel,
    .finish-panel {
        padding: 22px;
    }

    .likert-scale {
        gap: 6px;
    }

    .likert-scale span {
        min-height: 34px;
    }

    .message {
        max-width: min(285px, 100%);
    }

    .finish-cta-row {
        margin-left: 42px;
    }

    .chat-page {
        padding: 8px;
    }

    .phone-device {
        width: min(430px, calc(100vw - 12px));
        height: min(900px, calc(100svh - 12px));
        padding: 7px;
        border-radius: 34px;
        background: #111318;
        box-shadow:
            0 12px 28px rgba(23, 32, 42, 0.22),
            inset 0 0 0 1px rgba(255, 255, 255, 0.12);
    }

    .phone-device::before {
        content: "";
        top: 14px;
        width: 74px;
        height: 5px;
    }

    .chat-shell {
        border-radius: 27px;
    }

    .chat-header {
        padding-top: 24px;
    }
}
.task-intro-page { background: #f4f6f5; color: #18221e; margin: 0; }
.task-intro { max-width: 760px; margin: 0 auto; padding: 32px 24px 48px; }
.task-intro-top { display: flex; justify-content: space-between; gap: 16px; font-size: 15px; }
.task-intro-top a { color: #52645c; }
.task-progress { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 40px 0; }
.task-progress span { border-top: 4px solid #d6dfda; padding-top: 12px; color: #68776f; font-size: 14px; }
.task-progress .is-current, .task-progress .is-done { border-color: #20775b; color: #205e4a; }
.task-reading { min-height: 360px; }
.task-step { color: #52645c; font-size: 14px; }
.task-reading h1 { font-size: 28px; line-height: 1.5; margin: 12px 0 24px; overflow-wrap: anywhere; }
.task-reading p, .task-reading li { font-size: 17px; line-height: 1.9; }
.task-reading p { margin: 18px 0; }
.task-reading ul { padding-left: 24px; }
.task-confirm { border-top: 1px solid #d6dfda; margin-top: 32px; padding-top: 24px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.task-confirm button { background: #20775b; color: white; border: 0; border-radius: 6px; padding: 14px 36px; min-height: 48px; font-size: 18px; cursor: pointer; }
.task-confirm button:focus-visible { outline: 3px solid #ba8422; outline-offset: 4px; }
.task-confirm span { color: #52645c; font-size: 14px; }
@media (max-width: 520px) {
    .task-intro { padding: 24px 20px 32px; }
    .task-progress { margin: 28px 0; gap: 8px; }
    .task-reading { min-height: 0; }
    .task-reading h1 { font-size: 24px; }
    .task-confirm button { width: 100%; }
}
.completion-code { margin: 36px 0; padding: 24px 0; text-align: center; border-top: 1px solid #d6dfda; border-bottom: 1px solid #d6dfda; }
.completion-code p { margin: 0 0 12px; color: #52645c; font-size: 16px; }
.completion-code strong { display: block; font-size: 32px; line-height: 1.5; color: #20775b; overflow-wrap: anywhere; white-space: pre-wrap; }
