body>header {
  padding-top: 0;
}

.shake {
  display: inline-block;
}

#dark-mode-icon {
  fill: var(--pico-color);
}

.is-between,
.is-center,
.is-right,
.is-left {
  display: flex;
  align-items: center;
}

.is-between {
  justify-content: space-between;
}

.is-center {
  justify-content: center;
}

.is-right {
  justify-content: flex-end;
}

.is-left {
  justify-content: flex-start;
}

.nowrap {
  white-space: nowrap;
}

/* Filter form with grid - 2 columns: search 50%, rest auto-fit */
.filter-form {
  display: grid;
  grid-template-columns: 2fr auto auto;
  align-items: baseline;
  gap: var(--pico-spacing);
}

.filter-form>label,
.filter-form>button {
  margin-bottom: 0;
}

@media (max-width: 768px) {
  .filter-form {
    grid-template-columns: 1fr;
  }
}

.mb2 {
  margin-bottom: 2rem;
}

.mt2 {
  margin-top: 2rem;
}

/* Ensure SVGs inside buttons don't block click events */
button svg,
a svg {
  pointer-events: none;
}

/* Tags - small status indicators */
.tag {
  padding: 0.5em;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--pico-border-radius);
  white-space: nowrap;
  vertical-align: middle;
}

.tag-success {
  background-color: var(--color-success);
  color: #fff;
}

.tag-error {
  background-color: var(--color-error);
  color: #fff;
}

.tag-warning {
  background-color: var(--color-warning);
  color: #000;
}

.tag-info {
  background-color: var(--color-info);
  color: #fff;
}

.tag-primary {
  background-color: var(--color-primary);
  color: var(--pico-primary-inverse);
}

/* Outline variants */
.tag-outline {
  background-color: transparent;
  border: 1px solid currentColor;
}

.tag-outline.tag-success {
  color: var(--color-success);
}

.tag-outline.tag-error {
  color: var(--color-error);
}

.tag-outline.tag-warning {
  color: var(--color-warning);
}

.tag-outline.tag-info {
  color: var(--color-info);
}

.tag-outline.tag-primary {
  color: var(--color-primary);
}

/* Generic actions column alignment for any table */
.table-actions th:last-child,
.table-actions td:last-child {
  text-align: right;
}

/* Vertically center all cells in table-actions rows */
.table-actions th,
.table-actions td {
  vertical-align: middle;
}

/* Space buttons/links without needing a flex wrapper */
.table-actions td:last-child .button+.button,
.table-actions td:last-child a.button+.button,
.table-actions td:last-child .button+a.button,
.table-actions td:last-child a.button+a.button {
  margin-left: 0.5rem;
}

.table-actions td:last-child {
  white-space: nowrap;
}

footer {
  border-top: 1px solid var(--pico-form-element-border-color);
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  [data-slot] {
    transition: none !important;
  }
}

:where(a:not([role=button])):is([aria-current]:not([aria-current=false]), :hover, :active, :focus),
[role=link]:is([aria-current]:not([aria-current=false]), :hover, :active, :focus) {
  text-decoration: underline;
}

.small {
  padding: 0.25rem 0.45rem;
}

.capitalize {
  text-transform: capitalize;
}

.row {
  display: flex;
  flex-flow: row wrap;
  justify-content: flex-start;
  align-items: baseline;
  margin-left: calc(var(--grid-gutter)/-2);
  margin-right: calc(var(--grid-gutter)/-2)
}

.row.reverse {
  flex-direction: row-reverse
}

.col {
  flex: 1
}

.col,
[class*=" col-"],
[class^=col-] {
  margin: 0 calc(var(--grid-gutter)/2) calc(var(--grid-gutter)/2)
}

.col-1 {
  flex: 0 0 calc(8.33333% - var(--grid-gutter));
  max-width: calc(8.33333% - var(--grid-gutter))
}

.col-2 {
  flex: 0 0 calc(16.66667% - var(--grid-gutter));
  max-width: calc(16.66667% - var(--grid-gutter))
}

