:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-strong: #f2f5f8;
  --text: #17202a;
  --muted: #5f6b7a;
  --line: #d9e0e8;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(39, 50, 66, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.05) 0%, transparent 40%), linear-gradient(315deg, rgba(37, 99, 235, 0.04) 0%, transparent 40%), var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(15, 118, 110, 0.15);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 118, 110, 0.25);
}

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

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.workbench {
  min-height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 8px 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.15;
  letter-spacing: 0;
}

.status-pill {
  min-width: 92px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(39, 50, 66, 0.08);
}

.status-pill.running {
  color: var(--accent-dark);
  border-color: rgba(15, 118, 110, 0.25);
}

.status-pill.failed {
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.28);
}

.icon-button {
  width: 40px;
  height: 40px;
  padding: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms ease;
}

.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #edf8f6;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 18px;
  flex: 1;
  transition: grid-template-columns 250ms cubic-bezier(0.4, 0, 0.2, 1), gap 250ms ease;
}

.layout.preview-focus {
  grid-template-columns: 0 minmax(0, 1fr);
  gap: 0;
}

.layout.preview-focus .input-panel {
  padding: 0;
  border: none;
  box-shadow: none;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

.layout.preview-focus .result-panel {
  min-height: calc(100vh - 100px);
}

.layout.preview-focus .progress-block,
.layout.preview-focus .result-actions,
.layout.preview-focus .file-manager {
  display: none !important;
}

.layout.preview-focus .preview-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.layout.preview-focus .preview-surface {
  flex: 1;
  overflow-y: auto;
}

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

.input-panel {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-self: start;
}

.result-panel {
  min-height: 620px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.input-content {
  min-height: 120px;
}

.drop-zone {
  position: relative;
  min-height: 120px;
  border: 1.5px dashed #aab6c4;
  border-radius: 8px;
  background: var(--surface-strong);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  text-align: center;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.drop-zone:hover, .drop-zone.dragging {
  border-color: var(--accent);
  background: #eef8f6;
  transform: translateY(-1px);
}

.drop-zone.uploading {
  border-color: var(--accent);
  background: #eef8f6;
}

.drop-zone input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.drop-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #0f766e;
  color: white;
  font-weight: 800;
  font-size: 16px;
}

.drop-title {
  font-weight: 700;
  font-size: 14px;
}

.drop-meta {
  color: var(--muted);
  font-size: 13px;
}

.drop-upload-state {
  width: min(320px, calc(100% - 24px));
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(15, 118, 110, 0.16);
  background: rgba(255, 255, 255, 0.92);
}

.drop-upload-text {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.drop-upload-track {
  height: 8px;
  margin-top: 8px;
  background: #dce5ee;
  border-radius: 999px;
  overflow: hidden;
}

.drop-upload-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #0f766e);
  transition: width 120ms linear;
}

.file-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.file-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface-strong);
  border-radius: 8px;
  border: 1px solid var(--line);
}

