:root {
  --ui-ink: #101519;
  --ui-graphite: #182025;
  --ui-slate: #28343b;
  --ui-line: #dce3e6;
  --ui-muted: #6b777e;
  --ui-paper: #ffffff;
  --ui-canvas: #edf1f3;
  --ui-blue: #6f91a2;
  --ui-blue-dark: #405d6c;
  --ui-focus: #8fb3c5;
  --ui-danger: #a84a4a;
  --topbar-height: 70px;
  --sidebar-width: 262px;
  --inspector-width: 330px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ui-ink);
  background: var(--ui-canvas);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; min-width: 960px; height: 100%; margin: 0; overflow: hidden; }
button, input, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 2px; }

.builder {
  height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(420px, 1fr) var(--inspector-width);
  grid-template-rows: var(--topbar-height) minmax(0, 1fr);
  grid-template-areas:
    "topbar topbar topbar"
    "sidebar workspace inspector";
  background: var(--ui-canvas);
}

.builder-topbar {
  grid-area: topbar;
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: var(--sidebar-width) auto minmax(170px, 1fr) auto auto;
  align-items: center;
  min-width: 0;
  color: #e9eef0;
  background: var(--ui-ink);
  border-bottom: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 8px 24px rgba(11, 16, 19, .12);
}

.builder-brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-right: 1px solid rgba(255,255,255,.1);
}
.builder-brand__mark {
  width: 38px;
  height: 42px;
  display: grid;
  place-items: center;
  clip-path: polygon(50% 0, 91% 17%, 91% 58%, 78% 80%, 50% 100%, 22% 80%, 9% 58%, 9% 17%);
  color: #11171a;
  background: linear-gradient(145deg, #eef3f5, #87959d 48%, #f5f8f9 64%, #728087);
  font: 700 .68rem/1 Georgia, serif;
}
.builder-brand__copy { display: grid; gap: 3px; line-height: 1; }
.builder-brand__copy strong { font: 400 1rem/1 Georgia, serif; letter-spacing: .04em; }
.builder-brand__copy small { color: #89969d; font-size: .64rem; letter-spacing: .08em; text-transform: uppercase; }

.history-tools { display: flex; gap: 6px; padding: 0 13px; }
.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 6px;
  color: #cfd8dc;
  background: rgba(255,255,255,.035);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.icon-button:hover:not(:disabled) { background: rgba(255,255,255,.1); }
.icon-button:disabled { opacity: .3; cursor: default; }

.page-indicator { min-width: 0; display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.page-indicator__label { color: #7f8d94; font-size: .68rem; letter-spacing: .11em; text-transform: uppercase; }
.page-indicator strong { max-width: 270px; overflow: hidden; color: white; font: 400 .92rem/1.2 Georgia, serif; text-overflow: ellipsis; white-space: nowrap; }
.save-state { padding: 5px 8px; border-radius: 999px; color: #9eb2bc; background: rgba(147, 174, 187, .11); font-size: .64rem; letter-spacing: .05em; }
.save-state.is-dirty { color: #eed7ad; background: rgba(214, 170, 93, .13); }

.viewport-switcher { display: flex; padding: 4px; border: 1px solid rgba(255,255,255,.12); border-radius: 8px; background: #0b0f12; }
.viewport-switcher button {
  min-height: 31px;
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  color: #849198;
  background: transparent;
  font-size: .7rem;
  cursor: pointer;
}
.viewport-switcher button.is-active { color: #eff4f6; background: #29343a; }
.viewport-switcher--canvas { display: none; border-color: #d6dee1; background: #edf1f3; }
.viewport-switcher--canvas button { color: #718087; }
.viewport-switcher--canvas button.is-active { color: white; background: #526d7a; }

.topbar-actions { display: flex; align-items: center; gap: 8px; padding: 0 14px; }
.topbar-actions #connect-folder { display: none; }
.demo-notice { max-width: 225px; color: #d7e1e5; font-size: .7rem; line-height: 1.25; text-align: right; }
.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--ui-line);
  border-radius: 6px;
  font-size: .74rem;
  font-weight: 720;
  letter-spacing: .02em;
  cursor: pointer;
}
.button--quiet { color: #334047; background: white; }
.builder-topbar .button--quiet { color: #c8d2d6; background: transparent; border-color: rgba(255,255,255,.16); }
.button--quiet:hover { background: #f3f6f7; }
.builder-topbar .button--quiet:hover { color: white; background: rgba(255,255,255,.08); }
.button--primary { color: white; background: var(--ui-blue-dark); border-color: var(--ui-blue-dark); }
.button--primary:hover { background: #527384; }
.button--wide { width: 100%; }

.builder-sidebar {
  grid-area: sidebar;
  min-height: 0;
  overflow-y: auto;
  color: #d6dee1;
  background: var(--ui-graphite);
  border-right: 1px solid #263137;
}
.sidebar-section { padding: 22px 15px 18px; border-bottom: 1px solid rgba(255,255,255,.075); }
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 4px 12px; }
.sidebar-heading h2 { margin: 0; color: #86959c; font-size: .68rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.sidebar-heading span { color: #66757c; font-size: .7rem; }
.page-list { display: grid; gap: 3px; }
.page-button {
  position: relative;
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  color: #abb7bc;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.page-button::before { content: ""; width: 4px; height: 4px; flex: 0 0 auto; border-radius: 50%; background: #4e5b61; }
.page-button:hover { color: white; background: rgba(255,255,255,.055); }
.page-button.is-active { color: white; background: #2a363d; box-shadow: inset 2px 0 #92adba; }
.page-button.is-dirty::after { content: ""; width: 6px; height: 6px; margin-left: auto; flex: 0 0 auto; border-radius: 50%; background: #d2a75d; }
.page-button__copy { min-width: 0; display: grid; gap: 2px; }
.page-button__copy strong { overflow: hidden; font-size: .76rem; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.page-button__copy small { overflow: hidden; color: #68767d; font-size: .61rem; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-section--blocks { padding-bottom: 22px; }
.block-library { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.block-card {
  min-height: 84px;
  display: grid;
  align-content: space-between;
  justify-items: start;
  gap: 10px;
  padding: 11px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 7px;
  color: #b9c4c8;
  background: #1e282d;
  text-align: left;
  cursor: pointer;
}
.block-card:hover { color: white; border-color: #536872; background: #263239; transform: translateY(-1px); }
.block-card__icon { color: #91aab6; font: 400 .9rem/1 Georgia, serif; }
.block-card > span:last-child { display: grid; gap: 2px; }
.block-card strong { font-size: .7rem; }
.block-card small { color: #69777e; font-size: .58rem; }
.sidebar-tip { margin: 18px 15px 24px; padding: 14px; border-left: 2px solid #708e9d; color: #85939a; background: rgba(255,255,255,.035); }
.sidebar-tip strong { color: #bcc7cb; font-size: .71rem; }
.sidebar-tip p { margin: 7px 0 0; font-size: .66rem; line-height: 1.55; }

.builder-workspace { grid-area: workspace; min-width: 0; min-height: 0; display: grid; grid-template-rows: 44px minmax(0, 1fr); background: var(--ui-canvas); }
.canvas-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 14px; background: #f9fbfb; border-bottom: 1px solid var(--ui-line); }
.canvas-toolbar__selection { min-width: 0; display: flex; align-items: center; gap: 7px; color: #7c888e; font-size: .68rem; }
.canvas-toolbar__selection strong { max-width: 240px; overflow: hidden; color: #344047; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.canvas-toolbar__actions { display: flex; gap: 4px; }
.canvas-toolbar button { min-height: 28px; padding: 0 9px; border: 1px solid transparent; border-radius: 5px; color: #536067; background: transparent; font-size: .67rem; cursor: pointer; }
.canvas-toolbar__actions button:hover:not(:disabled) { border-color: #d5dde0; background: white; }
.canvas-toolbar button:disabled { opacity: .36; cursor: default; }
.canvas-toolbar .danger-action:not(:disabled) { color: var(--ui-danger); }

.canvas-stage { min-width: 0; min-height: 0; overflow: auto; padding: 28px; }
.canvas-scale { position: relative; margin: 0 auto; }
.canvas-device {
  position: relative;
  width: 1200px;
  height: 900px;
  overflow: hidden;
  background: white;
  border: 1px solid #cfd8dc;
  border-radius: 6px;
  box-shadow: 0 18px 54px rgba(32, 45, 52, .16);
  transform-origin: top left;
  transition: width .25s ease, transform .25s ease;
}
.canvas-device iframe { width: 100%; height: 100%; display: block; border: 0; background: white; }
.canvas-loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 11px; color: #536169; background: #f7f9fa; }
.canvas-loading[hidden] { display: none; }
.canvas-loading__mark { color: #708995; font: 400 1.1rem/1 Georgia, serif; letter-spacing: .12em; }
.canvas-loading strong { font-size: .75rem; letter-spacing: .04em; }

.builder-inspector { grid-area: inspector; min-height: 0; overflow-y: auto; background: var(--ui-paper); border-left: 1px solid var(--ui-line); }
.inspector-tabs { position: sticky; top: 0; z-index: 4; display: grid; grid-template-columns: repeat(5, 1fr); background: white; border-bottom: 1px solid var(--ui-line); }
.inspector-tabs button { position: relative; min-height: 45px; border: 0; color: #7a868c; background: white; font-size: .69rem; font-weight: 700; cursor: pointer; }
.inspector-tabs button::after { content: ""; position: absolute; right: 50%; bottom: -1px; left: 50%; height: 2px; background: var(--ui-blue-dark); transition: left .18s ease, right .18s ease; }
.inspector-tabs button[aria-selected="true"] { color: #233038; }
.inspector-tabs button[aria-selected="true"]::after { right: 16px; left: 16px; }
.inspector-panel { padding: 20px; }
.inspector-panel[hidden] { display: none; }
.empty-selection { min-height: 340px; display: grid; align-content: center; justify-items: center; text-align: center; color: #7a878e; }
.empty-selection > span { width: 52px; height: 52px; display: grid; place-items: center; margin-bottom: 17px; border: 1px solid #d9e1e4; border-radius: 50%; color: #7593a1; font-size: 1.3rem; }
.empty-selection strong { color: #344149; font: 400 1.15rem/1.2 Georgia, serif; }
.empty-selection p { max-width: 230px; margin: 10px 0 0; font-size: .73rem; line-height: 1.55; }

.property-form, .page-settings { display: grid; gap: 15px; }
.element-badge { display: flex; align-items: center; gap: 9px; padding-bottom: 14px; border-bottom: 1px solid #e5eaec; }
.element-badge span { padding: 4px 7px; border-radius: 4px; color: white; background: var(--ui-slate); font: 700 .62rem/1 monospace; }
.element-badge small { min-width: 0; overflow: hidden; color: #89959b; font: .65rem/1.3 monospace; text-overflow: ellipsis; white-space: nowrap; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-group { min-width: 0; display: grid; gap: 6px; }
.field-group > span, .field-group > label, .code-editor-label { color: #718087; font-size: .64rem; font-weight: 760; letter-spacing: .07em; text-transform: uppercase; }
.field-group input, .field-group textarea, .field-group select, .code-editor {
  width: 100%;
  border: 1px solid #d8e0e3;
  border-radius: 5px;
  color: #253139;
  background: #f9fbfb;
  font-size: .75rem;
}
.field-group input { height: 38px; padding: 0 10px; }
.field-group select { height: 38px; padding: 0 10px; }
.field-group textarea { min-height: 76px; padding: 9px 10px; resize: vertical; line-height: 1.45; }
.field-group input:focus, .field-group textarea:focus, .code-editor:focus { border-color: #86a7b6; background: white; outline: none; box-shadow: 0 0 0 3px rgba(134, 167, 182, .12); }
.field-group--color input { height: 38px; padding: 4px; cursor: pointer; }
.unit-input { position: relative; }
.unit-input input { padding-right: 31px; }
.unit-input em { position: absolute; top: 50%; right: 9px; color: #8e9aa0; font-size: .65rem; font-style: normal; transform: translateY(-50%); }
.property-divider { position: relative; margin: 5px 0 0; color: #87949a; font-size: .62rem; font-weight: 760; letter-spacing: .09em; text-align: center; text-transform: uppercase; }
.property-divider::before { content: ""; position: absolute; top: 50%; right: 0; left: 0; height: 1px; background: #e4e9eb; }
.property-divider span { position: relative; padding: 0 9px; background: white; }
.alignment-control { margin: 0; padding: 0; border: 0; }
.alignment-control legend { margin-bottom: 6px; color: #718087; font-size: .64rem; font-weight: 760; letter-spacing: .07em; text-transform: uppercase; }
.alignment-control > div { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid #d8e0e3; border-radius: 5px; overflow: hidden; }
.alignment-control button { height: 36px; border: 0; border-right: 1px solid #d8e0e3; color: #69767d; background: #f9fbfb; cursor: pointer; }
.alignment-control button:nth-child(2) { text-align: center; }
.alignment-control button:nth-child(3) { border-right: 0; text-align: right; }
.alignment-control button.is-active { color: white; background: var(--ui-blue-dark); }

.code-scope { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 18px; padding: 3px; border-radius: 6px; background: #eef2f4; }
.code-scope button { height: 34px; border: 0; border-radius: 4px; color: #748087; background: transparent; font-size: .69rem; font-weight: 700; cursor: pointer; }
.code-scope button.is-active { color: #27343b; background: white; box-shadow: 0 2px 8px rgba(34, 48, 55, .09); }
.code-editor-label { display: block; margin-bottom: 7px; }
.code-editor { min-height: calc(100vh - 245px); padding: 12px; resize: none; color: #d8e2e6; background: #141b1f; border-color: #141b1f; font: .68rem/1.55 "Cascadia Code", Consolas, monospace; tab-size: 2; }
.code-editor:focus { color: #ecf2f4; background: #11171a; border-color: #557484; box-shadow: 0 0 0 3px rgba(85, 116, 132, .18); }
.code-help, .panel-copy { color: #7d898f; font-size: .69rem; line-height: 1.55; }
.code-help { margin: 9px 0 14px; }
.panel-copy { margin: 0; }
.site-manager { display: grid; gap: 12px; }
.site-manager h2 { margin: 13px 0 0; padding-top: 14px; border-top: 1px solid #e4e9eb; font: 400 1.15rem/1.2 Georgia, serif; }
.site-manager h2:first-child { margin-top: 0; padding-top: 0; border: 0; }
.common-subheading { margin: 4px 0 0; color: #344149; font-size: .76rem; }
.link-manager { display: grid; gap: 8px; }
.link-manager-row { display: grid; grid-template-columns: minmax(0, 1fr) 28px 28px 28px; gap: 5px; padding: 8px; border: 1px solid #d8e0e3; border-radius: 5px; }
.link-manager-row label { grid-column: 1 / -1; display: grid; gap: 3px; color: #718087; font-size: .63rem; }
.link-manager-row input { width: 100%; min-width: 0; height: 34px; padding: 0 8px; border: 1px solid #d8e0e3; border-radius: 4px; background: white; color: #25333a; font: inherit; }
.link-manager-row button { min-height: 27px; border: 1px solid #d8e0e3; border-radius: 4px; background: #f9fbfb; color: #344149; cursor: pointer; }
.link-manager-row button:first-of-type { grid-column: 2; }
.photo-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 4px; }
.photo-actions button { padding: 8px 6px; border: 1px solid #d8e0e3; border-radius: 4px; background: #f9fbfb; color: #344149; font-size: .68rem; cursor: pointer; }
.photo-actions button:last-child { grid-column: 1 / -1; color: #914b4b; }
.photo-actions button:disabled { opacity: .4; cursor: default; }
.site-check { display: flex; align-items: center; gap: 8px; font-size: .74rem; }
.media-list { display: grid; gap: 8px; }
.media-item { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 7px 9px; padding: 8px; border: 1px solid #d8e0e3; border-radius: 5px; }
.media-item img { width: 38px; height: 38px; object-fit: cover; background: #edf1f3; }
.media-item strong { overflow: hidden; font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.media-item small { color: #7d898f; font-size: .63rem; }
.media-item button { grid-column: 1 / -1; padding: 7px; border: 1px solid #d8e0e3; border-radius: 4px; background: #f9fbfb; font-size: .68rem; }
.validation-results { display: grid; gap: 5px; color: #344149; font-size: .69rem; line-height: 1.45; }
.validation-results p { margin: 0; }
.validation-results .is-error { color: #a84a4a; }

.builder-toast {
  position: fixed;
  z-index: 100;
  left: calc(var(--sidebar-width) + 24px);
  bottom: 22px;
  max-width: 420px;
  padding: 11px 15px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 7px;
  color: white;
  background: #172126;
  box-shadow: 0 15px 40px rgba(13, 19, 22, .25);
  font-size: .74rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity .18s ease, transform .18s ease;
}
.builder-toast.is-visible { opacity: 1; transform: translateY(0); }
.builder-toast.is-error { background: #5f2f31; }

@media (max-width: 1220px) {
  :root { --sidebar-width: 225px; --inspector-width: 300px; }
  .builder-topbar { grid-template-columns: var(--sidebar-width) auto minmax(130px, 1fr) auto; }
  .viewport-switcher--top { display: none; }
  .viewport-switcher--canvas { display: flex; }
  .topbar-actions .button { padding-inline: 10px; }
  .page-indicator__label { display: none; }
}

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