/* Siblings' editor chrome. Loaded AFTER the real site.css on the gallery page,
   so anything the grid preview needs from site.css is left untouched; these
   rules only style the editor's own UI (.topbar, .btn, panels, listings). */

:root {
  --ed-accent: #2f6f4f;
  --ed-accent-dark: #275e43;
  --ed-danger: #b3403a;
  --ed-border: #ddd;
  --ed-bg: #f7f6f3;
}

body {
  margin: 0;
  font-family: "Fira Sans", Helvetica, Arial, sans-serif;
  font-size: 16px;
  color: #333;
  background: var(--ed-bg);
}

/* ---- top bar ---- */

.topbar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 10px 22px;
  background: #fff;
  border-bottom: 1px solid var(--ed-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  font-weight: 600;
  color: #222;
  text-decoration: none;
  font-size: 18px;
}

.topnav { display: flex; gap: 16px; }
.topnav a { color: #333; text-decoration: none; padding: 4px 2px; }
.topnav a:hover { text-decoration: underline; }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.whoami { color: #777; font-size: 14px; }
.publish-status { font-size: 14px; color: #555; }
.publish-status a { color: var(--ed-accent); }

/* ---- main column ---- */

.editor-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 22px 80px;
}

h1 { font-size: 26px; margin: 8px 0 10px; }
h2 { font-size: 18px; margin: 22px 0 8px; }
.hint { color: #666; font-size: 14px; margin: 4px 0 14px; }
.quiet { color: #888; font-weight: normal; }
.mono { font-family: Consolas, Menlo, monospace; font-size: 0.92em; }
.error { color: var(--ed-danger); }

/* ---- buttons & inputs ---- */

.btn {
  font: inherit;
  font-size: 14px;
  padding: 6px 14px;
  border: 1px solid var(--ed-border);
  border-radius: 6px;
  background: #fff;
  color: #222;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn:hover { border-color: #aaa; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary, .btn-publish {
  background: var(--ed-accent);
  border-color: var(--ed-accent);
  color: #fff;
}
.btn-primary:hover, .btn-publish:hover { background: var(--ed-accent-dark); border-color: var(--ed-accent-dark); }
.btn-danger { color: var(--ed-danger); border-color: #d8b1af; }
.btn-danger:hover { border-color: var(--ed-danger); }
.btn-small { font-size: 13px; padding: 4px 10px; }
.btn-quiet { border-color: transparent; background: none; color: #777; }
.btn-quiet:hover { color: #222; border-color: transparent; text-decoration: underline; }

input[type="text"], input[type="number"], input[type="password"], select, textarea {
  font: inherit;
  font-size: 15px;
  padding: 6px 8px;
  border: 1px solid var(--ed-border);
  border-radius: 6px;
  background: #fff;
  color: #222;
}
textarea { width: 100%; box-sizing: border-box; font-family: Consolas, Menlo, monospace; font-size: 13px; }
label { display: block; font-size: 14px; color: #555; margin: 10px 0; }
label > input[type="text"], label > input[type="password"] { display: block; width: 100%; box-sizing: border-box; margin-top: 3px; }

.save-area {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}
.save-status { font-size: 14px; }
.save-status.dirty { color: #a06a00; }
.save-status.saved { color: var(--ed-accent); }
.save-status.error { color: var(--ed-danger); font-weight: 500; }

/* ---- login ---- */

.login-main { display: flex; justify-content: center; padding-top: 10vh; }
.login-box {
  background: #fff;
  border: 1px solid var(--ed-border);
  border-radius: 10px;
  padding: 28px 32px 32px;
  width: 320px;
}
.login-box h1 { font-size: 22px; margin-top: 0; }
.login-box .btn { width: 100%; margin-top: 10px; padding: 9px; }

/* ---- dashboard listing ---- */

.listing {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--ed-border);
  border-radius: 8px;
  overflow: hidden;
}
.listing th, .listing td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid #eee;
  font-size: 15px;
}
.listing th { background: #fafafa; font-weight: 600; font-size: 13px; color: #666; }
.listing tr:last-child td { border-bottom: 0; }
.listing .actions { text-align: right; white-space: nowrap; }
.listing .actions .btn { margin-left: 6px; }

/* ---- gallery editor ---- */

.gallery-editor { max-width: 1180px; }
.editor-cols { display: flex; gap: 28px; align-items: flex-start; }
.preview-col { flex: none; }
.panel-col { flex: 1; min-width: 260px; }

/* the preview column is exactly as wide as the published content column
   (790px main minus 2x25px padding), so cqw-based row sizing matches too */
.gallery-wrap { width: 740px; }

.sticky-panel {
  position: sticky;
  top: 64px;
  background: #fff;
  border: 1px solid var(--ed-border);
  border-radius: 10px;
  padding: 16px 18px 18px;
}
.sticky-panel h2 { margin-top: 0; }

/* the two steppers share the panel row and shrink instead of overflowing it */
.spans { display: flex; gap: 14px; }
.spans > label { flex: 1; min-width: 0; }
.stepper { display: flex; align-items: center; gap: 4px; margin-top: 3px; }
.stepper input { flex: 1; width: 100%; min-width: 30px; text-align: center; padding: 6px 2px; }
.stepper .btn { padding: 5px 9px; font-weight: 600; flex: none; }
.panel-close { float: right; font-size: 15px; padding: 2px 6px; }
.row-buttons { display: flex; gap: 8px; margin: 12px 0; }
.gallery-settings { border-top: 1px solid #eee; margin-top: 16px; padding-top: 6px; }
.gallery-settings input { width: 80px; }

/* editor-only affordances on the real .modula-grid cells */
.modula-grid .cell { cursor: grab; position: relative; }
.modula-grid .cell:focus { outline: none; }
.modula-grid .cell.selected {
  outline: 3px solid var(--ed-accent);
  outline-offset: -3px;
}
.modula-grid .cell img { pointer-events: none; }
.cell-badge {
  position: absolute;
  right: 4px;
  bottom: 4px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 4px;
  pointer-events: none;
}
.sortable-ghost { opacity: 0.35; }
.sortable-drag { opacity: 0.9; }

/* corner drag-resize handle */
.modula-grid .cell .resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 20px;
  height: 20px;
  cursor: nwse-resize;
  touch-action: none;
  opacity: 0;
  background:
    linear-gradient(135deg, transparent 55%, rgba(255, 255, 255, 0.95) 55%);
  border-right: 3px solid var(--ed-accent);
  border-bottom: 3px solid var(--ed-accent);
  transition: opacity 0.12s ease;
}
.modula-grid .cell:hover .resize-handle,
.modula-grid .cell.selected .resize-handle { opacity: 1; }
body.resizing { cursor: nwse-resize; user-select: none; }

.upload-area { border-top: 1px solid #eee; margin-top: 16px; padding-top: 6px; }
.upload-area .save-status { display: inline-block; margin-left: 8px; }

/* ---- page editor ---- */

.page-editor .page-form { max-width: 820px; }
.page-title-label input { font-size: 17px; }
.block-list { list-style: none; margin: 0; padding: 0; }
.block-card {
  display: flex;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--ed-border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 8px;
}
.block-body { flex: 1; }
.block-body label { margin: 6px 0; }
.block-type {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
}
.block-image-row { display: flex; gap: 14px; align-items: center; }
.block-image-row label { flex: 1; }
.block-thumb { width: 72px; height: 54px; object-fit: cover; border-radius: 4px; flex: none; }
.two-col { display: flex; gap: 14px; }
.two-col label { flex: 1; }
.drag-handle {
  cursor: grab;
  color: #999;
  font-size: 18px;
  padding: 2px 4px;
  align-self: flex-start;
  user-select: none;
}

/* ---- menu editor ---- */

.menu-form { max-width: 760px; }
.menu-children { list-style: none; margin: 0; padding: 0 0 0 34px; min-height: 8px; }
.menu-top { padding-left: 0; }
.menu-item { margin: 6px 0; }
.menu-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--ed-border);
  border-radius: 8px;
  padding: 6px 10px;
}
.menu-item-row .f-label { flex: 1; min-width: 120px; }
.menu-item-row .f-page { max-width: 260px; }
.menu-item-row .vis-label {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  white-space: nowrap;
}
.menu-item.hidden-item > .menu-item-row { opacity: 0.55; }