.col-3 {
  flex: 0 0 calc(25% - var(--grid-gutter));
  max-width: calc(25% - var(--grid-gutter))
}

.col-4 {
  flex: 0 0 calc(33.33333% - var(--grid-gutter));
  max-width: calc(33.33333% - var(--grid-gutter))
}

.col-5 {
  flex: 0 0 calc(41.66667% - var(--grid-gutter));
  max-width: calc(41.66667% - var(--grid-gutter))
}

.col-6 {
  flex: 0 0 calc(50% - var(--grid-gutter));
  max-width: calc(50% - var(--grid-gutter))
}

.col-7 {
  flex: 0 0 calc(58.33333% - var(--grid-gutter));
  max-width: calc(58.33333% - var(--grid-gutter))
}

.col-8 {
  flex: 0 0 calc(66.66667% - var(--grid-gutter));
  max-width: calc(66.66667% - var(--grid-gutter))
}

.col-9 {
  flex: 0 0 calc(75% - var(--grid-gutter));
  max-width: calc(75% - var(--grid-gutter))
}

.col-10 {
  flex: 0 0 calc(83.33333% - var(--grid-gutter));
  max-width: calc(83.33333% - var(--grid-gutter))
}

.col-11 {
  flex: 0 0 calc(91.66667% - var(--grid-gutter));
  max-width: calc(91.66667% - var(--grid-gutter))
}

.col-12 {
  flex: 0 0 calc(100% - var(--grid-gutter));
  max-width: calc(100% - var(--grid-gutter))
}

@media screen and (max-width:599px) {
  .container {
    width: 100%
  }

  .col,
  [class*=col-],
  [class^=col-] {
    flex: 0 1 100%;
    max-width: 100%
  }
}

@media screen and (min-width:900px) {
  .col-1-md {
    flex: 0 0 calc(8.33333% - var(--grid-gutter));
    max-width: calc(8.33333% - var(--grid-gutter))
  }

  .col-2-md {
    flex: 0 0 calc(16.66667% - var(--grid-gutter));
    max-width: calc(16.66667% - var(--grid-gutter))
  }

  .col-3-md {
    flex: 0 0 calc(25% - var(--grid-gutter));
    max-width: calc(25% - var(--grid-gutter))
  }

  .col-4-md {
    flex: 0 0 calc(33.33333% - var(--grid-gutter));
    max-width: calc(33.33333% - var(--grid-gutter))
  }

  .col-5-md {
    flex: 0 0 calc(41.66667% - var(--grid-gutter));
    max-width: calc(41.66667% - var(--grid-gutter))
  }

  .col-6-md {
    flex: 0 0 calc(50% - var(--grid-gutter));
    max-width: calc(50% - var(--grid-gutter))
  }

  .col-7-md {
    flex: 0 0 calc(58.33333% - var(--grid-gutter));
    max-width: calc(58.33333% - var(--grid-gutter))
  }

  .col-8-md {
    flex: 0 0 calc(66.66667% - var(--grid-gutter));
    max-width: calc(66.66667% - var(--grid-gutter))
  }

  .col-9-md {
    flex: 0 0 calc(75% - var(--grid-gutter));
    max-width: calc(75% - var(--grid-gutter))
  }

  .col-10-md {
    flex: 0 0 calc(83.33333% - var(--grid-gutter));
    max-width: calc(83.33333% - var(--grid-gutter))
  }

  .col-11-md {
    flex: 0 0 calc(91.66667% - var(--grid-gutter));
    max-width: calc(91.66667% - var(--grid-gutter))
  }

  .col-12-md {
    flex: 0 0 calc(100% - var(--grid-gutter));
    max-width: calc(100% - var(--grid-gutter))
  }
}

