:root {
  color-scheme: light;
  --ink: #151b48;
  --muted: #7c86a6;
  --soft: #a8b0c8;
  --line: #dfe4f3;
  --page: #e9edfc;
  --panel: #ffffff;
  --indigo: #465de0;
  --indigo-dark: #2a3db3;
  --lavender: #e5e9ff;
  --mint-soft: #e3f5f0;
  --warm-soft: #fff1d9;
  --shadow: 0 18px 44px rgba(43, 56, 116, 0.1);
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.58; }
a { color: inherit; text-decoration: none; }

.web-app { width: min(1480px, 100%); min-height: 100vh; margin: 0 auto; padding: 0 28px 34px; }
.site-header {
  min-height: 76px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  border-bottom: 1px solid rgba(208, 215, 237, 0.94);
}
.brand-mark { display: inline-flex; align-items: center; gap: 11px; width: fit-content; }
.brand-symbol {
  width: 42px; height: 42px; display: grid; place-items: center; border-radius: 8px;
  color: #fff; background: var(--indigo); font-size: 20px; font-weight: 900;
  box-shadow: 0 9px 18px rgba(70, 93, 224, 0.24);
}
.brand-copy strong, .brand-copy small { display: block; }
.brand-copy strong { font-size: 19px; }
.brand-copy small { margin-top: 2px; color: var(--muted); font-size: 12px; }
.top-nav { display: flex; justify-content: center; gap: 8px; }
.top-nav a { min-height: 38px; display: inline-flex; align-items: center; padding: 0 15px; border-radius: 7px; color: var(--muted); font-size: 14px; font-weight: 700; }
.top-nav a.active, .top-nav a:hover { color: var(--indigo-dark); background: rgba(255, 255, 255, 0.72); }
.header-actions { display: flex; align-items: center; gap: 10px; }
.history-toggle { display: none; min-height: 38px; border: 1px solid var(--line); border-radius: 8px; padding: 0 13px; color: var(--indigo-dark); background: rgba(255, 255, 255, 0.78); font-weight: 800; }
.solid-button, .ghost-button { min-height: 42px; border: 0; border-radius: 8px; padding: 0 18px; font-weight: 800; transition: transform 0.18s ease, box-shadow 0.18s ease; }
.solid-button:hover, .ghost-button:hover, .send-button:hover, .upload-button:hover { transform: translateY(-1px); }
.solid-button { color: #fff; background: var(--indigo); box-shadow: 0 12px 24px rgba(70, 93, 224, 0.22); }
.solid-button.small { min-height: 38px; padding: 0 16px; }
.solid-button.wide { width: 100%; }
.ghost-button { min-height: 38px; border: 1px solid var(--line); color: var(--ink); background: rgba(255, 255, 255, 0.72); }

.workspace-shell { display: grid; grid-template-columns: 244px minmax(0, 1fr); gap: 28px; align-items: start; }
.history-sidebar { position: sticky; top: 94px; min-height: calc(100vh - 126px); padding: 6px 0 20px; }
.history-sidebar-head { min-height: 42px; display: flex; align-items: center; justify-content: space-between; padding: 0 8px; }
.history-sidebar-head strong { font-size: 17px; }
.history-close { display: none; width: 34px; height: 34px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; font-size: 22px; }
.new-conversation-button { width: 100%; min-height: 48px; display: flex; align-items: center; gap: 9px; margin-top: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 0 14px; color: var(--indigo-dark); background: rgba(255, 255, 255, 0.88); box-shadow: 0 10px 26px rgba(47, 58, 112, 0.06); font-weight: 820; text-align: left; }
.new-conversation-button span { font-size: 20px; font-weight: 500; }
.history-section-label { margin: 25px 9px 10px; color: var(--soft); font-size: 12px; font-weight: 760; }
.conversation-list { display: grid; gap: 5px; }
.conversation-list-empty { margin: 0; padding: 14px 10px; color: var(--soft); font-size: 12px; line-height: 1.65; }
.conversation-list-item { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) 34px; align-items: center; border-radius: 8px; }
.conversation-list-item:hover, .conversation-list-item.active { background: rgba(255, 255, 255, 0.72); }
.conversation-open { min-width: 0; min-height: 54px; display: grid; gap: 3px; align-content: center; border: 0; padding: 7px 7px 7px 11px; color: var(--ink); background: transparent; text-align: left; }
.conversation-open strong { overflow: hidden; font-size: 13px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.conversation-open small { color: var(--soft); font-size: 11px; }
.conversation-delete { width: 30px; height: 30px; border: 0; border-radius: 7px; color: var(--soft); background: transparent; font-size: 17px; }
.conversation-delete:hover { color: #b33c55; background: #fff0f3; }
.history-scrim { display: none; }
.conversation-shell { width: min(1080px, 100%); min-width: 0; min-height: calc(100vh - 111px); margin: 0 auto; padding-top: clamp(34px, 8vh, 108px); }
.home-stage { min-height: 286px; display: flex; align-items: center; justify-content: center; gap: 40px; padding: 0 22px 26px; }
.home-mascot { width: min(250px, 26vw); height: 276px; object-fit: contain; filter: drop-shadow(0 18px 18px rgba(47, 57, 112, 0.12)); }
.home-stage h1 { margin: 0; color: var(--ink); font-size: clamp(40px, 5.3vw, 66px); line-height: 1.13; letter-spacing: 0; }
.home-stage h1 span { color: var(--indigo); }
.home-stage p { margin: 19px 0 0; color: var(--muted); font-size: clamp(16px, 1.8vw, 21px); }

.prompt-panel { position: relative; z-index: 2; overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.88); border-radius: 8px; background: var(--panel); box-shadow: var(--shadow); }
.prompt-tabs { min-height: 76px; display: flex; align-items: end; padding: 0 20px; background: #f7f8fd; }
.prompt-tabs span { min-height: 76px; display: inline-flex; align-items: center; gap: 10px; padding: 0 18px; border-radius: 8px 8px 0 0; color: var(--indigo-dark); background: #fff; font-size: 18px; font-weight: 850; }
.prompt-tabs i { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--indigo); font-size: 13px; font-style: normal; }
.prompt-textarea-wrap { position: relative; min-height: 154px; padding: 21px 22px 8px; }
.prompt-textarea-wrap textarea { width: 100%; min-height: 108px; resize: vertical; border: 0; outline: 0; padding: 8px 0; color: var(--ink); background: transparent; font-size: 18px; line-height: 1.65; }
.prompt-textarea-wrap textarea::placeholder { color: #a5afc8; }
.prompt-actions { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 20px 16px; }
.prompt-hint { color: var(--soft); font-size: 13px; }
.prompt-buttons { display: flex; align-items: center; gap: 10px; }
.upload-button { min-height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 0 14px; color: var(--indigo-dark); background: #fff; font-weight: 760; transition: transform 0.18s ease; }
.send-button { min-height: 42px; display: inline-flex; align-items: center; gap: 12px; border: 0; border-radius: 8px; padding: 0 14px 0 17px; color: #fff; background: var(--indigo); box-shadow: 0 10px 20px rgba(70, 93, 224, 0.2); font-weight: 850; transition: transform 0.18s ease; }
.send-button > span:last-child { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 7px; color: var(--indigo); background: #fff; font-size: 16px; }
.attachment-preview { max-width: 380px; display: grid; grid-template-columns: 52px minmax(0, 1fr) 28px; align-items: center; gap: 10px; margin: 2px 0 8px; border: 1px solid var(--line); border-radius: 8px; padding: 7px; background: #f7f8fd; }
.attachment-preview img { width: 52px; height: 52px; border-radius: 6px; object-fit: cover; background: var(--lavender); }
.attachment-preview span { min-width: 0; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.attachment-preview button { width: 28px; height: 28px; border: 0; border-radius: 7px; color: var(--muted); background: #fff; font-size: 18px; }

.chat-history { display: none; width: min(100%, 1010px); margin: 0 auto 20px; }
.chat-session-label { margin-bottom: 19px; color: var(--indigo-dark); text-align: center; font-size: 18px; font-weight: 780; }
.chat-stream { min-height: 420px; padding: 0; }
.chat-time { margin: 0 0 20px; color: var(--soft); text-align: center; font-size: 12px; }
.message { max-width: 100%; margin: 0 auto 18px; line-height: 1.8; overflow-wrap: anywhere; word-break: break-word; }
.message p { margin: 0; }
.bot-message { padding: 26px 28px; border: 1px solid rgba(255, 255, 255, 0.84); border-radius: 8px; color: #202858; background: rgba(255, 255, 255, 0.88); box-shadow: 0 16px 35px rgba(47, 58, 112, 0.07); font-size: 17px; }
.assistant-copy p + p { margin-top: 12px; }
.assistant-copy h3 { margin: 20px 0 8px; font-size: 19px; line-height: 1.45; }
.assistant-copy h3:first-child { margin-top: 0; }
.assistant-copy ul, .assistant-copy ol { margin: 10px 0; padding-left: 24px; }
.assistant-copy li + li { margin-top: 7px; }
.assistant-copy strong { color: #111944; font-weight: 850; }
.assistant-copy code { border-radius: 4px; padding: 2px 5px; background: #eef1fb; font-family: Consolas, monospace; font-size: 0.92em; }
.user-message { max-width: min(90%, 760px); margin-bottom: 25px; color: #1b2360; text-align: center; font-size: 19px; font-weight: 720; }
.user-message .message-image { display: block; width: min(100%, 360px); max-height: 340px; margin: 13px auto 0; border: 1px solid var(--line); border-radius: 8px; object-fit: contain; background: #fff; }
.ai-note { display: block; margin-top: 18px; color: #aab2c8; font-size: 12px; }
.chart-preview { display: block; width: 100%; max-height: 780px; margin-top: 16px; border: 1px solid var(--line); border-radius: 7px; object-fit: contain; background: #fff; }
.conversation-shell.has-conversation { padding-top: 30px; }
.has-conversation .home-stage { display: none; }
.has-conversation .chat-history { display: block; }
.has-conversation .prompt-panel { position: sticky; bottom: 18px; }
.has-conversation .prompt-tabs { min-height: 55px; }
.has-conversation .prompt-tabs span { min-height: 55px; font-size: 15px; }
.has-conversation .prompt-textarea-wrap { min-height: 91px; padding-top: 11px; }
.has-conversation .prompt-textarea-wrap textarea { min-height: 55px; font-size: 16px; }
.has-conversation .prompt-actions { min-height: 48px; padding-top: 3px; }
.has-conversation .send-label { display: none; }
.has-conversation .send-button { min-width: 42px; padding: 0 9px; }

.page-boundary { margin: 22px 0 0; padding: 0 12px; color: var(--soft); text-align: center; font-size: 12px; line-height: 1.7; }

.modal-backdrop { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 18px; background: rgba(26, 29, 55, 0.48); backdrop-filter: blur(10px); }
.modal-backdrop.hidden, .hidden { display: none !important; }
.modal-card { width: min(100%, 490px); max-height: calc(100vh - 36px); overflow-y: auto; padding: 28px; border: 1px solid rgba(255, 255, 255, 0.65); border-radius: 8px; color: var(--ink); background: #fff; box-shadow: 0 28px 70px rgba(24, 27, 57, 0.23); }
.auth-card { width: min(100%, 620px); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.modal-kicker { min-height: 27px; display: inline-flex; align-items: center; border-radius: 7px; padding: 0 9px; color: var(--indigo); background: var(--lavender); font-size: 12px; font-weight: 850; }
.modal-card h2 { margin: 13px 0 10px; font-size: 26px; }
.modal-card p { margin: 0; color: var(--muted); line-height: 1.7; }
.risk-list { margin: 16px 0 22px; padding-left: 20px; color: #606884; line-height: 1.72; }
.icon-close { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #f6f7fb; font-size: 20px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 18px 0; }
.auth-tabs button { min-height: 40px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: #f6f7fb; font-weight: 850; }
.auth-tabs button.active { color: #fff; background: var(--indigo); }
.auth-form { display: grid; gap: 13px; }
.auth-form > label, .registration-profile label { min-width: 0; display: grid; gap: 6px; color: #68708d; font-size: 12px; font-weight: 750; }
.auth-form input, .auth-form select { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; outline: none; padding: 0 12px; color: var(--ink); background: #f8f9fc; }
.auth-form input:focus, .auth-form select:focus { border-color: rgba(70, 93, 224, 0.55); box-shadow: 0 0 0 3px rgba(70, 93, 224, 0.1); }
.auth-form > .agreement-check { display: flex; align-items: flex-start; gap: 9px; color: var(--muted); line-height: 1.6; }
.auth-form .agreement-check input { flex: 0 0 17px; width: 17px; min-height: 17px; margin: 2px 0 0; padding: 0; accent-color: var(--indigo); }
.agreement-check a { color: var(--indigo-dark); font-weight: 800; }
.registration-profile { display: grid; gap: 13px; margin: 4px 0 1px; border: 1px solid #e1e4f1; border-radius: 8px; padding: 15px; background: #fbfbfe; }
.registration-profile legend { padding: 0 5px; color: var(--ink); font-size: 14px; font-weight: 850; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 5px; border: 1px solid var(--line); border-radius: 8px; background: #f3f4f9; }
.segmented label { min-height: 36px; display: grid; place-items: center; border-radius: 6px; color: var(--muted); font-size: 13px; font-weight: 800; }
.segmented input { display: none; }
.segmented label:has(input:checked) { color: var(--indigo-dark); background: #fff; box-shadow: 0 5px 14px rgba(45, 53, 96, 0.08); }
.registration-grid { display: grid; gap: 9px; }
.birth-date-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.region-grid { grid-template-columns: 1fr 1fr; }
.region-grid label:last-child { grid-column: 1 / -1; }
.region-heading { margin-bottom: -4px; color: #4f5775; font-size: 12px; font-weight: 850; }
.solar-hint { padding: 10px 11px; border-radius: 7px; color: #277666; background: var(--mint-soft); font-size: 12px; line-height: 1.55; }
.longitude-field { display: grid; gap: 6px; color: #68708d; font-size: 12px; font-weight: 750; }
.auth-hint { font-size: 12px; }
.site-footer { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 18px; border-top: 1px solid rgba(208, 215, 237, 0.94); padding: 22px 8px 0; color: var(--soft); font-size: 12px; }
.site-footer nav { display: flex; gap: 18px; }
.site-footer a:hover { color: var(--indigo-dark); }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translateX(-50%); max-width: min(92vw, 460px); padding: 11px 15px; border-radius: 8px; color: #fff; background: rgba(31, 35, 69, 0.94); box-shadow: 0 14px 30px rgba(27, 31, 66, 0.22); }

@media (max-width: 780px) {
  .web-app { padding: 0 12px 24px; }
  .site-header { min-height: 64px; grid-template-columns: 1fr auto; }
  .top-nav, .brand-copy small, .ghost-button { display: none; }
  .conversation-shell { min-height: calc(100vh - 88px); padding-top: 54px; }
  .home-stage { min-height: 225px; gap: 6px; padding: 0 6px 20px; }
  .home-mascot { width: 116px; height: 176px; }
  .home-stage h1 { font-size: 33px; }
  .home-stage p { margin-top: 12px; font-size: 14px; line-height: 1.65; }
  .prompt-tabs { min-height: 58px; padding-inline: 10px; }
  .prompt-tabs span { min-height: 58px; padding-inline: 13px; font-size: 15px; }
  .prompt-textarea-wrap { min-height: 138px; padding: 15px 16px 4px; }
  .prompt-textarea-wrap textarea { min-height: 100px; font-size: 16px; }
  .prompt-actions { align-items: flex-end; padding: 9px 14px 13px; }
  .prompt-hint { max-width: 130px; font-size: 11px; line-height: 1.45; }
  .upload-button { min-height: 38px; padding: 0 10px; font-size: 12px; }
  .send-button { min-height: 38px; gap: 6px; padding: 0 9px 0 12px; font-size: 12px; }
  .send-button > span:last-child { width: 20px; height: 20px; border-radius: 6px; }
  .chat-history { margin-bottom: 14px; }
  .chat-stream { min-height: 360px; }
  .bot-message { padding: 19px 18px; font-size: 16px; }
  .user-message { max-width: 94%; font-size: 16px; }
  .has-conversation .prompt-panel { bottom: 10px; }
  .has-conversation .prompt-hint { display: none; }
  .modal-card { padding: 22px; }
  .auth-card { max-height: calc(100vh - 24px); }
  .site-footer { align-items: flex-start; flex-direction: column; gap: 10px; padding-inline: 4px; }
}

@media (max-width: 980px) {
  .workspace-shell { display: block; }
  .history-toggle { display: inline-flex; align-items: center; }
  .history-sidebar { position: fixed; z-index: 26; top: 0; bottom: 0; left: 0; width: min(86vw, 310px); min-height: 100vh; overflow-y: auto; padding: 18px 14px; background: #f5f7ff; box-shadow: 24px 0 60px rgba(30, 37, 84, 0.18); transform: translateX(-105%); transition: transform 0.2s ease; }
  .history-sidebar.open { transform: translateX(0); }
  .history-close { display: grid; place-items: center; }
  .history-scrim { position: fixed; z-index: 25; inset: 0; border: 0; background: rgba(25, 29, 55, 0.35); opacity: 0; pointer-events: none; transition: opacity 0.2s ease; }
  .history-scrim.open { display: block; opacity: 1; pointer-events: auto; }
}

@media (max-width: 460px) {
  .brand-symbol { width: 38px; height: 38px; }
  .brand-copy strong { font-size: 17px; }
  .solid-button.small { min-height: 36px; padding-inline: 13px; }
  .conversation-shell { padding-top: 37px; }
  .home-stage { align-items: center; }
  .home-mascot { width: 94px; height: 154px; }
  .home-stage h1 { font-size: 29px; }
  .birth-date-grid { grid-template-columns: 1fr 1fr; }
  .registration-profile { padding: 12px; }
}
