:root {
    --bg: #f5f6fb;
    --card-bg: #ffffff;
    --primary: #2f6fec;
    --primary-hover: #1f55c8;
    --secondary: #f4f6fb;
    --text: #1f2a44;
    --muted: #6c7a99;
    --border: #dfe4f2;
    --danger: #d64545;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app {
    width: 100%;
    max-width: 960px;
    padding: 24px;
}

.screen {
    display: none;
    background: var(--card-bg);
    border-radius: 18px;
    padding: 32px;
    min-height: 640px;
    position: relative;
    box-shadow: 0 12px 30px rgba(31, 42, 68, 0.08);
}

.screen.active {
    display: flex;
    flex-direction: column;
}

.intro-card,
.finish-card {
    margin: auto;
    text-align: center;
    max-width: 420px;
}

.intro-card h1 {
    margin-bottom: 12px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
    margin: 24px 0 12px;
    color: var(--muted);
}

.field input {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: 15px;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
    cursor: pointer;
    border: none;
    border-radius: 999px;
    padding: 12px 28px;
    font-size: 15px;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.primary-btn {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 8px 20px rgba(47, 111, 236, 0.35);
}

.primary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

.primary-btn:not(:disabled):hover {
    background: var(--primary-hover);
}

.secondary-btn {
    background: #fff;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.ghost-btn {
    background: transparent;
    color: var(--primary);
}

.status-text {
    min-height: 20px;
    margin-top: 16px;
    color: var(--danger);
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
    margin-bottom: 16px;
    gap: 12px;
}

.chat-subtitle {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.chat-log {
    flex: 1;
    background: var(--secondary);
    border-radius: 16px;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 420px;
    max-height: 560px;
}

.message {
    background: #fff;
    border-radius: 12px;
    padding: 12px 16px;
    border: 1px solid var(--border);
}

.message .meta {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 8px;
}

.message .body {
    line-height: 1.46;
    white-space: pre-wrap;
}

.chat-input-area {
    margin-top: 24px;
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 12px;
    align-items: stretch;
}

.chat-input-area textarea {
    flex: 1;
    resize: none;
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 12px 14px;
    font-size: 15px;
    min-height: 85px;
}

.voice-btn,
.send-btn {
    background: #c084fc;
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 0 18px;
    font-size: 15px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 10px 20px rgba(192, 132, 252, 0.35);
}

.voice-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.voice-btn.active {
    background: #7c3aed;
}

.send-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    box-shadow: none;
}

.send-btn:not(:disabled):hover {
    transform: translateY(-1px);
}

.session-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.session-tags span {
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--secondary);
    font-size: 13px;
    color: var(--muted);
}

.finish-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    gap: 16px;
    margin: 32px 0;
}

.select-card {
    border-radius: 16px;
    border: 1px solid var(--border);
    padding: 28px 16px;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
    transition: border 0.2s, box-shadow 0.2s, transform 0.2s;
}

.select-card:hover {
    border-color: var(--primary);
    box-shadow: 0 10px 24px rgba(47, 111, 236, 0.15);
    transform: translateY(-2px);
}

.select-card.selected {
    border-color: var(--primary);
    background: rgba(47, 111, 236, 0.08);
}

.option-title {
    font-size: 18px;
    font-weight: 600;
}

.option-desc {
    font-size: 14px;
    color: var(--muted);
}

@media (max-width: 720px) {
    .screen {
        padding: 24px;
    }

    .chat-input-area {
        grid-template-columns: 1fr;
        grid-auto-rows: auto;
    }

    .finish-options {
        grid-template-columns: 1fr;
    }

    .end-btn {
        position: static;
        margin-top: 16px;
        align-self: flex-end;
    }
}
.end-row {
    margin-top: 24px;
    display: flex;
    justify-content: center;
}

#end-conversation-btn {
    padding: 12px 30px;
}

.message.thinking {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-style: italic;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(124, 58, 237, 0.2);
    border-top-color: #7c3aed;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}