@media screen and (min-width:1200px) {
  .col-1-lg {
    flex: 0 0 calc(8.33333% - var(--grid-gutter));
    max-width: calc(8.33333% - var(--grid-gutter))
  }

  .col-2-lg {
    flex: 0 0 calc(16.66667% - var(--grid-gutter));
    max-width: calc(16.66667% - var(--grid-gutter))
  }

  .col-3-lg {
    flex: 0 0 calc(25% - var(--grid-gutter));
    max-width: calc(25% - var(--grid-gutter))
  }

  .col-4-lg {
    flex: 0 0 calc(33.33333% - var(--grid-gutter));
    max-width: calc(33.33333% - var(--grid-gutter))
  }

  .col-5-lg {
    flex: 0 0 calc(41.66667% - var(--grid-gutter));
    max-width: calc(41.66667% - var(--grid-gutter))
  }

  .col-6-lg {
    flex: 0 0 calc(50% - var(--grid-gutter));
    max-width: calc(50% - var(--grid-gutter))
  }

  .col-7-lg {
    flex: 0 0 calc(58.33333% - var(--grid-gutter));
    max-width: calc(58.33333% - var(--grid-gutter))
  }

  .col-8-lg {
    flex: 0 0 calc(66.66667% - var(--grid-gutter));
    max-width: calc(66.66667% - var(--grid-gutter))
  }

  .col-9-lg {
    flex: 0 0 calc(75% - var(--grid-gutter));
    max-width: calc(75% - var(--grid-gutter))
  }

  .col-10-lg {
    flex: 0 0 calc(83.33333% - var(--grid-gutter));
    max-width: calc(83.33333% - var(--grid-gutter))
  }

  .col-11-lg {
    flex: 0 0 calc(91.66667% - var(--grid-gutter));
    max-width: calc(91.66667% - var(--grid-gutter))
  }

  .col-12-lg {
    flex: 0 0 calc(100% - var(--grid-gutter));
    max-width: calc(100% - var(--grid-gutter))
  }
}

/* Fullscreen dialog modifier */
dialog.fullscreen,
dialog.fullscreen > article {
  width: 100%;
  max-width: 98%;
  height: auto;
  max-height: 95%;
  border-radius: var(--pico-border-radius);
}

/* Large dialog - useful for complex forms */
dialog.large > article {
  max-width: 900px;
}

dialog.xlarge > article {
  max-width: 1200px;
}

dialog footer {
  padding-top: 1rem;
}

dialog button[type=submit] {
  width: auto;
}

/* Toast notifications */
#toast-root {
  position: fixed;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  pointer-events: none;
}

#toast-root.bottom-right {
  bottom: 0;
  right: 0;
  align-items: flex-end;
}

#toast-root.bottom-left {
  bottom: 0;
  left: 0;
  align-items: flex-start;
}

#toast-root.top-right {
  top: 0;
  right: 0;
  align-items: flex-end;
}

#toast-root.top-left {
  top: 0;
  left: 0;
  align-items: flex-start;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--pico-border-radius);
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-muted-border-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  pointer-events: auto;
  opacity: 0;
  transform: translateX(100%);
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 400px;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast-msg {
  flex: 1;
  font-size: 0.9rem;
}

.toast button {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0;
  margin: 0;
  width: auto;
  line-height: 1;
  opacity: 0.8;
}

.toast button:hover {
  opacity: 1;
}

.toast.success {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #fff;
}

.toast.success button {
  color: rgba(255, 255, 255, 0.7);
}

.toast.success button:hover {
  color: #fff;
}

.toast.error {
  background: var(--color-error);
  border-color: var(--color-error);
  color: #fff;
}

.toast.error button {
  color: rgba(255, 255, 255, 0.7);
}

.toast.error button:hover {
  color: #fff;
}

.toast.warning {
  background: var(--color-warning);
  border-color: var(--color-warning);
  color: #000;
}

.toast.warning button {
  color: rgba(0, 0, 0, 0.6);
}

.toast.warning button:hover {
  color: #000;
}

.toast.info {
  background: var(--color-info);
  border-color: var(--color-info);
  color: #fff;
}

.toast.info button {
  color: rgba(255, 255, 255, 0.7);
}

.toast.info button:hover {
  color: #fff;
}

/* ═══════════════════════════════════════════════════════════════════════
   CMS Editor
   ═══════════════════════════════════════════════════════════════════════ */

