:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #1f2723;
  background: #f7f8f7;
  --page: #f7f8f7;
  --surface: #ffffff;
  --ink: #1f2723;
  --muted: #737e78;
  --line: #edf0ee;
  --line-strong: #dfe5e1;
  --soft: #f4f6f5;
  --accent: #1aad6c;
  --accent-dark: #148a57;
  --danger: #b34b4b;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--page); }
body { margin: 0; min-width: 320px; overflow-x: hidden; background: var(--page); color: var(--ink); }
button, select, input { font: inherit; }
button { color: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  min-height: 58px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-size: 16px; font-weight: 720; letter-spacing: .02em; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; background: var(--accent); }
.brand-mark img { width: 17px; height: 17px; filter: brightness(0) invert(1); }
.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.privacy-note, .save-state, .editor-hint { color: var(--muted); font-size: 12px; }
.save-state { display: inline-flex; align-items: center; gap: 6px; }
.save-state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

.button { height: 36px; padding: 0 14px; border: 1px solid #d5dcd8; border-radius: 6px; background: var(--surface); color: #354039; font-size: 13px; font-weight: 650; cursor: pointer; transition: background-color .15s, border-color .15s, color .15s; }
.button:hover { border-color: #b7c2bc; background: #fafbfa; }
.button.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.button.primary:hover { border-color: var(--accent-dark); background: var(--accent-dark); }
.button.ghost { border-color: transparent; color: var(--muted); }
.button.ghost:hover { border-color: var(--line); color: var(--ink); }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 64fr) minmax(360px, 36fr);
  max-width: 1640px;
  height: calc(100vh - 58px);
  min-height: 0;
  margin: 0 auto;
  overflow: hidden;
  background: var(--surface);
}
.editor-panel { display: flex; min-width: 0; height: 100%; min-height: 0; flex-direction: column; overflow: hidden; border-right: 1px solid var(--line-strong); background: var(--surface); }
.panel-heading, .section-title, .dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-heading { min-height: 58px; padding: 8px 28px 6px; }
.panel-heading h1, .section-title h2, .dialog-heading h2 { margin: 0; color: var(--ink); }
.panel-heading h1 { font-size: 17px; font-weight: 720; }
.panel-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.toolbar { display: flex; align-items: center; gap: 2px; min-height: 48px; padding: 7px 18px; overflow-x: auto; border-block: 1px solid var(--line); background: #fbfcfb; scrollbar-width: thin; }
.toolbar button, .toolbar select { flex: 0 0 auto; min-height: 32px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: #4a554f; font-size: 12px; cursor: pointer; }
.toolbar button:not(:disabled):hover, .toolbar select:hover { border-color: var(--line); background: #f0f3f1; color: var(--ink); }
.tool-button { display: grid; width: 32px; padding: 0; place-items: center; }
.tool-button img { width: 16px; height: 16px; opacity: .78; }
.tool-button:hover img { opacity: 1; }
.toolbar .block-picker { display: flex; flex: 0 0 auto; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.toolbar .block-picker select { min-width: 76px; padding: 0 22px 0 8px; border-color: var(--line); background: var(--surface); }
.toolbar-divider { flex: 0 0 auto; width: 1px; height: 20px; margin: 0 5px; background: var(--line); }
.toolbar .ai-button { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; padding: 0 9px; color: #909a94; cursor: not-allowed; }
.toolbar .ai-button span { padding: 2px 4px; border-radius: 4px; background: #edf0ee; font-size: 9px; }

.editor { flex: 1; min-height: 0; padding: 42px clamp(30px, 6vw, 92px); overflow-y: auto; outline: 0; background: var(--surface); color: #29322d; font-size: 16px; line-height: 1.8; overflow-wrap: anywhere; scrollbar-width: thin; scrollbar-color: transparent transparent; }
.editor:focus-visible { box-shadow: inset 0 0 0 1px #d9dedb; }
.editor:hover { scrollbar-color: #dfe4e1 transparent; }
.editor::-webkit-scrollbar { width: 4px; }
.editor::-webkit-scrollbar-track { background: transparent; }
.editor::-webkit-scrollbar-thumb { border-radius: 999px; background: transparent; }
.editor:hover::-webkit-scrollbar-thumb { background: #dfe4e1; }
.editor:empty::before { content: attr(data-placeholder); white-space: pre-line; color: #9ba49f; pointer-events: none; }
.editor p { margin: 0 0 17px; }
.editor img { display: block; max-width: 100%; height: auto; margin: 22px auto; border-radius: 4px; }
.editor table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.editor td, .editor th { padding: 8px; border: 1px solid #ccd8d1; overflow-wrap: anywhere; }
.editor-footer { display: flex; justify-content: space-between; gap: 12px; padding: 10px 22px; border-top: 1px solid var(--line); background: #fbfcfb; color: var(--muted); font-size: 11px; }

.side-panel { align-self: start; height: 100%; overflow-y: auto; background: #fcfdfc; scrollbar-width: thin; scrollbar-color: transparent transparent; }
.side-panel:hover { scrollbar-color: #dfe4e1 transparent; }
.side-panel::-webkit-scrollbar { width: 4px; }
.side-panel::-webkit-scrollbar-track { background: transparent; }
.side-panel::-webkit-scrollbar-thumb { border-radius: 999px; background: transparent; }
.side-panel:hover::-webkit-scrollbar-thumb { background: #dfe4e1; }
.side-panel::-webkit-scrollbar-thumb:hover { background: #c9d0cc; }
.side-section { padding: 17px 20px; border-bottom: 1px solid var(--line); }
.theme-section { padding-top: 9px; }
.section-title h2 { font-size: 14px; font-weight: 700; }
.section-title span { color: var(--muted); font-size: 11px; }

.theme-rail { position: relative; margin-top: 12px; }
.theme-list { display: grid; grid-auto-columns: 52px; grid-auto-flow: column; gap: 8px; padding: 1px 2px 3px; overflow-x: auto; overscroll-behavior-inline: contain; scroll-behavior: smooth; scroll-snap-type: x proximity; scrollbar-width: none; }
.theme-list::-webkit-scrollbar { display: none; }
.theme-option { min-width: 0; padding: 0; border: 0; border-radius: 0; background: transparent; text-align: left; color: #37413c; cursor: pointer; scroll-snap-align: start; }
.theme-sample { display: block; height: 78px; margin-bottom: 7px; padding: 10px 6px; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); transition: border-color .15s, box-shadow .15s, background-color .15s; }
.theme-option:hover .theme-sample { border-color: #cbd4cf; background: #fdfefd; }
.theme-option.active .theme-sample { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(26, 173, 108, .08); }
.theme-sample b, .theme-sample span { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.theme-sample b { padding-left: 4px; border-left: 2px solid var(--accent); color: #89938d; font-size: 7px; font-weight: 620; line-height: 1.45; }
.theme-sample span { margin-top: 8px; color: #c1c8c4; font-size: 7px; line-height: 1.6; }
.theme-preview-detail { display: block; margin-top: 5px; overflow: hidden; color: #c9cfcb; font-size: 6px; font-style: normal; line-height: 1.35; white-space: nowrap; text-overflow: ellipsis; }
.theme-option strong { display: block; overflow: hidden; color: #37413c; font-size: 10px; font-weight: 650; text-align: center; white-space: nowrap; text-overflow: ellipsis; }
.theme-option small { display: none; }
.theme-option.active strong { color: var(--accent-dark); }
.theme-rail-nav { position: absolute; top: 35px; z-index: 2; display: grid; width: 22px; height: 32px; padding: 0; place-items: center; border: 0; border-radius: 4px; background: #fcfdfc; box-shadow: none; cursor: pointer; transform: translateY(-50%); transition: opacity .15s, color .15s; }
.theme-rail-nav.previous { left: -9px; }
.theme-rail-nav.next { right: -9px; }
.theme-rail-nav img { width: 14px; height: 14px; opacity: .62; }
.theme-rail-nav:hover { border-color: #ccd5d0; }
.theme-rail-nav:disabled { opacity: 0; pointer-events: none; }

.check-switches { display: grid; gap: 0; margin-top: 8px; }
.check-switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px; border-bottom: 1px solid #edf0ee; color: #36413b; cursor: pointer; }
.check-switch:last-child { border-bottom: 0; }
.check-switch > span { display: grid; gap: 3px; }
.check-switch b { font-size: 12px; font-weight: 650; }
.check-switch small { color: var(--muted); font-size: 10px; }
.check-switch input { position: relative; flex: 0 0 auto; width: 34px; height: 19px; margin: 0; appearance: none; border: 1px solid #c7cfcb; border-radius: 999px; background: #d8ddda; cursor: pointer; transition: background-color .15s, border-color .15s; }
.check-switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(31, 39, 35, .18); transition: transform .15s; }
.check-switch input:checked { border-color: var(--accent); background: var(--accent); }
.check-switch input:checked::after { transform: translateX(15px); }
.recent-check { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 7px; padding: 9px 10px; border-radius: 6px; background: #f3f6f4; color: #44504a; }
.recent-check > span:first-child { display: grid; min-width: 0; gap: 2px; }
.recent-check b { overflow: hidden; font-size: 10px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.recent-check small { color: var(--muted); font-size: 9px; }
.recent-check-actions { display: flex; flex: 0 0 auto; gap: 3px; }
.recent-check button { padding: 4px 6px; border: 0; border-radius: 4px; background: transparent; color: var(--accent-dark); font-size: 10px; cursor: pointer; }
.recent-check button:hover { background: #e5ece8; }
.legal-hint { margin: 6px 0 0; color: #929a96; font-size: 10px; line-height: 1.45; }

.preview-section { padding-bottom: 20px; }
.phone-frame { position: relative; display: flex; width: min(100%, 370px); height: min(520px, max(360px, calc(100vh - 430px))); margin: 12px auto 0; flex-direction: column; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); box-shadow: 0 8px 24px rgba(31, 39, 35, .055); }
.wechat-bar { z-index: 2; display: flex; flex: 0 0 40px; align-items: center; justify-content: space-between; padding: 0 14px; border-bottom: 1px solid #edf0ee; background: var(--surface); color: #2c342f; font-size: 12px; }
.wechat-bar span { display: flex; min-width: 24px; align-items: center; }
.wechat-bar span:last-child { justify-content: flex-end; }
.wechat-bar img { width: 17px; height: 17px; opacity: .72; }
.preview { flex: 1 1 auto; min-height: 0; padding: 20px 18px 28px; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; scrollbar-width: thin; scrollbar-color: #d5dcd8 transparent; }
.preview:empty { display: none; }
.preview::-webkit-scrollbar { width: 5px; }
.preview::-webkit-scrollbar-track { background: transparent; }
.preview::-webkit-scrollbar-thumb { border-radius: 999px; background: #d5dcd8; }
.preview::-webkit-scrollbar-thumb:hover { background: #bdc7c1; }
.preview-empty { position: absolute; inset: 40px 0 0; display: grid; padding: 34px; place-items: center; color: #98a19c; text-align: center; font-size: 12px; }

.style-section { padding-block: 0; }
details { padding: 12px 0; }
summary { display: flex; align-items: center; justify-content: space-between; list-style: none; color: #3d4742; cursor: pointer; }
summary::-webkit-details-marker { display: none; }
summary > img { width: 16px; height: 16px; opacity: .56; transition: transform .15s; }
details[open] summary > img { transform: rotate(180deg); }
.style-summary-copy { display: grid; gap: 2px; }
.style-summary-copy b { font-size: 12px; font-weight: 650; }
.style-summary-copy small { color: var(--muted); font-size: 10px; font-weight: 400; }
.controls-grid { display: grid; grid-template-columns: 1fr; gap: 0; margin-top: 10px; border-top: 1px solid var(--line); }
.control-row { display: flex; min-height: 48px; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.control-label { flex: 0 0 auto; white-space: nowrap; }
.control-value { display: flex; min-width: 0; align-items: center; justify-content: flex-end; gap: 8px; }
.range-value { flex: 1; max-width: 300px; }
.controls-grid input[type=color] { width: 30px; height: 30px; padding: 3px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); cursor: pointer; }
.controls-grid input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
.controls-grid input[type=color]::-webkit-color-swatch { border: 0; border-radius: 4px; }
.controls-grid input[type=range] { width: 100%; min-width: 90px; height: 18px; margin: 0; appearance: none; background: transparent; cursor: pointer; }
.controls-grid input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 999px; background: #e1e7e3; }
.controls-grid input[type=range]::-webkit-slider-thumb { width: 14px; height: 14px; margin-top: -5px; appearance: none; border: 0; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--surface); }
.controls-grid input[type=range]::-moz-range-track { height: 4px; border-radius: 999px; background: #e1e7e3; }
.controls-grid input[type=range]::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--accent); }
.controls-grid input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border: 3px solid var(--surface); border-radius: 50%; background: var(--accent); }
.controls-grid select { width: 66px; height: 32px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: #354039; }
.controls-grid output { min-width: 40px; color: #354039; text-align: right; font-variant-numeric: tabular-nums; }
.color-value output { min-width: 62px; color: var(--muted); }

.warnings { display: none; margin: 12px 20px 0; padding: 9px 10px; border: 1px solid #eadba9; border-radius: 6px; background: #fffbed; color: #735f2d; font-size: 11px; line-height: 1.5; }
.warnings.show { display: block; }
.copy-main { width: calc(100% - 40px); margin: 14px 20px 20px; color: var(--accent-dark); }
.copy-main:hover { border-color: var(--accent); color: var(--accent-dark); }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 30; display: flex; align-items: center; gap: 14px; max-width: min(620px, calc(100vw - 28px)); padding: 10px 12px 10px 15px; border: 1px solid rgba(255,255,255,.12); border-radius: 7px; background: #202a25; color: #fff; box-shadow: 0 10px 28px rgba(18, 31, 24, .18); font-size: 12px; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: opacity .18s, transform .18s; }
.toast.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.toast-actions { display: flex; gap: 5px; margin-left: auto; }
.toast button { padding: 5px 8px; border: 0; border-radius: 4px; background: rgba(255,255,255,.13); color: #fff; font-size: 11px; cursor: pointer; }
.toast button:hover { background: rgba(255,255,255,.22); }

.change-dialog { width: min(640px, calc(100vw - 28px)); max-height: min(720px, calc(100vh - 40px)); padding: 0; border: 1px solid #d9e0dc; border-radius: 9px; color: #26312b; box-shadow: 0 20px 60px rgba(21, 35, 28, .2); }
.change-dialog::backdrop { background: rgba(23, 35, 29, .36); }
.dialog-heading { padding: 17px 19px; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { font-size: 16px; }
.dialog-heading p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.dialog-close { padding: 6px 9px; border: 1px solid #d3dbd7; border-radius: 5px; background: var(--surface); color: #53605a; cursor: pointer; }
.change-list { display: grid; gap: 7px; max-height: 520px; margin: 0; padding: 15px 20px 20px 42px; overflow-y: auto; }
.change-list li { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.change-type { display: inline-block; min-width: 52px; margin-right: 8px; color: var(--accent-dark); font-size: 11px; font-weight: 700; }
.change-detail { color: #44504a; font-size: 12px; overflow-wrap: anywhere; }

button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid rgba(26, 173, 108, .25); outline-offset: 2px; }

@media (min-width: 1181px) {
  body { overflow-y: hidden; }
}

@media (max-width: 1180px) {
  .workspace { height: auto; min-height: calc(100vh - 58px); overflow: visible; grid-template-columns: 1fr; }
  .editor-panel { height: auto; min-height: 720px; overflow: visible; border-right: 0; border-bottom: 1px solid var(--line); }
  .side-panel { display: grid; height: auto; grid-template-columns: 1fr 1fr; overflow: visible; }
  .side-section { border-right: 1px solid var(--line); }
  .preview-section { grid-column: 1 / -1; }
  .style-section { grid-column: 1 / -1; border-top: 1px solid var(--line); }
  .warnings, .copy-main { grid-column: 1 / -1; }
  .phone-frame { width: min(100%, 420px); height: 520px; }
}

@media (max-width: 700px) {
  .topbar { min-height: 58px; padding: 0 12px; }
  .privacy-note, .top-actions .ghost, .editor-hint { display: none; }
  .top-actions { gap: 7px; }
  .save-state { font-size: 10px; }
  .button { padding-inline: 11px; }
  .panel-heading { min-height: 58px; padding: 8px 17px 6px; }
  .workspace, .editor-panel { width: 100%; min-width: 0; }
  .toolbar { width: 100%; min-width: 0; padding-inline: 10px; overflow-x: auto; overscroll-behavior-inline: contain; }
  .toolbar .ai-button { display: none; }
  .editor { width: 100%; min-width: 0; min-height: 540px; padding: 28px 18px; }
  .editor-footer { padding-inline: 14px; }
  #paste-status { max-width: 65%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .side-panel { display: flex; flex-direction: column; min-width: 0; width: 100%; }
  .side-section { min-width: 0; width: 100%; padding-inline: 16px; border-right: 0; }
  .phone-frame { width: 100%; height: 540px; }
  .controls-grid { grid-template-columns: 1fr; }
  .warnings { margin-inline: 16px; }
  .copy-main { width: calc(100% - 32px); margin-inline: 16px; }
  .toast { align-items: flex-start; flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
