:root {
  color-scheme: light;
  --ink: #18342d;
  --muted: #72827d;
  --green-900: #154b3b;
  --green-800: #185b47;
  --green-700: #237158;
  --green-100: #e5f3ec;
  --green-50: #f1f8f4;
  --cream: #f6f7f3;
  --line: #e2e9e5;
  --danger: #b54a4a;
  --shadow: 0 18px 60px rgba(28, 63, 51, 0.08);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--cream); }
body.drawer-open { overflow: hidden; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
input, textarea, select { color: var(--ink); }
input::placeholder, textarea::placeholder { color: #a2afa9; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 48px 20px 80px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 14% 18%, rgba(183, 219, 199, 0.42), transparent 34%),
    radial-gradient(circle at 88% 78%, rgba(220, 229, 193, 0.45), transparent 32%),
    linear-gradient(145deg, #f7faf7, #f3f5ed);
}
.login-orb { position: absolute; border: 1px solid rgba(35, 113, 88, 0.1); border-radius: 50%; pointer-events: none; }
.orb-one { width: 440px; height: 440px; left: -210px; top: -170px; box-shadow: 0 0 0 70px rgba(35, 113, 88, 0.025); }
.orb-two { width: 520px; height: 520px; right: -280px; bottom: -270px; box-shadow: 0 0 0 90px rgba(35, 113, 88, 0.02); }
.login-card {
  width: min(440px, 100%);
  padding: 38px 40px 32px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 30px 90px rgba(30, 73, 56, 0.12);
  backdrop-filter: blur(20px);
  position: relative;
  z-index: 1;
}
.login-brand { display: flex; align-items: center; gap: 12px; color: var(--green-800); font-size: 14px; font-weight: 650; }
.brand-mark {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(145deg, var(--green-700), var(--green-900));
  box-shadow: 0 8px 20px rgba(24, 91, 71, 0.2);
  font-family: serif;
  font-size: 20px;
}
.brand-mark.large { width: 44px; height: 44px; }
.login-copy { margin: 46px 0 30px; }
.eyebrow { margin: 0 0 9px; color: var(--green-700); font-size: 10px; font-weight: 750; letter-spacing: 0.18em; }
.login-copy h1 { margin: 0 0 12px; font-size: 34px; letter-spacing: -0.04em; font-weight: 720; }
.login-copy > p:last-child { margin: 0; color: var(--muted); font-size: 14px; }
.login-form { display: grid; gap: 20px; }
.login-form label { display: grid; gap: 9px; font-size: 13px; font-weight: 600; }
.login-form input {
  width: 100%;
  height: 50px;
  padding: 0 15px;
  border: 1px solid #dce5df;
  border-radius: 12px;
  outline: none;
  background: #fbfcfb;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.login-form input:focus { border-color: var(--green-700); box-shadow: 0 0 0 4px rgba(35, 113, 88, 0.09); }
.login-button { width: 100%; height: 50px; margin-top: 3px; }
.login-note { display: flex; align-items: center; justify-content: center; gap: 7px; margin: 26px 0 0; color: #89958f; font-size: 11px; }
.login-footer { position: absolute; bottom: 28px; margin: 0; color: #84938b; font-size: 12px; letter-spacing: 0.08em; }
.form-error { margin: -5px 0; color: var(--danger); font-size: 13px; line-height: 1.6; }

.button {
  min-height: 38px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.18s, transform 0.18s, border-color 0.18s;
}
.button:active:not(:disabled) { transform: translateY(1px); }
.button.primary { color: #fff; background: var(--green-800); box-shadow: 0 6px 16px rgba(24, 91, 71, 0.16); }
.button.primary:hover:not(:disabled) { background: var(--green-900); }
.button.secondary { color: var(--green-800); border-color: #d5e3da; background: #fff; }
.button.secondary:hover:not(:disabled) { background: var(--green-50); }
.button.ghost { color: #566a62; background: transparent; }
.button.ghost:hover { background: #edf2ee; }
.danger-text { color: var(--danger) !important; }

.app-shell { min-height: 100vh; }
.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 clamp(20px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  position: relative;
  z-index: 5;
}
.brand-group { display: flex; align-items: center; gap: 12px; }
.brand-title { font-size: 16px; font-weight: 720; letter-spacing: 0.01em; }
.brand-subtitle { margin-top: 3px; color: #89968f; font-size: 10px; }
.account-actions { display: flex; align-items: center; gap: 4px; }
.user-badge { margin-right: 12px; padding: 6px 11px; border-radius: 999px; color: var(--green-800); background: var(--green-50); font-size: 12px; font-weight: 600; }

.workspace { width: min(1180px, calc(100% - 40px)); margin: 28px auto 18px; }
.chat-panel {
  height: calc(100vh - 142px);
  min-height: 590px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(220, 229, 222, 0.9);
  border-radius: 22px;
  background: #fff;
  box-shadow: var(--shadow);
}
.task-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 24px 16px; }
.task-title-row { display: flex; align-items: center; gap: 10px; }
.task-heading h1 { margin: 0; font-size: 18px; font-weight: 700; }
.task-heading p { display: flex; align-items: center; gap: 7px; margin: 7px 0 0; color: #8a9791; font-size: 11px; }
.status-dot { width: 6px; height: 6px; display: inline-block; flex: 0 0 auto; border-radius: 50%; background: #65a88b; box-shadow: 0 0 0 3px rgba(101, 168, 139, 0.12); }
.continue-badge { padding: 3px 8px; border-radius: 999px; color: #8c6b2d; background: #fbf3dc; font-size: 10px; }
.task-actions { display: flex; gap: 8px; }
.chat-settings {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) minmax(200px, 0.8fr);
  align-items: end;
  gap: 22px;
  padding: 15px 24px;
  border-top: 1px solid #f0f3f0;
  border-bottom: 1px solid var(--line);
  background: #fafcfa;
}
.setting-group, .field-setting { display: grid; gap: 8px; }
.setting-label { color: #7d8d85; font-size: 11px; font-weight: 600; }
.segmented { display: flex; width: max-content; padding: 3px; border: 1px solid #e1e8e3; border-radius: 10px; background: #f0f3f0; }
.scene-button { min-width: 62px; padding: 6px 13px; border: 0; border-radius: 7px; color: #7d8a84; background: transparent; font-size: 12px; }
.scene-button.active { color: var(--green-800); background: #fff; box-shadow: 0 2px 8px rgba(31, 65, 51, 0.08); font-weight: 650; }
.field-setting input, .field-setting select {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border: 1px solid #dfe7e1;
  border-radius: 9px;
  outline: none;
  background: #fff;
  font-size: 12px;
}
.field-setting input:focus, .field-setting select:focus { border-color: #86b29e; box-shadow: 0 0 0 3px rgba(35, 113, 88, 0.07); }

.messages {
  flex: 1;
  min-height: 180px;
  overflow-y: auto;
  padding: 28px clamp(18px, 4vw, 50px);
  scroll-behavior: smooth;
  background:
    linear-gradient(rgba(255, 255, 255, 0.93), rgba(255, 255, 255, 0.93)),
    radial-gradient(circle at 1px 1px, #cddbd2 1px, transparent 0);
  background-size: auto, 24px 24px;
}
.empty-chat { height: 100%; min-height: 250px; display: grid; place-content: center; justify-items: center; text-align: center; }
.empty-icon { width: 64px; height: 64px; display: grid; place-items: center; margin-bottom: 18px; border: 1px solid #dce9e0; border-radius: 22px; color: var(--green-700); background: var(--green-50); font-size: 25px; transform: rotate(-4deg); }
.empty-chat h2 { margin: 0 0 9px; font-size: 17px; font-weight: 650; }
.empty-chat p { max-width: 350px; margin: 0; color: #8b9892; font-size: 12px; line-height: 1.8; }
.message { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 24px; }
.message.a { flex-direction: row-reverse; }
.avatar { width: 32px; height: 32px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 10px; color: #6e7b75; background: #edf0ee; font-size: 11px; font-weight: 700; }
.message.a .avatar { color: #fff; background: var(--green-700); }
.message-body { max-width: min(73%, 690px); }
.message-meta { display: flex; align-items: center; gap: 8px; margin: 0 0 6px 2px; color: #97a29d; font-size: 10px; }
.message.a .message-meta { justify-content: flex-end; margin-right: 2px; }
.bubble { padding: 12px 15px; border: 1px solid #e5e9e6; border-radius: 4px 15px 15px 15px; color: #384a43; background: #f1f3f2; font-size: 14px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.a .bubble { border-color: #cfe5d7; border-radius: 15px 4px 15px 15px; color: #174c39; background: #dcf1df; }
.message-images { display: grid; grid-template-columns: repeat(2, minmax(0, 180px)); gap: 7px; margin-top: 8px; }
.message-images img { width: 100%; max-height: 230px; object-fit: cover; border: 1px solid #dce3de; border-radius: 10px; background: #fff; }
.screenshot-marker { display: inline-block; margin-top: 8px; padding: 5px 9px; border-radius: 7px; color: #89948f; background: #f1f3f2; font-size: 11px; }
.model-name { margin-top: 6px; color: #92a199; font-size: 9px; text-align: right; }
.copy-reply { margin-top: 5px; padding: 2px 0; border: 0; color: #6d8c7c; background: transparent; font-size: 10px; }
.copy-reply:hover { color: var(--green-800); }
.loading-bubble { display: flex; align-items: center; gap: 5px; min-width: 62px; min-height: 43px; }
.loading-bubble i { width: 6px; height: 6px; border-radius: 50%; background: #72a489; animation: bounce 1.2s infinite; }
.loading-bubble i:nth-child(2) { animation-delay: 0.15s; }
.loading-bubble i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.45; } 30% { transform: translateY(-4px); opacity: 1; } }

.composer-wrap { padding: 14px 22px 13px; border-top: 1px solid var(--line); background: #fff; }
.composer { display: flex; align-items: flex-end; gap: 12px; }
.composer textarea {
  flex: 1;
  min-height: 66px;
  max-height: 150px;
  resize: vertical;
  padding: 12px 14px;
  border: 1px solid #dfe7e1;
  border-radius: 12px;
  outline: none;
  background: #fafcfa;
  font-size: 13px;
  line-height: 1.65;
}
.composer textarea:focus { border-color: #8ab39f; box-shadow: 0 0 0 4px rgba(35, 113, 88, 0.06); background: #fff; }
.send-button { height: 42px; min-width: 82px; display: flex; align-items: center; justify-content: center; gap: 10px; border: 0; border-radius: 11px; color: #fff; background: var(--green-800); font-size: 13px; font-weight: 650; }
.send-button:hover:not(:disabled) { background: var(--green-900); }
.composer-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; color: #9aa59f; font-size: 9px; }
kbd { padding: 1px 4px; border: 1px solid #e1e6e2; border-radius: 4px; background: #f7f9f7; font-family: inherit; font-size: 8px; }
.attachments { display: flex; gap: 10px; overflow-x: auto; padding: 0 0 12px; }
.attachment { width: 76px; height: 66px; position: relative; flex: 0 0 auto; }
.attachment img { width: 100%; height: 100%; object-fit: cover; border: 1px solid #dbe5de; border-radius: 9px; }
.remove-attachment { width: 20px; height: 20px; display: grid; place-items: center; position: absolute; top: -6px; right: -6px; padding: 0; border: 2px solid #fff; border-radius: 50%; color: #fff; background: #67766f; font-size: 12px; line-height: 1; }
.privacy-note { margin: 12px 4px 0; color: #909b95; font-size: 10px; text-align: center; }

.toast { max-width: min(480px, calc(100% - 32px)); position: fixed; top: 22px; left: 50%; z-index: 100; transform: translateX(-50%); padding: 12px 18px; border: 1px solid #d5e6da; border-radius: 12px; color: #245740; background: rgba(246, 252, 247, 0.97); box-shadow: 0 12px 40px rgba(23, 65, 46, 0.16); font-size: 13px; line-height: 1.6; text-align: center; }
.toast.error { border-color: #edd3d3; color: #934343; background: rgba(255, 248, 248, 0.98); }
.drawer-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(20, 42, 34, 0.26); backdrop-filter: blur(2px); }
.history-drawer { width: min(520px, 100%); position: fixed; inset: 0 0 0 auto; z-index: 21; display: flex; flex-direction: column; padding: 28px; background: #fbfcfb; box-shadow: -20px 0 70px rgba(20, 53, 39, 0.14); }
.drawer-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.drawer-header h2 { margin: 0; font-size: 23px; }
.icon-button { width: 36px; height: 36px; border: 1px solid #e0e7e2; border-radius: 10px; color: #6c7d74; background: #fff; font-size: 23px; line-height: 1; }
.drawer-description { margin: 14px 0 20px; color: #86948d; font-size: 12px; line-height: 1.7; }
.history-content { flex: 1; overflow-y: auto; padding-right: 4px; }
.history-empty { display: grid; place-items: center; min-height: 280px; color: #8d9a93; font-size: 13px; text-align: center; line-height: 2; }
.history-card { margin-bottom: 13px; padding: 17px; border: 1px solid #e0e8e2; border-radius: 15px; background: #fff; }
.history-card-top { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.log-badge { padding: 3px 7px; border-radius: 6px; color: var(--green-700); background: var(--green-50); font-size: 10px; }
.log-customer { color: #62746b; font-size: 11px; font-weight: 600; }
.log-time { margin-left: auto; color: #9aa69f; font-size: 9px; }
.history-card h3 { margin: 12px 0 7px; font-size: 14px; font-weight: 650; line-height: 1.6; overflow-wrap: anywhere; }
.log-model { margin: 0; color: #93a098; font-size: 9px; overflow-wrap: anywhere; }
.log-details { margin-top: 12px; border-top: 1px solid #eef2ef; padding-top: 10px; }
.log-details summary { color: #73877b; cursor: pointer; font-size: 11px; }
.log-transcript { max-height: 280px; overflow: auto; margin: 10px 0 0; color: #54675d; font-family: inherit; font-size: 11px; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.log-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 13px; }
.log-actions .button { min-height: 32px; padding: 5px 12px; font-size: 11px; }
.deleted-label { color: var(--danger); }

@media (max-width: 760px) {
  .topbar { height: auto; min-height: 68px; padding: 12px 16px; }
  .brand-subtitle, .user-badge { display: none; }
  .brand-mark { width: 35px; height: 35px; border-radius: 11px; }
  .brand-title { font-size: 14px; }
  .account-actions { gap: 0; }
  .account-actions .button { min-height: 34px; padding: 6px 9px; font-size: 11px; }
  .workspace { width: calc(100% - 20px); margin-top: 12px; }
  .chat-panel { height: calc(100vh - 117px); min-height: 540px; border-radius: 16px; }
  .task-toolbar { padding: 15px 15px 12px; }
  .task-heading h1 { font-size: 16px; }
  .task-actions .button { padding: 7px 10px; font-size: 11px; }
  .chat-settings { grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px 15px; }
  .scene-setting { grid-column: 1 / -1; grid-template-columns: auto 1fr; align-items: center; }
  .model-setting { min-width: 0; }
  .messages { padding: 20px 13px; }
  .message-body { max-width: 84%; }
  .bubble { padding: 10px 12px; font-size: 13px; }
  .composer-wrap { padding: 11px 12px; }
  .composer { gap: 8px; }
  .send-button { min-width: 60px; }
  .composer-meta > span:first-child { max-width: 80%; line-height: 1.8; }
  .privacy-note { display: none; }
  .history-drawer { padding: 22px 17px; }
}

@media (max-width: 480px) {
  .login-card { padding: 30px 24px 26px; border-radius: 22px; }
  .login-copy { margin-top: 38px; }
  .login-copy h1 { font-size: 30px; }
  .brand-group { gap: 8px; }
  .account-actions .danger-text { display: none; }
  .task-heading p { max-width: 170px; line-height: 1.5; }
  .task-actions { gap: 5px; }
  .chat-settings { gap: 10px; }
  .field-setting input, .field-setting select { padding: 0 8px; font-size: 11px; }
  .composer-meta > span:first-child { font-size: 8px; }
  .message { gap: 8px; }
  .avatar { width: 28px; height: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
