:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  --bg: #f4f7f2;
  --panel: #ffffff;
  --panel-2: #eef3ec;
  --text: #1a211a;
  --muted: #687163;
  --line: #d9e1d5;
  --accent: #0e7c66;
  --accent-2: #2457a6;
  --danger: #9b2c2c;
  --shadow: 0 18px 50px rgba(30, 48, 36, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(14, 124, 102, 0.12), transparent 34%),
    linear-gradient(210deg, rgba(36, 87, 166, 0.12), transparent 38%),
    var(--bg);
  color: var(--text);
}

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

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.workspace {
  width: min(1120px, 100%);
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 750;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4.2rem);
  line-height: 0.98;
}

h2 {
  font-size: 1rem;
}

.status-pill {
  min-width: 128px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  padding: 10px 14px;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
}

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

.server-note {
  display: none;
  margin: 0 0 14px;
  border: 1px solid #e2b86b;
  border-radius: 8px;
  background: #fff7e8;
  color: #65451f;
  padding: 12px 14px;
  line-height: 1.45;
}

body.file-mode .server-note {
  display: block;
}

.drop-panel,
.settings-panel,
.log-panel,
.preview-panel,
.code-panel {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.drop-panel {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.drop-zone {
  min-height: 310px;
  width: 100%;
  border: 2px dashed #b5c4ae;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 13px;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

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

.drop-icon {
  width: 82px;
  height: 82px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #1f2f2b;
  color: white;
  font-weight: 850;
}

.drop-title {
  font-size: 1.35rem;
  font-weight: 780;
}

.drop-meta {
  color: var(--muted);
}

.comparison,
.analysis-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.comparison div,
.analysis-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #fbfcfa;
  min-width: 0;
}

.comparison span,
.analysis-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 7px;
}

.comparison strong,
.analysis-grid strong {
  display: block;
  font-size: 1.25rem;
  overflow-wrap: anywhere;
}

.analysis-grid {
  margin-top: -8px;
}

.analysis-grid div {
  background: #f7faf8;
}

.analysis-grid strong {
  font-size: 1rem;
}

.insight {
  margin: -4px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.actions {
  display: flex;
  gap: 10px;
}

.primary,
.secondary,
.log-head button {
  border: 0;
  border-radius: 8px;
  min-height: 44px;
  padding: 0 18px;
  cursor: pointer;
  text-decoration: none;
  display: inline-grid;
  place-items: center;
}

.primary {
  background: var(--accent);
  color: white;
  font-weight: 760;
  flex: 1;
}

.primary:disabled {
  background: #9eb8ae;
  cursor: not-allowed;
}

.secondary {
  border: 1px solid var(--accent-2);
  color: var(--accent-2);
  background: #f9fbff;
  min-width: 130px;
}

.secondary.disabled {
  pointer-events: none;
  border-color: var(--line);
  color: #98a094;
}

.settings-panel {
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 18px;
}

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

label,
.check-row {
  color: var(--text);
  font-weight: 700;
}

output {
  color: var(--accent);
  float: right;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  padding: 0 12px;
  color: var(--text);
}

input[type="range"] {
  accent-color: var(--accent);
}

.check-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  line-height: 1.35;
}

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

.log-panel {
  margin-top: 16px;
  padding: 16px 18px;
}

.preview-panel,
.code-panel {
  margin-top: 16px;
  padding: 16px 18px;
}

.preview-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.preview-head p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

#viewerStatus {
  color: var(--muted);
  white-space: nowrap;
}

.viewer-frame {
  height: min(54vh, 460px);
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101513;
  overflow: hidden;
}

.viewer-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.code-panel pre {
  margin: 0;
  overflow: auto;
  border-radius: 8px;
  background: #17211d;
  color: #e9f5ee;
  padding: 14px;
  line-height: 1.55;
}

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

.log-head button {
  min-height: 34px;
  padding: 0 12px;
  background: #edf1ea;
  color: var(--muted);
}

#logList {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.65;
  max-height: 190px;
  overflow: auto;
}

.error {
  color: var(--danger);
}

@media (max-width: 860px) {
  .app-shell {
    padding: 18px;
    place-items: start center;
  }

  .topbar {
    display: grid;
    align-items: start;
  }

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

  .drop-zone {
    min-height: 240px;
  }

  .comparison,
  .analysis-grid,
  .actions {
    grid-template-columns: 1fr;
    display: grid;
  }

  .secondary {
    width: 100%;
  }

  .preview-head {
    display: grid;
  }

  #viewerStatus {
    white-space: normal;
  }
}