.file-item-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-item-name {
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item-meta {
  color: var(--muted);
  font-size: 12px;
}

.file-item-actions {
  display: flex;
  gap: 8px;
}

.file-action {
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid rgba(15, 118, 110, 0.2);
  background: #edf8f6;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.file-action.danger {
  border-color: rgba(180, 35, 24, 0.28);
  background: #fef3f2;
  color: var(--danger);
}

.file-action:hover {
  filter: brightness(0.98);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field.full {
  width: 100%;
}

.checkbox-field {
  min-height: 65px;
}

.check-row {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 11px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
}

.check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.check-row span {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.output-options {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.output-options legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.model-hint {
  justify-content: flex-end;
}

.model-hint span:last-child {
  min-height: 42px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.55;
}

.custom-models {
  display: contents;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.field input, .field select {
  height: 42px;
  padding: 0 11px;
}

.check-row input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.field textarea {
  resize: vertical;
  min-height: 104px;
  padding: 10px 11px;
}

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.show-api-btn-wrapper {
  text-align: center;
}

.text-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}

.text-btn:hover {
  color: var(--accent-dark);
}

.primary, .ghost-button {
  height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-weight: 800;
  cursor: pointer;
}

.primary {
  margin-top: 4px;
  background: var(--accent);
  color: #fff;
}

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

.primary:disabled {
  cursor: wait;
  background: #94a3b8;
}

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

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

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

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #2563eb);
  transition: width 220ms ease;
}

.result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.ghost-button {
  min-width: 118px;
  padding: 0 16px;
  color: var(--accent-dark);
  background: #edf8f6;
  border-color: rgba(15, 118, 110, 0.2);
}

.ghost-button.slim {
  min-width: auto;
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.ghost-button.danger {
  color: var(--danger);
  background: #fef3f2;
  border-color: rgba(180, 35, 24, 0.28);
}

.message {
  padding: 11px 12px;
  border-radius: 8px;
  background: #fff7ed;
  color: #7c2d12;
  border: 1px solid #fed7aa;
  font-size: 14px;
}

.message.success {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}

.message.error {
  background: #fef3f2;
  color: var(--danger);
  border-color: #fecdca;
}

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

.batch-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #ffffff;
}

.batch-item.running {
  border-color: rgba(15, 118, 110, 0.35);
  background: #f0fdfa;
}

.batch-item.succeeded {
  border-color: #bbf7d0;
}

.batch-item.failed {
  border-color: #fecaca;
  background: #fff7f7;
}

.batch-main {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.batch-index {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.batch-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.batch-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.batch-path {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.batch-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.batch-links a {
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid rgba(15, 118, 110, 0.2);
  border-radius: 8px;
  color: var(--accent-dark);
  background: #edf8f6;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}

.batch-error {
  margin-top: 8px;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.45;
}

.file-manager {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-strong);
}

.file-manager-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.file-manager-title {
  font-size: 14px;
  font-weight: 800;
}

.file-manager-path {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.file-manager-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.file-manager-message {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.file-manager-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.file-manager-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.file-manager-entry {
  min-width: 0;
  padding: 0;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-manager-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: #f1f5f9;
  border-radius: 8px;
  color: var(--muted);
  flex-shrink: 0;
}

.file-manager-entry.folder .file-manager-icon {
  background: #edf8f6;
  color: var(--accent-dark);
}

.file-manager-entry-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.file-manager-entry-name {
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-manager-entry-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.file-manager-entry.folder .file-manager-entry-name {
  color: var(--accent-dark);
}

.file-manager-item-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.file-manager-link,
.file-manager-preview,
.file-manager-delete {
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid rgba(15, 118, 110, 0.2);
  background: #edf8f6;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.file-manager-preview {
  border-color: rgba(37, 99, 235, 0.18);
  background: #eff6ff;
  color: #1d4ed8;
}

.file-manager-delete {
  border-color: rgba(180, 35, 24, 0.28);
  background: #fef3f2;
  color: var(--danger);
}

.preview-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 420px;
}

.preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.preview-head-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.preview-head .ghost-button {
  flex: 0 0 auto;
}

.preview-title {
  font-size: 14px;
  font-weight: 800;
  flex-shrink: 0;
}

.preview-path {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-surface {
  flex: 1;
  min-height: 340px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  overflow: hidden;
  position: relative;
}

.preview-empty,
.preview-text {
  margin: 0;
  padding: 16px;
}

.preview-empty {
  color: var(--muted);
  font-size: 14px;
}

.preview-text {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  white-space: pre-wrap;
  overflow: auto;
  line-height: 1.65;
  color: #263241;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

.markdown-rendered {
  white-space: normal;
}

.markdown-rendered h1,
.markdown-rendered h2,
.markdown-rendered h3,
.markdown-rendered h4 {
  margin: 16px 0 10px;
  line-height: 1.4;
}

.markdown-rendered p,
.markdown-rendered ul {
  margin: 0 0 12px;
}

.md-table-wrap {
  width: 100%;
  margin: 0 0 14px;
  overflow-x: auto;
}

.md-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
}

.md-table th,
.md-table td {
  padding: 10px 12px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  line-height: 1.6;
}

.md-table th {
  background: #f4f7fb;
  font-weight: 700;
}

.md-table tr:nth-child(even) td {
  background: #fafcff;
}

.markdown-rendered ul {
  padding-left: 20px;
}

.markdown-rendered code {
  padding: 2px 6px;
  border-radius: 6px;
  background: #eef2f7;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.md-figure {
  margin: 16px 0;
}

.md-figure img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.md-figure figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.preview-image {
  width: 100%;
  height: 100%;
  border: none;
}

.preview-frame {
  width: 100%;
  height: calc(100vh - 120px);
  border: none;
  border-radius: 8px;
}

.preview-image {
  object-fit: contain;
  background: #fff;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal {
  width: min(520px, 100%);
  max-height: calc(100vh - 40px);
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: var(--surface-strong);
  color: var(--text);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
}

.modal-footer .secondary {
  height: 40px;
  padding: 0 20px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

.modal-footer .secondary:hover {
  background: var(--surface-strong);
}

.modal-footer .primary {
  height: 40px;
  padding: 0 20px;
  margin: 0;
}
