:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --panel-2: #eef2ed;
  --ink: #17211d;
  --muted: #66736c;
  --line: #dbe1dc;
  --accent: #116a5c;
  --accent-2: #c95d3f;
  --warn: #b95033;
  --ok: #168157;
  --shadow: 0 18px 50px rgba(26, 38, 31, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

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

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px;
  background: #111a17;
  color: #f7fbf8;
}

.brand {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 12px;
  align-items: center;
  min-height: 62px;
}

.brand img {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  object-fit: cover;
}

.brand strong {
  display: block;
  font-size: 20px;
  line-height: 1.1;
}

.brand span {
  display: block;
  margin-top: 5px;
  color: #afbbb5;
  font-size: 13px;
}

.task-list {
  display: grid;
  gap: 8px;
}

.task-item {
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 10px;
  background: transparent;
  color: #dbe5df;
  text-align: left;
  cursor: pointer;
}

.task-item:hover,
.task-item.active {
  background: #20312b;
  border-color: #345048;
  color: #ffffff;
}

.task-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: #29443b;
  color: #a9dfcc;
  font-weight: 700;
  font-size: 13px;
}

.connection-panel {
  margin-top: auto;
  padding: 14px;
  border: 1px solid #293832;
  border-radius: 8px;
  background: #16231f;
}

.panel-title {
  margin-bottom: 12px;
  color: #d6e0da;
  font-weight: 700;
}

.connection-panel label {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: #b5c1bb;
  font-size: 12px;
}

.connection-panel input {
  width: 100%;
  min-height: 38px;
  border: 1px solid #31473f;
  border-radius: 6px;
  padding: 8px 10px;
  background: #0e1714;
  color: #f6fbf8;
  outline: none;
}

.connection-panel input:focus,
.fields input:focus,
.fields textarea:focus,
select:focus {
  border-color: #2b9a83;
  box-shadow: 0 0 0 3px rgba(43, 154, 131, 0.15);
}

.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  color: #bdc9c3;
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #738078;
}

.status-dot.ok {
  background: var(--ok);
}

.status-dot.bad {
  background: var(--warn);
}

.secondary-action,
.primary-action,
.icon-text,
.mode {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.secondary-action {
  width: 100%;
  min-height: 38px;
  margin-top: 6px;
  border-color: #38534a;
  background: #22382f;
  color: #eef7f2;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.2;
}

.topbar p {
  margin-top: 7px;
  color: var(--muted);
}

.toolbar {
  display: flex;
  gap: 8px;
}

.icon-text {
  min-width: 70px;
  min-height: 38px;
  padding: 0 12px;
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.input-panel,
.output-panel {
  min-width: 0;
  min-height: 640px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.input-panel {
  display: flex;
  flex-direction: column;
  padding: 18px;
}

.output-panel {
  display: flex;
  flex-direction: column;
  padding: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  margin-bottom: 14px;
}

.section-head h2 {
  font-size: 17px;
}

#resultMeta {
  color: var(--muted);
  font-size: 13px;
}

.mini-note {
  color: var(--muted);
  font-size: 13px;
}

.strategy-panel {
  display: grid;
  gap: 13px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid #d5e0da;
  border-radius: 8px;
  background: #f7faf7;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel-2);
}

.mode {
  min-height: 34px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.mode.active {
  background: #113f36;
  color: #ffffff;
}

.fields {
  display: grid;
  gap: 13px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.tone-select span {
  color: #46524c;
  font-size: 13px;
  font-weight: 700;
}

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

.fields input {
  min-height: 42px;
}

.fields textarea {
  min-height: 116px;
  resize: vertical;
  line-height: 1.55;
}

.form-footer {
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 12px;
  align-items: end;
  margin-top: auto;
  padding-top: 18px;
}

.expanded-footer {
  grid-template-columns: minmax(150px, 1fr) minmax(170px, 1fr) minmax(170px, 1fr) 150px;
}

.tone-select {
  display: grid;
  gap: 7px;
}

.tone-select input {
  width: 100%;
  min-height: 45px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fcfdfb;
  color: var(--ink);
  outline: none;
}

.hidden {
  display: none;
}

.primary-action {
  min-height: 45px;
  border-color: #0f5b50;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

.primary-action:disabled {
  cursor: wait;
  opacity: 0.7;
}

.result-box {
  flex: 1;
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcfa;
  color: #1d2823;
  white-space: pre-wrap;
  line-height: 1.65;
}

.result-box.loading {
  color: var(--muted);
}

.result-box.error {
  border-color: #e5b6a7;
  background: #fff8f5;
  color: #853b27;
}

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

  .sidebar {
    min-height: auto;
  }

  .task-list {
    grid-template-columns: repeat(5, minmax(110px, 1fr));
    overflow-x: auto;
  }

  .connection-panel {
    margin-top: 0;
  }

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

@media (max-width: 680px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .topbar,
  .section-head,
  .form-footer {
    grid-template-columns: 1fr;
    display: grid;
  }

  .task-list {
    grid-template-columns: 1fr 1fr;
  }

  .input-panel,
  .output-panel {
    min-height: auto;
  }
}
