:root {
  --page: #edf1ec;
  --paper: #ffffff;
  --paper-soft: #f7f9f5;
  --ink: #14241f;
  --muted: #66716d;
  --line: #d9e0da;
  --green-950: #0b362d;
  --green-900: #10483b;
  --green-700: #17745b;
  --green-100: #e6f2eb;
  --orange: #d96c13;
  --orange-soft: #fff0e3;
  --blue: #3479b8;
  --blue-soft: #eaf3fb;
  --violet: #7358a6;
  --violet-soft: #f0ebf8;
  --cyan: #218a8d;
  --cyan-soft: #e4f4f3;
  --gold: #b78931;
  --shadow: 0 18px 45px rgba(27, 50, 41, 0.1);
  --radius: 8px;
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
}

button,
textarea,
input {
  font: inherit;
}

button,
a,
label {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

[hidden] {
  display: none !important;
}

.desktop-app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 16px 18px;
  color: #eef7f2;
  background:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px),
    var(--green-950);
  background-size: 34px 34px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  color: #8ed3aa;
}

.brand-mark svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
  stroke-width: 2.5;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 16px;
  line-height: 1.25;
}

.brand small {
  margin-top: 3px;
  color: rgba(238, 247, 242, 0.64);
  font-size: 12px;
}

.tool-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
}

.tool-nav > p {
  margin: 10px 12px 8px;
  color: rgba(238, 247, 242, 0.48);
  font-size: 12px;
  font-weight: 800;
}

.nav-item {
  width: 100%;
  min-height: 62px;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin: 4px 0;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius);
  color: rgba(238, 247, 242, 0.76);
  background: transparent;
  text-align: left;
  transition: background 160ms ease, color 160ms ease;
}

.nav-item:hover,
.nav-item.is-active {
  color: #ffffff;
  background: rgba(255,255,255,0.11);
}

.nav-item.is-active {
  box-shadow: inset 3px 0 #8ed3aa;
}

.nav-item > span:last-child {
  min-width: 0;
}

.nav-item strong,
.nav-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item strong {
  font-size: 14px;
}

.nav-item small {
  margin-top: 2px;
  color: rgba(238, 247, 242, 0.52);
  font-size: 11px;
}

.nav-icon,
.summary-icon {
  display: grid;
  place-items: center;
  border-radius: var(--radius);
}

.nav-icon {
  width: 36px;
  height: 36px;
  color: #8ed3aa;
  background: rgba(255,255,255,0.08);
}

.nav-icon svg {
  width: 20px;
  height: 20px;
}

.nav-icon.orange { color: #ffad66; }
.nav-icon.violet { color: #b6a1e0; }
.nav-icon.blue { color: #83b8e6; }
.nav-icon.cyan { color: #79c8c7; }

.sidebar-footer {
  display: grid;
  grid-template-columns: 1fr;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.12);
}

.sidebar-footer a {
  padding: 9px 8px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  color: rgba(238, 247, 242, 0.72);
  font-size: 11px;
  text-align: center;
}

.sidebar-footer a:hover {
  color: #fff;
  background: rgba(255,255,255,0.08);
}

.workspace {
  min-width: 0;
}

.topbar {
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 28px;
  background: rgba(255,255,255,0.95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.topbar p,
.topbar h1 {
  margin: 0;
}

.topbar p {
  color: var(--muted);
  font-size: 12px;
}

.topbar h1 {
  margin-top: 4px;
  font-size: 22px;
  line-height: 1.15;
}

.top-actions,
.runtime-status,
.view-switch {
  display: flex;
  align-items: center;
}

.top-actions {
  gap: 10px;
}

.view-switch {
  min-height: 38px;
  gap: 7px;
  padding: 0 13px;
  border: 1px solid #b9cfbf;
  border-radius: var(--radius);
  color: var(--green-700);
  background: var(--green-100);
  font-size: 12px;
  font-weight: 900;
}

.view-switch:hover {
  background: #dbece2;
}

.view-switch svg {
  width: 16px;
  height: 16px;
}

.runtime-status {
  min-height: 38px;
  gap: 8px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--paper-soft);
  font-size: 12px;
  font-weight: 700;
}

.runtime-status i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c2c8c4;
}

.runtime-status.is-online {
  color: var(--green-700);
}

.runtime-status.is-online i {
  background: #27a168;
  box-shadow: 0 0 0 4px rgba(39,161,104,0.13);
}

.runtime-status.is-mock {
  color: var(--orange);
}

.runtime-status.is-mock i {
  background: var(--orange);
}

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--green-900);
  background: #fff;
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.main-area {
  padding: 22px 26px 30px;
}

.function-summary {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
  padding: 14px 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.function-summary > div {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.summary-icon {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  color: var(--green-700);
  background: var(--green-100);
}

.summary-icon.orange { color: var(--orange); background: var(--orange-soft); }
.summary-icon.violet { color: var(--violet); background: var(--violet-soft); }
.summary-icon.blue { color: var(--blue); background: var(--blue-soft); }
.summary-icon.cyan { color: var(--cyan); background: var(--cyan-soft); }

.summary-icon svg {
  width: 25px;
  height: 25px;
}

.function-summary strong,
.function-summary p {
  display: block;
  margin: 0;
}

.function-summary strong {
  font-size: 16px;
}

.function-summary p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.flow-hint {
  flex: 0 0 auto;
  padding: 8px 12px;
  color: var(--green-700);
  background: var(--green-100);
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 800;
}

.flow-hint b {
  margin: 0 6px;
  color: var(--gold);
}

.work-grid,
.upload-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.82fr) minmax(500px, 1.18fr);
  gap: 18px;
  align-items: stretch;
}

.input-panel,
.result-panel {
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(27,50,41,0.05);
}

.input-panel {
  padding: 18px;
}

.result-panel {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 216px);
}

.panel-head,
.panel-head > div,
.result-head {
  display: flex;
  align-items: center;
}

.panel-head {
  min-height: 42px;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-head > div {
  gap: 9px;
}

.panel-head > div > span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--green-700);
  font-size: 11px;
  font-weight: 900;
}

