/* ================================================================
   ColourLab — Editor Styles
   All class names prefixed with .cl- to avoid site-wide conflicts
   ================================================================ */

:root {
  --cl-ink: #0b1220;
  --cl-muted: #5b6573;
  --cl-faint: #7b8794;
  --cl-line: rgba(11, 18, 32, .10);
  --cl-soft: rgba(11, 18, 32, .04);
  --cl-surface: #ffffff;
  --cl-bg: #edf0f4;
  --cl-radius: 10px;
}

/* ── Reset (scoped) ──────────────────────────────────────────── */
.cl-body {
  margin: 0;
  padding: 0;
  font-family: "Google Sans", system-ui, -apple-system, sans-serif;
  background: var(--cl-bg);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

.cl-body * {
  box-sizing: border-box;
}

.cl-body a {
  color: inherit;
  text-decoration: none;
}

/* ── Header ──────────────────────────────────────────────────── */
.cl-header {
  height: 52px;
  background: var(--cl-surface);
  border-bottom: 1px solid var(--cl-line);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 50;
}

.cl-header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.cl-back-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: var(--cl-muted);
  transition: background .12s, color .12s;
  flex-shrink: 0;
}
.cl-back-link:hover {
  background: var(--cl-soft);
  color: var(--cl-ink);
}

.cl-logo {
  height: 24px;
  flex-shrink: 0;
}

.cl-brand-name {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--cl-ink);
}

.cl-badge {
  background: var(--cl-soft);
  border: 1px solid var(--cl-line);
  color: var(--cl-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}

.cl-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.cl-header-actions::-webkit-scrollbar {
  display: none;
}

/* Header buttons */
.cl-hbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, opacity .12s;
  white-space: nowrap;
}
.cl-hbtn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.cl-hbtn-ghost {
  background: transparent;
  color: var(--cl-muted);
  border: 1px solid var(--cl-line);
}
.cl-hbtn-ghost:hover {
  background: var(--cl-soft);
  color: var(--cl-ink);
}
.cl-hbtn-ghost.active-bg {
  background: rgba(11, 18, 32, .08);
  color: var(--cl-ink);
  border-color: rgba(11, 18, 32, .2);
}

.cl-hbtn-icon {
  width: 34px;
  padding: 7px 0;
}

.cl-hbtn-zoom {
  min-width: 58px;
  padding: 7px 10px;
}

.cl-hbtn-primary {
  background: var(--cl-ink);
  color: #fff;
}
.cl-hbtn-primary:hover {
  opacity: .85;
}
.cl-hbtn-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* ── Editor Layout ────────────────────────────────────────────── */
.cl-editor {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── Left Toolbar ─────────────────────────────────────────────── */
.cl-toolbar {
  width: 72px;
  background: var(--cl-surface);
  border-right: 1px solid var(--cl-line);
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 8px 5px;
  overflow-y: auto;
  flex-shrink: 0;
}

.cl-tool-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--cl-line);
}
.cl-tool-group:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.cl-tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: var(--cl-muted);
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
  transition: background .1s, color .1s;
  width: 100%;
  line-height: 1.2;
}
.cl-tool-btn:hover {
  background: var(--cl-soft);
  color: var(--cl-ink);
}
.cl-tool-btn.active {
  background: rgba(11, 18, 32, .08);
  color: var(--cl-ink);
}
.cl-tool-btn:active {
  background: rgba(11, 18, 32, .08);
}
.cl-tool-btn.cl-danger {
  color: #b91c1c;
}
.cl-tool-btn.cl-danger:hover {
  background: rgba(185, 28, 28, .07);
}

/* ── Canvas Area (grid accommodates rulers) ───────────────────── */
.cl-canvas-area {
  flex: 1;
  display: grid;
  grid-template-columns: 20px 1fr;
  grid-template-rows: 20px 1fr;
  overflow: hidden;
  position: relative;
  min-width: 0;
}

/* ── Rulers ───────────────────────────────────────────────────── */
.cl-ruler-corner {
  grid-column: 1;
  grid-row: 1;
  background: var(--cl-bg);
  border-right: 1px solid var(--cl-line);
  border-bottom: 1px solid var(--cl-line);
  z-index: 10;
}

.cl-ruler-h {
  grid-column: 2;
  grid-row: 1;
  display: block;
  width: 100%;
  height: 20px;
  cursor: default;
  z-index: 10;
}

