/* =====================================================================
   Smart Invitation Builder — Canva-inspired UI
   ===================================================================== */

/* === FOUNDATIONS === */
.asib-app-root,
.asib-admin-shell {
  color: #1d1d1f;
  font-family: -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern" 1, "liga" 1;
}

.asib-browser,
.asib-admin,
.asib-workspace {
  box-sizing: border-box;
}

.asib-browser {
  display: grid;
  gap: 1.25rem;
}

/* === SURFACE CARDS & PANELS ===
   Clean white with very subtle shadows — no heavy warm gradients.
   ===================================================================== */
.asib-hero,
.asib-section,
.asib-panel,
.asib-banner,
.asib-card,
.asib-toolbar,
.asib-table-shell {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 4px 16px rgba(0, 0, 0, 0.04);
}

.asib-hero,
.asib-section,
.asib-panel,
.asib-card-body,
.asib-toolbar,
.asib-banner,
.asib-font-upload,
.asib-admin-head {
  padding: 1.1rem 1.25rem;
}

/* === TYPOGRAPHY === */
.asib-eyebrow {
  color: #d26e2f;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.asib-title,
.asib-admin-head h1 {
  font-size: clamp(1.75rem, 3vw, 2.8rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0.4rem 0 0.6rem;
  color: #1d1d1f;
}

.asib-subtitle,
.asib-admin-head p {
  color: #6b6b6b;
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0;
  max-width: 56rem;
}

/* === FLEX LAYOUTS === */
.asib-section-head,
.asib-admin-head,
.asib-tabs,
.asib-card-actions,
.asib-inline-pills,
.asib-layer-row,
.asib-stage-top,
.asib-font-upload,
.asib-banner {
  align-items: center;
  display: flex;
  gap: 0.65rem;
  justify-content: space-between;
}

/* === TOOLBAR (top nav bar) === */
.asib-toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  border-radius: 12px;
}

.asib-toolbar-group,
.asib-toolbar-properties,
.asib-toolbar-icon-group {
  align-items: center;
  display: flex;
  gap: 0.35rem;
}

.asib-toolbar-group,
.asib-toolbar-properties {
  flex-wrap: wrap;
}

.asib-toolbar-group:last-child {
  justify-content: flex-end;
}

.asib-toolbar-properties {
  justify-content: center;
  min-width: 0;
}

.asib-toolbar-icon-group {
  gap: 0.15rem;
  flex-wrap: nowrap;
}

/* Subtle divider between icon groups */
.asib-toolbar-icon-group + .asib-toolbar-icon-group {
  padding-left: 0.45rem;
  margin-left: 0.2rem;
  border-left: 1px solid rgba(0, 0, 0, 0.09);
}

.asib-toolbar-pill,
.asib-toolbar-hint {
  color: #6b6b6b;
  font-size: 0.8rem;
}

.asib-toolbar-pill {
  background: #f2f2f2;
  border-radius: 6px;
  color: #1d1d1f;
  display: inline-flex;
  font-size: 0.76rem;
  font-weight: 600;
  max-width: 11rem;
  overflow: hidden;
  padding: 0.28rem 0.6rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* === FORM CONTROLS (selects & number inputs) === */
.asib-toolbar-select,
.asib-toolbar-number {
  appearance: none;
  background: #f5f5f5;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 7px;
  box-sizing: border-box;
  color: inherit;
  font: inherit;
  font-size: 0.84rem;
  height: 2rem;
  padding: 0 0.7rem;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.asib-toolbar-select:focus,
.asib-toolbar-number:focus {
  outline: none;
  border-color: #d26e2f;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(210, 110, 47, 0.12);
}

.asib-toolbar-select {
  max-width: 14rem;
  min-width: 8.5rem;
}

.asib-toolbar-number {
  width: 4.75rem;
}

/* === CARD GRID === */
.asib-card-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.asib-card {
  overflow: hidden;
  transition: box-shadow 220ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 220ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

.asib-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), 0 12px 36px rgba(0, 0, 0, 0.07);
  transform: translateY(-3px);
}

.asib-card h3,
.asib-panel h3,
.asib-section h2 {
  margin: 0 0 0.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.asib-card p,
.asib-helper,
.asib-section-head p {
  color: #6b6b6b;
  font-size: 0.88rem;
  margin: 0;
}

.asib-card-actions {
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding: 0.75rem 1.1rem 1rem;
}

/* === BUTTONS === */
.asib-btn {
  appearance: none;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.6rem 0.95rem;
  transition: transform 120ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
              opacity 120ms ease,
              background 140ms ease,
              box-shadow 140ms ease;
  will-change: transform;
}

.asib-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.asib-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

.asib-btn:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.asib-btn-default {
  background: #1f7a6d;
  color: #fff;
  box-shadow: 0 1px 3px rgba(31, 122, 109, 0.28);
}

.asib-btn-default:hover:not(:disabled) {
  background: #1a6b5f;
  box-shadow: 0 3px 10px rgba(31, 122, 109, 0.36);
}

.asib-btn-accent {
  background: #d26e2f;
  color: #fff;
  box-shadow: 0 1px 3px rgba(210, 110, 47, 0.28);
}

.asib-btn-accent:hover:not(:disabled) {
  background: #be6029;
  box-shadow: 0 3px 10px rgba(210, 110, 47, 0.36);
}

.asib-btn-ghost {
  background: #f2f2f2;
  color: #1d1d1f;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.asib-btn-ghost:hover:not(:disabled) {
  background: #e8e8e8;
  border-color: rgba(0, 0, 0, 0.15);
}

.asib-btn-danger {
  background: #dc2626;
  color: #fff;
  box-shadow: 0 1px 3px rgba(220, 38, 38, 0.28);
}

.asib-btn-danger:hover:not(:disabled) {
  background: #c51f1f;
  box-shadow: 0 3px 10px rgba(220, 38, 38, 0.36);
}

/* === ICON BUTTONS === */
.asib-icon-btn {
  align-items: center;
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #3d3d3d;
  cursor: pointer;
  display: inline-flex;
  height: 2rem;
  justify-content: center;
  padding: 0;
  transition: background 110ms ease,
              border-color 110ms ease,
              color 110ms ease,
              transform 120ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  width: 2rem;
  will-change: transform;
}

.asib-icon-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

.asib-icon-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.95);
  background: rgba(0, 0, 0, 0.1);
}

.asib-icon-btn:disabled {
  cursor: not-allowed;
  opacity: 0.32;
}

/* === STATUS PILLS === */
.asib-pill {
  background: #f0f0f0;
  border-radius: 999px;
  color: #4a4a4a;
  display: inline-flex;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 0.25rem 0.6rem;
}

.asib-pill-success {
  background: #d1fae5;
  color: #065f46;
}

.asib-pill-danger {
  background: #fee2e2;
  color: #991b1b;
}

.asib-pill-info {
  background: #dbeafe;
  color: #1e40af;
}

.asib-pill-accent {
  background: #ffedd5;
  color: #9a3412;
}

/* === TABS === */
.asib-tabs {
  justify-content: flex-start;
  margin: 0.85rem 0;
  gap: 0.3rem;
}

/* === TABLE === */
.asib-table-shell {
  overflow: auto;
  padding: 0;
  border-radius: 10px;
}

.asib-table {
  border-collapse: collapse;
  width: 100%;
}

.asib-table th,
.asib-table td {
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  padding: 0.75rem 1rem;
  text-align: left;
}

.asib-table th {
  background: #f8f8f8;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b6b6b;
}

.asib-table tr:hover td {
  background: #fafafa;
}

.asib-table tr:last-child td {
  border-bottom: none;
}

/* === WORKSPACE LAYOUT === */
.asib-workspace {
  display: grid;
  gap: 0.65rem;
}

.asib-editor-grid {
  align-items: start;
  display: grid;
  gap: 0.65rem;
  grid-template-columns: minmax(148px, 180px) minmax(0, 1fr) minmax(172px, 210px);
}

.asib-side {
  align-content: start;
  display: grid;
  gap: 0.55rem;
}

.asib-panel {
  align-content: start;
  display: grid;
  gap: 0.6rem;
}

.asib-panel-compact {
  gap: 0.38rem;
  padding: 0.7rem 0.85rem;
}

/* === ELEMENT & SHAPE PICKER === */
.asib-element-grid {
  display: grid;
  gap: 0.28rem;
  grid-template-columns: repeat(3, 2.3rem);
  justify-content: flex-start;
}

.asib-shape-picker {
  display: grid;
  gap: 0.28rem;
  grid-template-columns: repeat(3, 2.3rem);
  justify-content: flex-start;
}

/* === FORM FIELDS === */
.asib-field-label,
.asib-field-inline {
  color: #6b6b6b;
  display: block;
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.asib-input,
.asib-textarea,
.asib-upload {
  background: #f8f8f8;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  box-sizing: border-box;
  font: inherit;
  padding: 0.65rem 0.9rem;
  width: 100%;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.asib-input:focus,
.asib-textarea:focus {
  outline: none;
  border-color: #d26e2f;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(210, 110, 47, 0.12);
}

.asib-textarea {
  min-height: 96px;
  resize: vertical;
}

.asib-upload {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
}

.asib-upload-icon {
  align-items: center;
  gap: 0.45rem;
  justify-content: center;
  min-height: 2.4rem;
  padding: 0;
}

.asib-upload-label {
  font-size: 0.78rem;
  font-weight: 600;
}

.asib-upload input {
  display: none;
}

/* === LAYER PANEL === */
.asib-layer-row {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 7px;
  display: grid;
  gap: 0.12rem;
  padding: 0.26rem 0.32rem;
  transition: background 110ms ease, border-color 110ms ease, box-shadow 110ms ease;
}

.asib-layer-row:hover {
  background: #fafafa;
  border-color: rgba(0, 0, 0, 0.13);
}

.asib-layer-row.is-selected {
  background: #fff5f0;
  border-color: #d26e2f;
  box-shadow: 0 0 0 2px rgba(210, 110, 47, 0.12);
}

.asib-layer-list {
  display: grid;
  gap: 0.22rem;
  max-height: min(52vh, 560px);
  overflow: auto;
  padding-right: 0.05rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.14) transparent;
}

.asib-layer-list::-webkit-scrollbar {
  width: 3px;
}

.asib-layer-list::-webkit-scrollbar-track {
  background: transparent;
}

.asib-layer-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.14);
  border-radius: 2px;
}

