:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #f0f4f8;
  --text: #18212f;
  --muted: #667085;
  --line: #d9e0ea;
  --accent: #1769aa;
  --accent-strong: #0f4c81;
  --danger: #b42318;
  --success: #1b7f4c;
  --shadow: 0 16px 40px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  min-height: 100vh;
  padding: clamp(14px, 2vw, 32px);
}

.workspace {
  width: min(100%, max(1180px, calc(100vw - 64px)));
  margin: 0 auto;
}

.workspace__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 1.8vw, 36px);
  line-height: 1.2;
  font-weight: 700;
}

.workspace__header p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 16px;
}

.service-status {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  color: var(--muted);
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #98a2b3;
}

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

.status-dot.is-error {
  background: var(--danger);
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.88fr) minmax(520px, 1.12fr);
  gap: clamp(14px, 1.3vw, 22px);
  align-items: stretch;
}

.input-panel,
.result-panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(16px, 1.5vw, 26px);
}

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

h2 {
  font-size: 20px;
  line-height: 1.3;
}

.field-label,
.options-grid label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 14px;
}

.options-grid label small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

textarea,
select,
.static-field {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

textarea {
  min-height: clamp(160px, 21vh, 260px);
  resize: vertical;
  padding: 14px;
  line-height: 1.55;
  font-size: 16px;
}

select {
  height: 42px;
  padding: 0 12px;
  font-size: 16px;
}

.static-field {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  color: var(--text);
  font-size: 16px;
}

textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.12);
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.actions,
.result-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.actions {
  margin-top: 20px;
}

.primary-button,
.summary-button,
.secondary-button,
.ghost-button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-size: 16px;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

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

.summary-button {
  background: #1b7f4c;
  color: #fff;
}

.summary-button:hover {
  background: #14663d;
}

.secondary-button {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text);
}

.ghost-button {
  background: transparent;
  border-color: var(--line);
  color: var(--accent-strong);
}

.progress-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 14px;
}

.progress-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

#progressTitle {
  color: var(--text);
  font-weight: 600;
}

.progress-track {
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #d8e2ec;
}

#progressBar {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

#progressBar.is-running {
  width: 72%;
  animation: pulse-progress 1.35s ease-in-out infinite;
}

@keyframes pulse-progress {
  0% {
    transform: translateX(-75%);
  }
  50% {
    transform: translateX(20%);
  }
  100% {
    transform: translateX(120%);
  }
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 16px 0 10px;
}

.tab-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.tab-button.is-active {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: #edf6ff;
}

.result-output {
  min-height: clamp(360px, 52vh, 620px);
  max-height: calc(100vh - 320px);
  margin: 0;
  padding: 16px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
  color: #f8fafc;
  font-size: 16px;
  line-height: 1.65;
  word-break: break-word;
  white-space: pre-wrap;
}

.is-error-text {
  color: #ffd7d2;
}

.result-output.is-rich-output {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #ffffff;
  color: var(--text);
  white-space: normal !important;
}

.transcript-item {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.transcript-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.transcript-title {
  margin: 0 0 6px;
  color: #111827;
  font-size: 21px;
  line-height: 1.35;
  font-weight: 700;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.transcript-meta {
  display: grid;
  gap: 1px;
  margin-bottom: 10px;
}

.transcript-meta-line {
  display: block;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #8a94a6;
  font-size: 12px;
  line-height: 1.45;
}

.transcript-body {
  color: #1f2937;
  font-size: 16px;
  line-height: 1.82;
  white-space: pre-wrap;
}

.transcript-body p {
  margin: 0 0 10px;
}

.transcript-body p:last-child {
  margin-bottom: 0;
}

.transcript-summary {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.transcript-summary h4 {
  margin: 0 0 7px;
  color: #334155;
  font-size: 15px;
  line-height: 1.4;
  font-weight: 700;
}

.transcript-summary div {
  color: #475467;
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
}

.transcript-error {
  margin-bottom: 12px;
  color: var(--danger);
  font-size: 14px;
  line-height: 1.6;
}

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

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

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

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

  h1 {
    font-size: 24px;
  }

  .input-panel,
  .result-panel {
    padding: 14px;
  }

  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .primary-button,
  .summary-button,
  .secondary-button,
  .ghost-button {
    width: 100%;
  }

  .result-actions,
  .actions {
    width: 100%;
  }
}
