* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: #f4f7fc; color: #0b1a33; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif; }
button, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
[hidden] { display: none !important; }
.calculator-header { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px; flex-shrink: 0; min-height: 66px; padding: 10px 28px; background: #fff; border-bottom: 1px solid #e7edf5; }
.calculator-plan { justify-self: start; display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 8px; font-size: .8rem; font-weight: 500; }
.calculator-plan strong { font-size: .85rem; font-style: italic; font-weight: 800; }
.calculator-plan.is-free { color: #16803d; background: #eaf8ef; }
.calculator-plan.is-paid { color: #9a6100; background: #fff4d9; }
.calculator-plan img { width: 16px; height: 16px; object-fit: contain; }
.calculator-title { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0; font-size: 1.325rem; font-weight: 700; line-height: 1.4; }
.calculator-title-icon { display: grid; place-items: center; width: 36px; height: 36px; color: #006acd; font-size: 1.5rem; }
.calculator-open-link { display: inline-flex; align-items: center; gap: 6px; justify-self: end; color: #69798d; font-size: .9rem; text-decoration: none; white-space: nowrap; }
.calculator-open-link:hover { color: #006acd; }
.calculator-main { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 24px; width: 100%; padding: 32px 24px 16px; }
.calculator-wrapper { display: flex; flex: 1 0 auto; align-items: center; justify-content: center; width: 100%; min-width: 0; }
.chat-card { width: 100%; max-width: 1040px; min-width: 0; padding: 24px; border: 1px solid #e5ebf3; border-radius: 24px; background: #fff; box-shadow: 0 12px 40px rgba(18, 61, 107, .06); }
.chat-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 18px; border-bottom: 1px solid #eef2f8; }
.chat-model { display: flex; align-items: center; gap: 12px; min-width: 0; }
.model-icon { display: grid; place-items: center; flex-shrink: 0; width: 42px; height: 42px; border-radius: 12px; background: #eef4fe; color: #006acd; font-size: 1.35rem; }
.chat-model h2 { margin: 0 0 4px; font-size: 1rem; font-weight: 700; overflow-wrap: anywhere; }
.chat-model p { margin: 0; color: #8895a7; font-size: .75rem; }
.chat-secondary { flex-shrink: 0; min-height: 38px; padding: 8px 12px; border: 1px solid #dce5f0; border-radius: 10px; background: #fff; color: #526278; font-size: .85rem; }
.chat-secondary:hover:not(:disabled) { color: #006acd; background: #eef4fe; border-color: #b6cde8; }
.chat-config-notice { margin: 16px 0 0; padding: 12px 16px; border: 1px solid #f1dfb3; border-radius: 12px; background: #fffaee; color: #8a6722; font-size: .85rem; line-height: 1.7; }
.chat-messages { height: clamp(340px, 50vh, 600px); padding: 24px 8px; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.chat-welcome { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100%; padding: 12px 16px; text-align: center; }
.welcome-icon { display: grid; place-items: center; width: 60px; height: 60px; margin-bottom: 18px; border-radius: 20px; background: #eef4fe; color: #006acd; font-size: 1.8rem; }
.chat-welcome h2 { margin: 0 0 10px; font-size: 1.5rem; font-weight: 700; }
.chat-welcome > p { margin: 0; color: #8895a7; font-size: .9rem; }
.chat-examples { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; width: 100%; max-width: 600px; margin-top: 28px; }
.chat-examples button { position: relative; min-width: 0; padding: 14px 14px 14px 42px; border: 1px solid #e5ebf3; border-radius: 12px; background: #f8faff; color: #315d8d; text-align: left; transition: background .15s, border-color .15s; }
.chat-examples button:hover:not(:disabled) { border-color: #b6cde8; background: #eef4fe; }
.chat-examples button > i { position: absolute; top: 15px; left: 15px; color: #006acd; }
.chat-examples span { display: block; font-size: .85rem; font-weight: 600; }
.chat-examples small { display: block; margin-top: 6px; color: #8895a7; font-size: .72rem; line-height: 1.5; }
.chat-message { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 24px; }
.chat-avatar { display: grid; place-items: center; flex-shrink: 0; width: 32px; height: 32px; border-radius: 10px; color: #006acd; background: #eef4fe; font-size: 1rem; }
.chat-message.user { flex-direction: row-reverse; }
.chat-message.user .chat-avatar { background: #f0f2f5; color: #69798d; }
.chat-message-body { max-width: calc(100% - 46px); min-width: 0; }
.chat-message-role { margin-bottom: 6px; color: #8895a7; font-size: .72rem; }
.chat-message.user .chat-message-role { text-align: right; }
.chat-bubble { padding: 14px 18px; border: 1px solid #eef2f8; border-radius: 0 16px 16px; background: #f8faff; color: #263b55; font-size: .95rem; line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4; }
.chat-message.user .chat-bubble { border-color: #dce8fa; border-radius: 16px 0 16px 16px; background: #eef4fe; color: #204e7e; }
.chat-message.is-error .chat-bubble { background: #fff5f4; border-color: #f2d6d1; color: #a34739; }
.chat-message.is-pending .chat-bubble { color: #69798d; }
.message-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 8px; color: #8895a7; font-size: .72rem; }
.message-action { min-height: 30px; padding: 3px 8px; border: 1px solid #e5ebf3; border-radius: 7px; background: #fff; color: #69798d; font-size: .75rem; }
.message-action:hover:not(:disabled) { color: #006acd; border-color: #b6cde8; }
.message-truncated { margin-top: 8px; color: #9a6100; font-size: .8rem; line-height: 1.7; }
.chat-composer { padding: 14px 16px 12px; border: 1px solid #dce5f0; border-radius: 16px; background: #f8faff; }
.chat-composer:focus-within { border-color: #8ec7ff; box-shadow: 0 0 0 3px #eef4fe; }
.chat-composer textarea { display: block; width: 100%; min-height: 80px; max-height: 220px; padding: 0; resize: vertical; outline: none; border: 0; background: transparent; color: #0b1a33; font-size: .95rem; line-height: 1.8; }
.chat-composer textarea::placeholder { color: #8895a7; }
.composer-footer { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-top: 10px; color: #8895a7; font-size: .75rem; }
.composer-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.chat-send { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 8px 18px; border: 0; border-radius: 10px; background: #006acd; color: #fff; font-size: .875rem; font-weight: 600; }
.chat-send:hover:not(:disabled) { background: #0059b3; }
.chat-status { min-height: 22px; margin-top: 10px; color: #8895a7; font-size: .75rem; line-height: 1.7; text-align: center; }
.chat-status.is-error, #inputCount.is-over { color: #c44838; }
.calculator-tips { flex-shrink: 0; width: 100%; max-width: 1040px; margin-top: auto; padding: 18px 16px 0; border-top: 1px solid #e5ebf3; color: #66758a; font-size: .85rem; line-height: 1.9; }
.calculator-tips h2 { margin: 0 0 6px; color: #526278; font-size: .95rem; font-weight: 600; }
.calculator-tips p { margin: 0; }
.calculator-tips a { color: #006acd; text-decoration: none; }
.calculator-tips a:hover { text-decoration: underline; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
button:focus-visible, a:focus-visible, .chat-messages:focus-visible { outline: 3px solid #8ec7ff; outline-offset: 3px; }
@media (max-width: 767.98px) {
    .calculator-header { padding: 8px 16px; gap: 10px; }
    .calculator-plan { padding: 5px 8px; font-size: .72rem; }
    .calculator-title { gap: 7px; font-size: 1.175rem; }
    .calculator-title-icon { width: 32px; height: 32px; font-size: 1.3rem; }
    .calculator-open-link { font-size: .8rem; }
    .calculator-main { padding: 24px 16px 16px; gap: 20px; }
    .chat-card { padding: 18px 16px; border-radius: 22px; }
    .calculator-tips { padding: 16px 0 0; font-size: .8rem; }
}
@media (max-width: 575.98px) {
    .calculator-header { grid-template-columns: minmax(0, 1fr) auto; }
    .calculator-title { grid-column: 1 / -1; grid-row: 1; }
    .calculator-plan { grid-column: 1; grid-row: 2; }
    .calculator-open-link { grid-column: 2; grid-row: 2; }
    .chat-toolbar { gap: 8px; }
    .chat-model { gap: 8px; }
    .model-icon { width: 34px; height: 34px; font-size: 1.15rem; }
    .chat-model h2 { font-size: .9rem; }
    .chat-secondary { padding: 7px 9px; font-size: .75rem; }
    .chat-messages { height: clamp(340px, 48vh, 520px); padding: 20px 0; }
    .chat-welcome { padding: 8px 0; }
    .chat-welcome h2 { font-size: 1.25rem; }
    .welcome-icon { width: 48px; height: 48px; margin-bottom: 14px; font-size: 1.5rem; }
    .chat-examples { gap: 8px; margin-top: 18px; }
    .chat-examples button { padding: 12px 8px; }
    .chat-examples button > i { position: static; display: block; margin-bottom: 6px; }
    .chat-examples small { display: none; }
    .chat-examples span { font-size: .8rem; }
    .chat-bubble { padding: 10px 12px; font-size: .9rem; }
    .chat-composer { padding: 12px; }
    .chat-composer textarea { font-size: 16px; }
    .composer-footer { font-size: .68rem; }
    .composer-actions { gap: 8px; }
    .chat-send { padding: 8px 12px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
