:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #647084;
  --line: #d9deea;
  --brand: #2563eb;
  --accent: #f59e0b;
  --danger: #dc2626;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  min-height: 38px;
  padding: 0 12px;
  cursor: pointer;
}

button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  min-height: 40px;
  padding: 8px 10px;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-box {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 18px 45px rgba(23, 32, 51, 0.08);
}

.login-box h1,
.topbar h1,
.editor-title h2 {
  margin: 0;
  letter-spacing: 0;
}

.login-box p,
.empty,
.hint {
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 14px;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  background: #111827;
  color: #f9fafb;
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 16px;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.sidebar h1 {
  font-size: 18px;
}

.sidebar button {
  background: #1f2937;
  border-color: #374151;
  color: #f9fafb;
}

.site-list {
  display: grid;
  gap: 8px;
}

.site-row {
  width: 100%;
  text-align: left;
  justify-content: start;
}

.site-row.active {
  background: var(--brand);
  border-color: var(--brand);
}

.content {
  padding: 18px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.topbar,
.panel,
.editor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.topbar {
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

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

.panel,
.editor {
  padding: 16px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
}

.pages-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.page-list {
  display: grid;
  gap: 8px;
  align-content: start;
}

.page-button {
  justify-content: start;
  text-align: left;
}

.page-button.active {
  border-color: var(--brand);
  box-shadow: inset 3px 0 0 var(--brand);
}

.editor-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.blocks {
  display: grid;
  gap: 12px;
}

.block-editor {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcff;
  overflow: hidden;
}

.block-editor.dragging {
  opacity: 0.45;
}

.block-toolbar {
  min-height: 44px;
  padding: 8px;
  display: grid;
  grid-template-columns: 32px minmax(120px, 220px) 38px;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: #f1f4fa;
}

.drag-handle {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  cursor: grab;
}

.icon-button {
  width: 38px;
  padding: 0;
}

.block-fields {
  padding: 12px;
  display: grid;
  gap: 12px;
}

.image-preview {
  width: min(260px, 100%);
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.field-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.image-height-editor {
  display: grid;
  gap: 8px;
}

.resizable-image-frame {
  position: relative;
  width: min(420px, 100%);
  min-height: 120px;
  max-height: 900px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #eef2f8;
}

.resizable-image-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.resize-handle {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.8);
  background: rgba(37, 99, 235, 0.72);
  cursor: ns-resize;
}

.resize-handle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 5px;
  width: 42px;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  transform: translateX(-50%);
}

.layout-editor {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.layout-column-editor {
  min-width: 0;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 10px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.layout-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink);
}

.layout-column-blocks {
  display: grid;
  gap: 10px;
}

.layout-column-blocks .block-toolbar {
  grid-template-columns: 32px minmax(0, 1fr) 38px;
}

.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.error {
  color: var(--danger);
  min-height: 20px;
}

.preview-link {
  color: var(--brand);
  font-weight: 700;
  text-decoration: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(17, 24, 39, 0.52);
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 20px;
  box-shadow: 0 24px 70px rgba(17, 24, 39, 0.24);
}

.modal h2,
.modal p {
  margin: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  .shell,
  .pages-layout,
  .settings-grid,
  .two {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
