:root {
  color-scheme: light;
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-soft: #f8f7f4;
  --ink: #202124;
  --muted: #6c706f;
  --line: #ded9d0;
  --accent: #1d7f64;
  --accent-dark: #12624d;
  --accent-soft: #e5f3ee;
  --warn: #a55a18;
  --warn-soft: #fff3e4;
  --shadow: 0 14px 40px rgba(32, 33, 36, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

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

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

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.25;
}

.status-pill {
  min-width: 110px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.status-pill.ready {
  border-color: #99cfbe;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.status-pill.busy {
  border-color: #e8c692;
  background: var(--warn-soft);
  color: var(--warn);
}

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

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

.control-panel {
  padding: 18px;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 154px;
  padding: 20px;
  border: 2px dashed #bfb8ab;
  border-radius: 8px;
  background: var(--surface-soft);
  text-align: center;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.drop-zone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.drop-title {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
}

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

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}

.primary,
.secondary {
  min-height: 42px;
  border-radius: 6px;
  padding: 0 12px;
  font-weight: 700;
}

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

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

.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.secondary:hover:not(:disabled) {
  border-color: #b7b0a2;
  background: var(--surface-soft);
}

.metrics {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
}

.metrics div {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 38px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.metrics dt {
  color: var(--muted);
  font-size: 13px;
}

.metrics dd {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.issue-panel {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

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

h2 {
  margin: 0;
  font-size: 16px;
}

.section-heading span {
  min-width: 28px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.issue-list {
  display: grid;
  gap: 8px;
  max-height: 310px;
  margin: 0;
  padding-left: 22px;
  overflow: auto;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.preview-panel {
  min-width: 0;
  overflow: hidden;
}

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.tab {
  min-height: 46px;
  padding: 0 18px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab.active {
  background: var(--surface);
  color: var(--accent-dark);
}

.panel {
  display: none;
  height: calc(100vh - 144px);
  min-height: 620px;
  background: #f6f5f2;
  overflow: auto;
}

.panel.active {
  display: block;
}

.wechat-preview {
  width: min(100%, 760px);
  min-height: 100%;
  margin: 0 auto;
  padding: 28px 24px 60px;
  background: #fff;
  overflow: visible;
}

.wechat-preview.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.wechat-preview img {
  max-width: 100%;
}

#sourceFrame,
#htmlOutput {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

#htmlOutput {
  display: block;
  padding: 18px;
  resize: none;
  color: #2a2c2b;
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 13px;
  line-height: 1.55;
}

.work-frame {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 760px;
  height: 1000px;
  border: 0;
  visibility: hidden;
}

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

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

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

  .panel {
    height: calc(100vh - 190px);
    min-height: 560px;
    overflow: auto;
  }

  .wechat-preview {
    min-height: 560px;
  }
}
