:root {
  --bg: #f2f4f6;
  --surface: #ffffff;
  --surface-soft: #f7f9fa;
  --surface-strong: #edf2f3;
  --ink: #1d2831;
  --muted: #667585;
  --line: #d7dee4;
  --line-strong: #bbc8d0;
  --primary: #245b5f;
  --primary-dark: #173f43;
  --accent: #9a5539;
  --good: #2f6f55;
  --warn: #a45f1f;
  --risk: #9c3d3d;
  --shadow: 0 10px 28px rgba(26, 38, 50, 0.07);
}

* {
  box-sizing: border-box;
}

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

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

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

button,
summary {
  cursor: pointer;
}

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

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  font-weight: 780;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  font-weight: 750;
  letter-spacing: 0;
}

h3 {
  font-size: 15px;
  font-weight: 740;
  letter-spacing: 0;
}

.app-shell {
  min-height: 100vh;
  padding: 18px 22px 22px;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin: 0 auto 12px;
  max-width: 1800px;
}

.brand-block {
  min-width: 0;
}

.eyebrow,
.panel-kicker {
  color: var(--accent);
  font-size: 11px;
  font-weight: 780;
  letter-spacing: 0;
  margin: 0 0 5px;
  text-transform: uppercase;
}

.topbar-actions {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  min-width: 0;
}

.connection-status {
  background: #e8eef1;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #40505f;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  max-width: 360px;
  overflow-wrap: anywhere;
  padding: 9px 11px;
}

.user-session {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  font-size: 11px;
  font-weight: 700;
  gap: 8px;
  padding: 8px 10px;
}

.profile-trigger {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 8px;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  min-height: 48px;
  min-width: 250px;
  padding: 6px 9px;
  text-align: left;
}

.profile-trigger:hover {
  border-color: var(--primary);
}