.asib-panel-layers .asib-layer-list {
  max-height: clamp(280px, calc(100vh - 17rem), 720px);
}

.asib-layer-actions {
  display: flex;
  gap: 0.12rem;
}

.asib-layer-main {
  align-items: center;
  display: flex;
  gap: 0.28rem;
  min-width: 0;
}

.asib-layer-name,
.asib-layer-toggle {
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.asib-layer-name {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  text-align: left;
}

.asib-layer-type {
  color: #b0b0b0;
  display: inline-flex;
  flex: 0 0 auto;
}

.asib-layer-label {
  color: #1d1d1f;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asib-layer-meta {
  color: #9e9e9e;
  font-size: 0.7rem;
  margin-left: 2.2rem;
}

.asib-layer-toggle {
  color: #6b6b6b;
  font-weight: 600;
  transition: color 110ms ease;
}

.asib-layer-toggle:hover {
  color: #1d1d1f;
}

/* =====================================================================
   CANVAS STAGE — Canva-style workspace with dot-grid background
   ===================================================================== */
.asib-canvas-stage {
  align-content: start;
  /* Dot grid like Canva */
  background-color: #f0f0f0;
  background-image: radial-gradient(circle, rgba(0, 0, 0, 0.18) 1px, transparent 1px);
  background-size: 24px 24px;
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 12px;
  contain: layout style;
  display: grid;
  gap: 0.7rem;
  justify-items: center;
  grid-template-rows: auto minmax(0, 1fr);
  height: clamp(400px, calc(100vh - 4.5rem), 100vh);
  overflow: auto;
  padding: 0.75rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.14) transparent;
}

