:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --line: #e4e9ef;
  --ink: #1f2328;
  --muted: #6b7683;
  --brand: #1668dc;
  --brand-dark: #0f57bd;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

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

.logo {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2a7ae4, #1668dc 55%, #0d4fa8);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  box-shadow: 0 4px 12px rgba(22, 104, 220, 0.28);
}

.brand-text h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.health {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  color: var(--muted);
  cursor: default;
}

.health .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b6bfc9;
  transition: background 0.2s;
}

.health.ok .dot { background: #22a06b; box-shadow: 0 0 0 3px rgba(34, 160, 107, 0.14); }
.health.ok { color: #1a7f54; }
.health.warn .dot { background: #e0a106; box-shadow: 0 0 0 3px rgba(224, 161, 6, 0.14); }
.health.warn { color: #9a6d00; }
.health.bad .dot { background: #d93025; box-shadow: 0 0 0 3px rgba(217, 48, 37, 0.14); }
.health.bad { color: #b3271e; }

/* 主区域 */
.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(380px, 1.1fr);
  gap: 14px;
  padding: 14px 18px 0;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
  min-height: 44px;
}

.panel-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel-meta {
  font-size: 12px;
  color: #9aa4b0;
  margin-right: auto;
}

.panel-actions { display: flex; gap: 6px; }

.ghost-btn {
  padding: 5px 10px;
  font-size: 12px;
  color: #3c4752;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.ghost-btn:hover { background: #f4f7fb; border-color: #cfd9e4; }

#editor {
  flex: 1;
  width: 100%;
  padding: 18px 20px;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: #24292f;
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, "Courier New", monospace;
  font-size: 13.5px;
  line-height: 1.75;
  tab-size: 2;
}

#editor::placeholder { color: #a7b1bc; }

#preview {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}

/* 底部操作栏 */
.actionbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 18px 14px;
}

.options {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.field select {
  height: 30px;
  padding: 0 26px 0 9px;
  font-size: 12.5px;
  color: var(--ink);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23818c99' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 9px center;
  border: 1px solid var(--line);
  border-radius: 7px;
  appearance: none;
  cursor: pointer;
}

.field select:focus { outline: 2px solid rgba(22, 104, 220, 0.28); outline-offset: 1px; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: #3c4752;
  cursor: pointer;
  user-select: none;
}

.check input { width: 14px; height: 14px; accent-color: var(--brand); cursor: pointer; }

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 18px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 9px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.08s;
}

.btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 8px rgba(22, 104, 220, 0.25);
}

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

.btn-secondary {
  background: #fff;
  color: #1f2328;
  border-color: #d5dde6;
}

.btn-secondary:hover { background: #f5f8fc; }

.btn[disabled] {
  opacity: 0.55;
  cursor: progress;
  transform: none;
  box-shadow: none;
}

/* 拖拽遮罩 */
.drop-overlay {
  position: fixed;
  inset: 12px;
  display: none;
  place-items: center;
  z-index: 30;
  border: 2px dashed #8fb6e8;
  border-radius: 16px;
  background: rgba(233, 242, 253, 0.92);
  color: var(--brand);
  font-size: 15px;
  font-weight: 500;
  pointer-events: none;
}

.drop-overlay.show { display: grid; }

/* 提示 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translate(-50%, 12px);
  padding: 10px 18px;
  max-width: min(560px, calc(100vw - 32px));
  background: #1f2937;
  color: #f5f7fa;
  font-size: 13px;
  border-radius: 9px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.24);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 40;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #b3271e; }

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(320px, auto);
    overflow-y: auto;
    padding-bottom: 4px;
  }
  .panel { min-height: 320px; }
  .actionbar { position: sticky; bottom: 0; background: var(--bg); }
  .options { gap: 10px; }
}