.cl-ruler-v {
  grid-column: 1;
  grid-row: 2;
  display: block;
  width: 20px;
  height: 100%;
  cursor: default;
  z-index: 10;
}

.cl-canvas-scroll {
  grid-column: 2;
  grid-row: 2;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}

/* ── Floating selection toolbar ───────────────────────────────── */
.cl-sel-toolbar {
  display: none;
  position: absolute;
  z-index: 200;
  align-items: center;
  gap: 3px;
  background: #1a2233;
  border-radius: 8px;
  padding: 4px 8px;
  box-shadow: 0 4px 20px rgba(11,18,32,.35);
  pointer-events: auto;
  transform: translateX(-50%);
  white-space: nowrap;
}

.cl-sel-tb-size {
  font-size: 11px;
  color: rgba(255,255,255,.55);
  font-family: inherit;
  padding-right: 2px;
}

.cl-sel-tb-sep {
  width: 1px;
  height: 16px;
  background: rgba(255,255,255,.15);
  margin: 0 3px;
}

.cl-sel-tb-btn {
  padding: 4px 10px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: #fff;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background .1s;
}

.cl-sel-tb-btn:hover {
  background: rgba(255,255,255,.14);
}

.cl-sel-tb-danger {
  color: #fca5a5;
}

.cl-sel-tb-danger:hover {
  background: rgba(185,28,28,.3);
}

/* Canvas outer — receives checkerboard when transparent bg is on */
.cl-canvas-outer {
  position: relative;
  display: inline-block;
}

.cl-canvas-outer.transparent-mode::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(45deg, #c8c8c8 25%, transparent 25%),
    linear-gradient(-45deg, #c8c8c8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #c8c8c8 75%),
    linear-gradient(-45deg, transparent 75%, #c8c8c8 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  background-color: #ebebeb;
  border-radius: 2px;
  z-index: 0;
  pointer-events: none;
}

.cl-canvas-wrapper {
  position: relative;
  z-index: 1;
  box-shadow: 0 4px 32px rgba(11, 18, 32, .18);
  border-radius: 2px;
  overflow: hidden;
  /* Border helps see canvas edge against any background */
  outline: 1px solid rgba(11, 18, 32, .08);
}

/* Floating hint — fades away after first layer added */
.cl-canvas-hint {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(11, 18, 32, .65);
  color: #fff;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 12px;
  pointer-events: none;
  transition: opacity .4s;
  white-space: nowrap;
  backdrop-filter: blur(4px);
}

/* ── Right Panel (desktop) ────────────────────────────────────── */
.cl-right-panel {
  width: 256px;
  background: var(--cl-surface);
  border-left: 1px solid var(--cl-line);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.cl-panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--cl-line);
  flex-shrink: 0;
}

.cl-panel-tab {
  flex: 1;
  padding: 10px 8px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--cl-faint);
  transition: color .12s, border-color .12s;
}
.cl-panel-tab.active {
  color: var(--cl-ink);
  border-bottom-color: var(--cl-ink);
}

.cl-panel-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.cl-panel-body.hidden {
  display: none;
}

/* ── Layer List ───────────────────────────────────────────────── */
.cl-layer-list {
  padding: 4px 0;
}

.cl-empty-msg {
  padding: 20px 16px;
  font-size: 12px;
  color: var(--cl-faint);
  text-align: center;
  line-height: 1.6;
}

.cl-layer-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  cursor: pointer;
  font-size: 12px;
  color: var(--cl-ink);
  border-bottom: 1px solid transparent;
  transition: background .1s;
  user-select: none;
}
.cl-layer-item:hover {
  background: rgba(11, 18, 32, .03);
}
.cl-layer-item.cl-selected {
  background: rgba(11, 18, 32, .055);
}
.cl-layer-item.cl-dragging {
  opacity: .55;
}
.cl-layer-item.cl-drop-before {
  box-shadow: inset 0 2px 0 var(--cl-ink);
}
.cl-layer-item.cl-drop-after {
  box-shadow: inset 0 -2px 0 var(--cl-ink);
}

.cl-layer-drag {
  flex-shrink: 0;
  color: var(--cl-faint);
  font-size: 11px;
  letter-spacing: -1px;
  cursor: grab;
  user-select: none;
}

