:root {
  --paper: #f3f6f3;
  --surface: #fff;
  --ink: #1b2d26;
  --muted: #53675d;
  --line: #dce6de;
  --green: #186348;
  --green-soft: #e7f2eb;
  --danger: #a43c36;
  --studio-forest: #132f27;
  --studio-nav-text: #d2e3d9;
  --studio-nav-muted: #adc5b8;
  --studio-nav-line: #ffffff26;
  --studio-well: #f5f8f5;
  --studio-border-control: #aebfb3;
  --studio-focus: #238361;
  --studio-radius: 12px;
  --studio-gutter: clamp(20px, 2.4vw, 38px);
  --sidebar: 220px;
  --shadow: 0 1px 2px #1535260f;
  accent-color: var(--green);
}

h1, h2, h3, h4 { text-wrap: balance; }
p { text-wrap: pretty; }
:where(button, a, summary, input, select, textarea):focus-visible {
  outline: 2px solid var(--studio-focus);
  outline-offset: 3px;
}

:where(.version-node strong, .content-table, .history-table, .job-row, .lead-table, .business-metrics, #revision-badge) {
  font-variant-numeric: tabular-nums;
}

.button {
  min-height: 42px;
  padding-inline: 15px;
  border-color: var(--studio-border-control);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 650;
}

