:root {
    color-scheme: light;
    --green-900: #075e54;
    --green-800: #0b6f64;
    --green-600: #128c7e;
    --green-500: #25d366;
    --cream: #f6f0e4;
    --ink: #1f2933;
    --muted: #6b7280;
    --line: #d9e2dc;
    --bubble-in: #ffffff;
    --bubble-out: #dcf8c6;
    --danger: #b42318;
    --shadow: 0 18px 50px rgba(16, 24, 40, 0.18);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--ink);
    background:
        linear-gradient(rgba(246, 240, 228, 0.92), rgba(246, 240, 228, 0.92)),
        repeating-linear-gradient(45deg, rgba(7, 94, 84, 0.12) 0 1px, transparent 1px 18px);
}

button,
textarea {
    font: inherit;
}

.chat-shell {
    min-height: 100%;
    display: grid;
    place-items: center;
    padding: 24px;
}

.chat-panel {
    width: min(100%, 860px);
    height: min(880px, calc(100vh - 48px));
    min-height: 620px;
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    overflow: hidden;
    background:
        linear-gradient(rgba(239, 232, 219, 0.94), rgba(239, 232, 219, 0.94)),
        repeating-linear-gradient(135deg, rgba(31, 41, 51, 0.07) 0 1px, transparent 1px 22px);
    border: 1px solid rgba(7, 94, 84, 0.2);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.chat-header {
    min-height: 72px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #ffffff;
    background: linear-gradient(90deg, var(--green-900), var(--green-800));
}

.doctor-avatar {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 50%;
    color: var(--green-900);
    background: #ffffff;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0;
}

.doctor-meta {
    min-width: 0;
    flex: 1;
}

.doctor-meta h1 {
    margin: 0;
    font-size: 18px;
    line-height: 1.2;
    letter-spacing: 0;
}

.doctor-meta p {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0 0;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.84);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green-500);
    box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.22);
}

.clear-button {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
    cursor: pointer;
}

.clear-button:hover {
    background: rgba(255, 255, 255, 0.22);
}

.chat-body {
    overflow-y: auto;
    padding: 22px 18px 18px;
    scroll-behavior: smooth;
}

.message-row {
    display: flex;
    margin: 10px 0;
}

.message-row.user {
    justify-content: flex-end;
}

.message-row.assistant {
    justify-content: flex-start;
}

.bubble {
    width: fit-content;
    max-width: min(78%, 620px);
    padding: 10px 12px 7px;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.12);
    line-height: 1.45;
    font-size: 15px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.message-row.user .bubble {
    background: var(--bubble-out);
    border-top-right-radius: 2px;
}

.message-row.assistant .bubble {
    background: var(--bubble-in);
    border-top-left-radius: 2px;
}

.bubble.error {
    color: var(--danger);
}

.message-time {
    display: block;
    margin-top: 5px;
    text-align: right;
    color: var(--muted);
    font-size: 11px;
}

.typing {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-width: 54px;
}

.typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9ca3af;
    animation: blink 1.2s infinite ease-in-out;
}

.typing span:nth-child(2) {
    animation-delay: 0.16s;
}

.typing span:nth-child(3) {
    animation-delay: 0.32s;
}

@keyframes blink {
    0%, 80%, 100% {
        opacity: 0.35;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-2px);
    }
}

.quick-replies {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 10px 12px;
    border-top: 1px solid rgba(7, 94, 84, 0.13);
    background: rgba(246, 240, 228, 0.9);
}

.quick-replies button {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 7px 12px;
    border: 1px solid rgba(18, 140, 126, 0.35);
    border-radius: 999px;
    color: var(--green-900);
    background: #ffffff;
    font-size: 13px;
    cursor: pointer;
}

.quick-replies button:hover {
    border-color: var(--green-600);
    background: #eefbf2;
}

.composer {
    display: grid;
    grid-template-columns: 1fr 46px;
    gap: 10px;
    align-items: end;
    padding: 12px;
    background: #f0f2f5;
}

.composer textarea {
    width: 100%;
    max-height: 132px;
    min-height: 46px;
    resize: none;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
    outline: none;
    background: #ffffff;
    line-height: 1.35;
}

.composer textarea:focus {
    border-color: var(--green-600);
    box-shadow: 0 0 0 3px rgba(18, 140, 126, 0.12);
}

.send-button {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    color: #ffffff;
    background: var(--green-600);
    cursor: pointer;
}

.send-button:hover {
    background: var(--green-800);
}

.send-button:disabled {
    cursor: wait;
    opacity: 0.65;
}

@media (max-width: 720px) {
    .chat-shell {
        padding: 0;
    }

    .chat-panel {
        width: 100%;
        height: 100vh;
        min-height: 100vh;
        border: 0;
        border-radius: 0;
    }

    .bubble {
        max-width: 88%;
        font-size: 14px;
    }

    .doctor-meta h1 {
        font-size: 16px;
    }
}
