:root {
  --ink: #171914;
  --muted: #70746a;
  --line: #dedfd8;
  --soft-line: #e9eae4;
  --paper: #f7f7f2;
  --white: #ffffff;
  --accent: #c7ff4a;
  --accent-dark: #1d2a00;
  --dark: #10110f;
  --danger: #bb3d2f;
  --shadow: 0 18px 55px rgba(22, 24, 18, 0.12);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, textarea, select { font: inherit; }
button { color: inherit; }

.topbar {
  height: 68px;
  display: grid;
  grid-template-columns: 280px 1fr auto;
  align-items: center;
  gap: 20px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 247, 242, 0.96);
  position: relative;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 9px; background: var(--dark); color: var(--accent);
  font-size: 12px; font-weight: 800; letter-spacing: -.04em;
}
.brand div { display: flex; flex-direction: column; line-height: 1.1; }
.brand strong { font-size: 14px; }
.brand small { color: var(--muted); font-size: 10px; margin-top: 4px; }
.project-title-wrap { display: flex; align-items: center; justify-content: center; gap: 10px; }
.project-name {
  width: min(320px, 40vw); border: 1px solid transparent; background: transparent;
  border-radius: 7px; padding: 7px 10px; text-align: center; font-weight: 650;
}
.project-name:hover, .project-name:focus { background: var(--white); border-color: var(--line); outline: none; }
.save-status { font-size: 10px; color: var(--muted); white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 7px; }

