:root {
  --ink: #142033;
  --ink-soft: #24344a;
  --paper: #eef2f5;
  --card: #ffffff;
  --line: #d5dee7;
  --accent: #1f4e79;
  --accent-dark: #16395a;
  --brass: #b08948;
  --brass-soft: #d7b56d;
  --muted: #5e6d7e;
  --danger: #9c3434;
  --ok: #1d7a46;
  --shadow: 0 12px 32px rgba(20, 32, 51, 0.08);
  color: var(--ink);
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--paper);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, p { margin: 0; }

#auth-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 42%) 1fr;
}

.brand-panel {
  background: var(--ink);
  color: #f4f7fa;
  padding: 72px 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.brand-panel h1 { font-size: 40px; letter-spacing: 0.04em; font-weight: 650; }
.brand-panel p { max-width: 360px; color: #c5d0db; line-height: 1.7; }

.brand-mark {
  width: 64px;
  height: 64px;
  border: 1px solid var(--brass-soft);
  color: var(--brass-soft);
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.brand-mark.sm { width: 36px; height: 36px; font-size: 12px; }

.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 10vw;
  background: var(--paper);
}

.tabs { display: flex; gap: 8px; margin-bottom: 22px; }
.tab, .ghost, .primary {
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 10px 16px;
}
.tab { background: transparent; color: var(--muted); }
.tab.active { background: white; color: var(--ink); border-color: var(--line); }
.primary { background: var(--accent); color: white; border-color: var(--accent); }
.primary:hover { background: var(--accent-dark); }
.ghost { background: white; border-color: var(--line); color: var(--ink-soft); }
.ghost.active { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: 0.55; cursor: wait; }

form { display: flex; flex-direction: column; gap: 8px; }
label { font-size: 13px; color: var(--muted); margin-top: 8px; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: 6px;
  padding: 11px 12px;
}
textarea { min-height: 140px; resize: vertical; line-height: 1.6; }
input:focus, textarea:focus, select:focus, .drop:focus {
  outline: 2px solid rgba(31, 78, 121, 0.25);
  border-color: var(--accent);
}
.auth-panel h2 { font-size: 22px; margin-bottom: 8px; }
.auth-panel .primary { margin-top: 16px; }

.hint { color: var(--muted); font-size: 13px; line-height: 1.6; }
.form-error { min-height: 1.2em; color: var(--danger); font-size: 14px; }
.form-error:empty { display: none; }

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: white;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
}
.brand-lockup, .top-actions, .action-row, .result-head { display: flex; align-items: center; gap: 12px; }
.brand-lockup strong, .brand-lockup span { display: block; }
.brand-lockup span, #who { color: var(--muted); font-size: 13px; }
#app-view { min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0; max-width: none; margin: 0; }
.banner { margin: 12px 16px 0; }

.banner {
  background: #f8f1e3;
  border: 1px solid #e4d2ae;
  color: #6d5424;
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 280px minmax(0, 1fr); background: #f5f6f8; }
.sidebar { background: #f3f4f6; border-right: 1px solid #e6e8ec; padding: 16px 12px; display: flex; flex-direction: column; min-height: 0; }
.new-task {
  width: 100%;
  background: white;
  border: 1px solid #e1e4e8;
  border-radius: 12px;
  padding: 12px 14px;
  text-align: left;
  font-weight: 650;
}
.new-task::before { content: "+  "; color: var(--accent); }
.side-label { margin: 18px 8px 8px; color: var(--muted); font-size: 12px; }
.thread-list { list-style: none; margin: 0; padding: 0; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.thread-list li { border-radius: 10px; }
.thread-list li.active { background: #e7e9ee; }
.thread-row, .thread-delete { border: 0; background: transparent; }
.thread-row { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; text-align: left; border-radius: 10px; }
.thread-row:hover { background: #eceef2; }
.thread-title { font-size: 14px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-time { color: var(--muted); font-size: 12px; }
.thread-list li { display: grid; grid-template-columns: 1fr auto; align-items: center; }
.thread-delete { color: var(--muted); padding: 8px; border-radius: 8px; }
.thread-delete:hover { color: var(--danger); background: white; }
.chat { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: #f7f8fa; }
.transcript { flex: 1; overflow: auto; padding: 28px 8vw 12px; display: flex; flex-direction: column; gap: 16px; }
.empty-thread { margin: auto; color: var(--muted); text-align: center; line-height: 1.7; }
.bubble { max-width: 760px; width: 100%; }
.bubble.user { margin-left: auto; max-width: min(680px, 86%); }
.bubble.user .bubble-body { background: #eceff3; border-radius: 16px; padding: 12px 14px; white-space: pre-wrap; word-break: break-word; line-height: 1.7; }
.bubble.assistant .bubble-body { background: white; border: 1px solid #e6e8ec; border-radius: 16px; padding: 16px 18px; white-space: pre-wrap; word-break: break-word; line-height: 1.75; }
.bubble-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.file-chip { display: inline-block; margin: 6px 6px 0 0; padding: 2px 8px; border-radius: 999px; background: white; border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.composer-wrap { padding: 8px 8vw 22px; }
.composer { background: white; border: 1px solid #e3e6eb; border-radius: 18px; box-shadow: 0 8px 24px rgba(20, 32, 51, 0.06); padding: 12px 12px 8px; }
.composer.over { border-color: var(--accent); }
.composer textarea { border: 0; padding: 6px 8px; resize: none; min-height: 52px; background: transparent; }
.composer textarea:focus { outline: none; border: 0; }
.composer-bar { display: flex; align-items: center; gap: 10px; }
.icon-button, .send { border-radius: 999px; }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); background: white; font-size: 20px; line-height: 1; }
.send { margin-left: auto; background: var(--ink); color: white; border: 0; padding: 8px 16px; }
.send:disabled { opacity: 0.45; }
.settings-card { margin: 28px auto; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 22px;
}
.card h2 { font-size: 18px; margin-bottom: 14px; }
.settings-card { max-width: 640px; }

.drop {
  border: 1.5px dashed #b7c4d1;
  background: #f7f9fb;
  border-radius: 8px;
  min-height: 148px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  padding: 18px;
}
.drop.over { border-color: var(--accent); background: #f3f7fb; }
.drop p, .drop span { color: var(--muted); font-size: 13px; }

.file-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 8px; }
.file-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: #f7f9fb;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
}
.file-list button { padding: 4px 8px; }

.result-card { display: flex; flex-direction: column; }
.result-head { justify-content: space-between; }
.status { color: var(--accent); font-size: 13px; min-height: 1.2em; margin-bottom: 8px; }
#result {
  flex: 1;
  margin: 0;
  min-height: 360px;
  white-space: pre-wrap;
  word-break: break-word;
  background: #f7f9fb;
  border-radius: 8px;
  padding: 16px;
  line-height: 1.7;
  font-family: Consolas, "Sarasa Mono SC", "Microsoft YaHei", monospace;
  font-size: 14px;
}
#result.placeholder { color: var(--muted); }

@media (max-width: 900px) {
  #auth-view { grid-template-columns: 1fr; }
  .brand-panel { padding: 36px 24px; }
  .brand-panel h1 { font-size: 30px; }
  .auth-panel, main, .topbar { padding-left: 16px; padding-right: 16px; }
  .topbar { height: auto; flex-wrap: wrap; gap: 10px; padding-top: 12px; padding-bottom: 12px; }
  .workspace { grid-template-columns: 1fr; }
  .sidebar { max-height: 220px; }
  .transcript, .composer-wrap { padding-left: 16px; padding-right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