.cl-layer-vis {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cl-faint);
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  transition: color .1s, background .1s;
}
.cl-layer-vis:hover {
  color: var(--cl-ink);
  background: var(--cl-soft);
}
.cl-layer-vis.hidden-layer {
  opacity: .4;
}

.cl-layer-type-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cl-muted);
}

.cl-layer-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--cl-ink);
  cursor: text;
}

.cl-layer-name-input {
  flex: 1;
  border: 1px solid rgba(11, 18, 32, .2);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 12px;
  color: var(--cl-ink);
  outline: none;
  min-width: 0;
}

.cl-layer-lock {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cl-faint);
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  opacity: .5;
  transition: opacity .1s, color .1s;
}
.cl-layer-lock:hover {
  opacity: 1;
  color: var(--cl-ink);
}
.cl-layer-lock.locked {
  opacity: 1;
  color: var(--cl-ink);
}

.cl-layer-del {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cl-faint);
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  opacity: 0;
  transition: opacity .1s, color .1s;
}
.cl-layer-item:hover .cl-layer-del {
  opacity: 1;
}
.cl-layer-del:hover {
  color: #b91c1c;
  background: rgba(185, 28, 28, .07);
}

.cl-layer-fill-badge {
  font-size: 9px;
  background: #e0f2fe;
  color: #0369a1;
  padding: 1px 4px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ── Inspector ────────────────────────────────────────────────── */
.cl-inspector {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--cl-ink);
}

.cl-insp-section {
  margin-bottom: 14px;
}

.cl-insp-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--cl-faint);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 7px;
}

.cl-insp-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
}

.cl-insp-row-top {
  align-items: flex-start;
}

.cl-insp-row > label {
  font-size: 11px;
  color: var(--cl-muted);
  flex-shrink: 0;
  width: 50px;
}

.cl-inline-label {
  width: auto !important;
  margin-left: 4px;
}

.cl-inline-unit {
  font-size: 11px;
  color: var(--cl-muted);
}

.cl-field {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid var(--cl-line);
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  color: var(--cl-ink);
  background: #fff;
  outline: none;
  transition: border-color .12s;
  min-width: 0;
}
.cl-field:focus {
  border-color: rgba(11, 18, 32, .35);
}

.cl-field-sm {
  width: 60px;
  flex: none;
}

.cl-field-textarea {
  min-height: 82px;
  resize: vertical;
  line-height: 1.45;
}

.cl-field-color {
  padding: 2px 3px;
  width: 32px;
  height: 28px;
  border: 1px solid var(--cl-line);
  border-radius: 6px;
  cursor: pointer;
  background: #fff;
  flex: none;
}

.cl-field-note {
  font-size: 11px;
  color: var(--cl-muted);
  line-height: 1.4;
}

.cl-field-note.strong {
  color: var(--cl-ink);
}

.cl-check-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--cl-muted);
}

.cl-check-label input {
  margin: 0;
}

.cl-align-group {
  display: flex;
  gap: 4px;
  flex: 1;
}

.cl-wrap-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1;
}

.cl-check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
  margin-top: 8px;
}

.cl-insp-mini-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--cl-faint);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 10px 0 6px;
}

.cl-align-btn {
  flex: 1;
  padding: 5px 4px;
  background: transparent;
  border: 1px solid var(--cl-line);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  color: var(--cl-muted);
  transition: background .1s, color .1s, border-color .1s;
}
.cl-align-btn.active {
  background: var(--cl-ink);
  color: #fff;
  border-color: var(--cl-ink);
}
.cl-align-btn:hover {
  background: var(--cl-soft);
  color: var(--cl-ink);
}

.cl-align-btn-mini {
  flex: none;
  min-width: 0;
  width: 100%;
}

.cl-align-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.cl-mode-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.cl-mode-btn {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--cl-line);
  border-radius: 7px;
  background: #fff;
  color: var(--cl-muted);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}

.cl-mode-btn.active {
  background: var(--cl-ink);
  border-color: var(--cl-ink);
  color: #fff;
}

.cl-grad-presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}