.panel-head strong {
  font-size: 15px;
}

.text-button {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--green-700);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.input-block {
  display: grid;
  gap: 8px;
}

.input-block > span {
  font-size: 13px;
  font-weight: 800;
}

.input-block textarea {
  width: 100%;
  min-height: 230px;
  resize: vertical;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  color: var(--ink);
  background: var(--paper-soft);
  font-size: 14px;
  line-height: 1.75;
}

.input-block textarea:focus {
  border-color: var(--green-700);
  box-shadow: 0 0 0 3px rgba(23,116,91,0.12);
}

.examples {
  margin-top: 16px;
}

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

.examples-head strong {
  font-size: 12px;
}

.examples-head small {
  color: var(--muted);
  font-size: 11px;
}

.example-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.example-chip {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: #4d5b55;
  background: var(--paper-soft);
  font-size: 11px;
}

.example-chip:hover {
  color: var(--green-700);
  border-color: #a9c8b9;
  background: var(--green-100);
}

.generate-button {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
  border: 0;
  border-radius: var(--radius);
  color: #fff;
  background: linear-gradient(135deg, var(--green-700), var(--green-900));
  box-shadow: 0 12px 24px rgba(16,72,59,0.18);
  font-size: 14px;
  font-weight: 900;
}

.generate-button:hover {
  filter: brightness(1.05);
}

.generate-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.generate-button svg {
  width: 18px;
  height: 18px;
}

.notice {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.result-head {
  min-height: 64px;
  margin: 0;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
}

.copy-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid #b9cfbf;
  border-radius: var(--radius);
  color: var(--green-700);
  background: var(--green-100);
  font-size: 12px;
  font-weight: 900;
}

.copy-button:disabled {
  color: #9da5a1;
  border-color: var(--line);
  background: var(--paper-soft);
  cursor: not-allowed;
}

.copy-button svg {
  width: 16px;
  height: 16px;
}

.result-state {
  flex: 1;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 48px;
  color: var(--muted);
  text-align: center;
}

.result-state strong {
  margin-top: 16px;
  color: #415049;
  font-size: 16px;
}

.result-state p {
  max-width: 340px;
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.7;
}

.result-illustration {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--green-700);
  background: var(--green-100);
}

.result-illustration svg {
  width: 38px;
  height: 38px;
}

.output {
  flex: 1;
  max-height: calc(100vh - 280px);
  margin: 0;
  padding: 18px 20px 28px;
  overflow: auto;
  color: #25352f;
  background: #fff;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  line-height: 1.9;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.upload-grid {
  grid-template-columns: minmax(400px, 0.9fr) minmax(500px, 1.1fr);
}

.upload-panel,
.docs-panel {
  min-height: calc(100vh - 216px);
}

.upload-dropzone {
  min-height: 300px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 28px;
  border: 2px dashed #b9cfbf;
  border-radius: var(--radius);
  color: var(--green-700);
  background: var(--paper-soft);
  text-align: center;
  cursor: pointer;
}

.upload-dropzone:hover {
  background: var(--green-100);
}

.upload-dropzone svg {
  width: 48px;
  height: 48px;
}

.upload-dropzone strong {
  font-size: 15px;
}

.upload-dropzone small {
  max-width: 360px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.upload-dropzone input {
  max-width: 280px;
  color: var(--muted);
  font-size: 11px;
}

.doc-list {
  margin: 0;
  padding: 14px 16px 22px;
  display: grid;
  gap: 8px;
  list-style: none;
  overflow: auto;
}

.doc-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-soft);
  font-size: 12px;
}

.doc-list li span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-list li small {
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: var(--radius);
  color: #fff;
  background: var(--green-950);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  .desktop-app {
    grid-template-columns: 232px minmax(0, 1fr);
  }

  .work-grid,
  .upload-grid {
    grid-template-columns: 1fr;
  }

  .result-panel,
  .upload-panel,
  .docs-panel {
    min-height: 520px;
  }

  .output {
    max-height: 560px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
