:root {
  --ink: #171717;
  --muted: #63635f;
  --paper: #f7f4ef;
  --panel: #fffefa;
  --line: #d8d1c7;
  --accent: #1f6f61;
  --accent-dark: #15584d;
  --danger: #a93625;
  --shadow: 0 18px 48px rgba(36, 31, 25, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.site-header {
  position: fixed;
  z-index: 10;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 72px;
  padding: 14px clamp(18px, 4vw, 54px);
  color: #fff;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.52), rgba(0, 0, 0, 0));
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.logo-frame {
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(14px);
}

.logo-frame img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.logo-frame.has-image img {
  display: block;
}

.logo-frame.has-image .logo-fallback {
  display: none;
}

.logo-fallback {
  font-weight: 800;
  font-size: 1.1rem;
}

.brand-name {
  overflow: hidden;
  max-width: min(52vw, 520px);
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  font-weight: 800;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.94rem;
  font-weight: 700;
}

.site-nav a {
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.16);
}

.portfolio {
  min-height: 100vh;
}

.portfolio-block {
  position: relative;
  display: grid;
  min-height: 100vh;
  padding: clamp(96px, 12vh, 150px) clamp(20px, 7vw, 96px) clamp(38px, 8vh, 90px);
  color: #fff;
  background-color: var(--block-bg, #2c6e67);
  background-image:
    linear-gradient(90deg, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0.18)),
    var(--block-image, none);
  background-position: center;
  background-size: cover;
}

.portfolio-block:nth-child(even) .block-content {
  justify-self: end;
}

.portfolio-block.has-addon {
  grid-template-columns: minmax(280px, 0.85fr) minmax(340px, 1.15fr);
  align-items: end;
  gap: clamp(22px, 5vw, 72px);
}

.portfolio-block.has-addon:nth-child(even) .block-content {
  justify-self: start;
}

.block-content {
  min-width: 0;
  align-self: end;
  width: min(760px, 100%);
}

.portfolio-block h2 {
  overflow: hidden;
  max-width: 100%;
  margin: 0;
  font-size: var(--block-heading-size, 6rem);
  line-height: 1.2;
  letter-spacing: 0;
  text-overflow: clip;
  white-space: nowrap;
}

.portfolio-block p:last-child {
  max-width: 66ch;
  margin: 28px 0 0;
  font-size: clamp(1.02rem, 2vw, 1.2rem);
  line-height: 1.72;
}

.block-addon {
  align-self: center;
  justify-self: stretch;
  overflow: hidden;
  min-height: min(62vh, 620px);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(16px);
}

.gallery-canvas {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: clamp(8px, 1.4vw, 16px);
  padding: clamp(10px, 2vw, 22px);
}

.gallery-canvas.align-left {
  justify-self: start;
  width: min(760px, 100%);
}

.gallery-canvas.align-center {
  justify-self: center;
  width: min(820px, 100%);
}

.gallery-canvas.align-right {
  justify-self: end;
  width: min(760px, 100%);
}

.gallery-canvas img {
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: 8px;
  object-fit: cover;
}

.gallery-canvas img:nth-child(1) {
  grid-column: 1 / 5;
  grid-row: 1 / 5;
}

.gallery-canvas img:nth-child(2) {
  grid-column: 5 / 7;
  grid-row: 1 / 4;
}

.gallery-canvas img:nth-child(3) {
  grid-column: 3 / 7;
  grid-row: 4 / 7;
}

.gallery-canvas img:nth-child(4) {
  grid-column: 1 / 3;
  grid-row: 5 / 7;
}

.gallery-canvas img:nth-child(5) {
  grid-column: 1 / 3;
  grid-row: 3 / 5;
}

.map-canvas {
  min-height: min(58vh, 560px);
}

.map-canvas iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-height: min(58vh, 560px);
  border: 0;
  filter: saturate(0.9) contrast(1.04);
}

.addon-empty {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: inherit;
  place-items: center;
  color: rgba(255, 255, 255, 0.84);
  font-size: clamp(1.2rem, 3vw, 2rem);
  font-weight: 850;
  text-align: center;
}

.empty-state {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 90px 24px;
  text-align: center;
  color: #fff;
  background: #385a54;
}

.empty-state div {
  max-width: 620px;
}

.empty-state h2 {
  margin: 0 0 12px;
  font-size: clamp(2.4rem, 9vw, 5rem);
  line-height: 1;
}

.empty-state p {
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 1.08rem;
  line-height: 1.6;
}

.backstage-page {
  min-height: 100vh;
}

.form-error {
  min-height: 1.4em;
  margin: 0;
  color: var(--danger);
  font-weight: 800;
}

.backstage-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.backstage-topbar h1,
.panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.backstage-topbar h1 {
  font-size: clamp(1.8rem, 4vw, 3.4rem);
}

.backstage-shell {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 18px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.panel,
.block-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  align-self: start;
  padding: 18px;
}

.panel-heading,
.block-editor-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.block-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.panel-heading {
  margin-bottom: 18px;
}

.panel-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.stacked-form,
.block-editor-fields,
.block-list {
  display: grid;
  gap: 16px;
}

.insert-block-row {
  display: grid;
  place-items: center;
  min-height: 28px;
}

.insert-block-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  color: var(--accent);
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(31, 111, 97, 0.18);
  cursor: pointer;
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1;
}