button, .file-label { border: 0; cursor: pointer; transition: .16s ease; }
.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 8px;
  background: transparent; font-size: 18px;
}
.icon-btn:hover { background: #e8e9e2; }
.quiet-btn, .primary-btn, .text-btn, .copy-btn {
  min-height: 36px; padding: 0 14px; border-radius: 8px; font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.quiet-btn { background: var(--white); border: 1px solid var(--line); }
.quiet-btn:hover { border-color: #aeb1a7; transform: translateY(-1px); }
.primary-btn { background: var(--dark); color: var(--white); box-shadow: 0 4px 0 #cbd0c1; }
.primary-btn:hover { background: #282b25; transform: translateY(-1px); }
.text-btn { background: transparent; color: var(--ink); }
.text-btn:hover { background: #eceee6; }
button:disabled { opacity: .35; cursor: not-allowed; transform: none !important; }

.workspace { height: calc(100vh - 68px); min-height: 0; overflow: hidden; display: grid; grid-template-columns: 258px minmax(420px, 1fr) 292px; grid-template-rows: minmax(0, 1fr); }
.panel { background: var(--white); min-width: 0; position: relative; z-index: 10; }
.left-panel { border-right: 1px solid var(--line); }
.right-panel { border-left: 1px solid var(--line); }
.panel-tabs { height: 48px; display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); padding: 0 7px; }
.panel-tab { background: transparent; color: var(--muted); font-size: 10px; font-weight: 750; position: relative; }
.panel-tab::after { content: ""; position: absolute; left: 9px; right: 9px; bottom: -1px; height: 2px; background: transparent; }
.panel-tab.active { color: var(--ink); }
.panel-tab.active::after { background: var(--ink); }
.panel-content { height: calc(100% - 48px); overflow-y: auto; padding: 16px; }
.panel-section { margin-bottom: 25px; }
.panel-section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel-section h3 { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; margin: 0; color: var(--muted); }
.panel-section p.hint { color: var(--muted); font-size: 11px; line-height: 1.5; margin: 7px 0 13px; }

.block-library { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.library-block {
  min-height: 75px; border: 1px solid var(--soft-line); border-radius: 10px; background: #fafbf7;
  padding: 12px 9px; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between;
  text-align: left;
}
.library-block:hover { border-color: #afb3a6; box-shadow: 0 4px 16px rgba(19, 21, 16, .06); transform: translateY(-1px); }
.library-icon { font-size: 17px; line-height: 1; color: #52574c; }
.library-block strong { font-size: 11px; }
.library-block small { font-size: 9px; color: var(--muted); }
.drag-hint { border: 1px dashed #c9ccc1; border-radius: 9px; padding: 10px; font-size: 10px; color: var(--muted); text-align: center; margin-top: 12px; }

.page-list { display: flex; flex-direction: column; gap: 7px; }
.page-item { display: flex; gap: 5px; }
.page-select {
  flex: 1; min-width: 0; height: 42px; padding: 0 11px; display: flex; align-items: center; justify-content: space-between;
  border-radius: 8px; border: 1px solid var(--soft-line); background: var(--white); text-align: left;
}
.page-select:hover { border-color: #bdc0b6; }
.page-select.active { color: var(--accent-dark); background: #f3ffda; border-color: #c2e77a; }
.page-select span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 700; }
.page-select small { color: var(--muted); font-size: 9px; }
.page-menu { width: 38px; border: 1px solid var(--soft-line); border-radius: 8px; background: var(--white); }
.wide-btn { width: 100%; margin-top: 9px; }

.theme-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.theme-card { border: 1px solid var(--soft-line); border-radius: 9px; background: white; overflow: hidden; padding: 0; text-align: left; }
.theme-card:hover, .theme-card.active { border-color: #8f9587; box-shadow: 0 0 0 1px #8f9587; }
.theme-swatches { height: 35px; display: grid; grid-template-columns: 2fr 1fr 1fr; }
.theme-card strong { display: block; padding: 8px; font-size: 10px; }
.field { margin-bottom: 13px; }
.field label, .toggle-row > label { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; color: #464a42; font-size: 10px; font-weight: 750; }
.field label span { color: var(--muted); font-weight: 500; }
.field input, .field textarea, .field select {
  width: 100%; border: 1px solid var(--line); border-radius: 7px; background: var(--white); padding: 9px 10px;
  font-size: 12px; color: var(--ink); outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: #757b6e; box-shadow: 0 0 0 3px rgba(107, 118, 91, .1); }
.field textarea { min-height: 76px; resize: vertical; line-height: 1.45; }
.field input[type="color"] { height: 38px; padding: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.field-divider { height: 1px; background: var(--soft-line); margin: 18px 0; }
.danger-btn { width: 100%; border: 1px solid #efc4be; background: #fff7f5; color: var(--danger); height: 36px; border-radius: 8px; font-size: 11px; font-weight: 700; }
.danger-btn:hover { background: #fff0ed; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; margin: 11px 0; }
.toggle-row > label { margin: 0; display: block; }
.toggle { width: 38px; height: 22px; border-radius: 99px; background: #d7d9d1; padding: 3px; }
.toggle::after { content: ""; display: block; width: 16px; height: 16px; background: white; border-radius: 50%; transition: .16s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle.active { background: #252920; }
.toggle.active::after { transform: translateX(16px); }

.stage { min-width: 0; min-height: 0; height: 100%; overflow: hidden; display: grid; grid-template-rows: 48px minmax(0, 1fr); background: #e7e8e2; }
.stage-toolbar {
  height: 48px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 18px;
  background: #f4f4ef; border-bottom: 1px solid #d8dad1;
}
.page-crumb { display: flex; align-items: baseline; gap: 8px; }
.page-crumb span { font-size: 11px; font-weight: 750; }
.page-crumb small, .zoom-label { color: var(--muted); font-size: 9px; }
.zoom-label { justify-self: end; }
.device-switcher { background: #e6e7e0; padding: 3px; border-radius: 7px; display: flex; }
.device-btn { height: 26px; padding: 0 10px; border-radius: 5px; background: transparent; font-size: 9px; font-weight: 700; color: var(--muted); }
.device-btn.active { background: var(--white); color: var(--ink); box-shadow: 0 1px 4px rgba(20,22,18,.09); }
.canvas-scroller {
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  overflow-y: scroll;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  padding: 28px;
  display: block;
}
.canvas-frame { width: 100%; min-height: 100%; margin: 0 auto; background: white; box-shadow: 0 4px 24px rgba(19, 22, 15, .11); transition: width .25s ease; }
.canvas-frame.tablet { width: 768px; min-width: 768px; }
.canvas-frame.mobile { width: 390px; min-width: 390px; }
.site-canvas { min-height: calc(100vh - 173px); background: var(--site-bg, white); font-family: var(--site-font, sans-serif); color: var(--site-text, #181818); }

.canvas-block { position: relative; outline: 0 solid transparent; transition: outline .1s; }
.canvas-block:hover { outline: 2px solid rgba(40, 48, 33, .27); outline-offset: -2px; }
.canvas-block.selected { outline: 2px solid #647b24; outline-offset: -2px; }
.canvas-block.dragging { opacity: .3; }
.canvas-block.drop-before::before, .canvas-block.drop-after::after { content: ""; position: absolute; left: 8px; right: 8px; z-index: 20; height: 3px; background: #7da700; border-radius: 4px; }
.canvas-block.drop-before::before { top: -2px; }
.canvas-block.drop-after::after { bottom: -2px; }
.block-tools { position: absolute; z-index: 30; top: 7px; right: 7px; display: none; gap: 4px; }
.canvas-block:hover .block-tools, .canvas-block.selected .block-tools { display: flex; }
.block-tool { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 6px; background: #171914; color: white; font-size: 11px; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.empty-canvas { min-height: 430px; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 40px; }
.empty-canvas div { border: 1px dashed #c9ccc1; padding: 45px 55px; border-radius: 16px; }
.empty-canvas span { font-size: 30px; }
.empty-canvas h3 { color: var(--ink); margin: 13px 0 5px; }
.empty-canvas p { font-size: 12px; max-width: 260px; line-height: 1.5; }

.sf-container { width: min(1120px, 88%); margin: 0 auto; }
.sf-nav { padding: 19px 0; background: var(--site-surface); }
.sf-nav .sf-container { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.sf-logo { font-weight: 850; letter-spacing: -.04em; font-size: 19px; }
.sf-nav-links { display: flex; gap: 20px; align-items: center; }
.sf-nav-links a { color: inherit; text-decoration: none; font-size: 13px; }
.sf-button { display: inline-flex; align-items: center; justify-content: center; padding: 11px 17px; background: var(--site-accent); color: var(--site-accent-text); border-radius: var(--site-radius); text-decoration: none; font-size: 13px; font-weight: 750; }
.sf-hero { padding: clamp(65px, 10vw, 130px) 0; background: var(--site-bg); }
.sf-hero.center { text-align: center; }
.sf-hero.center .sf-hero-copy { margin: 0 auto; }
.sf-hero-copy { max-width: 760px; }
.sf-kicker { color: var(--site-accent); font-size: 12px; font-weight: 850; text-transform: uppercase; letter-spacing: .15em; }
.sf-hero h1 { font-size: clamp(42px, 7vw, 88px); line-height: .97; letter-spacing: -.055em; margin: 18px 0 22px; }
.sf-hero p { font-size: clamp(16px, 2vw, 21px); line-height: 1.55; opacity: .72; margin: 0 0 28px; max-width: 680px; }
.sf-hero.center p { margin-left: auto; margin-right: auto; }
.sf-section { padding: clamp(54px, 8vw, 95px) 0; background: var(--site-bg); }
.sf-section.alt { background: var(--site-surface); }
.sf-section-heading { max-width: 670px; margin-bottom: 38px; }
.sf-section-heading.center { margin-left: auto; margin-right: auto; text-align: center; }
.sf-section h2 { font-size: clamp(31px, 4.5vw, 54px); line-height: 1.05; letter-spacing: -.04em; margin: 0 0 14px; }
.sf-section-heading p, .sf-rich-text p { line-height: 1.7; opacity: .72; }
.sf-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.sf-card { background: var(--site-bg); padding: 28px; border-radius: var(--site-radius); border: 1px solid color-mix(in srgb, var(--site-text) 12%, transparent); }
.sf-card-number { font-size: 12px; font-weight: 800; color: var(--site-accent); }
.sf-card h3 { font-size: 20px; margin: 28px 0 9px; }
.sf-card p { font-size: 14px; line-height: 1.6; opacity: .68; margin: 0; }
.sf-rich-text { max-width: 760px; }
.sf-rich-text.center { text-align: center; margin: 0 auto; }
.sf-rich-text h2 { margin-bottom: 20px; }
.sf-cta { padding: clamp(50px, 7vw, 80px) 0; background: var(--site-accent); color: var(--site-accent-text); }
.sf-cta .sf-container { display: flex; justify-content: space-between; align-items: center; gap: 30px; }
.sf-cta h2 { font-size: clamp(29px, 4vw, 48px); margin: 0 0 8px; letter-spacing: -.04em; }
.sf-cta p { margin: 0; opacity: .72; }
.sf-cta .sf-button { background: var(--site-accent-text); color: var(--site-accent); }
.sf-gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.sf-gallery-item { aspect-ratio: 4/3; border-radius: var(--site-radius); overflow: hidden; background: var(--site-surface); }
.sf-gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sf-gallery-placeholder { width: 100%; height: 100%; display: grid; place-items: center; font-size: 11px; opacity: .45; background: linear-gradient(135deg, var(--site-surface), var(--site-bg)); }
.sf-contact { display: grid; grid-template-columns: 1fr 1fr; gap: 50px; align-items: start; }
.sf-contact-form { display: grid; gap: 11px; }
.sf-contact-form input, .sf-contact-form textarea { width: 100%; padding: 13px; border-radius: calc(var(--site-radius) * .7); border: 1px solid color-mix(in srgb, var(--site-text) 18%, transparent); background: var(--site-bg); color: inherit; }
.sf-contact-form textarea { min-height: 100px; resize: vertical; }
.sf-footer { padding: 30px 0; background: var(--site-text); color: var(--site-bg); }
.sf-footer .sf-container { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.sf-footer small { opacity: .62; }

.inspector-heading { height: 70px; padding: 14px 15px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.inspector-heading small { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .1em; }
.inspector-heading h2 { font-size: 14px; margin: 4px 0 0; }
.inspector-content { height: calc(100% - 70px); overflow-y: auto; padding: 16px; }
.empty-inspector { height: 70%; display: grid; place-content: center; text-align: center; color: var(--muted); }
.empty-inspector span { font-size: 28px; }
.empty-inspector p { font-size: 11px; line-height: 1.55; max-width: 180px; }
.inspector-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 17px; }
.inspector-actions button { height: 34px; border: 1px solid var(--line); background: var(--white); border-radius: 7px; font-size: 10px; font-weight: 700; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(10, 11, 9, .66); display: none; align-items: center; justify-content: center; padding: 28px; backdrop-filter: blur(7px); }
.modal-backdrop.open { display: flex; }
.modal { width: min(960px, 96vw); max-height: 92vh; overflow: auto; border-radius: 18px; background: var(--paper); box-shadow: 0 30px 90px rgba(0,0,0,.35); }
.start-modal { padding: 37px; }
.start-copy { max-width: 600px; }
.eyebrow { color: #6e7467; font-size: 9px; font-weight: 850; letter-spacing: .17em; }
.start-copy h1 { font-size: clamp(35px, 5vw, 62px); line-height: 1; letter-spacing: -.055em; margin: 12px 0 13px; }
.start-copy p { color: var(--muted); line-height: 1.6; font-size: 13px; }
.template-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; margin: 27px 0 25px; }
.template-card { border: 1px solid var(--line); border-radius: 12px; background: white; padding: 0; overflow: hidden; text-align: left; }
.template-card:hover { transform: translateY(-3px); border-color: #9da293; box-shadow: var(--shadow); }
.template-preview { height: 150px; padding: 13px; background: #eceee6; }
.mini-browser { height: 100%; background: white; border-radius: 4px; overflow: hidden; box-shadow: 0 7px 20px rgba(0,0,0,.1); }
.mini-bar { height: 13px; background: #f5f5f0; border-bottom: 1px solid #eee; }
.mini-content { padding: 13px; }
.mini-line { height: 5px; background: #24261f; border-radius: 9px; margin-bottom: 7px; }
.mini-line.short { width: 44%; }
.mini-line.light { background: #d6d8cf; width: 72%; }
.mini-button { width: 29%; height: 13px; background: #b8f236; border-radius: 2px; margin-top: 13px; }
.template-info { padding: 13px; }
.template-info strong { display: block; font-size: 12px; }
.template-info small { display: block; color: var(--muted); font-size: 10px; margin-top: 4px; line-height: 1.4; }
.modal-footer { border-top: 1px solid var(--line); padding: 16px 0 0; display: flex; justify-content: flex-end; align-items: center; gap: 15px; }
.modal-footer.split { justify-content: space-between; }
.modal-footer p { color: var(--muted); font-size: 10px; margin-right: auto; }
.file-actions { display: flex; gap: 7px; }

.code-modal { width: min(1120px, 97vw); padding: 24px; }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 17px; }
.modal-header h2 { margin: 7px 0 0; font-size: 25px; letter-spacing: -.035em; }
.code-layout { height: 52vh; display: grid; grid-template-columns: 180px 1fr; border: 1px solid #30322e; overflow: hidden; border-radius: 10px; background: #151714; }
.code-files { border-right: 1px solid #30322e; padding: 9px; overflow-y: auto; }
.code-file { width: 100%; height: 33px; background: transparent; color: #aeb3a8; border-radius: 6px; padding: 0 9px; text-align: left; font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.code-file:hover, .code-file.active { background: #292c27; color: #d8ff7d; }
.code-editor-wrap { position: relative; min-width: 0; }
#codeOutput { width: 100%; height: 100%; resize: none; border: 0; outline: 0; background: #151714; color: #dae0d4; padding: 18px; font: 11px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre; overflow: auto; }
.copy-btn { position: absolute; right: 12px; top: 12px; background: #30342e; color: #d8ff7d; }
.custom-css-wrap { margin-top: 13px; }
.custom-css-wrap label { display: flex; justify-content: space-between; font-size: 10px; font-weight: 800; margin-bottom: 6px; }
.custom-css-wrap label span { color: var(--muted); font-weight: 500; }
#customCss { width: 100%; height: 82px; resize: vertical; border: 1px solid var(--line); background: white; border-radius: 8px; padding: 11px; font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }

.preview-backdrop { padding: 14px; }
.preview-shell { width: 100%; height: 100%; background: white; border-radius: 13px; overflow: hidden; display: flex; flex-direction: column; }
.preview-bar { height: 49px; flex: none; display: flex; align-items: center; gap: 16px; padding: 0 13px 0 18px; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 800; }
.preview-pages { flex: 1; display: flex; gap: 6px; justify-content: center; }
.preview-page-btn { border-radius: 6px; padding: 6px 9px; background: #f1f2ed; font-size: 9px; }
.preview-page-btn.active { background: #1b1d19; color: white; }
#previewFrame { flex: 1; width: 100%; border: 0; background: white; }
.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: #181a16; color: white; border-radius: 9px; padding: 11px 14px; font-size: 11px; box-shadow: 0 8px 28px rgba(0,0,0,.22); animation: toast-in .2s ease; }
@keyframes toast-in { from { transform: translateY(7px); opacity: 0; } }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 230px minmax(390px, 1fr) 260px; }
  .topbar { grid-template-columns: 230px 1fr auto; }
  .brand small, .save-status { display: none; }
  .quiet-btn { padding: 0 10px; }
}

@media (max-width: 820px) {
  .workspace { grid-template-columns: 210px 1fr; }
  .right-panel { display: none; }
  .topbar { grid-template-columns: 190px 1fr auto; }
  .top-actions .icon-btn, #previewBtn, #codeBtn { display: none; }
  .project-name { width: 180px; }
  .template-grid { grid-template-columns: 1fr; }
}

.canvas-frame.mobile .sf-nav-links { display: none; }
.canvas-frame.mobile .sf-grid, .canvas-frame.mobile .sf-gallery, .canvas-frame.mobile .sf-contact { grid-template-columns: 1fr; }
.canvas-frame.mobile .sf-cta .sf-container, .canvas-frame.mobile .sf-footer .sf-container { flex-direction: column; align-items: flex-start; }
.canvas-frame.mobile .sf-hero h1 { font-size: 44px; }
.canvas-frame.tablet .sf-grid { grid-template-columns: repeat(2, 1fr); }
.canvas-frame.tablet .sf-grid .sf-card:last-child { grid-column: 1 / -1; }
