:root {
  --accent: #1f6f64;
  --accent-soft: #e9f4f1;
  --ink: #20242a;
  --muted: #66717d;
  --line: #dfe4ea;
  --surface: #ffffff;
  --canvas: #f3f5f7;
  --shadow: 0 14px 36px rgba(31, 43, 54, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  background: var(--accent);
  border-radius: 8px;
  font-size: 22px;
  font-weight: 800;
}

.brand h1,
.brand p,
.stage-header h2,
.panel h2 {
  margin: 0;
}

.brand h1 {
  font-size: 19px;
  line-height: 1.2;
}

.brand p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-btn,
.ghost-btn,
.icon-btn,
.tool-grid button,
.theme-card {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
}

.primary-btn {
  padding: 0 14px;
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
  font-weight: 650;
}

.ghost-btn {
  padding: 0 12px;
}

.compact {
  min-height: 32px;
  padding: 0 10px;
}

.icon-btn {
  width: 36px;
  padding: 0;
  font-size: 18px;
}

.workspace {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 390px;
  gap: 14px;
  padding: 14px;
  min-height: 0;
}

.sidebar,
.editor-stage,
.preview-stage {
  min-height: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
}

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

.panel {
  padding: 12px;
}

.panel h2,
.stage-header h2 {
  font-size: 15px;
  line-height: 1.35;
}

.theme-list,
.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.theme-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  text-align: left;
}

.theme-card.is-active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  flex: 0 0 auto;
  background: var(--theme-color);
}

.field-label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 12px;
}

.color-input {
  width: 100%;
  height: 38px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.tool-grid button {
  padding: 7px 8px;
  text-align: center;
}

.tool-grid button:hover,
.ghost-btn:hover,
.icon-btn:hover,
.theme-card:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.editor-stage,
.preview-stage {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.stage-header {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  display: block;
  margin-bottom: 3px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.counter {
  min-width: 72px;
  padding: 6px 9px;
  color: var(--muted);
  background: var(--canvas);
  border-radius: 6px;
  text-align: center;
  font-size: 12px;
}

.article-editor {
  flex: 1;
  min-height: 560px;
  overflow: auto;
  padding: 28px clamp(18px, 4vw, 56px);
  outline: none;
  background: #fff;
}

.article-editor:focus {
  box-shadow: inset 0 0 0 2px rgba(31, 111, 100, 0.18);
}

.phone-frame {
  flex: 1;
  min-height: 560px;
  margin: 18px auto;
  width: min(350px, calc(100% - 28px));
  overflow: hidden;
  background: #fff;
  border: 1px solid #d7dde3;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.phone-bar {
  height: 34px;
  border-bottom: 1px solid var(--line);
  background: #f8fafb;
}

.wechat-preview {
  height: calc(100% - 34px);
  overflow: auto;
  padding: 24px 18px 44px;
}

.article-editor h2,
.wechat-preview h2 {
  margin: 26px 0 16px;
  padding-left: 12px;
  border-left: 4px solid var(--accent);
  color: var(--ink);
  font-size: 21px;
  line-height: 1.45;
}

.article-editor h3,
.wechat-preview h3 {
  margin: 22px 0 13px;
  color: var(--accent);
  font-size: 18px;
  line-height: 1.55;
}

.article-editor p,
.article-editor li,
.wechat-preview p,
.wechat-preview li {
  margin: 0 0 16px;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.9;
}

.article-editor img,
.wechat-preview img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 18px auto;
  border-radius: 6px;
}

.wla-quote {
  margin: 18px 0;
  padding: 14px 16px;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.85;
}

.wla-callout {
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.85;
}

.wla-divider {
  width: 48px;
  margin: 28px auto;
  border-top: 3px solid var(--accent);
}

.wla-button-wrap {
  margin: 22px 0;
  text-align: center;
}

.wla-button {
  display: inline-block;
  padding: 8px 18px;
  color: #fff;
  background: var(--accent);
  border-radius: 4px;
  font-size: 15px;
  line-height: 1.5;
}

.wla-numbered {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  margin: 18px 0;
  align-items: start;
}

.wla-numbered strong {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #fff;
  background: var(--accent);
  border-radius: 6px;
}

.wla-numbered p,
.wla-note p {
  margin-bottom: 0;
}

.wla-note {
  margin: 18px 0;
  padding: 12px 0 12px 14px;
  border-left: 2px solid var(--line);
  color: var(--muted);
}

.modal {
  width: min(620px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0;
}

.modal::backdrop {
  background: rgba(20, 26, 32, 0.36);
}

.modal form {
  padding: 16px;
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-head h2 {
  margin: 0;
  font-size: 17px;
}

.modal textarea {
  width: 100%;
  margin: 14px 0;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  line-height: 1.7;
}

.modal-actions {
  justify-content: flex-end;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  padding: 10px 12px;
  max-width: min(360px, calc(100vw - 36px));
  color: #fff;
  background: rgba(32, 36, 42, 0.9);
  border-radius: 6px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 236px minmax(0, 1fr);
  }

  .preview-stage {
    grid-column: 1 / -1;
  }

  .phone-frame {
    min-height: 460px;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-start;
  }

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

  .sidebar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .article-editor,
  .phone-frame {
    min-height: 420px;
  }
}
