:root {
    color-scheme: light;
    font-family: Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: #f3f5f7;
    color: #17212b;
}

main {
    width: min(920px, calc(100% - 32px));
    margin: 48px auto;
}

.card {
    padding: 28px;
    border: 1px solid #dce2e8;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 12px 32px rgba(23, 33, 43, .08);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.chat-title { margin: 0; line-height: 1.1; }
.chat-title-main { font-size: clamp(1.8rem, 4vw, 2.4rem); font-weight: 600; }
.chat-title-sub { margin-left: .35rem; color: #66717d; font-size: 1rem; font-weight: 400; }
.chat-title-icon { width: 24px; height: 24px; margin-left: 2px; vertical-align: middle; object-fit: contain; }
.chat-disclaimer { margin: .45rem 0 0; color: #6b7785; font-size: .9rem; line-height: 1.35; }
.chat-header-aside { display: flex; align-items: center; align-self: flex-start; gap: 12px; flex-shrink: 0; }
.chat-robot { width: 56px; height: 56px; object-fit: contain; display: block; }

.language-switch {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border: 1px solid #d4dce5;
    border-radius: 999px;
    background: #f2f5f8;
}

.language-switch a {
    min-width: 34px;
    padding: 8px 9px;
    border-radius: 999px;
    color: #66717d;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    text-transform: uppercase;
}

.language-switch a:hover { color: #0759ab; background: #e6edf5; }
.language-switch a[aria-current="page"] { color: #0759ab; background: #fff; box-shadow: 0 1px 3px rgba(23, 33, 43, .12); }
.language-switch a:focus-visible { outline: 3px solid rgba(0, 112, 243, .25); outline-offset: 2px; }

.help-tooltip { position: relative; display: inline-flex; }
.help-button {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    border: 1px solid #d4dce5;
    border-radius: 999px;
    background: #f2f5f8;
    color: #3d4b59;
    cursor: help;
    font-size: 16px;
}

.help-tooltip:hover .tooltip-content,
.help-tooltip:focus-within .tooltip-content {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

.tooltip-content {
    position: absolute;
    z-index: 2;
    top: calc(100% + 9px);
    right: 0;
    width: min(300px, calc(100vw - 64px));
    padding: 12px;
    border: 1px solid #d4dce5;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(23, 33, 43, .14);
    color: #3d4b59;
    font-size: .88rem;
    line-height: 1.45;
    visibility: hidden;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity .15s ease, transform .15s ease;
}

label { display: block; margin-bottom: 8px; font-weight: 700; }

textarea {
    width: 100%;
    min-height: 130px;
    padding: 14px;
    resize: vertical;
    border: 1px solid #b8c2cc;
    border-radius: 10px;
    font: inherit;
    line-height: 1.5;
}

textarea:focus { outline: 3px solid rgba(0, 112, 243, .18); border-color: #0070f3; }

button {
    margin-top: 14px;
    padding: 12px 20px;
    border: 0;
    border-radius: 10px;
    background: #0069d9;
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

button:hover { background: #0057b7; }
button:disabled { background: #7d8c9c; cursor: wait; }
.cf-turnstile { margin-top: 14px; }

.processing-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 14px 0 0;
    color: #7b8794;
    font-size: .85rem;
}

.processing-status[hidden] { display: none; }
.processing-spinner { width: 14px; height: 14px; border: 2px solid #d8dee5; border-top-color: #8b96a3; border-radius: 50%; animation: processing-spin .8s linear infinite; }
@keyframes processing-spin { to { transform: rotate(360deg); } }

section { margin-top: 24px; }
h2 { margin: 0 0 10px; font-size: 1.15rem; }
.chat-actions { display: flex; justify-content: flex-end; margin: -8px 0 18px; }
.secondary-button { margin: 0; padding: 8px 12px; border: 1px solid #c7d9ed; background: #eff5fc; color: #0759ab; }
.secondary-button:hover { background: #dceeff; }
.chat-history { display: grid; gap: 18px; margin: 24px 0; }
.chat-message { padding: 18px; border: 1px solid #dce2e8; border-radius: 12px; }
.chat-message-user { margin-left: 8%; border-color: #c7dff7; background: #eef6ff; }
.chat-message-assistant { margin-right: 4%; background: #fff; }
.message-label { margin-bottom: 10px; color: #52606d; font-size: .85rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.user-message-text { margin: 0; white-space: pre-wrap; line-height: 1.6; }
.result-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.copy-button { display: inline-grid; place-items: center; width: 40px; height: 40px; margin: 0; padding: 0; border: 1px solid #c7d9ed; border-radius: 9px; background: #eff5fc; color: #0759ab; }
.copy-button:hover, .copy-button.copied { background: #dceeff; }
.copy-button svg { width: 20px; height: 20px; }
.copy-feedback { margin: 0; color: #237245; font-size: .88rem; }
.answer-rating { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 16px; color: #6b7785; font-size: .85rem; }
.answer-rating .secondary-button { padding: 5px 10px; font-size: .85rem; font-weight: 400; }
.copy-source { position: fixed; top: 0; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.markdown-output { line-height: 1.6; }
.markdown-output h1, .markdown-output h2, .markdown-output h3, .markdown-output h4, .markdown-output h5, .markdown-output h6 { margin: 24px 0 10px; line-height: 1.25; }
.markdown-output h1:first-child, .markdown-output h2:first-child, .markdown-output h3:first-child { margin-top: 0; }
.markdown-output p { margin: 0 0 14px; }
.markdown-output ul, .markdown-output ol { margin: 0 0 14px; padding-left: 24px; }
.markdown-output a { color: #0069d9; overflow-wrap: anywhere; }
.markdown-output code { padding: 2px 5px; border-radius: 4px; background: #edf1f5; font: .9em ui-monospace, SFMono-Regular, Consolas, monospace; }
.markdown-output pre { margin: 0 0 14px; padding: 18px; overflow: auto; border-radius: 10px; background: #0f1720; color: #e8eef4; white-space: pre-wrap; word-break: break-word; font: 14px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; }
.markdown-output pre code { padding: 0; background: none; color: inherit; font: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.error { padding: 14px 16px; border: 1px solid #f1a8a8; border-radius: 10px; background: #fff1f1; color: #8d1d1d; }
.notice { padding: 12px 14px; border: 1px solid #9ed2b3; border-radius: 10px; background: #f0fbf4; color: #1f6a3c; }
.meta { margin-top: 12px; color: #6b7785; font-size: .88rem; }

@media (max-width: 620px) {
    main { width: min(100% - 20px, 920px); margin: 20px auto; }
    .card { padding: 20px; }
    .chat-header { flex-wrap: wrap; }
    .chat-header-aside { order: -1; width: 100%; justify-content: flex-end; }
    .chat-message-user, .chat-message-assistant { margin-right: 0; margin-left: 0; }
}