.profile-avatar {
  align-items: center;
  background: #edf5f2;
  border: 1px solid #c8ddd7;
  border-radius: 50%;
  color: var(--good);
  display: inline-flex;
  font-size: 14px;
  font-weight: 800;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.profile-trigger-copy {
  display: grid;
  min-width: 0;
}

.profile-trigger-copy strong,
.profile-trigger-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-trigger-copy strong {
  font-size: 13px;
}

.profile-trigger-copy span,
.profile-trigger-action {
  color: var(--muted);
  font-size: 11px;
}

.profile-trigger-action {
  color: var(--primary);
  font-weight: 750;
}

.notice {
  background: #fff8ee;
  border: 1px solid #ecd6b9;
  border-radius: 8px;
  color: #6b471f;
  font-size: 13px;
  line-height: 1.55;
  margin: 0 auto 12px;
  max-width: 1800px;
  padding: 9px 13px;
}

.mode-bar {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin: 0 auto 12px;
  max-width: 1800px;
}

.mode-switch {
  background: #e7ecef;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-grid;
  gap: 3px;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
}

.mode-button {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #536272;
  display: grid;
  font-size: 13px;
  font-weight: 760;
  gap: 1px;
  min-width: 184px;
  padding: 7px 12px;
  text-align: left;
}

.mode-button span {
  font-size: 10px;
  font-weight: 600;
}

.mode-button.active {
  background: #fff;
  border-color: var(--line-strong);
  color: var(--primary-dark);
  box-shadow: 0 2px 7px rgba(26, 38, 50, 0.08);
}

.mode-boundary {
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
  padding: 15px;
}

.panel-heading {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.pill,
.meta-pill,
.tag {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  font-size: 11px;
  font-weight: 700;
  min-height: 27px;
  padding: 4px 9px;
}

.pill {
  background: #e8eef1;
  color: #40505f;
  max-width: 240px;
  overflow-wrap: anywhere;
  text-align: right;
}

.formal-workspace {
  align-items: stretch;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(300px, 0.72fr) minmax(500px, 1.28fr) minmax(340px, 0.82fr);
  height: calc(100vh - 184px);
  margin: 0 auto;
  max-width: 1800px;
  min-height: 620px;
}

.workspace-column {
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.case-input-column {
  display: grid;
  gap: 14px;
  grid-auto-rows: max-content;
}

.case-output-column .output-panel,
.case-action-column .follow-panel {
  min-height: 100%;
}

.field-label {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 740;
  margin: 9px 0 5px;
}

.text-input,
textarea {
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  outline: none;
  padding: 9px 10px;
  width: 100%;
}

.text-input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(36, 91, 95, 0.12);
}

.compact-form-grid,
.profile-form-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 13px;
}

.split-actions > * {
  flex: 1 1 120px;
}

.primary-button,
.secondary-button,
.tab-button,
.task-button {
  border-radius: 8px;
  font-weight: 740;
  min-height: 38px;
  padding: 8px 12px;
}

.primary-button {
  background: var(--primary);
  border: 1px solid var(--primary);
  color: #fff;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.danger-button {
  color: var(--risk);
}

.save-status {
  color: var(--muted);
  font-size: 11px;
  margin-top: 8px;
}

.save-status.saved {
  color: var(--good);
}

.secondary-button,
.tab-button,
.task-button {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.secondary-button:hover,
.tab-button:hover,
.tab-button.active,
.task-button:hover,
.task-button.active {
  background: var(--surface-strong);
  border-color: var(--primary);
}

.material-stack {
  display: grid;
  gap: 8px;
}

.material-item {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.material-item summary {
  align-items: center;
  display: flex;
  font-size: 13px;
  font-weight: 750;
  gap: 10px;
  justify-content: space-between;
  list-style: none;
  min-height: 42px;
  padding: 9px 11px;
}

.material-item summary::-webkit-details-marker {
  display: none;
}

.material-item summary::before {
  color: var(--primary);
  content: "+";
  font-size: 17px;
  line-height: 1;
  width: 12px;
}

.material-item[open] summary::before {
  content: "−";
}

.material-item summary > :first-child {
  margin-right: auto;
}

.material-count {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.material-body {
  border-top: 1px solid var(--line);
  padding: 10px;
}

.material-file-input {
  margin-bottom: 8px;
  max-width: 100%;
}

.material-textarea {
  min-height: 150px;
  resize: vertical;
}

.drop-zone {
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.drop-zone.drag-active {
  background: #eef5f3;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(36, 91, 95, 0.12);
}

.file-input {
  color: var(--muted);
  font-size: 11px;
  max-width: 190px;
}

.output-tabs,
.task-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.output-tabs {
  border-bottom: 1px solid var(--line);
  margin-bottom: 13px;
  padding-bottom: 11px;
}

.tab-button,
.task-button {
  font-size: 12px;
  min-height: 33px;
  padding: 6px 9px;
}

.follow-textarea {
  min-height: 126px;
  resize: vertical;
}

.follow-upload {
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 11px;
  padding: 11px;
}

.follow-upload-heading {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.follow-upload-heading .field-label {
  margin-top: 0;
}

.follow-upload-heading p,
.attachment-empty,
.attachment-note,
.quick-drop p,
.quick-transfer p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.attachment-list {
  display: grid;
  gap: 7px;
  margin-top: 9px;
}

.attachment-item {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 9px;
  justify-content: space-between;
  min-width: 0;
  padding: 8px 9px;
}

.attachment-actions {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.attachment-name {
  display: inline-block;
  font-size: 12px;
  font-weight: 720;
  max-width: 250px;
  overflow-wrap: anywhere;
  vertical-align: middle;
}

.attachment-status {
  border-radius: 999px;
  display: inline-flex;
  font-size: 10px;
  font-weight: 740;
  margin-left: 5px;
  padding: 2px 7px;
}

.attachment-status.ready {
  background: #eef7f2;
  color: var(--good);
}

.attachment-status.blocked {
  background: #fff0f0;
  color: var(--risk);
}

.attachment-status.review {
  background: #fff4e8;
  color: var(--warn);
}

.attachment-status.working {
  background: #e8eef1;
  color: #40505f;
}

.attachment-note {
  display: block;
  margin-top: 3px;
}

.text-button {
  background: transparent;
  border: 0;
  color: var(--primary);
  font-size: 11px;
  font-weight: 740;
  padding: 4px 0;
}

.send-preview {
  background: #f7faf9;
  border: 1px solid #cddfda;
  border-radius: 8px;
  color: #31554f;
  line-height: 1.55;
  margin-top: 11px;
  padding: 10px 11px;
}

.send-preview summary {
  font-size: 12px;
  font-weight: 740;
}

.preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.preview-chip {
  background: #fff;
  border: 1px solid #c8ddd7;
  border-radius: 999px;
  color: #31554f;
  font-size: 10px;
  font-weight: 680;
  padding: 4px 7px;
}

.empty-state {
  align-items: center;
  background: #f7f9fb;
  border: 1px dashed #cbd4dc;
  border-radius: 8px;
  color: var(--muted);
  display: flex;
  justify-content: center;
  line-height: 1.65;
  min-height: 280px;
  padding: 22px;
  text-align: center;
}

.compact-empty {
  min-height: 220px;
}

.hidden {
  display: none !important;
}

.output-content {
  display: grid;
  gap: 11px;
  max-width: 100%;
  min-width: 0;
}

.source-card {
  background: #eef5f3;
  border: 1px solid #c8ddd7;
  border-radius: 8px;
  color: #285249;
  display: flex;
  flex-wrap: wrap;
  font-size: 11px;
  font-weight: 680;
  gap: 6px 14px;
  line-height: 1.5;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 9px 11px;
  word-break: break-word;
}

.output-card {
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 13px;
  word-break: break-word;
}

.output-card h3 {
  margin-bottom: 7px;
}

.output-card h3:not(:first-child) {
  margin-top: 15px;
}

.output-card ul {
  margin: 7px 0 0;
  padding-left: 18px;
}

.output-card li,
.output-card p {
  line-height: 1.68;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.output-card li {
  margin: 4px 0;
}

.error-card {
  background: #fff0f0;
  border-color: #ecc2c2;
  color: var(--risk);
}

.error-hint,
.error-time {
  color: #6f3d3d;
  font-size: 12px;
  margin-top: 7px;
}

.memo-box,
.draft-box,
.worklog-question,
.worklog-answer {
  line-height: 1.75;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  word-break: break-word;
}

.memo-box,
.draft-box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
}

.worklog-list {
  display: grid;
  gap: 11px;
}

.worklog-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
}

.worklog-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 10px;
  font-weight: 680;
  gap: 7px;
  margin-bottom: 7px;
}

.worklog-question,
.worklog-answer {
  padding: 8px 9px;
}

.worklog-question {
  background: #f7f9fb;
  border-left: 3px solid var(--primary);
  margin-bottom: 7px;
}

.worklog-answer {
  background: #fff;
  border-left: 3px solid #c8ddd7;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
  max-width: 100%;
  min-width: 0;
}

.meta-pill {
  max-width: 100%;
}

.amount-pill {
  border-radius: 8px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: normal;
  word-break: break-word;
}

.meta-pill.good {
  background: #eef7f2;
  border-color: #c6e0d2;
  color: var(--good);
}

.meta-pill.warn {
  background: #fff4e8;
  border-color: #e9c79f;
  color: var(--warn);
}

.meta-pill.risk {
  background: #fff0f0;
  border-color: #ecc2c2;
  color: var(--risk);
}

.quick-workspace {
  align-items: stretch;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(340px, 0.72fr) minmax(520px, 1.28fr);
  height: calc(100vh - 184px);
  margin: 0 auto;
  max-width: 1500px;
  min-height: 580px;
}

.quick-input-panel,
.quick-output-panel {
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.quick-question {
  min-height: 112px;
  resize: vertical;
}

.quick-material-text {
  min-height: 156px;
  resize: vertical;
}

.quick-drop {
  align-items: center;
  background: var(--surface-soft);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-top: 12px;
  min-height: 116px;
  padding: 15px;
}

.quick-drop strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}

.isolation-note {
  background: #f7faf9;
  border-left: 3px solid var(--good);
  color: #31554f;
  font-size: 12px;
  line-height: 1.6;
  margin-top: 12px;
  padding: 9px 11px;
}

.quick-transfer {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-top: 13px;
  padding-top: 13px;
}

.quick-follow-up {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 15px;
}

.quick-follow-up-heading {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.quick-follow-up-heading p,
.quick-conversation-empty {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  margin-top: 3px;
}

.quick-follow-up-question {
  min-height: 96px;
  resize: vertical;
}

.quick-conversation {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.quick-conversation-item {
  border-left: 3px solid var(--line-strong);
  min-width: 0;
  padding: 7px 0 7px 10px;
}

.quick-conversation-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 10px;
  font-weight: 680;
  gap: 7px;
  margin-bottom: 5px;
}

.quick-conversation-question {
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 720;
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.quick-conversation-answer {
  font-size: 13px;
  line-height: 1.72;
  margin-top: 7px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  word-break: break-word;
}

.quick-conversation-error {
  border-left-color: var(--risk);
  color: var(--risk);
}

.quick-transfer-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-transfer-actions .text-input {
  min-width: 132px;
  width: auto;
}

.quick-type-badge {
  background: #fff4e8;
  border: 1px solid #e9c79f;
  border-radius: 8px;
  color: var(--warn);
  display: inline-flex;
  font-size: 12px;
  font-weight: 740;
  margin-bottom: 10px;
  padding: 5px 8px;
}

.profile-dialog {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(20, 31, 40, 0.24);
  color: var(--ink);
  max-height: min(840px, calc(100vh - 36px));
  max-width: 720px;
  overflow-y: auto;
  padding: 18px;
  width: calc(100% - 28px);
}

.document-dialog {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(20, 31, 40, 0.24);
  color: var(--ink);
  max-height: calc(100vh - 32px);
  max-width: 920px;
  overflow-y: auto;
  padding: 18px;
  width: calc(100% - 28px);
}

.document-dialog::backdrop {
  background: rgba(22, 31, 39, 0.56);
}

.document-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 11px;
  gap: 6px 14px;
  margin: 12px 0;
}

.document-warnings {
  background: #fff4e8;
  border-left: 3px solid var(--warn);
  color: #754619;
  font-size: 12px;
  line-height: 1.6;
  margin-bottom: 10px;
  padding: 9px 11px;
  white-space: pre-wrap;
}

.document-review-textarea {
  min-height: min(55vh, 520px);
  resize: vertical;
}

.review-note {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
  margin-top: 8px;
}

.auth-gate {
  align-items: center;
  background: rgba(236, 240, 243, 0.96);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: fixed;
  z-index: 1000;
}

.login-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 22px 64px rgba(20, 31, 40, 0.2);
  max-width: 380px;
  padding: 22px;
  width: 100%;
}

.login-panel h2 {
  margin-bottom: 14px;
}

.login-button {
  margin-top: 8px;
  width: 100%;
}

.login-status {
  color: var(--risk);
  font-size: 12px;
  line-height: 1.5;
  min-height: 20px;
  padding-top: 6px;
}

.profile-dialog::backdrop {
  background: rgba(22, 31, 39, 0.48);
}

.dialog-heading,
.profile-status-row,
.dialog-actions {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.dialog-heading {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.dialog-close {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  display: inline-flex;
  font-size: 24px;
  height: 34px;
  justify-content: center;
  padding: 0;
  width: 34px;
}

.dialog-close:hover {
  background: var(--surface-strong);
  color: var(--ink);
}

.profile-status-row {
  color: var(--muted);
  font-size: 12px;
  justify-content: flex-start;
  margin: 12px 0 4px;
}

.compact-textarea {
  min-height: 72px;
  resize: vertical;
}

.dialog-actions {
  border-top: 1px solid var(--line);
  justify-content: flex-end;
  margin-top: 14px;
  padding-top: 14px;
}

@media (max-width: 1250px) {
  .formal-workspace {
    grid-template-columns: minmax(300px, 0.68fr) minmax(520px, 1.32fr);
    height: auto;
    min-height: 0;
  }

  .workspace-column {
    max-height: none;
    overflow-y: visible;
  }

  .case-action-column {
    grid-column: 1 / -1;
  }

  .case-action-column .follow-panel {
    min-height: auto;
  }
}

@media (max-width: 880px) {
  .app-shell {
    padding: 13px;
  }

  .topbar,
  .topbar-actions,
  .mode-bar,
  .quick-drop,
  .quick-transfer,
  .quick-follow-up-heading,
  .follow-upload-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .quick-transfer-actions,
  .quick-transfer-actions .text-input,
  .quick-transfer-actions .secondary-button {
    width: 100%;
  }

  .topbar-actions,
  .profile-trigger,
  .connection-status,
  .user-session {
    max-width: none;
    width: 100%;
  }

  .mode-switch {
    width: 100%;
  }

  .mode-button {
    min-width: 0;
  }

  .mode-boundary {
    display: none;
  }

  .formal-workspace,
  .quick-workspace {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }

  .case-action-column {
    grid-column: auto;
  }

  .profile-form-grid,
  .compact-form-grid {
    grid-template-columns: 1fr;
  }

  .quick-input-panel,
  .quick-output-panel {
    overflow-y: visible;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 23px;
  }

  .mode-button {
    padding: 7px 8px;
  }

  .mode-button span {
    display: none;
  }

  .panel-heading,
  .profile-status-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .pill {
    text-align: left;
  }

  .attachment-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .attachment-actions {
    justify-content: flex-end;
    width: 100%;
  }
}