.button:hover { background: var(--studio-well); }
.button.primary {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}
.button.primary:hover { background: #104d37; border-color: #104d37; }
.button.danger { color: var(--danger); border-color: #debab5; }
.button.small { min-height: 36px; }
.button:disabled {
  opacity: 1;
  color: #637469;
  background: #edf2ee;
  border-color: #dce5dd;
}
.button-preview { color: #15543d; border-color: #a7cbb7; background: #edf6ef; }
.button-preview:hover { background: #deeee4; }

.heading-actions:has(#save-button:not(:disabled):not([hidden])) #save-button {
  color: #fff;
  border-color: var(--green);
  background: var(--green);
}
.heading-actions:has(#save-button:not(:disabled):not([hidden])) #save-button:hover { background: #104d37; }
.heading-actions:has(#save-button:not(:disabled):not([hidden])) #publish-button:not(:disabled) {
  color: #15543d;
  border-color: #a7cbb7;
  background: var(--surface);
}
.heading-actions:has(#save-button:not(:disabled):not([hidden])) #publish-button:not(:disabled):hover { background: var(--green-soft); }

/* App shell */
.sidebar {
  color: var(--studio-nav-text);
  background: var(--studio-forest);
  border-right: 1px solid #0f291f;
  padding: max(23px, env(safe-area-inset-top)) 13px max(16px, env(safe-area-inset-bottom));
}

.sidebar-brand {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  margin: 0 0 16px;
  padding: 12px 12px 23px;
  border-bottom: 1px solid var(--studio-nav-line);
}
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand img { width: 128px; filter: brightness(0) invert(1); }
.sidebar-brand > span { color: #c4dace; font-size: 12px; }

.sidebar nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 3px;
  scrollbar-width: thin;
  scrollbar-color: #59746a transparent;
}
.sidebar-editor-links, .sidebar-tools-links, .sidebar-tool-group { display: grid; gap: 3px; }
.sidebar-editor-links {
  position: sticky;
  top: 0;
  z-index: 1;
  padding-bottom: 4px;
  background: var(--studio-forest);
}

.sidebar .sidebar-label {
  margin: 4px 8px 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--studio-nav-muted);
}

.sidebar nav button {
  width: 100%;
  min-height: 40px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  gap: 9px;
  color: var(--studio-nav-text);
  font-size: 13px;
  font-weight: 550;
}

.sidebar nav button:hover, .sidebar-tools summary:hover { color: #fff; background: #ffffff0d; }
.sidebar nav button.active {
  color: #fff;
  background: #255442;
  border-color: #3b6855;
  font-weight: 700;
}

.sidebar .nav-icon {
  display: grid;
  place-items: center;
  inline-size: 23px;
  block-size: 23px;
  flex: 0 0 23px;
  border-radius: 5px;
  color: #c2d8cc;
  background: #ffffff0e;
  font-size: 14px;
}
.sidebar button.active .nav-icon { color: #fff; background: #ffffff20; }
.sidebar nav button:disabled { color: #99b2a5; cursor: wait; }
.sidebar :where(a, button, summary):focus-visible { outline: 2px solid #a9e1be; outline-offset: 1px; }
.sidebar-tools summary:focus-visible { outline-color: #a9e1be; }

.sidebar-tools {
  margin-top: 14px;
  padding-top: 9px;
  border-color: var(--studio-nav-line);
}
.sidebar-tools summary { color: var(--studio-nav-text); border-radius: 7px; }
.sidebar-tools-links { gap: 12px; margin-top: 8px; }
.sidebar-tool-group:not(:has(button:not([hidden]))) { display: none; }

.sidebar-bottom {
  flex: 0 0 auto;
  margin: 12px 3px 0;
  padding: 13px 1px 0;
  border-top: 1px solid var(--studio-nav-line);
}
.local-tag { color: var(--studio-nav-text); }
.local-tag i { background: #8bc9a7; }
.sidebar-bottom button { min-height: 32px; padding-inline: 5px; color: var(--studio-nav-text); }
.sidebar-bottom button:hover { color: #fff; text-decoration: underline; }

.topbar {
  min-height: 62px;
  height: auto;
  padding: 8px var(--studio-gutter);
  gap: 12px;
  background: var(--surface);
}
.breadcrumbs { flex: 1 1 auto; min-width: 0; gap: 9px; font-size: 13px; }
.breadcrumbs > span { color: var(--muted); }
.breadcrumbs > b { color: #91a59a; }
.breadcrumbs > strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.topbar-right { flex: 0 0 auto; gap: 9px; }
.topbar-right > #dirty-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 3px 8px;
  border-radius: 5px;
  color: #215b45;
  background: var(--green-soft);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}
.save-state::before { content: ""; inline-size: 6px; block-size: 6px; border-radius: 50%; background: currentColor; }
#dirty-label[data-state="unsaved"] { color: #774714; background: #f9edda; }
.topbar-right > #revision-badge {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  background: var(--studio-well);
  font-size: 11px;
}
#live-link {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  min-height: 36px;
  padding-inline: 8px;
  border-radius: 6px;
  white-space: nowrap;
  font-weight: 650;
}
#live-link:hover { background: var(--green-soft); text-decoration: none; }

.workspace { padding: 24px var(--studio-gutter) 28px; }
.page-heading {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  margin-bottom: 23px;
}
.page-heading > div:first-child { flex: 1 1 260px; min-width: 0; }
.page-heading h1 {
  margin: 0 0 6px;
  font-size: clamp(25px, 2.35vw, 33px);
  line-height: 1.22;
  font-weight: 700;
}
.page-heading > div > p:last-child { font-size: 13px; color: var(--muted); line-height: 1.7; }
.heading-actions { gap: 7px; }

.notice {
  color: #24563e;
  background: #eef7ef;
  border-color: #c7e0cf;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
}
.notice.error { color: #8e392d; background: #ffefeb; border-color: #e9c4ba; }
.preview-ready { margin: 0 0 13px; font-size: 12px; }
.preview-ready .text-button { font-weight: 650; }
.preview-ready .text-button::after { content: "↗"; margin-inline-start: 5px; }

.admin-footer {
  padding: 13px var(--studio-gutter);
  color: var(--muted);
  background: var(--surface);
  font-size: 11px;
}

/* Login and shared surfaces */
.auth-shell { padding: 22px; background: #eaf0eb; }
.auth-card {
  width: min(100%, 432px);
  overflow: hidden;
  padding: 0;
  border-radius: 15px;
  border: 1px solid #cddacf;
  box-shadow: 0 8px 28px #19372a12;
}
.auth-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 27px;
  color: var(--studio-nav-text);
  background: var(--studio-forest);
  font-size: 12px;
}
.auth-logo { width: 125px; margin: 0; filter: brightness(0) invert(1); }
.auth-main { padding: 28px 29px 30px; }
.auth-card h1 { margin-bottom: 9px; font-weight: 720; }
.auth-card p { color: var(--muted); line-height: 1.75; }
.auth-card form { margin-top: 21px; }
.auth-card label { margin-bottom: 16px; font-weight: 650; }
.auth-card input { margin-top: 6px; border: 1px solid var(--studio-border-control); border-radius: 7px; }
.auth-card .help { margin: 3px 0 15px; }
.auth-card .help:empty { display: none; }
.auth-card .form-error { margin: 8px 0 0; color: var(--danger); }
.auth-card .form-error:empty { display: none; }

.panel, .release-board, .editor-panel, .table-wrap, .page-field, .business-metrics, .media-item {
  border-color: var(--line);
  border-radius: var(--studio-radius);
  box-shadow: var(--shadow);
}

.panel-heading, .release-board-heading {
  padding: 15px 19px;
  background: var(--surface);
  border-color: var(--line);
}
.panel-heading h2, .release-board-heading h2, .section-title {
  font-size: 15px;
  font-weight: 720;
  color: var(--ink);
}
.release-board-heading > span {
  padding: 4px 8px;
  border-radius: 5px;
  background: var(--green-soft);
  color: #245a44;
  font-weight: 650;
}
.version-line {
  align-items: stretch;
  grid-template-columns: minmax(0, 1fr) 42px minmax(0, 1fr);
  padding: 16px 19px;
}
.version-connector { align-self: center; background: #a7b9ac; }
.version-connector::after { border-color: #a7b9ac; }
.version-node {
  padding: 17px 18px;
  background: var(--studio-well);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.version-node.live { background: #eaf3ed; border-color: #d3e6d8; }
.version-node .label, .version-node p, .job-row p, .info-note, .subtle,
.content-table td small, .history-table th, .content-table th { color: var(--muted); }
.version-node strong { margin-block: 8px 7px; font-size: 36px; font-weight: 700; }
.version-node.live strong { color: #16583f; }
.release-board-footer {
  padding: 11px 19px;
  border-color: var(--line);
  background: var(--surface);
}
.overview-columns { gap: 16px; margin-top: 16px; }
.overview-columns > .panel { overflow: hidden; }
.list-row { padding-inline: 19px; min-height: 55px; }
.list-row .text-button { color: var(--green); }
.list-row .text-button:hover { text-decoration: underline; }
.editor-toolbar { margin-bottom: 14px; }
.form-field input:not([type="checkbox"]), .form-field select, .form-field textarea,
.search-field input, .select-field, .page-field textarea, .raw-editor {
  border-color: var(--studio-border-control);
  border-radius: 7px;
}
.content-table th, .history-table th, .lead-table th { background: #f1f6f1; }
.content-table :is(th,td), .history-table :is(th,td), .lead-table :is(th,td) { border-color: var(--line); }
.media-item strong, .page-field > label, .media-item small { color: var(--muted); }
.empty-state, .inline-loading { color: var(--muted); }
.dialog-heading, .dialog-tools { padding: 16px 20px; }
.dialog-heading h2 { font-size: 19px; }
.file-button:focus-within { outline: 2px solid var(--studio-focus); outline-offset: 3px; }

/* Website editing */
.visual-workspace {
  --studio-stage-height: clamp(435px, calc(100dvh - 290px), 900px);
  --studio-inspector-bar: 51px;
}
.visual-workspace .page-heading {
  margin-bottom: 15px;
  border-bottom: 1px solid var(--line);
  padding: 4px 0 13px;
}

.website-editor-bar {
  padding: 9px 12px;
  margin-bottom: 11px;
  border-radius: 9px;
  box-shadow: var(--shadow);
}
.website-language select, .website-other-pages select {
  min-height: 38px;
  border-color: var(--studio-border-control);
  color: var(--ink);
  background: var(--surface);
}
.website-menu-actions { gap: 12px; }
.website-menu-dropdown { border-radius: var(--studio-radius); box-shadow: 0 12px 30px #162f2224; }
.website-menu-column h2 { line-height: 1.4; }
.website-other-pages { margin-top: 0; }
.website-page-heading { margin: 16px 0 10px; gap: 7px 16px; }
.website-page-heading h2 { font-size: 20px; font-weight: 720; }

.website-empty {
  min-height: 230px;
  display: grid;
  align-content: center;
  gap: 8px;
  margin-top: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--studio-radius);
  background: var(--surface);
  text-align: center;
}
.website-empty h2 { margin: 0; font-size: 18px; }
.website-empty p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }

.visual-editor {
  grid-template-columns: minmax(0, 1fr) clamp(270px, 24vw, 330px);
  column-gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--studio-radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: clip;
}

.visual-preview, .visual-inspector {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.visual-preview { border-inline-end: 1px solid var(--line); }
.visual-preview-bar, .visual-inspector-bar {
  min-height: var(--studio-inspector-bar);
  border-color: var(--line);
  background: var(--surface);
}
.visual-preview-bar { padding: 6px 10px 6px 13px; }
.visual-preview-name strong { font-size: 13px; }
.visual-preview-name > span { color: var(--muted); }
.visual-device {
  background: #eaf1eb;
  border-radius: 7px;
  border: 1px solid #e1ebe2;
}
.visual-device button {
  min-height: 31px;
  font-weight: 650;
  color: #455e50;
}
.visual-device button[aria-pressed="true"] { color: #175e43; }

.visual-frame-stage { height: var(--studio-stage-height); background: #dee9e1; }
.visual-frame-shell { box-shadow: 0 0 12px #193f2e1f; }
.visual-inspector {
  height: calc(var(--studio-stage-height) + var(--studio-inspector-bar));
  min-width: 0;
}
.visual-inspector-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  padding: 4px 7px;
}
.visual-inspector-bar button {
  min-height: 35px;
  padding: 4px 2px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #52685b;
  font-size: 12px;
  font-weight: 650;
}
.visual-inspector-bar button:hover { background: var(--studio-well); }
.visual-inspector-bar button[aria-pressed="true"] {
  border-color: #d1e5d7;
  color: #124d37;
  background: var(--green-soft);
}

.visual-inspector-body { padding: 12px 12px 14px; }
.visual-block-order h3, .visual-settings-title h3, .visual-content-title h3,
.design-target-title { color: var(--ink); font-size: 13px; font-weight: 720; }
.visual-block-list { gap: 2px; }
.visual-block-order > .visual-block-list {
  max-height: min(28dvh, 270px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #a0b5a7 transparent;
  padding: 2px 3px;
  margin: 0 -3px;
}
.visual-block-link { min-height: 32px; border-radius: 6px; font-weight: 550; }
.visual-block-link[aria-pressed="true"] {
  border-color: #c9e0d2;
  color: #164d38;
  background: #e8f3ed;
}
.visual-chevron { color: #466b57; }
.visual-fixed-blocks, .visual-field-details { border-top: 1px solid var(--line); }
.visual-layout-settings { margin-top: 9px; padding-top: 9px; }
.visual-template {
  background: #fafcf9;
  border-color: #d9e6db;
  font-weight: 650;
}
.visual-template[aria-pressed="true"] { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.design-group, .visual-content-fields .website-field { border-color: var(--line); background: var(--studio-well); }
.design-field :is(input, select), .design-css-label textarea,
.website-field :is(input, textarea) { border-color: var(--studio-border-control); }
.design-field [aria-invalid="true"], .design-css-label [aria-invalid="true"] { border-color: var(--danger); }

@media (min-width: 821px) {
  .sidebar .sidebar-tool-group button { min-height: 35px; padding-block: 5px; }
}

@media (max-width: 1170px) and (min-width: 991px) {
  :root { --sidebar: 197px; }
  .visual-editor { grid-template-columns: minmax(0, 1fr) 264px; }
}

@media (max-width: 990px) {
  .visual-workspace { --studio-stage-height: clamp(340px, 64dvh, 635px); }
  .visual-editor {
    grid-template-columns: minmax(0, 1fr);
    gap: 11px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }
  .visual-preview, .visual-inspector {
    height: auto;
    border: 1px solid var(--line);
    border-radius: var(--studio-radius);
    overflow: hidden;
  }
  .visual-block-order > .visual-block-list { max-height: 15em; }
}

@media (max-width: 820px) {
  .sidebar {
    width: min(280px, calc(100vw - 46px));
    transform: translateX(-100%);
    visibility: hidden;
    box-shadow: 4px 0 14px #173b251b;
  }
  .sidebar.open { transform: none; visibility: visible; }
  .sidebar.open ~ .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 9;
    border: 0;
    background: #102e2466;
  }
  .app-body { margin-left: 0; }
  .mobile-menu {
    display: grid;
    place-items: center;
    flex: 0 0 44px;
    inline-size: 44px;
    block-size: 44px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--studio-well);
    color: var(--ink);
    font-size: 17px;
  }
}

@media (max-width: 650px) {
  :root { --studio-gutter: 14px; }
  .workspace { padding-top: 17px; }
  .topbar { gap: 8px; min-height: 57px; }
  .topbar-right { gap: 5px; }
  .sidebar nav button, .sidebar-tools summary { min-height: 44px; }
  .page-heading { gap: 10px; margin-bottom: 15px; }
  .page-heading > div:first-child { flex: 1 1 100%; }
  .heading-actions .button { min-height: 42px; }
  .version-line { grid-template-columns: minmax(0, 1fr); gap: 9px; padding: 12px 14px; }
  .version-node { padding: 13px 15px; }
  .version-node strong { font-size: 30px; }
  .version-connector { display: none; }
  .overview-columns { grid-template-columns: minmax(0, 1fr); }
  .website-editor-bar { padding: 8px 10px; }
  .visual-workspace { --studio-stage-height: clamp(328px, 54dvh, 470px); }
  .visual-inspector-bar button { min-height: 42px; }
  .visual-device button, .visual-block-link { min-height: 40px; }
  .auth-brand { padding: 19px 22px; }
  .auth-main { padding: 23px 22px; }
  .dialog-tools { gap: 7px; padding: 10px 13px; }
  .dialog-tools .button { padding-inline: 10px; }
}

@media (max-width: 430px) {
  .topbar-right > #revision-badge { display: none; }
  .topbar-right > #dirty-label { min-height: 25px; padding-inline: 6px; }
  #live-link { padding-inline: 5px; font-size: 11px; }
  .visual-preview-name > span { display: none; }
}