.cl-grad-preset {
  padding: 6px 0;
  border: 1px solid var(--cl-line);
  border-radius: 6px;
  background: #fff;
  color: var(--cl-muted);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.cl-grad-preset.active {
  background: rgba(11, 18, 32, .08);
  color: var(--cl-ink);
  border-color: rgba(11, 18, 32, .2);
}

.cl-grad-bar {
  height: 16px;
  border-radius: 999px;
  border: 1px solid var(--cl-line);
  margin-bottom: 8px;
}

.cl-grad-stop-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.cl-grad-stop-row {
  display: grid;
  grid-template-columns: 34px 1fr 38px 28px;
  gap: 8px;
  align-items: center;
}

.cl-stop-remove {
  width: 28px;
  height: 28px;
  border: 1px solid var(--cl-line);
  border-radius: 6px;
  background: #fff;
  color: var(--cl-muted);
  font-size: 14px;
  cursor: pointer;
}

.cl-stop-remove:disabled {
  cursor: not-allowed;
  opacity: .4;
}

.cl-insp-btn {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--cl-line);
  border-radius: 8px;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--cl-ink);
  margin-bottom: 5px;
  transition: background .12s, border-color .12s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.cl-wrap-group .cl-insp-btn {
  width: auto;
  flex: 1 1 calc(50% - 4px);
  margin-bottom: 0;
}
.cl-insp-btn:hover {
  background: var(--cl-soft);
}

.cl-insp-btn.primary {
  background: var(--cl-ink);
  color: #fff;
  border-color: var(--cl-ink);
}
.cl-insp-btn.primary:hover {
  opacity: .85;
}

.cl-insp-btn.warn {
  color: #0369a1;
  border-color: #bae6fd;
  background: #f0f9ff;
}
.cl-insp-btn.warn:hover {
  background: #e0f2fe;
}

.cl-insp-btn.danger {
  color: #b91c1c;
  border-color: rgba(185, 28, 28, .2);
}
.cl-insp-btn.danger:hover {
  background: rgba(185, 28, 28, .06);
}

.cl-font-trigger {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--cl-line);
  border-radius: 8px;
  background: #fff;
  color: var(--cl-ink);
  cursor: pointer;
  transition: border-color .12s, background .12s;
  text-align: left;
}

.cl-font-trigger:hover {
  background: var(--cl-soft);
  border-color: rgba(11, 18, 32, .2);
}

.cl-font-trigger__label {
  display: block;
  font-size: 12px;
  font-weight: 600;
}

.cl-font-trigger__meta {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  color: var(--cl-faint);
}

.cl-font-inline-preview {
  margin-top: 6px;
  padding: 7px 9px;
  border-radius: 7px;
  background: #f8fafc;
  color: var(--cl-muted);
  font-size: 12px;
  line-height: 1.3;
  border: 1px solid rgba(11, 18, 32, .05);
}

.cl-inline-status {
  margin-top: 6px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid rgba(3, 105, 161, .12);
  background: rgba(3, 105, 161, .06);
  color: #075985;
  font-size: 11px;
  line-height: 1.45;
}

.cl-inline-status.active {
  border-color: rgba(249, 115, 22, .2);
  background: rgba(249, 115, 22, .10);
  color: #9a3412;
}

.cl-slider-wide .cl-range-val {
  width: 42px;
}

.cl-insp-sep {
  height: 1px;
  background: var(--cl-line);
  margin: 10px 0;
}

.cl-img-fill-active {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 7px;
  margin-bottom: 6px;
  font-size: 11px;
  color: #0369a1;
}
.cl-img-fill-active svg {
  flex-shrink: 0;
}

.cl-range-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cl-range {
  flex: 1;
  accent-color: var(--cl-ink);
  cursor: pointer;
}

.cl-range-val {
  font-size: 11px;
  color: var(--cl-muted);
  width: 32px;
  text-align: right;
  flex-shrink: 0;
}

.cl-selection-status {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--cl-line);
  background: #f8fafc;
  color: var(--cl-muted);
  font-size: 11px;
  line-height: 1.45;
  margin-bottom: 8px;
}

.cl-selection-status.active {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

/* ── Mobile panel ─────────────────────────────────────────────── */
.cl-mobile-only {
  display: none;
}

.cl-mobile-panel {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--cl-surface);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -6px 32px rgba(11, 18, 32, .14);
  z-index: 300;
  /* Collapsed: only show handle */
  transform: translateY(calc(100% - 56px));
  transition: transform .3s cubic-bezier(.4, 0, .2, 1);
  max-height: 72vh;
}
.cl-mobile-panel.open {
  transform: translateY(0);
}