.asib-canvas-stage::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

.asib-canvas-stage::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.14);
  border-radius: 3px;
}

.asib-canvas-stage::-webkit-scrollbar-track {
  background: transparent;
}

/* =====================================================================
   STAGE TOP BAR — frosted-glass floating property bar (like Canva)
   ===================================================================== */
.asib-stage-top {
  align-items: center;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.09), 0 1px 3px rgba(0, 0, 0, 0.06);
  box-sizing: border-box;
  display: grid;
  gap: 0.55rem;
  grid-template-columns: auto minmax(0, 1fr) auto;
  min-width: 0;
  padding: 0.45rem 0.75rem;
  width: 100%;
  transition: box-shadow 200ms ease;
  /* Stick to the top of the canvas-stage scroll container so the
     properties panel stays visible when the user scrolls or zooms the
     canvas. The canvas-stage is the scroll parent (overflow: auto), so
     `position: sticky` anchors here. The high z-index keeps the toolbar
     above the canvas pixels and any selection handles. */
  position: sticky;
  top: 0;
  z-index: 6;
}

.asib-stage-top:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), 0 1px 4px rgba(0, 0, 0, 0.06);
}

.asib-stage-properties {
  align-items: center;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.3rem;
  justify-content: center;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.asib-stage-properties::-webkit-scrollbar {
  display: none;
}

.asib-stage-meta {
  align-items: center;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  justify-content: flex-end;
  min-width: 0;
}

.asib-stage-properties .asib-toolbar-pill {
  margin-right: 0.1rem;
  max-width: 10rem;
}

.asib-stage-properties .asib-toolbar-select,
.asib-stage-properties .asib-toolbar-number {
  border-radius: 6px;
  height: 1.8rem;
}

.asib-stage-properties .asib-toolbar-select {
  flex: 0 0 auto;
  max-width: 12rem;
}

.asib-toolbar-select-font {
  min-width: 10rem;
}

/* === FONT SIZE STEPPER — pill-shaped group like Canva === */
.asib-font-size-stepper {
  align-items: center;
  background: #f2f2f2;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 7px;
  box-sizing: border-box;
  display: inline-flex;
  flex: 0 0 auto;
  height: 2rem;
  overflow: hidden;
}

.asib-font-size-stepper .asib-icon-btn {
  background: transparent;
  border: none;
  border-radius: 0;
  height: 100%;
  width: 1.7rem;
}

.asib-toolbar-number-compact {
  appearance: textfield;
  -moz-appearance: textfield;
  background: transparent;
  border: none;
  border-left: 1px solid rgba(0, 0, 0, 0.1);
  border-right: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 0;
  box-sizing: border-box;
  color: inherit;
  font: inherit;
  font-size: 0.84rem;
  height: 100%;
  padding: 0 0.35rem;
  text-align: center;
  width: 3rem;
}

.asib-toolbar-number-compact::-webkit-outer-spin-button,
.asib-toolbar-number-compact::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.asib-toolbar-number-compact:focus {
  outline: none;
  background: #fff;
}

/* Line height + letter spacing pair. Each control is an icon paired
 * with a compact numeric input, matching the 2rem (32px) height every
 * other toolbar pill uses (icon buttons, font-size stepper, sliders)
 * so the strip lines up vertically. */
.asib-spacing-group {
  gap: 0.3rem;
}

.asib-spacing-control {
  align-items: center;
  background: #f2f2f2;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 7px;
  box-sizing: border-box;
  color: #2d2018;
  display: inline-flex;
  flex: 0 0 auto;
  gap: 0.3rem;
  height: 2rem;
  overflow: hidden;
  padding: 0 0.3rem 0 0.45rem;
}

.asib-spacing-control.is-disabled {
  background: #ececec;
  border-color: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.32);
  cursor: not-allowed;
  opacity: 0.55;
}