.insert-block-button:hover {
  color: #fff;
  background: var(--accent);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

input[type="text"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
}

input[type="text"],
select {
  height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 150px;
  resize: vertical;
  padding: 12px;
  line-height: 1.55;
}

input[type="file"] {
  width: 100%;
  min-width: 0;
}

input[type="color"] {
  width: 72px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: #fff;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 850;
}

.button {
  padding: 0 16px;
  color: #fff;
  background: var(--accent);
}

.button:hover {
  background: var(--accent-dark);
}

.button-secondary {
  color: var(--ink);
  border-color: var(--line);
  background: #fff;
}

.button-secondary:hover {
  background: #f0ebe3;
}

.icon-button {
  width: 42px;
  color: var(--ink);
  border-color: var(--line);
  background: #fff;
  font-size: 1.3rem;
}

.icon-button:hover {
  background: #f0ebe3;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.icon-button.danger {
  color: var(--danger);
}

.logo-preview-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.logo-frame-large {
  width: 78px;
  height: 78px;
  color: #fff;
  border-color: var(--line);
  background: var(--accent);
}

.block-editor {
  display: grid;
  grid-template-columns: minmax(180px, 32%) minmax(0, 1fr);
  overflow: hidden;
}

.block-editor-preview {
  min-height: 100%;
  background-color: var(--preview-bg, #2c6e67);
  background-image:
    linear-gradient(180deg, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.5)),
    var(--preview-image, none);
  background-position: center;
  background-size: cover;
}

.block-editor-fields {
  padding: 16px;
}

.block-editor-bar strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 16px;
}

.type-fields {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f4ed;
}

.type-fields[hidden] {
  display: none;
}

.gallery-thumbs {
  display: grid;
  grid-template-columns: repeat(5, minmax(42px, 1fr));
  gap: 8px;
  min-height: 54px;
  align-items: center;
}

.gallery-thumb {
  position: relative;
  min-width: 0;
}

.gallery-thumb img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  object-fit: cover;
}

.thumb-remove {
  position: absolute;
  top: -7px;
  right: -7px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: var(--danger);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
}

.thumb-remove:hover {
  background: #7e281c;
}

.gallery-thumbs span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 820px) {
  .site-header {
    min-height: 64px;
    padding: 12px 16px;
  }

  .site-nav a:first-child {
    display: none;
  }

  .backstage-topbar,
  .backstage-shell {
    display: grid;
    grid-template-columns: 1fr;
  }

  .backstage-topbar {
    padding: 22px 16px;
  }

  .block-editor {
    grid-template-columns: 1fr;
  }

  .portfolio-block.has-addon {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .block-addon {
    min-height: 42vh;
  }

  .block-editor-preview {
    min-height: 170px;
  }

  .field-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .brand-name {
    max-width: 46vw;
  }

  .portfolio-block p:last-child {
    font-size: 1rem;
  }
}
