:root {
  --bg: #f7fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --muted: #5c6675;
  --accent: #2563eb;
  --accent-purple: #7c3aed;
  --accent-soft: rgba(37,99,235,0.10);
  --accent-purple-soft: rgba(124,58,237,0.12);
  --warn: #ba7517;
  --ok: #1a7f37;
  --danger: #a32d2d;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body, .app { height: 100%; }
body {
  margin: 0; overflow: hidden;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(180deg, #eef8ff 0%, #fff5f8 100%);
  background-attachment: fixed;
  color: var(--text); -webkit-text-size-adjust: 100%;
  position: relative;
}
.app { display: flex; flex-direction: column; }
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(560px 380px at 12% 6%, rgba(37,99,235,0.10), transparent 70%),
    radial-gradient(500px 360px at 90% 16%, rgba(124,58,237,0.10), transparent 70%),
    radial-gradient(520px 400px at 72% 94%, rgba(236,72,153,0.07), transparent 70%);
}

.app-header {
  flex-shrink: 0;
  z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255,255,255,0.72);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid rgba(226,232,240,0.6);
}
.brand { font-weight: 600; font-size: 16px; }
.header-sub { color: var(--muted); font-size: 13px; }
.site-nav { display: flex; align-items: center; gap: 26px; list-style: none; margin: 0; padding: 0; }
.site-nav a {
  font-size: 15px; font-weight: 500; color: var(--muted);
  position: relative; padding: 4px 0; transition: color .2s ease; white-space: nowrap; text-decoration: none;
}
.site-nav a:hover { color: var(--accent); }
.site-nav a.active { color: var(--accent); }
.site-nav a.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px;
  background: var(--accent); border-radius: 2px;
}
@media (max-width: 768px) { .site-nav { display: none; } }
.header-right { display: flex; align-items: center; gap: 22px; margin-left: auto; }
.auth-bar { display: flex; gap: 8px; align-items: center; }
.auth-bar .btn.ghost { padding: 6px 12px; font-size: 13px; background: rgba(255,255,255,.18); color: #1a2238; border: 1px solid rgba(26,34,56,.18); }
.auth-bar .btn.ghost:hover { background: rgba(255,255,255,.4); }

.tc-main {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  max-width: 1100px; width: 100%; margin: 0 auto; padding: 16px;
}

.welcome-head { text-align: center; padding: 10px 0 8px; flex-shrink: 0; }
.welcome-title { font-size: 34px; font-weight: 500; margin: 0; color: var(--text); line-height: 1.35; letter-spacing: -0.02em; }
.welcome-title .accent-word {
  font-weight: 700;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
@media (max-width: 640px) { .welcome-title { font-size: 26px; line-height: 1.4; } }

.start-row {
  flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.start-btn { min-width: 150px; padding: 13px 32px; font-size: 16px; border-radius: 999px; }
.start-status { display: flex; align-items: center; gap: 10px; min-height: 22px; }
.start-tools {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 14px; cursor: pointer; transition: box-shadow .2s ease, transform .05s ease;
}
.btn:hover { box-shadow: 0 2px 8px rgba(15,23,42,0.08); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent); color: #fff; border-color: transparent;
  box-shadow: 0 4px 14px rgba(37,99,235,0.20);
}
.btn.primary:hover { box-shadow: 0 6px 18px rgba(37,99,235,0.28); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; background: var(--surface); }
.seg button {
  border: 0; background: transparent; padding: 7px 13px; font-size: 13px; color: var(--muted); cursor: pointer;
}
.seg button.on { background: var(--accent); color: #fff; }

.badge { font-size: 12px; padding: 3px 10px; border-radius: 999px; font-weight: 600; }
.badge.draft { background: #fff3e0; color: var(--warn); }
.badge.live { background: #e7f6ee; color: var(--ok); }
.muted { color: var(--muted); font-size: 13px; }

.card {
  background: var(--surface); border: 1px solid rgba(226,232,240,0.9);
  border-radius: var(--radius); padding: 16px;
  box-shadow: 0 2px 12px rgba(37,99,235,0.06);
}
.card > label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }

.editor-card {
  flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
  margin-bottom: 0; padding-bottom: 12px;
}
.canvas-scroll {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  display: flex; justify-content: center; padding: 18px;
  background: #f8fafc; border: 1px solid rgba(226,232,240,0.9); border-radius: 10px;
}
.canvas-wrap {
  box-shadow: 0 12px 44px rgba(20,24,50,.12); border-radius: 14px; overflow: hidden; flex-shrink: 0;
}
.canvas {
  position: relative; background: #0f1226; margin: 0 auto;
  /* width/height set by JS */
}
.canvas:empty::before {
  content: "页面还没有模块\A点击上方「添加区块」开始搭建";
  white-space: pre; text-align: center; color: rgba(255,255,255,.55);
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); font-size: 14px;
}

.module {
  position: relative;
  margin: 0 auto 12px; overflow: hidden;
  /* last child no margin handled in JS via class or CSS */
}
.module:last-child { margin-bottom: 0; }
.module.sel { outline: 2px solid var(--accent); outline-offset: 1px; }
.mod-handle {
  position: absolute; left: 6px; top: 6px; z-index: 20;
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; background: rgba(255,255,255,.85); color: var(--muted);
  cursor: grab; font-size: 14px; line-height: 1; opacity: 0; transition: opacity .15s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
.module:hover .mod-handle { opacity: 1; }
.mod-del {
  position: absolute; right: 6px; top: 6px; z-index: 20;
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; background: rgba(255,255,255,.85); color: var(--danger);
  cursor: pointer; font-size: 13px; opacity: 0; transition: opacity .15s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
.module:hover .mod-del { opacity: 1; }
.mod-handle:active { cursor: grabbing; }

.item {
  position: absolute; display: flex; align-items: center; overflow: hidden; word-break: break-word;
}
.item.text { white-space: pre-wrap; line-height: 1.35; padding: 2px 4px; }
.item.text[contenteditable="true"] { outline: 2px solid var(--accent); cursor: text; }
.item.button { justify-content: center; border: none; font-weight: 600; }
.item.image { background-size: cover; background-position: center; }

.prop-bar { flex-shrink: 0; margin-top: 4px; }
.prop-bar.hidden { display: none; }
.prop-bar-inner {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px;
  max-height: 210px; overflow-y: auto; padding-right: 4px;
}
.prop-field { display: flex; flex-direction: column; gap: 4px; }
.prop-field label { font-size: 12px; color: var(--muted); }
.prop-field.wide { grid-column: 1 / -1; }
.prop-field input[type="range"] { width: 100%; }
.prop-field input[type="color"] { width: 42px; height: 34px; border: 1px solid var(--border); border-radius: 8px; padding: 2px; background: none; cursor: pointer; }
.prop-field .row { display: flex; gap: 8px; align-items: center; }
.prop-field .val { flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: 7px; font-size: 13px; }
.prop-tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); margin-bottom: 6px; }
.divider { height: 1px; background: rgba(226,232,240,0.9); margin: 12px 0 10px; }

input, textarea, select {
  width: 100%; padding: 9px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
  font-family: inherit; background: #fff; color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.modal { position: fixed; inset: 0; background: rgba(15,18,38,.45); display: none; place-items: center; z-index: 200; }
.modal.show { display: grid; }
.sheet { background: var(--surface); border-radius: 16px; width: min(640px,92vw); max-height: 82vh; overflow: auto; padding: 20px; box-shadow: 0 20px 60px rgba(15,18,38,.18); }
.sheet h3 { margin: 0 0 14px; font-size: 18px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 12px; }
.lib-card {
  padding: 14px 12px; border: 1px solid var(--border); border-radius: 12px; background: #fafbff;
  cursor: pointer; text-align: center; transition: border-color .15s, box-shadow .15s, transform .1s;
}
.lib-card:hover { border-color: var(--accent); box-shadow: 0 4px 14px rgba(37,99,235,.10); transform: translateY(-1px); }
.lib-card .t { font-weight: 600; font-size: 14px; }
.lib-card .d { font-size: 12px; color: var(--muted); margin-top: 4px; }
.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 30px 10px; }
.hidden { display: none !important; }
.hidden-file { display: none; }

.row { display: flex; gap: 8px; align-items: center; }
.import-preview { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; max-height: 240px; overflow-y: auto; }
.import-preview .imp-mod {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: #fafbff;
}
.import-preview .imp-mod .imp-name { font-weight: 600; font-size: 13px; color: var(--text); }
.import-preview .imp-mod .imp-type { font-size: 11px; color: var(--muted); margin-left: 6px; }
.import-preview .imp-mod .imp-items { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.import-preview .imp-mod .imp-items .t { color: #1f2937; }
.import-preview .imp-mod .imp-items .img { color: var(--accent); }
.import-preview .imp-mod .imp-items .btn-t { color: var(--accent-purple); }
.import-preview .imp-stats { font-size: 13px; font-weight: 600; color: var(--text); }
.import-preview .imp-note { font-size: 12px; color: var(--muted); line-height: 1.5; }

@media (max-width: 640px) {
  .tc-main { padding: 12px; }
  .start-tools { gap: 8px; }
  .canvas-scroll { padding: 10px; }
}
