:root {
  --wechat-green: #07c160;
  --wechat-green-pressed: #06ad56;
  --page-bg: #f7f7f7;
  --panel-bg: #ffffff;
  --line: #e5e5e5;
  --text: #111111;
  --muted: #8a8a8a;
  --soft: #f2f3f5;
  --danger-bg: #fff1f0;
  --danger: #d93026;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page-bg);
}

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
textarea {
  font: inherit;
}

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

.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 2px 18px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--wechat-green);
  color: #fff;
  font-size: 19px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(7, 193, 96, 0.22);
}

h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.25;
  font-weight: 700;
}

p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

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

.editor {
  display: flex;
  min-height: calc(100vh - 98px);
  flex-direction: column;
}

.panel-head {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  color: #1f1f1f;
  font-size: 15px;
  font-weight: 600;
}

.panel-head label {
  font-weight: 600;
}

.panel-head span,
.panel-head a {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.panel-head a {
  color: var(--wechat-green);
  text-decoration: none;
}

textarea {
  width: 100%;
  flex: 1;
  min-height: 440px;
  resize: vertical;
  border: 0;
  padding: 16px;
  background: #fff;
  color: #161616;
  outline: none;
  line-height: 1.75;
  font-size: 16px;
}

textarea:focus {
  box-shadow: inset 0 0 0 2px rgba(7, 193, 96, 0.16);
}

.action-row {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  background: #fff;
}

button {
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: 6px;
  background: var(--wechat-green);
  color: white;
  cursor: pointer;
  font-weight: 600;
  font-size: 16px;
}

button:hover {
  background: var(--wechat-green-pressed);
}

button:active {
  transform: translateY(1px);
}

.notice {
  margin: 12px 16px 0;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
}

.error {
  background: var(--danger-bg);
  color: var(--danger);
}

.preview {
  min-height: calc(100vh - 98px);
  display: flex;
  flex-direction: column;
}

.image-stage {
  flex: 1;
  overflow: auto;
  padding: 18px;
  background: var(--soft);
}

.image-stage img {
  display: block;
  width: min(100%, 750px);
  height: auto;
  margin: 0 auto;
  background: white;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.08);
}

.empty {
  min-height: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  background: #fff;
  border: 1px dashed #d8d8d8;
  border-radius: 8px;
}

.empty strong {
  color: #4c4c4c;
  font-size: 15px;
}

.empty span {
  font-size: 13px;
}

@media (max-width: 920px) {
  .app-shell {
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }

  .app-header {
    position: sticky;
    top: 0;
    z-index: 5;
    margin: -12px -12px 12px;
    padding: 12px;
    background: rgba(247, 247, 247, 0.94);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    font-size: 17px;
  }

  h1 {
    font-size: 18px;
  }

  p {
    font-size: 12px;
  }

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

  .editor,
  .preview {
    min-height: auto;
  }

  .panel-head {
    min-height: 48px;
    padding: 0 14px;
  }

  textarea {
    min-height: 260px;
    padding: 14px;
  }

  .action-row {
    position: sticky;
    bottom: 0;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(14px);
  }

  .image-stage {
    padding: 12px;
  }

  .image-stage img {
    width: 100%;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
  }

  .empty {
    min-height: 220px;
  }
}

@media (max-width: 430px) {
  .app-shell {
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .app-header {
    margin: 0;
  }

  .workspace {
    gap: 10px;
  }

  .editor,
  .preview {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  textarea {
    min-height: 238px;
  }
}