.cl-mobile-panel-handle {
  padding: 8px 14px 0;
  cursor: pointer;
  flex-shrink: 0;
}

.cl-handle-pill {
  width: 36px;
  height: 4px;
  background: var(--cl-line);
  border-radius: 2px;
  margin: 0 auto 8px;
}

.cl-mobile-panel-body {
  overflow-y: auto;
  /* Subtracts handle height */
  max-height: calc(72vh - 56px);
  padding-bottom: env(safe-area-inset-bottom, 8px);
}

.cl-font-modal[hidden] {
  display: none;
}

.cl-font-modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.cl-font-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 18, 32, .54);
  backdrop-filter: blur(6px);
}

.cl-font-modal__dialog {
  position: relative;
  width: min(980px, 100%);
  max-height: min(82vh, 840px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 22px 18px;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 24px 90px rgba(11, 18, 32, .24);
}

.cl-font-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.cl-font-modal__eyebrow {
  font-size: 10px;
  font-weight: 700;
  color: var(--cl-faint);
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.cl-font-modal__title {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
  color: var(--cl-ink);
}

.cl-font-modal__close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--cl-line);
  border-radius: 10px;
  background: #fff;
  color: var(--cl-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}

.cl-font-modal__close:hover {
  background: var(--cl-soft);
  color: var(--cl-ink);
  border-color: rgba(11, 18, 32, .18);
}

.cl-font-modal__controls {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(280px, 1fr);
  gap: 12px;
}

.cl-font-modal__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cl-font-modal__field span {
  font-size: 11px;
  font-weight: 700;
  color: var(--cl-faint);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.cl-font-modal__field input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--cl-line);
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  color: var(--cl-ink);
  outline: none;
  transition: border-color .12s;
}

.cl-font-modal__field input:focus {
  border-color: rgba(11, 18, 32, .28);
}

.cl-font-modal__status {
  min-height: 20px;
  font-size: 12px;
  color: var(--cl-muted);
}

.cl-font-modal__status.error {
  color: #b91c1c;
}

.cl-font-modal__status.ready {
  color: #0369a1;
}

.cl-font-modal__list {
  overflow: auto;
  border: 1px solid rgba(11, 18, 32, .08);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(248, 250, 252, .9), #fff 18%);
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  min-height: 260px;
}

.cl-font-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(11, 18, 32, .08);
  background: #fff;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease, background .12s ease;
  text-align: left;
}

.cl-font-card:hover {
  transform: translateY(-1px);
  border-color: rgba(11, 18, 32, .18);
  box-shadow: 0 12px 28px rgba(11, 18, 32, .08);
}

.cl-font-card.active {
  border-color: rgba(3, 105, 161, .26);
  background: rgba(240, 249, 255, .88);
}

.cl-font-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.cl-font-card__name {
  font-size: 13px;
  font-weight: 700;
  color: var(--cl-ink);
}

.cl-font-card__cat {
  font-size: 10px;
  font-weight: 700;
  color: var(--cl-faint);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.cl-font-card__preview {
  min-height: 74px;
  font-size: 28px;
  line-height: 1.08;
  color: var(--cl-ink);
  word-break: break-word;
}

.cl-font-card__sample {
  font-size: 12px;
  color: var(--cl-muted);
  line-height: 1.45;
}

.cl-font-modal__empty {
  padding: 40px 14px;
  text-align: center;
  color: var(--cl-faint);
  font-size: 13px;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 840px) {
  .cl-right-panel {
    display: none;
  }

  .cl-mobile-only {
    display: flex;
  }

  .cl-mobile-panel {
    display: block;
  }

  /* Hide rulers on mobile — collapse grid to single cell */
  .cl-ruler-corner,
  .cl-ruler-h,
  .cl-ruler-v {
    display: none;
  }

  .cl-canvas-area {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }

  .cl-canvas-scroll {
    grid-column: 1;
    grid-row: 1;
    padding: 12px 8px;
    align-items: flex-start;
    justify-content: flex-start;
  }

  .cl-header-actions .cl-hbtn-ghost span {
    display: none;
  }
  .cl-header-actions .cl-hbtn-ghost {
    padding: 7px 9px;
  }
  .cl-hbtn-zoom {
    min-width: 48px;
  }

  .cl-font-modal {
    padding: 12px;
  }

  .cl-font-modal__dialog {
    max-height: 88vh;
    padding: 18px 16px 14px;
  }

  .cl-font-modal__controls {
    grid-template-columns: 1fr;
  }

  .cl-font-modal__list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .cl-toolbar {
    width: 56px;
    padding: 6px 3px;
  }

  .cl-tool-btn span {
    display: none;
  }

  .cl-tool-btn {
    padding: 8px 2px;
  }

  .cl-brand-name {
    display: none;
  }
}

@media (max-width: 400px) {
  .cl-badge {
    display: none;
  }
}

/* ── Mobile panel close button ────────────────────────────────── */
.cl-handle-toprow {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding-top: 2px;
  margin-bottom: 6px;
}

.cl-mobile-panel-close {
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  background: var(--cl-soft);
  border: 1px solid var(--cl-line);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--cl-muted);
  transition: background .12s, color .12s;
  flex-shrink: 0;
  padding: 0;
}
.cl-mobile-panel-close:hover {
  background: var(--cl-line);
  color: var(--cl-ink);
}