/* Layout: sidebar + canvas */
.editor-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1rem;
  min-height: 60vh;
}

@media (max-width: 768px) {
  .editor-layout {
    grid-template-columns: 1fr;
  }
  .editor-sidebar {
    order: 1;
  }
  .editor-canvas {
    order: 0;
  }
}

/* Sidebar */
.editor-sidebar {
  border: 1px solid var(--pico-form-element-border-color);
  border-radius: var(--pico-border-radius);
  padding: 0.75rem;
  max-height: 80vh;
  overflow-y: auto;
  position: sticky;
  top: 1rem;
}

.editor-sidebar h4 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.editor-sidebar details {
  margin-bottom: 0.5rem;
  border: none;
  padding: 0;
}

.editor-sidebar summary {
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0;
  user-select: none;
}

.component-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0.25rem 0;
}

.component-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: var(--pico-border-radius);
  cursor: grab;
  font-size: 0.85rem;
  transition: background 0.15s;
  user-select: none;
}

.component-item:hover {
  background: var(--pico-primary-focus);
}

.component-item:active {
  cursor: grabbing;
}

.component-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.component-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Template buttons */
.template-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0.25rem 0;
}

.template-btn {
  width: 100%;
  text-align: left;
  margin: 0;
}

/* Canvas — WYSIWYG page preview */
.editor-canvas {
  border: 1px solid var(--pico-form-element-border-color);
  border-radius: var(--pico-border-radius);
  padding: 0;
  min-height: 300px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  transition: border-color 0.2s, box-shadow 0.2s;

  /* Theme variables scoped to canvas */
  --primary: #3b82f6;
  --secondary: #1e40af;
  --text: #1f2937;
  --text-muted: #6b7280;
  --bg: #ffffff;
  --bg-alt: #f9fafb;
  --border: #e5e7eb;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  line-height: 1.6;
  color: var(--text);
}

.editor-canvas.is-drag-target {
  border-color: var(--pico-primary);
  box-shadow: 0 0 0 2px var(--pico-primary-focus);
}

/* Empty state */
.editor-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  text-align: center;
  transition: background 0.15s;
  padding: 2rem;
}

.editor-empty.drag-over {
  background: var(--pico-primary-focus);
}

/* Block — seamless WYSIWYG */
.editor-block {
  position: relative;
  margin-bottom: 0;
  background: transparent;
  transition: opacity 0.15s;
}

.editor-block:hover {
  outline: 2px solid var(--pico-primary);
  outline-offset: -2px;
  z-index: 5;
}

.editor-block.is-dragging {
  opacity: 0.4;
}

.editor-block.drag-over {
  outline: 2px dashed var(--pico-primary);
  outline-offset: -2px;
}

.editor-block.is-editing {
  outline: 2px solid var(--pico-primary);
  outline-offset: -2px;
  z-index: 5;
}

/* Hover toolbar overlay */
.editor-block-toolbar {
  display: none;
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 10;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--pico-border-radius);
  background: var(--pico-card-background-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  font-size: 0.8rem;
}

.editor-block:hover .editor-block-toolbar,
.editor-block.is-editing .editor-block-toolbar {
  display: flex;
}

.editor-block-handle {
  cursor: grab;
  font-size: 1rem;
  line-height: 1;
  color: var(--pico-muted-color);
  user-select: none;
}

.editor-block-handle:active {
  cursor: grabbing;
}

.editor-block-actions {
  margin-left: auto;
  display: flex;
  gap: 2px;
}

.editor-block-actions button {
  margin: 0;
  padding: 0.15rem 0.3rem;
  font-size: 0.75rem;
  line-height: 1;
  border: none;
}

/* Live render area */
.editor-block-live {
  /* Content renders naturally */
}

.editor-block-live .placeholder {
  color: var(--text-muted);
  font-style: italic;
}

/* Inline editor form */
.editor-inline-form {
  padding: 1rem;
  background: var(--pico-card-background-color);
}

