.widgets-shell {
  display: grid;
  gap: 16px;
}

.widgets-panel {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.widgets-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #e2e8f0;
}

.widgets-panel-title {
  font-size: 15px;
  font-weight: 700;
}

.widgets-muted {
  color: #64748b;
  font-size: 12px;
}

.widgets-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 8px 12px;
  background: #fff;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.widgets-btn:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.widgets-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

.widgets-btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.widgets-btn-danger {
  color: #b91c1c;
  border-color: #fecaca;
}

.widgets-btn-danger:hover {
  background: #fef2f2;
  border-color: #fca5a5;
}

.widgets-input,
.widgets-select {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  background: #fff;
}

.widgets-label {
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.widgets-textarea {
  resize: vertical;
  min-height: 88px;
}

.widgets-format-row {
  display: flex;
  gap: 8px;
}

.widgets-btn.widgets-format-toggle[aria-pressed="true"],
html.dark .widgets-btn.widgets-format-toggle[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
  box-shadow: inset 0 0 0 1px currentColor;
}

.widgets-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.widgets-empty {
  padding: 28px 16px;
  text-align: center;
  color: #64748b;
  font-size: 13px;
}

.widgets-list {
  display: grid;
}

.widgets-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
}

.widgets-row:last-child {
  border-bottom: 0;
}

.widgets-row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.widgets-name {
  font-weight: 700;
  font-size: 14px;
}

/* ---------- Editor ---------- */

.widgets-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
}

.widgets-editor-main {
  min-width: 0;
}

.widgets-toolbar {
  display: grid;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
}

.widgets-toolbar-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.widgets-toolbar .widgets-name-field {
  width: 400px;
  max-width: 100%;
  flex: 0 1 400px;
}

.widgets-toolbar-actions,
.widgets-tool-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.widgets-toolbar .widgets-input,
.widgets-toolbar .widgets-btn {
  height: 36px;
  box-sizing: border-box;
}

.widgets-toolbar .widgets-btn {
  white-space: nowrap;
}

.widgets-toolbar-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--border, #e2e8f0);
  padding-top: 12px;
}

.widgets-tool-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.widgets-tool-buttons .widgets-btn {
  padding: 8px;
}

.widgets-tool-label {
  color: var(--muted, #64748b);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.widgets-arrange-group {
  border-left: 1px solid var(--border, #e2e8f0);
  padding-left: 12px;
}

.widgets-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.widgets-toolbar .widgets-toolbar-save,
html.dark .widgets-toolbar .widgets-toolbar-save {
  background: var(--text, #172033);
  border-color: var(--text, #172033);
  color: var(--surface, #ffffff);
}

.widgets-toolbar .widgets-toolbar-save:hover {
  opacity: 0.9;
}

.widgets-deploy-row[hidden] {
  display: none;
}

@media (max-width: 600px) {
  .widgets-toolbar-top,
  .widgets-tool-group {
    align-items: stretch;
    flex-direction: column;
  }
  .widgets-toolbar .widgets-name-field {
    width: 100%;
    flex: auto;
  }
  .widgets-toolbar-actions {
    justify-content: flex-end;
  }
  .widgets-tool-group {
    width: 100%;
  }
  .widgets-tool-buttons {
    flex-wrap: wrap;
  }
  .widgets-arrange-group {
    border-left: 0;
    padding-left: 0;
  }
}

.widgets-stage-wrap {
  padding: 16px;
  background: #0f172a;
}

.widgets-stage-container {
  width: 100%;
  aspect-ratio: 1920 / 302;
  background: #111;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.widgets-props-panel {
  padding: 14px 16px;
  display: grid;
  gap: 12px;
  align-content: start;
}

.widgets-props-empty {
  color: #64748b;
  font-size: 13px;
  text-align: center;
  padding: 24px 8px;
}

.widgets-geom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.widgets-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.widgets-color-row input[type="color"] {
  width: 36px;
  height: 30px;
  padding: 0;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
}

.widgets-slideshow-list {
  display: grid;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.widgets-slideshow-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
}

.widgets-slideshow-item img {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
  flex: 0 0 auto;
}

.widgets-slideshow-item span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.widgets-deploy-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #e2e8f0;
}

/* ---------- Image picker modal ---------- */

.widgets-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.widgets-modal {
  background: #fff;
  border-radius: 10px;
  width: min(640px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.widgets-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #e2e8f0;
}

.widgets-modal-body {
  padding: 16px;
  overflow-y: auto;
}

.widgets-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}

.widgets-image-tile {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: #f8fafc;
  text-align: center;
  transition: border-color 0.15s;
}

.widgets-image-tile:hover {
  border-color: var(--accent);
}

.widgets-image-tile img {
  width: 100%;
  height: 72px;
  object-fit: cover;
  display: block;
}

.widgets-image-tile span {
  display: block;
  font-size: 11px;
  padding: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .widgets-editor {
    grid-template-columns: 1fr;
  }

  .widgets-panel-head {
    flex-wrap: wrap;
  }
}
