:root {
  color-scheme: light;
  --bg: #edf2f6;
  --panel: #ffffff;
  --panel-muted: #f6f8fb;
  --text: #18212f;
  --muted: #647083;
  --line: #dbe3ee;
  --accent: #147d74;
  --accent-dark: #0c5d56;
  --navy: #173b57;
  --warning: #b75c2d;
  --shadow: 0 18px 48px rgba(35, 51, 77, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea,
a,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  width: min(1440px, calc(100vw - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
}

.work-panel,
.assistant-workspace,
.tool-pane,
.chat-pane {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.work-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  padding: 20px;
}

.brand-row {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  align-items: center;
}

.brand-mark,
.avatar {
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
}

.brand-mark {
  width: 48px;
  height: 48px;
  font-size: 17px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.25;
}

.brand-row p,
.status-grid dt,
.source-card span,
.source-card a,
.next-action,
.stage-row span,
.eyebrow {
  color: var(--muted);
  font-size: 13px;
}

.quick-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.quick-nav a,
.header-link,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid rgba(20, 125, 116, 0.22);
  border-radius: 8px;
  color: var(--accent-dark);
  background: rgba(20, 125, 116, 0.08);
  font-weight: 700;
  text-decoration: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-actions label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select {
  width: min(360px, 32vw);
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--text);
  background: #fff;
  outline: none;
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 125, 116, 0.14);
}

.ghost-button {
  min-width: 60px;
  cursor: pointer;
}

.panel-section {
  display: grid;
  gap: 12px;
}

.section-header,
.workspace-header,
.stage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-section h2,
.workspace-header h2 {
  font-size: 16px;
  letter-spacing: 0;
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-dark);
  background: var(--panel);
  cursor: pointer;
}

.status-grid {
  display: grid;
  gap: 8px;
  margin: 0;
}

.status-grid div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.status-grid dd {
  margin: 0;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}

.source-list {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
}

.source-list.compact .source-card:nth-child(n + 4) {
  display: none;
}

.source-card {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-muted);
}

.source-card strong {
  font-size: 13px;
}

.source-card a {
  overflow-wrap: anywhere;
}

.tip-box {
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-muted);
}

.sample-question {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  cursor: pointer;
  text-align: left;
  padding: 0 10px;
}

.assistant-workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  overflow: hidden;
}

.workspace-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.eyebrow {
  margin-bottom: 4px;
  text-transform: uppercase;
  font-weight: 800;
}

.reply-layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
  padding: 16px;
}

.tool-pane,
.chat-pane {
  min-height: 0;
  box-shadow: none;
}

.tool-pane {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 16px;
}

.tool-pane label {
  font-size: 14px;
  font-weight: 800;
}

textarea {
  width: 100%;
  min-height: 54px;
  max-height: 180px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 125, 116, 0.14);
}

.primary-button,
.secondary-button,
.composer button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

.secondary-button {
  color: var(--accent-dark);
  border: 1px solid rgba(20, 125, 116, 0.24);
  background: rgba(20, 125, 116, 0.1);
}

.sales-result {
  display: grid;
  gap: 10px;
}

.stage-row {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-muted);
}

.stage-row strong {
  color: var(--accent-dark);
  font-size: 13px;
}

.reply-output {
  min-height: 178px;
  font-size: 14px;
  line-height: 1.6;
  background: #fff;
}

.chat-pane {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 18px;
  overflow: auto;
  background: #fbfcfd;
}

.message {
  display: grid;
  grid-template-columns: 38px minmax(0, 720px);
  gap: 12px;
  align-items: start;
}

.message.user {
  grid-template-columns: minmax(0, 720px) 38px;
  justify-content: end;
}

.avatar {
  width: 38px;
  height: 38px;
  font-size: 12px;
}

.message.user .avatar {
  grid-column: 2;
  background: var(--navy);
}

.bubble {
  min-width: 0;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  line-height: 1.65;
  white-space: pre-wrap;
}

.message.user .bubble {
  grid-column: 1;
  grid-row: 1;
  color: #fff;
  border-color: transparent;
  background: var(--navy);
}

.source-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.source-chip {
  display: inline-flex;
  max-width: 100%;
  padding: 5px 8px;
  border-radius: 8px;
  color: var(--accent-dark);
  background: rgba(20, 125, 116, 0.1);
  font-size: 12px;
  text-decoration: none;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

@media (max-width: 980px) {
  .app-shell,
  .reply-layout {
    grid-template-columns: 1fr;
  }

  .workspace-header,
  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  select {
    width: 100%;
  }

  .app-shell {
    width: 100vw;
    min-height: 100vh;
    margin: 0;
  }
}