/* Dedicated input for the spacing pills. Wider than the font-size
 * stepper input so values like "-150" or "1.16" stay fully visible
 * (the previous 3rem clipped sign + 3 digits). */
.asib-spacing-input {
  appearance: textfield;
  -moz-appearance: textfield;
  background: transparent;
  border: none;
  border-left: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 0;
  box-sizing: border-box;
  color: inherit;
  font: inherit;
  font-size: 0.84rem;
  height: 100%;
  margin-left: 0.1rem;
  min-width: 0;
  padding: 0 0.3rem;
  text-align: center;
  width: 3.6rem;
}

.asib-spacing-input::-webkit-outer-spin-button,
.asib-spacing-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.asib-spacing-input:focus {
  background: #fff;
  outline: none;
}

.asib-spacing-input:disabled {
  color: rgba(0, 0, 0, 0.4);
  cursor: not-allowed;
}

/* === COLOUR GROUP (replaces CMYK) === */
.asib-color-group {
  align-items: center;
  background: #f2f2f2;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.28rem;
  min-width: 0;
  padding: 0.14rem 0.28rem 0.14rem 0.14rem;
}

.asib-recent-colors {
  align-items: center;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.22rem;
}

.asib-recent-color-swatch {
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.15);
  cursor: pointer;
  flex-shrink: 0;
  height: 1.18rem;
  outline: none;
  padding: 0;
  transition: transform 100ms ease, border-color 100ms ease;
  width: 1.18rem;
}

.asib-recent-color-swatch:hover {
  border-color: rgba(0, 0, 0, 0.35);
  transform: scale(1.15);
}

.asib-recent-color-swatch.is-active {
  border-color: #4c8bf5;
  box-shadow: 0 0 0 1.5px #4c8bf5;
}

