:root {
  color-scheme: light;
  --ink: #17313a;
  --muted: #668087;
  --line: #dce8e8;
  --surface: #ffffff;
  --surface-soft: #f5faf9;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --accent-pale: #d9f2ee;
  --warning: #a15c12;
  --danger: #a14343;
  --shadow: 0 18px 45px rgba(30, 70, 75, 0.12);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  background: #eef5f4;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-shell { display: flex; height: 100dvh; overflow: hidden; }
.sidebar {
  width: 276px;
  flex: 0 0 276px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 28px 22px 20px;
  background: #12363c;
  color: #edfafa;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 10px; background: #d9f2ee; color: #0b5f59;
  font-weight: 800; font-size: 21px;
}
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: 0; }
.brand-subtitle { color: #a8c7c8; font-size: 12px; margin-top: 1px; }
.status-panel, .side-note { border: 1px solid rgba(217,242,238,.18); border-radius: 10px; padding: 16px; background: rgba(255,255,255,.055); }
.panel-label { color: #9fc2c3; font-size: 12px; font-weight: 700; letter-spacing: .04em; margin-bottom: 11px; }
.status-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 9px; font-size: 13px; }
.status-row.muted { color: #b6cece; }
.status-row strong { color: #effafa; font-weight: 600; text-align: right; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #f2b45d; box-shadow: 0 0 0 4px rgba(242,180,93,.13); margin-right: 4px; }
.status-dot.ready { background: #66d3a6; box-shadow: 0 0 0 4px rgba(102,211,166,.14); }
.status-dot.offline { background: #e67a7a; box-shadow: 0 0 0 4px rgba(230,122,122,.14); }
.status-row:first-of-type { justify-content: flex-start; }
.side-note p { margin: 7px 0 0; color: #c3d8d8; font-size: 12px; line-height: 1.65; }
.side-footer { margin-top: auto; display: grid; gap: 5px; color: #85aaab; font-size: 11px; line-height: 1.55; }

.main-panel { min-width: 0; height: 100%; flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--surface); }
.topbar { height: 76px; flex: 0 0 76px; display: flex; align-items: center; gap: 14px; padding: 0 34px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 8px; color: var(--accent-dark); background: #fff; font-size: 18px; line-height: 1; }
.icon-button:hover { background: var(--surface-soft); }
.topbar-title { display: flex; flex-direction: column; min-width: 0; }
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.topbar-heading { font-size: 18px; font-weight: 700; line-height: 1.3; }
.topbar-actions { min-width: 0; margin-left: auto; display: flex; gap: 8px; }
.quiet-button { border: 1px solid var(--line); border-radius: 7px; background: #fff; color: #38616a; padding: 7px 12px; font-size: 12px; }
.quiet-button:hover { border-color: #9fc9c5; background: var(--surface-soft); }
.quiet-button.danger { color: var(--danger); }
.content-area { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.login-view { flex: 1; min-height: 0; display: grid; place-items: center; padding: 42px 20px; overflow-y: auto; background: linear-gradient(135deg, #f8fcfb 0%, #edf7f5 100%); }
.login-card { width: min(100%, 440px); padding: 38px 40px 32px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.login-kicker { color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .1em; }
.login-card h1 { margin: 7px 0 9px; font-size: 26px; line-height: 1.25; }
.login-intro { margin: 0 0 25px; color: var(--muted); font-size: 13px; }
.field-label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 700; }
.password-wrap { position: relative; }
.password-wrap input { width: 100%; height: 44px; padding: 0 62px 0 13px; border: 1px solid #c9dada; border-radius: 7px; outline: none; color: var(--ink); background: #fbfdfd; }
.password-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15,118,110,.12); }
.show-password { position: absolute; top: 0; right: 0; height: 44px; padding: 0 12px; border: 0; background: transparent; color: var(--accent); font-size: 12px; }
.primary-button { width: 100%; height: 44px; margin-top: 17px; border: 0; border-radius: 7px; background: var(--accent); color: #fff; font-weight: 700; }
.primary-button:hover, .send-button:hover { background: var(--accent-dark); }
.form-error { min-height: 22px; padding-top: 8px; color: var(--danger); font-size: 12px; }
.login-footnote { display: flex; align-items: center; gap: 7px; margin-top: 15px; padding-top: 15px; border-top: 1px solid #edf2f2; color: #7a9296; font-size: 11px; }
.lock-icon { color: var(--accent); font-size: 13px; }

.chat-view { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.conversation { flex: 1; overflow: auto; padding: 30px max(22px, calc((100% - 940px) / 2)); }
.welcome { max-width: 680px; margin: 8vh auto 0; padding: 26px 28px; border: 1px solid #d7ebe7; border-radius: 12px; background: #f7fcfb; }
.welcome h2 { margin: 0 0 8px; font-size: 21px; }
.welcome p { margin: 0; color: var(--muted); font-size: 13px; }
.message { display: flex; gap: 12px; max-width: 860px; margin: 0 auto 23px; }
.message.user { flex-direction: row-reverse; }
.avatar { width: 32px; height: 32px; flex: 0 0 32px; display: grid; place-items: center; border-radius: 8px; font-size: 13px; font-weight: 800; }
.message.assistant .avatar { background: var(--accent-pale); color: var(--accent-dark); }
.message.user .avatar { background: #e8edf0; color: #48636a; }
.message-body { min-width: 0; max-width: calc(100% - 44px); }
.message-meta { margin-bottom: 5px; color: #7c9397; font-size: 11px; }
.message.user .message-meta { text-align: right; }
.bubble { padding: 12px 15px; border: 1px solid #dce8e8; border-radius: 10px; background: #fff; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.message.user .bubble { border-color: #c5e6e1; background: #effaf8; }
.answer-summary { margin-top: 10px; padding: 11px 13px; border-left: 3px solid var(--accent); border-radius: 6px; background: #f3faf8; }
.summary-title { margin-bottom: 4px; color: var(--accent-dark); font-size: 12px; font-weight: 800; }
.summary-text { color: #31585a; font-size: 12px; line-height: 1.65; overflow-wrap: anywhere; }
.analysis-summary { margin: 0 0 10px; border: 1px solid #dce8e8; border-radius: 9px; background: #fbfdfd; overflow: hidden; }
.analysis-summary > summary { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; min-height: 38px; padding: 8px 12px; color: var(--accent-dark); cursor: pointer; list-style: none; outline-offset: 2px; font-size: 12px; font-weight: 750; }
.analysis-summary > summary::-webkit-details-marker { display: none; }
.analysis-summary > summary::marker { content: ""; }
.analysis-summary > summary::after { content: "⌄"; margin-left: 0; color: #7c9899; font-size: 15px; line-height: 1; transition: transform .16s ease; }
.analysis-summary[open] > summary { border-bottom: 1px solid #e8f0ef; background: #f8fcfb; }
.analysis-summary[open] > summary::after { transform: rotate(180deg); }
.analysis-title { min-width: 0; overflow-wrap: anywhere; }
.analysis-duration { margin-left: auto; color: #789294; font-size: 11px; font-weight: 500; white-space: nowrap; }
.analysis-steps-complete { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 10px 12px 12px; }
.analysis-step-complete { display: flex; align-items: flex-start; gap: 6px; min-width: 0; color: #527274; font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
.analysis-check { display: grid; place-items: center; width: 16px; height: 16px; flex: 0 0 16px; margin-top: 1px; border-radius: 50%; background: #d9f2ee; color: var(--accent-dark); font-size: 10px; font-weight: 800; }
.analysis-step-text { display: grid; min-width: 0; gap: 1px; overflow-wrap: anywhere; }
.analysis-step-text strong { color: #315f60; font-size: 11px; font-weight: 700; }
.analysis-step-text small { color: #82999a; font-size: 10px; line-height: 1.35; overflow-wrap: anywhere; }
.thinking-card { padding: 12px 14px; border: 1px solid #dce8e8; border-radius: 10px; background: #fbfdfd; color: #557377; }
.thinking-heading { display: flex; align-items: center; gap: 7px; min-height: 20px; color: var(--accent-dark); font-size: 13px; }
.thinking-heading strong { font-weight: 750; }
.thinking-current { margin-left: auto; color: #779092; font-size: 11px; }
.thinking-spinner { width: 13px; height: 13px; flex: 0 0 13px; border: 2px solid #c9e4df; border-top-color: var(--accent); border-radius: 50%; animation: thinking-spin .8s linear infinite; }
.thinking-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 11px; }
.thinking-step { position: relative; min-width: 0; padding-top: 14px; color: #9aaeb0; font-size: 10px; line-height: 1.35; text-align: center; }
.thinking-step::before { content: ""; position: absolute; top: 0; left: 50%; width: 7px; height: 7px; border: 2px solid #d5e1e1; border-radius: 50%; background: #fff; transform: translateX(-50%); }
.thinking-step.active { color: var(--accent-dark); font-weight: 700; }
.thinking-step.active::before { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 3px rgba(15,118,110,.12); }
.thinking-step.done { color: #668b87; }
.thinking-step.done::before { border-color: #74b9ad; background: #74b9ad; }
@keyframes thinking-spin { to { transform: rotate(360deg); } }
.composer-wrap { padding: 12px max(22px, calc((100% - 940px) / 2)) 17px; border-top: 1px solid var(--line); background: #fbfdfd; }
.composer-hint, .composer-foot { display: flex; justify-content: space-between; gap: 14px; color: #80979b; font-size: 11px; }
.composer-hint { margin-bottom: 7px; }
.composer-hint span:first-child { color: var(--accent); font-weight: 700; }
.composer { display: flex; align-items: flex-end; gap: 10px; }
.composer textarea { min-height: 58px; max-height: 180px; flex: 1; resize: vertical; padding: 11px 13px; border: 1px solid #c9dada; border-radius: 8px; outline: none; color: var(--ink); background: #fff; }
.composer textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15,118,110,.1); }
.send-button { width: 76px; height: 44px; flex: 0 0 76px; border: 0; border-radius: 7px; background: var(--accent); color: #fff; font-weight: 700; }
.composer-foot { margin-top: 6px; }
.attachment-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin-top: 9px; min-height: 31px; }
.upload-button { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 10px; border: 1px solid #b8d9d5; border-radius: 6px; color: var(--accent-dark); background: #f3fbf9; font-size: 12px; font-weight: 700; cursor: pointer; }
.upload-button:hover { border-color: var(--accent); background: #e9f7f4; }
.upload-button input { display: none; }
.upload-note, .upload-status { color: #80979b; font-size: 11px; }
.upload-status { color: var(--accent); }
.optional-label { margin-top: 14px; }
.field-hint { margin-top: 5px; color: #80979b; font-size: 12px; line-height: 1.5; }
.recovery-note code { display: block; margin: 7px 0 8px; padding: 7px 8px; border: 1px solid #cde1de; border-radius: 5px; background: #f7fbfa; color: #135b54; font-size: 11px; overflow-wrap: anywhere; }
.recovery-copy { width: 100%; min-height: 30px; border: 1px solid #b8d9d5; border-radius: 5px; background: #f3fbf9; color: var(--accent-dark); font-size: 12px; font-weight: 700; cursor: pointer; }
.recovery-copy:hover { border-color: var(--accent); background: #e9f7f4; }
.attachments { display: flex; flex-wrap: wrap; gap: 6px; min-height: 0; margin-top: 4px; }
.attachment-chip { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; padding: 4px 7px 4px 9px; border: 1px solid #d4e7e4; border-radius: 5px; color: #47706e; background: #f8fcfb; font-size: 11px; }
.attachment-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 230px; }
.attachment-chip button { width: 18px; height: 18px; padding: 0; border: 0; border-radius: 4px; color: #6f8c8e; background: transparent; line-height: 1; }
.attachment-chip button:hover { color: var(--danger); background: #fbeeee; }
.send-button:disabled { cursor: wait; opacity: .65; }

@media (max-width: 760px) {
  .app-shell { display: block; height: 100dvh; }
  .sidebar { position: fixed; z-index: 10; inset: 0 auto 0 0; width: min(84vw, 300px); transform: translateX(-102%); transition: transform .18s ease; box-shadow: 12px 0 30px rgba(10,50,55,.18); }
  .sidebar.open { transform: translateX(0); }
  .main-panel { height: 100dvh; min-height: 0; }
  .topbar { height: 64px; flex-basis: 64px; gap: 8px; padding: 0 15px; }
  .topbar-heading { font-size: 16px; }
  .topbar-actions { flex: 1 1 auto; justify-content: flex-start; gap: 5px; overflow-x: auto; overscroll-behavior-x: contain; padding: 3px 0; scrollbar-width: thin; }
  .quiet-button { flex: 0 0 auto; padding: 6px 8px; font-size: 11px; white-space: nowrap; }
  .conversation { padding: 22px 14px; }
  .composer-wrap { padding: 10px 14px 13px; }
  .composer-hint span:last-child { display: none; }
  .login-card { padding: 30px 24px 25px; }
  .message-body { max-width: calc(100% - 41px); }
  .upload-note { display: none; }
  .analysis-steps-complete { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analysis-duration { display: none; }
}

@media (max-width: 430px) {
  .topbar-title { flex: 0 0 74px; }
  .eyebrow { display: none; }
  .topbar-heading { max-width: 74px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .message { gap: 8px; }
  .avatar { width: 29px; height: 29px; flex-basis: 29px; font-size: 12px; }
  .message-body { max-width: calc(100% - 37px); }
  .thinking-current { display: none; }
  .thinking-steps { gap: 3px; }
  .thinking-step { font-size: 9px; }
}

@media (max-width: 360px) {
  .analysis-steps-complete { grid-template-columns: 1fr; }
}
