/* ============ Penink Builder · 筆墨 UI ============ */
:root {
  --app-bg: #15120e;
  --app-panel: #1d1915;
  --app-panel2: #262119;
  --app-border: #332d23;
  --app-text: #e9e2d4;
  --app-muted: #9b917f;
  --app-primary: #c2492f;
  --app-primary-hover: #d65a3d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--app-bg);
  color: var(--app-text);
  font-family: ui-sans-serif, system-ui, -apple-system, "PingFang TC", "Microsoft JhengHei", "Noto Sans CJK TC", sans-serif;
  font-size: 14px;
  overflow: hidden;
}

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

/* top bar */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #232019, var(--app-panel));
  border-bottom: 1px solid var(--app-border);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.brand-mark svg { width: 100%; height: 100%; }
.brand-mark { background: #23201b; }
.brand-name { font-size: 15px; letter-spacing: .02em; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }

.icon-btn {
  background: var(--app-panel2); color: var(--app-text);
  border: 1px solid var(--app-border); border-radius: 8px;
  width: 32px; height: 32px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover:not(:disabled) { background: #2e2921; border-color: var(--app-primary); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.sm { width: 26px; height: 26px; }
.icon-btn.sm svg { width: 13px; height: 13px; }

.seg { display: flex; border: 1px solid var(--app-border); border-radius: 8px; overflow: hidden; }
.seg-btn {
  background: var(--app-panel2); color: var(--app-muted);
  border: 0; padding: 4px 9px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.seg-btn svg { width: 15px; height: 15px; }
.seg-btn:hover { color: var(--app-text); }
.seg-btn.active { background: var(--app-primary); color: #fff; }

select {
  background: var(--app-panel2); color: var(--app-text);
  border: 1px solid var(--app-border); border-radius: 8px;
  padding: 6px 8px; max-width: 170px;
  font-size: 13px;
}
select:focus { outline: 1px solid var(--app-primary); }

.btn {
  border: 1px solid var(--app-border); border-radius: 8px;
  padding: 7px 14px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.btn-ghost { background: var(--app-panel2); color: var(--app-text); }
.btn-ghost:hover { background: #2e2921; border-color: var(--app-primary); }
.btn-primary { background: var(--app-primary); color: #fff; border-color: var(--app-primary); }
.btn-primary:hover { background: var(--app-primary-hover); }

/* workspace */
.workspace { flex: 1; display: flex; min-height: 0; }

.palette {
  width: 230px; flex-shrink: 0;
  background: var(--app-panel);
  border-right: 1px solid var(--app-border);
  overflow-y: auto; padding: 14px;
}
.palette-head h3 { margin: 0 0 4px; font-size: 14px; font-family: Georgia, "Songti TC", "Noto Serif CJK TC", serif; }
.hint { color: var(--app-muted); font-size: 12px; margin: 0 0 12px; line-height: 1.6; }
.palette-list { display: flex; flex-direction: column; gap: 6px; }
.pal-card {
  display: flex; align-items: center; gap: 9px;
  background: var(--app-panel2);
  border: 1px solid var(--app-border); border-radius: 9px;
  padding: 8px 11px; cursor: grab; user-select: none;
  font-size: 13px; color: var(--app-text);
}
.pal-card:hover { border-color: var(--app-primary); background: #2b2627; }
.pal-card:active { cursor: grabbing; }
.pal-ico {
  width: 24px; height: 24px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 7px; color: var(--app-primary);
  background: rgba(194,73,47,.14);
}
.pal-ico svg { width: 15px; height: 15px; }

.canvas-area {
  flex: 1; min-width: 0;
  overflow: auto;
  display: flex; justify-content: center; align-items: flex-start;
  padding: 30px 20px;
  background:
    radial-gradient(#2a2419 1px, transparent 0) 0 0/26px 26px,
    radial-gradient(#241f16 1px, transparent 0) 13px 13px/26px 26px,
    var(--app-bg);
}

.device-frame {
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(0,0,0,.6), 0 4px 14px rgba(0,0,0,.4);
  overflow: hidden;
  transition: max-width .25s ease, width .25s ease;
  min-height: 75vh;
  align-self: flex-start;
}
.device-frame.is-mobile, .device-frame.is-mobile .canvas { width: 390px; }
.device-frame.is-tablet, .device-frame.is-tablet .canvas { width: 768px; }
.device-frame.is-desktop { width: min(940px, 100%); }

/* canvas */
.canvas {
  --c-bg: #ffffff;
  --c-text: #262019;
  --c-muted: #6b6255;
  --c-primary: #b8463a;
  --c-primary-contrast: #fff;
  --c-soft: #eae3d2;
  --c-card: #fbf6e9;
  --c-border: #ddd5c2;
  --c-accent: #8a7654;
  --c-code: #f3efe3;
  --radius: 14px;
  color: var(--c-text);
  font-family: var(--font);
  min-height: 80vh;
  position: relative;
}
.canvas.th-dark {
  --c-bg: #14120e;
  --c-text: #efe9dc;
  --c-muted: #9aa08f;
  --c-soft: #211d18;
  --c-card: #23201b;
  --c-border: #37312a;
  --c-code: #1b1814;
  --c-primary-contrast: #fff;
}
.canvas.th-paper { --c-bg: #f3ecdc; }

/* editor wrapper chrome */
.eb { position: relative; outline: 1px solid transparent; }
.eb.selected { outline: 2px solid var(--app-primary); z-index: 2; }
.eb:hover { outline: 1px dashed var(--app-primary); }
.eb-toolbar {
  position: absolute; top: 6px; right: 6px;
  display: none; gap: 2px; z-index: 6;
  background: #232019; color: #fff;
  border-radius: 9px; padding: 3px;
  box-shadow: 0 6px 18px rgba(0,0,0,.45);
  border: 1px solid rgba(255,255,255,.08);
}
.eb.selected .eb-toolbar, .eb:hover .eb-toolbar { display: flex; }
.eb-toolbar button {
  background: transparent; border: 0; color: #e9e2d4;
  width: 26px; height: 26px; border-radius: 6px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.eb-toolbar button svg { width: 14px; height: 14px; }
.eb-toolbar button:hover { background: var(--app-primary); color: #fff; }
.eb-grip { cursor: grab; }
.eb-grip svg { width: 15px; height: 15px; }
.eb-grip:active { cursor: grabbing; }
.eb-drop-zone { position: absolute; left: 0; right: 0; height: 30px; z-index: 3; }
.eb-drop-zone.top { top: -15px; }
.eb-drop-zone.bottom { bottom: -15px; }
.eb-drop-zone.hover::after {
  content: ""; position: absolute; left: 8px; right: 8px; top: 50%;
  height: 4px; border-radius: 3px; background: var(--app-primary);
}
.empty-hint.hover { outline: 2px dashed var(--app-primary); border-radius: 14px; }
.editable { cursor: text; border-radius: 3px; transition: box-shadow .12s ease; }
.editable:hover { box-shadow: 0 0 0 1px rgba(194,73,47,.45); outline: 1px dashed rgba(194,73,47,.4); outline-offset: 2px; }

/* inspector */
.inspector {
  width: 290px; flex-shrink: 0;
  background: var(--app-panel);
  border-left: 1px solid var(--app-border);
  overflow-y: auto;
  transition: opacity .15s ease;
}
.inspector.is-empty { opacity: .55; }
.inspector-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--app-border);
  position: sticky; top: 0; background: var(--app-panel);
}
.inspector-head h3 { margin: 0; font-size: 14px; font-family: Georgia, "Songti TC", "Noto Serif CJK TC", serif; }
.inspector-body { padding: 14px; }
.field { margin-bottom: 14px; }
.field label { display: block; color: var(--app-muted); font-size: 12px; margin-bottom: 5px; }
.field input[type=text], .field textarea, .field select {
  width: 100%; background: var(--app-panel2);
  border: 1px solid var(--app-border); border-radius: 8px;
  color: var(--app-text); padding: 8px 10px; font-size: 13px;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: 1px solid var(--app-primary); border-color: transparent; }
.field textarea { min-height: 76px; resize: vertical; }
.field input[type=color] { width: 100%; height: 34px; border: 1px solid var(--app-border); background: var(--app-panel2); border-radius: 8px; }
.field .row { display: flex; gap: 8px; }
.field .row > * { flex: 1; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--app-border); background: var(--app-panel2);
  color: var(--app-text); border-radius: 20px; padding: 4px 11px; font-size: 12px; cursor: pointer;
}
.chip.active { background: var(--app-primary); border-color: var(--app-primary); color: #fff; }
.section-title { font-weight: 700; font-size: 12px; color: var(--app-muted); text-transform: uppercase; letter-spacing: .06em; margin: 18px 0 8px; }
.list-field { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  background: var(--app-panel2); border: 1px solid var(--app-border); border-radius: 9px; padding: 8px;
}
.list-item .lr { display: flex; gap: 6px; }
.list-item input { flex: 1; margin-bottom: 4px; }

/* statusbar */
.statusbar {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 8px 16px; border-top: 1px solid var(--app-border);
  color: var(--app-muted); font-size: 12px; background: var(--app-panel);
}

/* toast */
.toast {
  position: fixed; bottom: 48px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #232019; color: var(--app-text);
  border: 1px solid var(--app-border); border-radius: 10px;
  padding: 10px 18px; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; z-index: 100;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); font-size: 13px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ Block styles (shared by editor & export) ============ */
.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
section.block { width: 100%; }

.block {
  background: transparent;
  padding: var(--sp, 56px) 0;
  color: var(--c-text);
}
.block.bg-soft { background: var(--c-soft); }
.block.bg-dark { background: var(--c-text); }
.block.bg-dark * { color: var(--c-bg, #fff); }

.row { display: grid; gap: 22px; }
.row.c2 { grid-template-columns: 1fr 1fr; }
.row.c3 { grid-template-columns: repeat(3, 1fr); }
.row.c4 { grid-template-columns: repeat(4, 1fr); }

.card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 2px 10px rgba(60,45,20,.05);
}
.card:hover { box-shadow: 0 8px 24px rgba(60,45,20,.1); }

/* typography on canvas */
.canvas h1, .canvas h2, .canvas h3,
.hero-title, .b-title, .stat-num, .t-name {
  font-family: var(--font-display);
}
.b-title, .hero-title { letter-spacing: .02em; }

/* navbar */
.b-navbar {
  display: flex; align-items: center; gap: 18px;
  padding: 16px 0;
}
.b-navbar .logo { font-weight: 800; font-size: 19px; color: var(--c-primary); font-family: var(--font-display); }
.b-navbar .links { display: flex; gap: 16px; font-size: 14px; }
.b-navbar .links a { color: var(--c-muted); text-decoration: none; }
.b-navbar .links a:hover { color: var(--c-primary); }
.b-navbar .cta {
  margin-left: auto; background: var(--c-primary); color: var(--c-primary-contrast);
  padding: 9px 18px; border-radius: 999px; font-size: 13px; font-weight: 600;
  text-decoration: none;
}
.center-block { text-align: center; }
.right-block { text-align: right; }

/* hero */
.btn-hero {
  display: inline-block; padding: 12px 26px; border-radius: 4px;
  font-weight: 700; font-size: 14px; text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease;
  letter-spacing: .04em;
}
.btn-hero:hover { transform: translateY(-2px); }
.btn-hero.primary { background: var(--c-primary); color: var(--c-primary-contrast); box-shadow: 0 4px 14px rgba(184,70,58,.25); }
.btn-hero.primary:hover { box-shadow: 0 8px 22px rgba(184,70,58,.32); }
.btn-hero.secondary { background: var(--c-soft); color: var(--c-primary); border: 1px solid var(--c-border); }
.hero-badge {
  display: inline-block; background: var(--c-soft); color: var(--c-primary);
  padding: 6px 14px; border-radius: 4px; font-size: 12px; font-weight: 600;
  letter-spacing: .06em;
}
.hero-title { font-size: clamp(30px, 4.4vw, 46px); line-height: 1.25; margin: 16px 0 14px; }
.hero-sub { color: var(--c-muted); font-size: clamp(15px, 1.6vw, 18px); max-width: 640px; margin: 0 auto 26px; line-height: 1.8; }
.hero-actions { display: flex; gap: 12px; justify-content: center; }
.hero-img {
  margin: 34px auto 0; max-width: 920px; width: 100%;
  border-radius: 6px;
  overflow: hidden; border: 1px solid var(--c-border);
  box-shadow: 0 24px 60px rgba(40,30,10,.18);
}
.hero-img img { display: block; width: 100%; height: 320px; object-fit: cover; }
.hero-beside-text { align-self: center; }
.hero-beside-text .hero-sub { margin: 0 0 26px; }

/* stats */
.stat { text-align: center; }
.stat-num { font-size: clamp(28px, 3.4vw, 40px); font-weight: 700; color: var(--c-primary); }
.stat-label { color: var(--c-muted); font-size: 14px; margin-top: 6px; letter-spacing: .04em; }

/* features / about */
.feature-ico {
  width: 46px; height: 46px; border-radius: 12px;
  background: var(--c-soft); color: var(--c-primary);
  display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
  border: 1px solid var(--c-border);
}
.feature-ico svg { width: 24px; height: 24px; }
.feature-ico:has(svg) { background: var(--c-soft); }
.about-img { border-radius: 6px; overflow: hidden; border: 1px solid var(--c-border); box-shadow: 0 18px 44px rgba(40,30,10,.12); }
.about-img img { display: block; width: 100%; height: 100%; min-height: 240px; object-fit: cover; }

/* gallery */
.g-item { border-radius: 6px; overflow: hidden; border: 1px solid var(--c-border); background: var(--c-card); }
.g-item img { display: block; width: 100%; height: 200px; object-fit: cover; }
.g-cap { padding: 10px 14px; font-size: 13px; color: var(--c-muted); letter-spacing: .02em; }

/* pricing */
.price-tier { position: relative; display: flex; flex-direction: column; }
.price-tier.badge { border: 2px solid var(--c-primary); }
.price-tier.badge::before {
  content: "";
  position: absolute; top: -11px; left: 50%; transform: translateX(-50%);
  background: var(--c-primary); width: 30px; height: 11px;
  border-radius: 6px 6px 2px 2px;
  box-shadow: 0 3px 10px rgba(184,70,58,.35);
}
.price-tag { font-size: 32px; font-weight: 700; font-family: var(--font-display); margin: 6px 0; }
.price-cur { font-size: 16px; vertical-align: super; color: var(--c-muted); }
.price-list { list-style: none; padding: 0; margin: 14px 0 20px; color: var(--c-muted); font-size: 14px; }
.price-list li { padding: 6px 0; position: relative; padding-left: 18px; }
.price-list li::before { content: "—"; position: absolute; left: 0; color: var(--c-primary); }
.price-btn {
  display: block; text-align: center; padding: 12px; border-radius: 4px;
  text-decoration: none; font-weight: 700; font-size: 14px; margin-top: auto;
  letter-spacing: .04em;
}
.price-btn.p-solid { background: var(--c-primary); color: var(--c-primary-contrast); }
.price-btn.p-ghost { background: var(--c-soft); color: var(--c-primary); border: 1px solid var(--c-border); }

/* testimonials */
.t-quote { color: var(--c-muted); font-size: 14px; line-height: 1.75; }
.t-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--c-primary); color: var(--c-primary-contrast);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px;
  flex-shrink: 0;
}
.t-foot { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.t-name { font-weight: 700; font-size: 13px; }
.t-role { color: var(--c-muted); font-size: 12px; }

/* faq */
.faq-item { border: 1px solid var(--c-border); border-radius: 6px; margin-bottom: 10px; overflow: hidden; background: var(--c-card); }
.faq-q {
  padding: 15px 18px; font-weight: 700; font-size: 14px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-display);
}
.faq-q .arw { transition: transform .2s ease; color: var(--c-primary); }
.faq-item.open .arw { transform: rotate(180deg); }
.faq-a { display: none; padding: 0 18px 16px; color: var(--c-muted); font-size: 14px; line-height: 1.8; }
.faq-item.open .faq-a { display: block; }

/* cta */
.cta-band {
  border-radius: 8px;
  background: linear-gradient(120deg, var(--c-primary), var(--c-accent));
  color: #fff; padding: 52px 36px; text-align: center;
  position: relative; overflow: hidden;
}
.cta-band::after {
  content: ""; position: absolute; right: -40px; bottom: -50px;
  width: 220px; height: 220px; border-radius: 50%;
  background: rgba(255,255,255,.08);
}
.cta-band h2 { margin: 0 0 10px; font-size: clamp(22px, 3vw, 32px); font-family: var(--font-display); }
.cta-band p { opacity: .92; margin: 0 auto 24px; max-width: 520px; }
.btn-white {
  display: inline-block; background: #fff; color: var(--c-primary);
  padding: 12px 26px; border-radius: 4px; font-weight: 700; font-size: 14px; text-decoration: none;
  letter-spacing: .04em; position: relative;
}

/* contact */
.c-field { width: 100%; margin-bottom: 12px; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--c-border); background: var(--c-card); font-size: 14px; color: var(--c-text); }
.c-field:focus { outline: 2px solid var(--c-primary); outline-offset: 0; border-color: transparent; }
.c-submit {
  background: var(--c-primary); color: var(--c-primary-contrast);
  border: 0; padding: 12px 24px; border-radius: 4px; font-weight: 700; font-size: 14px; cursor: pointer;
  letter-spacing: .04em;
}
.c-info { color: var(--c-muted); font-size: 14px; line-height: 2.2; }
.c-info span { cursor: text; }

/* footer */
.footer-links { display: flex; gap: 18px; font-size: 14px; }
.footer-links a { color: var(--c-muted); text-decoration: none; }
.footer-links a:hover { color: var(--c-primary); }
.copyright { color: var(--c-muted); font-size: 13px; }

h2.b-title { font-size: clamp(24px, 3.2vw, 36px); line-height: 1.25; margin: 0 0 12px; }
.b-sub { color: var(--c-muted); max-width: 620px; margin: 0 auto 32px; font-size: 15px; line-height: 1.8; }

/* section spacing variants */
.block.sp-sm { padding: 30px 0; }
.block.sp-lg { padding: 84px 0; }
.block.radius-top { border-top-left-radius: 26px; border-top-right-radius: 26px; }

/* images: broken placeholder */
.ph { height: 200px; background: repeating-linear-gradient(45deg, var(--c-soft) 0 12px, var(--c-border) 12px 24px); border-radius: 6px; }

/* responsive */
@media (max-width: 820px) {
  .row.c2, .row.c3, .row.c4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .row.c2, .row.c3, .row.c4 { grid-template-columns: 1fr; }
  .b-navbar .links { display: none; }
  .hero-actions { flex-direction: column; align-items: stretch; }
  .btn-hero { text-align: center; }
}