/* === ASSETS PANEL === */
.asib-panel-header-row {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.asib-upload-icon-sm {
  align-items: center;
  background: #f5f5f5;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  height: 1.5rem;
  justify-content: center;
  padding: 0 0.3rem;
  transition: background 120ms ease;
}

.asib-upload-icon-sm:hover {
  background: #ebebeb;
}

.asib-asset-grid {
  display: grid;
  gap: 0.5rem;
  /* Canva-style: 2 columns by default, fewer larger tiles instead of many tiny ones */
  grid-template-columns: repeat(2, 1fr);
  margin-top: 0.2rem;
}

.asib-asset-thumb {
  aspect-ratio: 1 / 1;
  /* Light/grey checker pattern so transparent assets read visually as transparent
     instead of looking like they have a black/coloured background. */
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #e2e2e2 25%, transparent 25%),
    linear-gradient(-45deg, #e2e2e2 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e2e2e2 75%),
    linear-gradient(-45deg, transparent 75%, #e2e2e2 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
  border: 1.5px solid rgba(0, 0, 0, 0.1);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
  transition: border-color 120ms ease, transform 100ms ease;
}

.asib-asset-thumb:hover:not(:disabled) {
  border-color: #4c8bf5;
  transform: scale(1.04);
}

.asib-asset-thumb img {
  height: 100%;
  object-fit: contain;
  width: 100%;
}

/* === STATUS BAR === */
.asib-status {
  color: #8a8a8a;
  font-size: 0.8rem;
  margin-left: 0;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* =====================================================================
   CANVAS SHELL — the canvas itself gets GPU-composited rendering
   ===================================================================== */
.asib-canvas-shell {
  align-items: flex-start;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  margin: 0 auto;
  max-width: 100%;
  min-height: 0;
  overflow: visible;
  padding: 0.5rem 0 1rem;
  position: relative;
}

.asib-canvas-shell .canvas-container,
.asib-locked-preview img {
  background: #fff;
  border-radius: 4px;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.1),
    0 8px 24px rgba(0, 0, 0, 0.1),
    0 24px 64px rgba(0, 0, 0, 0.08);
}

.asib-canvas-shell .canvas-container {
  overflow: hidden;
  transform: translateZ(0);
  will-change: transform;
}

.asib-canvas-shell .lower-canvas {
  background: #fff !important;
}

.asib-canvas-shell .upper-canvas {
  background: transparent !important;
}

.asib-canvas-shell .lower-canvas,
.asib-canvas-shell .upper-canvas {
  border-radius: 4px;
}

/* =====================================================================
   LIVE SUGGESTIONS — animated popup above canvas
   ===================================================================== */
.asib-live-suggestions {
  animation: asib-pop-in 150ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.06);
  display: grid;
  gap: 0.3rem;
  left: 0;
  max-width: min(270px, calc(100% - 1rem));
  padding: 0.6rem;
  position: absolute;
  top: 0;
  z-index: 20;
}

@keyframes asib-pop-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

.asib-live-suggestions-head {
  color: #9e9e9e;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0 0.1rem 0.15rem;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  margin-bottom: 0.1rem;
}

.asib-live-suggestion-item {
  align-items: center;
  background: #f8f8f8;
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 7px;
  color: #1d1d1f;
  cursor: pointer;
  display: flex;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  justify-content: flex-start;
  padding: 0.5rem 0.65rem;
  text-align: left;
  transition: background 110ms ease, border-color 110ms ease, transform 110ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  width: 100%;
  will-change: transform;
}

.asib-live-suggestion-item:hover {
  background: #fff;
  border-color: #d26e2f;
  transform: translateX(3px);
}

/* === LANGUAGE PILL === */
.asib-language-pill {
  background: #f0f0f0;
  border-radius: 6px;
  color: #3d3d3d;
  display: inline-flex;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 0.28rem 0.58rem;
  width: fit-content;
}

/* =====================================================================
   MODAL — animated overlay with frosted glass backdrop
   ===================================================================== */
.asib-modal-backdrop {
  align-items: center;
  animation: asib-backdrop-in 180ms ease;
  background: rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(4px) saturate(1.3);
  -webkit-backdrop-filter: blur(4px) saturate(1.3);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 1rem;
  position: fixed;
  z-index: 9999;
}

@keyframes asib-backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.asib-modal {
  animation: asib-modal-in 220ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22), 0 4px 16px rgba(0, 0, 0, 0.08);
  display: grid;
  gap: 0.8rem;
  max-width: 440px;
  padding: 1.4rem;
  width: min(100%, 440px);
}

@keyframes asib-modal-in {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

.asib-modal h3 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.asib-modal-icon {
  color: #dc2626;
  display: inline-flex;
}

.asib-modal-actions {
  display: flex;
  gap: 0.55rem;
  justify-content: flex-end;
}

/* =====================================================================
   PREVIEW MODAL — full-screen watermarked draft lightbox
   ===================================================================== */
.asib-preview-backdrop {
  align-items: center;
  animation: asib-backdrop-in 200ms ease;
  background: rgba(0, 0, 0, 0.82);
  bottom: 0;
  display: flex;
  justify-content: center;
  left: 0;
  padding: 1.5rem;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 9999;
  box-sizing: border-box;
}

.asib-preview-frame {
  animation: asib-preview-in 240ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  background: #1a1a1a;
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 3rem);
  max-width: 880px;
  overflow: hidden;
  width: 100%;
}

@keyframes asib-preview-in {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* Top bar — label + close button */
.asib-preview-topbar {
  align-items: center;
  background: #111;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-shrink: 0;
  justify-content: space-between;
  padding: 0.6rem 0.85rem 0.6rem 1rem;
}

.asib-preview-label {
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Close button — rotated plus = × */
.asib-preview-close {
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  display: flex;
  height: 1.75rem;
  justify-content: center;
  transition: background 120ms ease, color 120ms ease;
  width: 1.75rem;
  transform: rotate(45deg);
}

.asib-preview-close:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

/* Scrollable image area */
.asib-preview-img {
  display: block;
  flex: 1 1 auto;
  height: auto;
  margin: 0 auto;
  max-width: 100%;
  object-fit: contain;
  overflow-y: auto;
  width: 100%;
}

/* Bottom action bar */
.asib-preview-actions {
  align-items: center;
  background: #111;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: space-between;
  padding: 0.65rem 1rem;
}

.asib-preview-hint {
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.72rem;
  margin: 0;
}

.asib-preview-downloads {
  display: flex;
  gap: 0.45rem;
  flex-shrink: 0;
}

/* Download link styled as a ghost button */
.asib-preview-dl {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.38rem 0.8rem;
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
  white-space: nowrap;
}

.asib-preview-dl:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

/* === FONT CARD === */
.asib-font-card-body {
  display: grid;
  gap: 0.6rem;
}

/* === LOCKED PREVIEW === */
.asib-locked-preview {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 520px;
}

.asib-locked-preview img {
  max-width: min(100%, 780px);
}

/* === ALIGNMENT GRID === */
.asib-align-grid {
  display: grid;
  gap: 0.38rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.asib-align-grid-icons {
  grid-template-columns: repeat(3, 2rem);
  justify-content: flex-start;
}

.asib-inline-icon-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
}

/* === PROPERTY PANELS === */
.asib-panel-properties {
  gap: 0.48rem;
}

.asib-property-stack,
.asib-property-section,
.asib-property-toolbar-block {
  align-content: start;
  display: grid;
}

.asib-property-stack {
  gap: 0.7rem;
}

.asib-property-section,
.asib-property-toolbar-block {
  gap: 0.38rem;
}

.asib-property-toolbar {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.8rem;
}

/* === COLOR CHIP === */
.asib-color-chip {
  background: #f5f5f5;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 7px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.7);
  cursor: pointer;
  display: inline-flex;
  height: 2rem;
  overflow: hidden;
  position: relative;
  transition: border-color 130ms ease, transform 120ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  width: 2rem;
  will-change: transform;
}

.asib-color-chip:hover {
  border-color: rgba(0, 0, 0, 0.28);
  transform: scale(1.08);
}

.asib-toolbar-color {
  height: 1.8rem;
  width: 1.8rem;
}

.asib-color-chip-input {
  cursor: pointer;
  inset: 0;
  opacity: 0;
  position: absolute;
}

.asib-property-footer {
  display: flex;
  justify-content: flex-start;
}

/* === ACTIVE ICON BUTTON STATE === */
.asib-icon-btn.is-active {
  background: #d26e2f;
  border-color: #d26e2f;
  color: #fff;
}

.asib-icon-btn.is-active:hover:not(:disabled) {
  background: #be6029;
}

.asib-icon-btn-danger {
  color: #dc2626;
}

.asib-icon-btn-plain {
  border-radius: 999px;
  height: 1.72rem;
  width: 1.72rem;
}

/* === SMALLER ICON BUTTONS IN CONTEXT === */
.asib-layer-actions .asib-icon-btn,
.asib-align-grid-icons .asib-icon-btn,
.asib-inline-icon-group .asib-icon-btn,
.asib-toolbar-properties > .asib-icon-btn {
  border-radius: 6px;
  height: 1.8rem;
  width: 1.8rem;
}

.asib-toolbar-icon-group .asib-icon-btn,
.asib-stage-properties .asib-icon-btn {
  border-radius: 7px;
  height: 2rem;
  width: 2rem;
}

/* === LAYERS PANEL === */
.asib-panel-layers {
  gap: 0.38rem;
  padding: 0.6rem;
}

.asib-panel-layers h3 {
  margin-bottom: 0.05rem;
}

.asib-side-right,
.asib-side-left {
  min-width: 0;
}

/* === SUGGESTION CHIPS === */
.asib-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.asib-suggestion,
.asib-link {
  background: #f2f2f2;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 7px;
  color: #3d3d3d;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.42rem 0.72rem;
  text-decoration: none;
  transition: background 110ms ease,
              border-color 110ms ease,
              transform 110ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

.asib-suggestion:hover,
.asib-link:hover {
  background: #e8e8e8;
  border-color: rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

/* === BANNERS === */
.asib-banner {
  justify-content: flex-start;
}

.asib-banner-danger {
  background: #fff5f5;
  border-color: #fca5a5;
  color: #991b1b;
}

/* === LOADING & ERROR STATES === */
.asib-loading,
.asib-error {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  font-size: 0.88rem;
  padding: 0.9rem 1.1rem;
}

.asib-error {
  border-color: #fca5a5;
  background: #fff5f5;
  color: #dc2626;
}

/* =====================================================================
   GUEST NOTE — slide-in floating badge (bottom-right)
   ===================================================================== */
.asib-guest-note {
  animation: asib-slide-in-right 280ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  bottom: 1rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1), 0 1px 4px rgba(0, 0, 0, 0.06);
  color: #4a4a4a;
  display: grid;
  gap: 0.08rem;
  max-width: min(210px, calc(100vw - 2rem));
  padding: 0.55rem 0.75rem;
  position: fixed;
  right: 1rem;
  z-index: 120;
}

@keyframes asib-slide-in-right {
  from { opacity: 0; transform: translateX(14px); }
  to   { opacity: 1; transform: translateX(0);    }
}

.asib-guest-note strong {
  color: #1d1d1f;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
}

.asib-guest-note span {
  color: #6b6b6b;
  font-size: 0.7rem;
  line-height: 1.35;
}

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
@media (max-width: 1200px) {
  .asib-editor-grid {
    grid-template-columns: 1fr;
  }

  .asib-canvas-stage {
    min-height: 0;
    order: -1;
  }

  .asib-layer-list {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .asib-toolbar,
  .asib-section-head,
  .asib-stage-top,
  .asib-tabs,
  .asib-card-actions,
  .asib-inline-pills,
  .asib-font-upload {
    align-items: flex-start;
    flex-direction: column;
  }

  .asib-stage-top {
    border-radius: 8px;
    grid-template-columns: 1fr;
  }

  .asib-toolbar-properties {
    justify-content: flex-start;
  }

  .asib-stage-meta {
    justify-content: flex-start;
  }

  .asib-guest-note {
    bottom: 0.75rem;
    left: 0.75rem;
    max-width: calc(100vw - 1.5rem);
    right: auto;
  }
}

/* =====================================================================
   ASSETS PANEL ENHANCEMENTS — category filters, upload row
   ===================================================================== */

/* Upload row: category text input + file label side by side */
.asib-asset-upload-row {
  align-items: center;
  display: flex;
  gap: 0.3rem;
}

/* Tiny text input for category label in the editor panel */
.asib-input-xs {
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 5px;
  font-size: 0.72rem;
  height: 1.65rem;
  min-width: 0;
  padding: 0 0.4rem;
  width: 100%;
}

.asib-input-xs:focus {
  border-color: #4c8bf5;
  outline: none;
}

/* Category filter chips row */
.asib-category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
  margin: 0.4rem 0 0.2rem;
}

.asib-category-chip {
  background: #f0f0f0;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  color: #444;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1;
  padding: 0.24rem 0.6rem;
  transition: background 100ms ease, border-color 100ms ease, color 100ms ease;
  white-space: nowrap;
}

.asib-category-chip:hover {
  background: #e2e2e2;
  border-color: rgba(0, 0, 0, 0.2);
}

.asib-category-chip.is-active {
  background: #4c8bf5;
  border-color: #4c8bf5;
  color: #fff;
}

/* =====================================================================
   ADMIN ASSETS TAB — grid and cards
   ===================================================================== */
.asib-admin-asset-upload {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.asib-admin-asset-upload .asib-input {
  flex: 1 1 180px;
  min-width: 0;
}

.asib-btn-accent {
  background: #4c8bf5;
  border: none;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.42rem 0.85rem;
  transition: background 120ms ease;
  white-space: nowrap;
}

.asib-btn-accent:hover {
  background: #3a78e0;
}

/* 4-column responsive grid in admin */
.asib-admin-asset-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  margin-top: 0.5rem;
}

/* Individual admin asset card */
.asib-admin-asset-card {
  background: #fafafa;
  border: 1.5px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  transition: border-color 120ms ease;
}

.asib-admin-asset-card:hover {
  border-color: #4c8bf5;
}

.asib-admin-asset-card img {
  aspect-ratio: 1 / 1;
  /* Checker pattern background so transparent assets are clearly visible */
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #e2e2e2 25%, transparent 25%),
    linear-gradient(-45deg, #e2e2e2 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e2e2e2 75%),
    linear-gradient(-45deg, transparent 75%, #e2e2e2 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
  display: block;
  height: auto;
  object-fit: contain;
  padding: 0.35rem;
  width: 100%;
}

.asib-admin-asset-meta {
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.3rem 0.4rem;
}

.asib-admin-asset-name {
  color: #333;
  display: block;
  font-size: 0.68rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asib-admin-asset-category {
  background: #eef2ff;
  border-radius: 999px;
  color: #4c8bf5;
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  width: fit-content;
}

/* Delete button — absolute top-right corner */
.asib-admin-asset-delete {
  background: rgba(220, 40, 40, 0.85);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 1.3rem;
  opacity: 0;
  position: absolute;
  right: 0.25rem;
  top: 0.25rem;
  transition: opacity 120ms ease, background 120ms ease;
  width: 1.3rem;
}

.asib-admin-asset-card:hover .asib-admin-asset-delete {
  opacity: 1;
}

.asib-admin-asset-delete:hover {
  background: rgba(180, 20, 20, 0.95);
}

/* =====================================================================
   REDUCED MOTION — respect OS preference
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  .asib-btn,
  .asib-icon-btn,
  .asib-card,
  .asib-color-chip,
  .asib-suggestion,
  .asib-link,
  .asib-live-suggestion-item,
  .asib-layer-row {
    transition: none;
    animation: none;
  }

  .asib-live-suggestions,
  .asib-modal,
  .asib-modal-backdrop,
  .asib-preview-backdrop,
  .asib-preview-frame,
  .asib-guest-note {
    animation: none;
  }
}

/* Canvas loading overlay — shown while loadFromJSON is hydrating images.
   The stage needs `position: relative` so the absolute-positioned overlay
   anchors to it, and we override the dot-grid background while loading
   so it doesn't show through the translucent overlay. */
.asib-canvas-stage {
  position: relative;
}
.asib-canvas-loading {
  animation: asib-fade-in 200ms ease;
}
@keyframes asib-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes asib-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .asib-canvas-loading-spinner {
    animation-duration: 1.6s;
  }
}

/* Toolbar slider groups: opacity, fill-opacity. Inline pill that holds
   an icon (or label), a range input, and a value readout. Sized so it
   fits in the same toolbar row as the icon button groups. */
.asib-toolbar-slider-group {
  align-items: center;
  background: #f2f2f2;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 7px;
  box-sizing: border-box;
  display: inline-flex;
  flex: 0 0 auto;
  gap: 6px;
  padding: 0 0.55rem;
  height: 2rem;
}
.asib-toolbar-slider-group .asib-icon {
  flex: 0 0 auto;
}
.asib-toolbar-slider-label {
  font-size: 11px;
  color: rgba(0, 0, 0, 0.6);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.asib-toolbar-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 4px;
  background: rgba(0, 0, 0, 0.12);
  border-radius: 2px;
  outline: none;
}
.asib-toolbar-slider:disabled {
  opacity: 0.5;
}
.asib-toolbar-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: #2d2018;
  border-radius: 50%;
  cursor: pointer;
}
.asib-toolbar-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #2d2018;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
}
.asib-toolbar-slider-value {
  font-size: 11px;
  color: rgba(0, 0, 0, 0.7);
  font-variant-numeric: tabular-nums;
  min-width: 30px;
  text-align: right;
}