/* ── Filter panel ─────────────────────────────────────────────── */
.cl-editor {
  position: relative;
}

.cl-filter-panel {
  position: absolute;
  left: 72px;
  top: 0;
  bottom: 0;
  width: 210px;
  background: var(--cl-surface);
  border-right: 1px solid var(--cl-line);
  z-index: 120;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform .22s cubic-bezier(.4, 0, .2, 1);
  overflow: hidden;
}
.cl-filter-panel.open {
  transform: translateX(0);
}

.cl-filter-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 8px;
  border-bottom: 1px solid var(--cl-line);
  flex-shrink: 0;
}

.cl-filter-panel-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--cl-ink);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.cl-filter-panel-close {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--cl-muted);
  padding: 0;
  transition: background .12s, color .12s;
}
.cl-filter-panel-close:hover {
  background: var(--cl-soft);
  color: var(--cl-ink);
}

.cl-filter-hint {
  font-size: 11px;
  color: var(--cl-faint);
  padding: 8px 12px 4px;
  margin: 0;
  line-height: 1.4;
  flex-shrink: 0;
}

.cl-filter-chips {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-content: start;
}

.cl-filter-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 6px 4px 8px;
  border: 2px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  background: transparent;
  transition: border-color .12s, background .12s;
  font-family: inherit;
}
.cl-filter-chip:hover {
  background: var(--cl-soft);
}
.cl-filter-chip.active {
  border-color: var(--cl-ink);
  background: var(--cl-soft);
}

.cl-filter-swatch {
  width: 72px;
  height: 56px;
  border-radius: 7px;
  overflow: hidden;
  flex-shrink: 0;
  background: linear-gradient(135deg,
    #f97316 0%, #fb923c 15%,
    #60a5fa 40%, #818cf8 55%,
    #4ade80 75%, #f59e0b 100%);
  box-shadow: 0 1px 4px rgba(11,18,32,.12);
}

.cl-filter-name {
  font-size: 10px;
  font-weight: 600;
  color: var(--cl-muted);
  text-align: center;
  line-height: 1.2;
}
.cl-filter-chip.active .cl-filter-name {
  color: var(--cl-ink);
}

/* Mobile overrides for filter panel */
@media (max-width: 840px) {
  .cl-filter-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 56px;
    top: auto;
    width: 100%;
    height: 160px;
    border-right: none;
    border-top: 1px solid var(--cl-line);
    border-radius: 14px 14px 0 0;
    transform: translateY(100%);
    box-shadow: 0 -4px 24px rgba(11,18,32,.12);
    z-index: 310;
  }
  .cl-filter-panel.open {
    transform: translateY(0);
  }
  .cl-filter-chips {
    display: flex;
    flex-direction: row;
    gap: 8px;
    padding: 8px 12px;
    overflow-x: auto;
    overflow-y: hidden;
    align-items: flex-start;
    scrollbar-width: none;
  }
  .cl-filter-chips::-webkit-scrollbar {
    display: none;
  }
  .cl-filter-chip {
    flex-shrink: 0;
  }
  .cl-filter-swatch {
    width: 60px;
    height: 48px;
  }
}