.editor-inline-form label {
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.editor-inline-form input,
.editor-inline-form textarea,
.editor-inline-form select {
  font-size: 0.85rem;
}

.editor-inline-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--pico-form-element-border-color);
}

/* Tail drop zone */
.editor-drop-tail {
  padding: 1rem;
  text-align: center;
  border: 2px dashed transparent;
  transition: border-color 0.15s, background 0.15s;
}

.editor-drop-tail.drag-over {
  border-color: var(--pico-primary);
  background: var(--pico-primary-focus);
}

/* ─── Theme block styles scoped to editor canvas ─── */
.editor-canvas .container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.editor-canvas .btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-weight: 500;
  text-decoration: none;
  cursor: default;
  border: none;
}

.editor-canvas .btn-primary {
  background: var(--primary);
  color: white;
}

.editor-canvas section {
  padding: 4rem 0;
}

.editor-canvas .editor-block:nth-child(even) section {
  background: var(--bg-alt);
}

/* Hero */
.editor-canvas .block-hero {
  min-height: 50vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background-size: cover;
  background-position: center;
  position: relative;
}

.editor-canvas .block-hero.has-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}

.editor-canvas .block-hero .content {
  position: relative;
  z-index: 1;
}

.editor-canvas .block-hero.has-bg .content {
  color: white;
}

.editor-canvas .block-hero h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.editor-canvas .block-hero p {
  font-size: 1.15rem;
  margin-bottom: 2rem;
  opacity: 0.9;
}

/* Text */
.editor-canvas .block-text .container {
  max-width: 800px;
}

.editor-canvas .block-text h2 {
  margin-bottom: 1rem;
}

.editor-canvas .block-text .text-body {
  color: var(--text-muted);
}

/* Image */
.editor-canvas .block-image {
  text-align: center;
}

.editor-canvas .block-image img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.editor-canvas .block-image figcaption {
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Gallery */
.editor-canvas .gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.editor-canvas .gallery-grid img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: var(--radius);
}

/* CTA */
.editor-canvas .block-cta {
  text-align: center;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
}

.editor-canvas .block-cta h2 { margin-bottom: 1rem; }
.editor-canvas .block-cta p { margin-bottom: 2rem; opacity: 0.9; }
.editor-canvas .block-cta .btn-primary { background: white; color: var(--primary); }

/* Features */
.editor-canvas .features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.editor-canvas .feature {
  text-align: center;
  padding: 2rem;
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.editor-canvas .feature-icon {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: var(--primary);
}

.editor-canvas .feature h3 { margin-bottom: 0.5rem; }

/* Testimonials */
.editor-canvas .testimonials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.editor-canvas .testimonial {
  padding: 2rem;
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.editor-canvas .testimonial .quote { font-style: italic; margin-bottom: 1rem; }
.editor-canvas .testimonial .author { font-weight: 600; }
.editor-canvas .testimonial .company { color: var(--text-muted); font-size: 0.875rem; }

/* Contact */
.editor-canvas .block-contact form { max-width: 500px; margin: 2rem auto 0; }
.editor-canvas .block-contact label { display: block; margin-bottom: 1rem; }
.editor-canvas .block-contact label span { display: block; margin-bottom: 0.25rem; font-weight: 500; }
.editor-canvas .block-contact input,
.editor-canvas .block-contact textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.editor-canvas .block-contact textarea { min-height: 100px; resize: vertical; }

/* Video */
.editor-canvas .video-wrapper {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
}

.editor-canvas .video-wrapper iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: none;
  border-radius: var(--radius);
}

/* Map */
.editor-canvas .block-map iframe {
  width: 100%;
  height: 400px;
  border: none;
  border-radius: var(--radius);
}

/* Header block */
.editor-canvas .site-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
}

.editor-canvas .site-header nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.editor-canvas .site-header .logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
}

.editor-canvas .nav-links {
  display: flex;
  gap: 2rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.editor-canvas .nav-links a {
  color: var(--text);
  text-decoration: none;
}

/* Footer block */
.editor-canvas .site-footer {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  text-align: center;
  color: var(--text-muted);
}