:root {
  color-scheme: light;
  --ink: #102b2a;
  --ink-soft: #3b5552;
  --muted: #748581;
  --paper: #f4f7f5;
  --surface: #ffffff;
  --surface-soft: #edf4f0;
  --line: #dce6e1;
  --green: #1e7458;
  --green-deep: #123f3a;
  --green-pale: #e6f2ec;
  --blue: #2d719a;
  --amber: #9b6a21;
  --danger: #a64a42;
  --shadow: 0 20px 55px rgba(18, 63, 58, 0.1);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--paper); }
button, textarea, input, select { font: inherit; }
button { color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

.auth-screen {
  min-height: 100vh;
  padding: 36px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 18% 15%, rgba(53, 135, 99, .13), transparent 28rem),
    radial-gradient(circle at 88% 82%, rgba(45, 113, 154, .08), transparent 25rem),
    #f4f7f5;
}
.auth-panel {
  width: min(980px, 100%);
  min-height: 600px;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  overflow: hidden;
  border: 1px solid rgba(188, 210, 200, .75);
  border-radius: 25px;
  background: #fff;
  box-shadow: 0 35px 90px rgba(18, 63, 58, .14);
}
.auth-intro {
  padding: 54px 58px;
  color: #fff;
  background:
    linear-gradient(145deg, rgba(255,255,255,.05), transparent 38%),
    var(--green-deep);
}
.auth-brand { color: #fff; }
.auth-brand .brand-mark { color: var(--green-deep); background: #dcece5; }
.auth-brand small { color: rgba(255,255,255,.62); }
.auth-intro > .eyebrow { margin-top: 92px; color: #86c7a8; }
.auth-intro h1 { margin: 0; font-size: clamp(35px, 4vw, 49px); line-height: 1.2; letter-spacing: -.045em; }
.auth-intro > p:not(.eyebrow) { margin: 22px 0 0; color: rgba(255,255,255,.68); font-size: 13px; line-height: 1.9; }
.auth-intro ul { margin: 30px 0 0; padding: 0; display: grid; gap: 12px; list-style: none; color: rgba(255,255,255,.78); font-size: 11px; }
.auth-intro li { display: flex; align-items: center; gap: 9px; }
.auth-intro li::before { content: "✓"; width: 19px; height: 19px; display: grid; place-items: center; border-radius: 50%; color: var(--green-deep); background: #a9d8bf; font-size: 10px; font-weight: 900; }
.auth-card { padding: 54px 52px 36px; display: flex; flex-direction: column; justify-content: center; }
.auth-tabs { margin-bottom: 34px; padding: 4px; display: grid; grid-template-columns: 1fr 1fr; border-radius: 11px; background: var(--paper); }
.auth-tabs button { height: 39px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; font-weight: 800; }
.auth-tabs button.active { color: var(--green-deep); background: #fff; box-shadow: 0 4px 13px rgba(18,63,58,.08); }
.auth-form { display: grid; gap: 16px; }
.auth-form header { margin-bottom: 8px; }
.auth-form h2 { margin: 0; font-size: 25px; letter-spacing: -.025em; }
.auth-form header p { margin: 7px 0 0; color: var(--muted); font-size: 11px; }
.auth-form label { display: grid; gap: 7px; color: var(--ink-soft); font-size: 10px; font-weight: 800; }
.auth-form input { width: 100%; height: 45px; padding: 0 13px; border: 1px solid var(--line); border-radius: 10px; outline: 0; color: var(--ink); background: #fbfcfb; font-size: 12px; }
.auth-form input:focus { border-color: #8bb5a2; box-shadow: 0 0 0 3px rgba(30,116,88,.07); }
.auth-submit { height: 46px; margin-top: 6px; border: 0; border-radius: 11px; color: #fff; background: var(--green-deep); cursor: pointer; font-size: 12px; font-weight: 850; box-shadow: 0 10px 24px rgba(18,63,58,.16); }
.auth-submit:disabled { opacity: .6; cursor: wait; }
.auth-message { margin: 15px 0 0; padding: 10px 12px; border-radius: 9px; color: var(--green); background: var(--green-pale); font-size: 10px; line-height: 1.55; }
.auth-message.error { color: var(--danger); background: #fff0ee; }
.auth-footnote { margin: 20px 0 0; color: #9aa8a4; text-align: center; font-size: 9px; line-height: 1.55; }

.app-shell { height: 100vh; display: grid; grid-template-columns: 290px minmax(0, 1fr); overflow: hidden; }

.sidebar {
  min-height: 0;
  padding: 20px 15px 14px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #f8faf9;
  z-index: 20;
}

.sidebar-header { padding: 0 5px; }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark {
  width: 41px;
  height: 41px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: var(--green-deep);
  box-shadow: 0 8px 20px rgba(18, 63, 58, 0.18);
  font-size: 16px;
  font-weight: 900;
}
.brand > span:last-child { display: grid; gap: 2px; }
.brand strong { font-size: 14px; }
.brand small { color: var(--muted); font-size: 11px; }

.new-chat-button {
  width: 100%;
  min-height: 45px;
  margin-top: 22px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid #bcd2c8;
  border-radius: 11px;
  color: var(--green-deep);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  transition: border-color .16s ease, transform .16s ease;
}
.new-chat-button:hover { border-color: var(--green); transform: translateY(-1px); }
.new-chat-button span { font-size: 18px; font-weight: 400; }

.history-section { min-height: 0; margin-top: 24px; display: flex; flex: 1; flex-direction: column; }
.section-label { padding: 0 8px 9px; display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.session-list { min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.session-item { margin-bottom: 4px; display: flex; align-items: center; border-radius: 10px; }
.session-item:hover, .session-item.active { background: #e9f1ed; }
.session-open { min-width: 0; flex: 1; padding: 10px 8px 10px 11px; display: grid; gap: 4px; border: 0; text-align: left; background: transparent; cursor: pointer; }
.session-open strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 760; }
.session-open span { color: var(--muted); font-size: 10px; }
.session-delete { width: 30px; height: 30px; margin-right: 4px; border: 0; border-radius: 8px; color: transparent; background: transparent; cursor: pointer; }
.session-item:hover .session-delete { color: #81918d; }
.session-delete:hover { color: var(--danger) !important; background: rgba(166, 74, 66, .08); }
.session-empty { margin: 20px 8px; color: var(--muted); text-align: center; font-size: 12px; }
.sidebar-footer { padding: 12px 6px 2px; display: flex; gap: 7px; border-top: 1px solid var(--line); }
.sidebar-footer a { flex: 1; padding: 8px; border-radius: 8px; color: var(--muted); text-align: center; text-decoration: none; font-size: 11px; font-weight: 700; }
.sidebar-footer a:hover { color: var(--green); background: var(--green-pale); }

.chat-main { min-width: 0; min-height: 0; display: grid; grid-template-rows: 68px minmax(0, 1fr) auto; background: var(--surface); }
.chat-header { padding: 0 28px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); }
.header-title { min-width: 0; display: flex; align-items: center; gap: 12px; }
.header-title > div { min-width: 0; display: grid; gap: 3px; }
.header-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.header-title span { color: var(--muted); font-size: 10px; }
.header-actions { display: flex; align-items: center; gap: 15px; }
.icon-button { border: 0; background: transparent; cursor: pointer; }
.menu-button { display: none; width: 34px; height: 34px; border-radius: 8px; font-size: 19px; }
.service-state { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.service-state i { width: 7px; height: 7px; border-radius: 50%; background: #c28a39; box-shadow: 0 0 0 4px rgba(194,138,57,.12); }
.service-state.online i { background: #45a277; box-shadow: 0 0 0 4px rgba(69,162,119,.12); }
.service-state.offline i { background: var(--danger); box-shadow: 0 0 0 4px rgba(166,74,66,.1); }
.profile-button { min-height: 36px; padding: 4px 11px 4px 5px; display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; color: var(--ink-soft); font-size: 11px; font-weight: 750; }
.profile-button:hover { border-color: #a7c6b8; }
.profile-button.complete { color: var(--green); background: var(--green-pale); border-color: #c8ded3; }
.profile-icon { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; color: #fff; background: var(--green); font-size: 11px; font-weight: 850; }
.user-account { height: 36px; padding: 3px 5px 3px 4px; display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: #fff; font-size: 9px; }
.user-avatar { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; color: var(--green-deep); background: var(--green-pale); font-size: 10px; font-weight: 850; }
.user-account button { height: 25px; padding: 0 7px; border: 0; border-left: 1px solid var(--line); color: var(--muted); background: transparent; cursor: pointer; font-size: 9px; }
.user-account button:hover { color: var(--danger); }

.chat-scroller { min-height: 0; overflow-y: auto; background: radial-gradient(circle at 50% 0%, rgba(46,128,92,.055), transparent 32rem), #fff; }
.empty-state { width: min(760px, calc(100% - 40px)); margin: 0 auto; padding: max(80px, 11vh) 0 60px; text-align: center; }
.eyebrow { margin: 0 0 11px; color: var(--blue); font-size: 10px; font-weight: 850; letter-spacing: .15em; }
.empty-state h1 { margin: 0; font-size: clamp(34px, 5vw, 54px); line-height: 1.17; letter-spacing: -.05em; }
.empty-state > p:not(.eyebrow) { max-width: 630px; margin: 18px auto 0; color: var(--muted); font-size: 14px; line-height: 1.85; }

.message-list { padding: 32px 0 10px; }
.message-row { width: min(820px, calc(100% - 42px)); margin: 0 auto 25px; display: flex; align-items: flex-start; gap: 12px; }
.message-row.user { flex-direction: row-reverse; }
.avatar { width: 33px; height: 33px; flex: none; display: grid; place-items: center; border-radius: 10px; color: #fff; background: var(--green-deep); font-size: 10px; font-weight: 850; box-shadow: 0 5px 15px rgba(18,63,58,.12); }
.message-row.user .avatar { color: var(--green-deep); background: var(--green-pale); box-shadow: none; }
.message-body { min-width: 0; max-width: min(700px, calc(100% - 45px)); }
.message-content { padding: 15px 18px; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--line); border-radius: 5px 16px 16px 16px; color: #183735; background: var(--surface); box-shadow: 0 8px 28px rgba(18,63,58,.055); font-size: 14px; line-height: 1.9; }
.message-row.user .message-content { border: 0; border-radius: 16px 5px 16px 16px; color: #fff; background: var(--green-deep); box-shadow: 0 8px 24px rgba(18,63,58,.14); line-height: 1.72; }
.message-content p { margin: 0 0 10px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content h3 { margin: 14px 0 7px; color: var(--green-deep); font-size: 14px; }
.message-content h3:first-child { margin-top: 0; }
.message-content ul { margin: 4px 0 12px; padding-left: 20px; }
.message-content li { margin: 4px 0; }
.message-content blockquote { margin: 10px 0 0; padding: 9px 11px; border-left: 3px solid var(--green); border-radius: 0 8px 8px 0; background: var(--green-pale); font-weight: 760; }
.message-meta { padding: 7px 2px 0; display: flex; align-items: center; flex-wrap: wrap; gap: 7px; color: var(--muted); font-size: 9px; }
.message-badge { padding: 3px 7px; border-radius: 99px; color: var(--green); background: var(--green-pale); font-size: 9px; font-weight: 800; }
.message-badge.warning { color: var(--amber); background: #fff1d9; }
.birth-cta { width: 100%; margin-top: 10px; padding: 11px 12px; display: flex; align-items: center; gap: 10px; border: 1px solid #c9ded4; border-radius: 12px; color: var(--green-deep); background: #f1f8f4; cursor: pointer; text-align: left; }
.birth-cta span { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 8px; color: #fff; background: var(--green); font-size: 10px; }
.birth-cta strong { flex: 1; font-size: 11px; }
.birth-cta i { font-style: normal; font-size: 15px; }
.thinking-card { padding: 14px 17px; display: flex; align-items: center; gap: 13px; border: 1px solid var(--line); border-radius: 5px 15px 15px 15px; background: var(--surface); box-shadow: 0 8px 28px rgba(18,63,58,.05); }
.thinking-card strong { font-size: 12px; }
.thinking-card p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.thinking-dots { display: flex; gap: 3px; }
.thinking-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--green); animation: thinking 1s infinite ease-in-out; }
.thinking-dots i:nth-child(2) { animation-delay: .15s; }
.thinking-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes thinking { 0%, 70%, 100% { opacity: .25; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-3px); } }
.error-panel { width: min(820px, calc(100% - 42px)); margin: 0 auto 25px; padding: 12px 15px; display: flex; gap: 8px; border: 1px solid #edc9c5; border-radius: 11px; color: var(--danger); background: #fff2f0; font-size: 11px; }

.composer-shell { padding: 12px 24px 14px; border-top: 1px solid rgba(220,230,225,.75); background: rgba(255,255,255,.96); }
.composer { width: min(820px, 100%); margin: 0 auto; padding: 11px 12px 9px 17px; border: 1px solid #cfded7; border-radius: 16px; background: var(--surface); box-shadow: 0 12px 38px rgba(18,63,58,.09); }
.composer:focus-within { border-color: #91b9a7; box-shadow: 0 12px 38px rgba(18,63,58,.11), 0 0 0 3px rgba(30,116,88,.06); }
.composer textarea { width: 100%; min-height: 30px; max-height: 180px; padding: 4px 3px 8px; resize: none; overflow-y: auto; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 14px; line-height: 1.6; }
.composer textarea::placeholder { color: #9aaba6; }
.composer-actions { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.composer-actions > span { color: var(--muted); font-size: 9px; }
#submitButton { min-width: 82px; height: 35px; padding: 0 7px 0 13px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 0; border-radius: 10px; color: #fff; background: var(--green-deep); cursor: pointer; font-size: 11px; font-weight: 800; }
#submitButton > span:last-child { width: 23px; height: 23px; display: grid; place-items: center; border-radius: 7px; color: var(--green-deep); background: #dbece4; font-size: 14px; }
#submitButton:disabled { opacity: .55; cursor: wait; }
.composer-note { width: min(820px, 100%); margin: 7px auto 0; color: #95a39f; text-align: center; font-size: 9px; }

.birth-dialog { width: min(590px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 18px; color: var(--ink); background: var(--surface); box-shadow: 0 30px 90px rgba(15,48,44,.24); }
.birth-dialog::backdrop { background: rgba(13,38,35,.42); backdrop-filter: blur(3px); }
.birth-dialog form { padding: 25px; }
.birth-dialog header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.birth-dialog h2 { margin: 0; font-size: 23px; letter-spacing: -.02em; }
.birth-dialog header p:last-child { margin: 8px 0 0; max-width: 460px; color: var(--muted); font-size: 11px; line-height: 1.65; }
.dialog-close { width: 33px; height: 33px; flex: none; border: 0; border-radius: 9px; color: var(--muted); background: var(--paper); cursor: pointer; font-size: 20px; }
.birth-fields { margin-top: 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.birth-fields label { display: grid; gap: 7px; color: var(--ink-soft); font-size: 10px; font-weight: 750; }
.birth-fields input, .birth-fields select { width: 100%; height: 42px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; outline: none; color: var(--ink); background: #fbfcfb; font-size: 12px; }
.birth-fields input:focus, .birth-fields select:focus { border-color: #96bbaa; box-shadow: 0 0 0 3px rgba(30,116,88,.06); }
.full-field { grid-column: 1 / -1; }
.privacy-note { margin-top: 15px; padding: 10px 12px; border-radius: 9px; color: var(--muted); background: var(--paper); font-size: 10px; }
.birth-dialog footer { margin-top: 20px; display: flex; justify-content: flex-end; gap: 9px; }
.secondary-button, .primary-button { min-height: 39px; padding: 0 16px; border-radius: 9px; cursor: pointer; font-size: 11px; font-weight: 800; }
.secondary-button { border: 1px solid var(--line); background: var(--surface); }
.primary-button { border: 0; color: #fff; background: var(--green-deep); }
.sidebar-backdrop { display: none; }

@media (max-width: 850px) {
  .auth-screen { padding: 18px; }
  .auth-panel { width: min(520px, 100%); min-height: 0; grid-template-columns: 1fr; }
  .auth-intro { padding: 30px 34px; }
  .auth-intro > .eyebrow { margin-top: 35px; }
  .auth-intro h1 { font-size: 34px; }
  .auth-intro ul { display: none; }
  .auth-card { padding: 34px; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, calc(100% - 55px)); transform: translateX(-105%); transition: transform .2s ease; box-shadow: 18px 0 50px rgba(10,40,36,.15); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(14,40,37,.34); }
  .menu-button { display: grid; place-items: center; }
}

@media (max-width: 640px) {
  .auth-screen { padding: 0; place-items: stretch; }
  .auth-panel { min-height: 100vh; border: 0; border-radius: 0; }
  .auth-intro { padding: 24px; }
  .auth-intro > .eyebrow { margin-top: 26px; }
  .auth-intro h1 { font-size: 29px; }
  .auth-intro > p:not(.eyebrow) { display: none; }
  .auth-card { padding: 29px 24px 24px; justify-content: flex-start; }
  .auth-tabs { margin-bottom: 25px; }
  .chat-main { grid-template-rows: 62px minmax(0,1fr) auto; }
  .chat-header { padding: 0 13px; }
  .header-title span, .service-state { display: none; }
  .profile-button { padding-right: 6px; }
  .profile-button > span:last-child { display: none; }
  .user-account > span:not(.user-avatar) { display: none; }
  .user-account { gap: 2px; }
  .empty-state { width: calc(100% - 28px); padding-top: 58px; }
  .empty-state h1 { font-size: 35px; }
  .empty-state > p:not(.eyebrow) { font-size: 13px; }
  .message-list { padding-top: 22px; }
  .message-row, .error-panel { width: calc(100% - 22px); }
  .message-body { max-width: calc(100% - 39px); }
  .message-content { padding: 13px 15px; font-size: 13px; line-height: 1.8; }
  .avatar { width: 29px; height: 29px; border-radius: 9px; }
  .composer-shell { padding: 9px 10px 10px; }
  .composer { border-radius: 14px; }
  .composer-actions > span, .composer-note { display: none; }
  .composer-actions { justify-content: flex-end; }
  .birth-dialog form { padding: 20px 17px; }
  .birth-fields { grid-template-columns: 1fr; }
  .full-field { grid-column: auto; }
}
