﻿:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e4e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --success: #059669;
  --warn: #d97706;
  --error: #dc2626;
  --code-bg: #f3f4f6;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --radius: 8px;
  --radius-sm: 6px;
  --topbar-h: 52px;
  --actionbar-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  letter-spacing: 0;
}

/* ---------- top bar ---------- */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 15px;
  color: var(--text);
}
.brand svg { color: var(--accent); }

.topbar-right { display: flex; align-items: center; gap: 8px; }
.status-text { color: var(--muted); font-size: 13px; }

.dot {
  display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
}
.dot-ok { background: var(--success); }
.dot-error { background: var(--error); }
.dot-checking { background: var(--warn); animation: pulse 1.4s infinite; }
@keyframes pulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ---------- workspace ---------- */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px;
  min-height: 0;
}
.pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.pane-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.pane-header h2 {
  margin: 0; font-size: 13px; font-weight: 600;
  color: var(--text); text-transform: none;
  letter-spacing: 0;
}
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; }
.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.is-active {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.tab-panel { display: none; flex: 1; min-height: 0; padding: 12px 16px 16px; }
.tab-panel.is-active { display: flex; flex-direction: column; }

/* ---------- input textarea ---------- */
#md-input {
  flex: 1;
  min-height: 0;
  resize: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 12px 14px;
  font: 13px/1.6 "SF Mono", Consolas, "Liberation Mono", "Microsoft YaHei", monospace;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#md-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.hint {
  margin-top: 8px;
  display: flex; gap: 12px; align-items: center;
  color: var(--muted); font-size: 12px;
}

/* ---------- dropzone ---------- */
.dropzone {
  flex: 1;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.dropzone:hover, .dropzone:focus { border-color: var(--accent); color: var(--text); outline: none; }
.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.dz-title { font-size: 15px; color: var(--text); font-weight: 500; }
.dz-sub { font-size: 13px; }

.file-info {
  margin-top: 10px;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.file-info .muted { margin-left: auto; }

/* ---------- preview ---------- */
.preview {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 20px 24px;
  background: var(--surface);
}
.preview .placeholder {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  margin-top: 40px;
}

/* markdown body (also affects preview) */
.md-body { color: var(--text); line-height: 1.7; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4 {
  margin: 1.2em 0 0.6em; line-height: 1.3;
  font-weight: 600;
  letter-spacing: 0;
}
.md-body h1 { font-size: 1.7em; padding-bottom: .25em; border-bottom: 1px solid var(--border); }
.md-body h2 { font-size: 1.35em; padding-bottom: .2em; border-bottom: 1px solid var(--border); }
.md-body h3 { font-size: 1.15em; }
.md-body p { margin: 0.6em 0; }
.md-body ul, .md-body ol { margin: 0.5em 0; padding-left: 1.6em; }
.md-body li { margin: 0.2em 0; }
.md-body strong { font-weight: 600; }
.md-body code {
  background: var(--code-bg);
  padding: 1px 6px;
  border-radius: 4px;
  font: 12.5px/1.5 "SF Mono", Consolas, monospace;
}
.md-body pre {
  background: var(--code-bg);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  overflow: auto;
  font: 12.5px/1.55 "SF Mono", Consolas, monospace;
}
.md-body pre code { background: transparent; padding: 0; }
.md-body blockquote {
  margin: 0.6em 0;
  padding: 4px 14px;
  border-left: 3px solid var(--border-strong);
  color: var(--muted);
}
.md-body table {
  border-collapse: collapse;
  margin: 0.6em 0;
}
.md-body th, .md-body td {
  border: 1px solid var(--border);
  padding: 6px 10px;
}
.md-body hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.5em 0;
}

/* ---------- action bar ---------- */
.actionbar {
  height: var(--actionbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.message {
  flex: 1;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 16px;
}
.message.is-error { color: var(--error); }
.message.is-success { color: var(--success); }
.actionbar-right { display: flex; align-items: center; gap: 14px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: 13px/1 inherit; font-weight: 500;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn-primary:disabled { background: #93b3e8; border-color: #93b3e8; color: #fff; }

.btn .spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.link-btn {
  background: none; border: 0; padding: 0;
  color: var(--accent);
  cursor: pointer; font: inherit;
  text-decoration: none;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- responsive ---------- */
@media (max-width: 880px) {
  .workspace { grid-template-columns: 1fr; }
  .pane { min-height: 280px; }
  .pane-preview { min-height: 360px; }
}