:root {
  --bg: #071011;
  --panel: rgba(12, 23, 24, 0.94);
  --panel-strong: #101c1d;
  --line: rgba(173, 225, 214, 0.12);
  --line-strong: rgba(173, 225, 214, 0.22);
  --text: #eef8f5;
  --muted: #91aaa5;
  --muted-2: #6f8682;
  --accent: #39d49f;
  --accent-strong: #1fbd86;
  --accent-soft: rgba(57, 212, 159, 0.12);
  --danger: #ff7b7b;
  --user-bubble: linear-gradient(135deg, #39d49f 0%, #1fbd86 100%);
  --assistant-bubble: #152324;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; min-height: 0; }

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 18%, rgba(46, 184, 139, 0.10), transparent 30%),
    radial-gradient(circle at 90% 86%, rgba(49, 120, 107, 0.12), transparent 32%),
    var(--bg);
}

button, input, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.ambient {
  position: fixed;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.14;
  pointer-events: none;
}
.ambient-one { left: -190px; top: -190px; background: #20d998; }
.ambient-two { right: -220px; bottom: -220px; background: #2d8a7c; }

.login-view {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-card {
  width: min(520px, 100%);
  padding: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 28px;
  background: linear-gradient(160deg, rgba(18, 34, 34, 0.97), rgba(9, 18, 19, 0.97));
  box-shadow: var(--shadow);
  text-align: center;
  backdrop-filter: blur(18px);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #052319;
  background: linear-gradient(135deg, #83edc5, #32ca96);
  font-family: Georgia, serif;
  font-size: 23px;
  font-weight: 700;
  box-shadow: 0 10px 28px rgba(46, 210, 154, 0.22);
}
.brand-mark.large { width: 58px; height: 58px; margin: 0 auto 24px; border-radius: 18px; font-size: 31px; }

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
}
.login-card h1 { margin: 0; font-size: clamp(27px, 5vw, 36px); letter-spacing: -0.04em; }
.login-copy { max-width: 420px; margin: 18px auto 30px; color: var(--muted); line-height: 1.75; font-size: 14px; }
.login-form { text-align: left; }
.login-form label { display: block; margin: 0 0 9px 3px; color: #b7cbc6; font-size: 13px; }
.password-row { display: flex; gap: 10px; }
.password-row input {
  min-width: 0;
  flex: 1;
  height: 52px;
  padding: 0 16px;
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  outline: none;
  background: rgba(4, 11, 12, 0.62);
  transition: border-color .2s, box-shadow .2s;
}
.password-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(57, 212, 159, .12); }
.primary-button {
  border: 0;
  border-radius: 14px;
  font-weight: 700;
  color: #042219;
  background: var(--user-bubble);
  cursor: pointer;
}
.login-button { padding: 0 21px; }
.primary-button:hover { filter: brightness(1.05); }
.form-error { min-height: 20px; margin: 8px 3px 0; color: #ff9b9b; font-size: 12px; }
.privacy-line { margin-top: 20px; color: var(--muted-2); font-size: 12px; }
.status-dot { display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }

.app-shell {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
  overflow: hidden;
}
.sidebar {
  position: relative;
  z-index: 20;
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: rgba(8, 17, 18, 0.88);
  backdrop-filter: blur(18px);
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px 17px; }
.brand-title { font-size: 16px; font-weight: 750; letter-spacing: .06em; }
.brand-subtitle { margin-top: 2px; color: var(--muted-2); font-size: 11px; }
.sidebar-close { display: none !important; margin-left: auto; }
.new-conversation-button {
  margin: 8px 16px 20px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(57, 212, 159, .26);
  border-radius: 14px;
  color: #bff5df;
  background: var(--accent-soft);
  cursor: pointer;
  transition: .2s ease;
}
.new-conversation-button:hover { border-color: rgba(57, 212, 159, .55); background: rgba(57, 212, 159, .17); }
.plus-icon { font-size: 20px; line-height: 1; }
.list-heading { display: flex; justify-content: space-between; align-items: center; padding: 0 20px 9px; color: var(--muted-2); font-size: 11px; font-weight: 650; letter-spacing: .06em; }
.count-pill { min-width: 22px; padding: 2px 7px; border-radius: 999px; text-align: center; color: var(--muted); background: rgba(255,255,255,.05); }
.conversation-list { min-height: 0; flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 0 10px 18px; scrollbar-width: thin; scrollbar-color: rgba(120,160,150,.25) transparent; }
.conversation-item {
  width: 100%;
  display: grid;
  grid-template-columns: 34px minmax(0,1fr);
  gap: 10px;
  padding: 11px 10px;
  border: 1px solid transparent;
  border-radius: 13px;
  text-align: left;
  background: transparent;
  cursor: pointer;
  transition: .18s ease;
}
.conversation-item:hover { background: rgba(255,255,255,.035); }
.conversation-item.active { border-color: rgba(57,212,159,.18); background: rgba(57,212,159,.095); }
.conversation-avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; color: #97e6c8; background: rgba(57,212,159,.1); font-size: 13px; font-weight: 700; }
.conversation-copy { min-width: 0; }
.conversation-title { overflow: hidden; color: #dceae6; font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.conversation-meta { display: flex; align-items: center; gap: 6px; margin-top: 4px; color: var(--muted-2); font-size: 10px; }
.conversation-platform, .platform-badge { padding: 2px 6px; border-radius: 999px; color: #8de5c3; background: rgba(57,212,159,.09); font-size: 9px; font-weight: 650; white-space: nowrap; }
.conversation-platform.xiaohongshu, .platform-badge.xiaohongshu { color: #ffb9c7; background: rgba(255,112,141,.09); }
.conversation-platform.douyin, .platform-badge.douyin { color: #b8d2ff; background: rgba(104,157,255,.10); }
.conversation-platform.unknown, .platform-badge.unknown { color: #a6b5b2; background: rgba(255,255,255,.05); }
.pending-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: pulse 1.1s infinite; }
.sidebar-footer { padding: 15px 17px 18px; border-top: 1px solid var(--line); }
.training-link { display: flex; align-items: center; gap: 8px; margin-bottom: 13px; padding: 10px 11px; border: 1px solid rgba(57,212,159,.22); border-radius: 11px; color: #bff5df; background: rgba(57,212,159,.08); font-size: 12px; text-decoration: none; }
.training-link:hover { border-color: rgba(57,212,159,.45); background: rgba(57,212,159,.13); }
.shared-note { display: flex; align-items: center; gap: 7px; color: var(--muted-2); font-size: 11px; }
.shared-icon { color: var(--accent); }
.text-button { margin-top: 12px; padding: 0; border: 0; color: #9eb6b0; background: none; font-size: 12px; cursor: pointer; }
.text-button:hover { color: var(--text); }

.chat-panel {
  --composer-height: 96px;
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0,1fr) auto;
  overflow: hidden;
  background: rgba(6, 13, 14, .36);
}
.chat-header { min-height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 24px; border-bottom: 1px solid var(--line); background: rgba(8,17,18,.58); backdrop-filter: blur(14px); }
.header-left { min-width: 0; display: flex; align-items: center; gap: 12px; }
.header-title-row { display: flex; align-items: center; gap: 10px; }
.chat-header h2 { max-width: min(50vw, 580px); margin: 0; overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.chat-header p { margin: 5px 0 0; color: var(--muted-2); font-size: 11px; }
.online-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 999px; color: #8ce3c1; background: rgba(57,212,159,.08); font-size: 10px; font-weight: 650; }
.online-badge i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.role-badge { padding: 4px 8px; border: 1px solid rgba(218,174,255,.22); border-radius: 999px; color: #dfbaff; background: rgba(174,91,240,.09); font-size: 10px; font-weight: 650; }
.header-actions { display: flex; gap: 7px; }
.icon-button { width: 35px; height: 35px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: rgba(255,255,255,.025); cursor: pointer; }
.icon-button:hover { color: var(--text); border-color: var(--line-strong); }
.icon-button.danger:hover { color: var(--danger); border-color: rgba(255,123,123,.25); }
.menu-button { display: none; }

.message-viewport { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: rgba(120,160,150,.25) transparent; }
.message-list { width: min(900px, 100%); margin: 0 auto; padding: 30px 30px 22px; }
.empty-state { width: min(650px, calc(100% - 40px)); margin: 0 auto; padding: clamp(80px, 14vh, 160px) 0 50px; text-align: center; }
.assistant-orb { width: 72px; height: 72px; display: grid; place-items: center; margin: 0 auto 22px; border: 1px solid rgba(83,229,176,.3); border-radius: 24px; color: #06251b; background: linear-gradient(145deg,#8cecc8,#30c58f); box-shadow: 0 20px 60px rgba(36,200,145,.16); transform: rotate(-4deg); }
.assistant-orb span { font-family: Georgia,serif; font-size: 37px; font-weight: 800; transform: rotate(4deg); }
.empty-state h3 { margin: 7px 0 12px; font-size: 25px; letter-spacing: -.03em; }
.empty-state > p:not(.eyebrow) { max-width: 530px; margin: 0 auto; color: var(--muted); font-size: 14px; line-height: 1.7; }
.starter-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 9px; margin-top: 30px; }
.starter { padding: 13px 11px; border: 1px solid var(--line); border-radius: 12px; color: #b9cbc7; background: rgba(255,255,255,.025); font-size: 12px; cursor: pointer; }
.starter:hover { border-color: rgba(57,212,159,.28); color: #dff8ef; background: rgba(57,212,159,.06); }

.message-row { display: flex; gap: 11px; margin: 0 0 22px; animation: messageIn .22s ease both; }
.message-row.user { justify-content: flex-end; }
.message-avatar { flex: 0 0 auto; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 10px; color: #baf1dc; background: rgba(57,212,159,.11); font-family: Georgia,serif; font-size: 14px; font-weight: 700; }
.message-content { max-width: min(72%, 650px); }
.message-name { margin: 0 0 6px 3px; color: var(--muted-2); font-size: 10px; }
.message-row.user .message-name { text-align: right; }
.bubble { padding: 12px 15px; border: 1px solid var(--line); border-radius: 6px 17px 17px 17px; color: #e3efec; background: var(--assistant-bubble); font-size: 14px; line-height: 1.72; white-space: pre-wrap; word-break: break-word; box-shadow: 0 9px 30px rgba(0,0,0,.12); }
.message-row.user .bubble { border: 0; border-radius: 17px 6px 17px 17px; color: #032219; background: var(--user-bubble); font-weight: 520; }
.bubble.failed { color: #ffd0d0; border-color: rgba(255,123,123,.2); background: rgba(99,31,34,.28); }
.message-footer { display: flex; align-items: center; gap: 10px; margin-top: 5px; }
.message-row.user .message-footer { justify-content: flex-end; }
.message-time { color: var(--muted-2); font-size: 9px; }
.training-shortcut { padding: 0; border: 0; color: #8fb1aa; background: transparent; font-size: 10px; cursor: pointer; }
.training-shortcut::before { content: "⚑"; margin-right: 4px; color: #c8a1eb; }
.training-shortcut:hover { color: #e0c2f7; }
.message-images { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; margin-bottom: 8px; }
.message-images img { width: 100%; max-height: 250px; display: block; border-radius: 11px; object-fit: cover; border: 1px solid rgba(255,255,255,.12); cursor: zoom-in; }
.pending-copy { display: block; margin-bottom: 9px; color: #8da7a1; font-size: 11px; }
.typing { display: flex; align-items: center; gap: 5px; min-width: 64px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: #8ab1a8; animation: typing 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
.retry-button { margin-top: 8px; padding: 6px 10px; border: 1px solid rgba(255,123,123,.28); border-radius: 8px; color: #ffd0d0; background: transparent; font-size: 11px; cursor: pointer; }

.composer-wrap {
  position: relative;
  z-index: 8;
  min-height: 0;
  flex: 0 0 auto;
  padding: 10px 24px max(16px, env(safe-area-inset-bottom));
  overflow: hidden;
  background: linear-gradient(180deg,transparent,rgba(7,16,17,.95) 28%);
}
.composer, .image-preview { width: min(850px, 100%); margin: 0 auto; }
.composer { min-height: 58px; display: flex; align-items: flex-end; gap: 9px; padding: 9px; border: 1px solid var(--line-strong); border-radius: 18px; background: rgba(16,29,30,.94); box-shadow: 0 16px 50px rgba(0,0,0,.23); transition: border-color .2s, box-shadow .2s; }
.composer:focus-within { border-color: rgba(57,212,159,.42); box-shadow: 0 16px 50px rgba(0,0,0,.23),0 0 0 3px rgba(57,212,159,.07); }
.attach-button { flex: 0 0 auto; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; color: var(--muted); background: rgba(255,255,255,.04); font-size: 22px; cursor: pointer; }
.attach-button:hover { color: var(--accent); background: var(--accent-soft); }
.composer textarea { min-height: 38px; max-height: 135px; flex: 1; padding: 8px 4px; resize: none; overflow-y: auto; outline: 0; border: 0; color: var(--text); background: transparent; line-height: 1.5; }
.composer textarea::placeholder { color: #66807a; }
.composer textarea:disabled { cursor: not-allowed; }
.send-button { flex: 0 0 auto; width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 12px; color: #062219; background: var(--user-bubble); cursor: pointer; }
.send-button:disabled { color: #52635f; background: #253433; cursor: not-allowed; }
.send-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.composer-note { margin: 7px auto 0; color: #5d7470; font-size: 9px; text-align: center; }
.image-preview { min-height: 0; max-height: 76px; display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; padding: 0 3px 9px; }
.preview-item { position: relative; flex: 0 0 auto; width: 66px; height: 66px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line-strong); background: var(--panel-strong); }
.preview-item img { width: 100%; height: 100%; object-fit: cover; }
.preview-item button { position: absolute; right: 3px; top: 3px; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; color: white; background: rgba(0,0,0,.66); cursor: pointer; }

.scroll-bottom-button {
  position: absolute;
  right: 24px;
  bottom: calc(var(--composer-height) + 12px);
  z-index: 10;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(57,212,159,.32);
  border-radius: 50%;
  color: #bff5df;
  background: rgba(15,31,31,.96);
  box-shadow: 0 12px 34px rgba(0,0,0,.35);
  opacity: 0;
  transform: translateY(8px) scale(.92);
  pointer-events: none;
  cursor: pointer;
  transition: opacity .18s ease, transform .18s ease, border-color .18s ease;
}
.scroll-bottom-button:hover { border-color: rgba(57,212,159,.62); }
.scroll-bottom-button.visible { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.scroll-bottom-button span { font-size: 21px; line-height: 1; transform: translateY(-1px); }

.toast { position: fixed; left: 50%; bottom: 92px; z-index: 100; max-width: min(440px,calc(100% - 28px)); padding: 11px 15px; border: 1px solid var(--line-strong); border-radius: 12px; color: #eaf4f1; background: rgba(18,31,32,.96); box-shadow: var(--shadow); opacity: 0; transform: translate(-50%,12px); pointer-events: none; transition: .2s ease; font-size: 12px; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
.sidebar-backdrop { display: none; }

.correction-dialog { width: min(660px, calc(100% - 28px)); max-height: calc(100dvh - 28px); padding: 0; overflow: auto; border: 1px solid var(--line-strong); border-radius: 22px; color: var(--text); background: #0d191a; box-shadow: var(--shadow); }
.correction-dialog::backdrop { background: rgba(0,0,0,.7); backdrop-filter: blur(5px); }
.correction-card { padding: 25px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.dialog-heading h3 { margin: 0; font-size: 21px; }
.dialog-close { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: rgba(255,255,255,.03); cursor: pointer; }
.correction-context { display: grid; gap: 8px; margin: 20px 0; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: rgba(0,0,0,.16); }
.correction-context p { margin: 0; color: #b9cbc7; font-size: 12px; line-height: 1.6; white-space: pre-wrap; }
.correction-context strong { display: block; margin-bottom: 3px; color: var(--muted-2); font-size: 10px; }
.field-label { display: block; margin: 13px 0 7px; color: #b9cbc7; font-size: 12px; }
.field-label b { color: var(--danger); }
.correction-card textarea, .correction-card input, .correction-card select { width: 100%; padding: 11px 12px; border: 1px solid var(--line-strong); border-radius: 11px; outline: none; color: var(--text); background: rgba(4,11,12,.62); }
.correction-card textarea { resize: vertical; line-height: 1.6; }
.correction-card textarea:focus, .correction-card input:focus, .correction-card select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(57,212,159,.1); }
.field-grid { display: grid; grid-template-columns: 1fr 180px; gap: 12px; }
.dialog-note { margin: 14px 0 0; color: var(--muted-2); font-size: 11px; line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.secondary-button { padding: 10px 16px; border: 1px solid var(--line-strong); border-radius: 11px; color: #b9cbc7; background: transparent; cursor: pointer; }
.dialog-submit { padding: 10px 17px; }
.dialog-submit:disabled { opacity: .55; cursor: wait; }
.platform-dialog { width: min(560px, calc(100% - 28px)); }
.platform-options { display: grid; gap: 10px; margin-top: 20px; }
.platform-options button { display: grid; gap: 4px; padding: 15px 16px; border: 1px solid var(--line-strong); border-radius: 13px; color: var(--text); text-align: left; background: rgba(4,11,12,.62); cursor: pointer; }
.platform-options button:hover { border-color: rgba(57,212,159,.48); background: rgba(57,212,159,.08); }
.platform-options button:disabled { opacity: .5; cursor: wait; }
.platform-options strong { font-size: 14px; }
.platform-options span { color: var(--muted-2); font-size: 11px; }

@keyframes typing { 0%,60%,100% { transform: translateY(0); opacity:.45; } 30% { transform: translateY(-4px); opacity:1; } }
@keyframes pulse { 50% { opacity:.35; transform: scale(.8); } }
@keyframes messageIn { from { opacity:0; transform: translateY(6px); } }

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(310px,86vw); transform: translateX(-102%); transition: transform .22s ease; box-shadow: 30px 0 80px rgba(0,0,0,.4); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close, .menu-button { display: grid !important; }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 15; background: rgba(0,0,0,.5); backdrop-filter: blur(3px); }
  .sidebar-backdrop.show { display: block; }
  .chat-panel { height: 100vh; height: 100dvh; }
  .chat-header { padding: 12px 14px; }
  .chat-header h2 { max-width: 44vw; }
  .online-badge { display: none; }
  .message-list { padding: 24px 14px 18px; }
  .message-content { max-width: 84%; }
  .composer-wrap { padding: 8px 10px max(10px, env(safe-area-inset-bottom)); }
  .scroll-bottom-button { right: 14px; }
  .starter-grid { grid-template-columns: 1fr; }
  .empty-state { padding-top: 70px; }
}

@media (max-width: 540px) {
  .login-view { padding: 16px; }
  .login-card { padding: 34px 22px; border-radius: 22px; }
  .password-row { flex-direction: column; }
  .login-button { height: 48px; }
  .message-avatar { display: none; }
  .message-content { max-width: 91%; }
  .bubble { font-size: 13px; }
  .chat-header p { display: none; }
  .role-badge { display: none; }
  .field-grid { grid-template-columns: 1fr; }
  .correction-card { padding: 20px; }
}
