﻿:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #e4e6eb;
  --text: #1f2329;
  --muted: #8a9099;
  --brand: #0f4c81;
  --brand-2: #1668b8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
}

.brand .logo { color: var(--brand); }
.brand .sub { font-size: 12px; color: var(--muted); font-weight: 400; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-left: auto;
  flex-wrap: wrap;
}

.control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control .label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* Theme buttons */
.theme-bar { display: flex; gap: 6px; flex-wrap: wrap; }

.theme-btn {
  border: 1px solid var(--border);
  background: #fafbfc;
  color: var(--text);
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all .15s;
}
.theme-btn:hover { border-color: var(--brand-2); color: var(--brand-2); }
.theme-btn.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* Color swatches */
.color-bar { display: flex; gap: 6px; }

.color-sw {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  outline: 1px solid var(--border);
}
.color-sw.active {
  border-color: #fff;
  outline: 2px solid var(--text);
}

/* Font size slider */
input[type="range"] { width: 100px; accent-color: var(--brand); }
.font-size-val { font-size: 12px; color: var(--muted); width: 34px; }

/* Buttons */
.btn {
  border: 1px solid var(--border);
  background: #fafbfc;
  color: var(--text);
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all .15s;
}
.btn:hover { border-color: var(--brand-2); color: var(--brand-2); }

.btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  font-weight: 600;
}
.btn-primary:hover { background: var(--brand-2); color: #fff; }

/* Main split */
.main {
  display: flex;
  flex: 1;
  min-height: 0;
}

.pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}
.pane + .pane { border-left: 1px solid var(--border); }

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: #fbfcfd;
}

#editor {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  padding: 20px 24px;
  font-family: "SF Mono", Menlo, Consolas, "Courier New", monospace;
  font-size: 14px;
  line-height: 1.7;
  color: #2b2b2b;
  tab-size: 2;
}

.preview-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  justify-content: center;
  background: #f0f2f5;
}

#preview {
  width: 100%;
  max-width: 660px;
  background: #fff;
  padding: 28px 26px;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30, 34, 40, .92);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all .25s;
  z-index: 100;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 820px) {
  .main { flex-direction: column; }
  .pane + .pane { border-left: none; border-top: 1px solid var(--border); }
  .toolbar { gap: 12px; }
}
