/* ─────────────────────────────────────────────
   ACP — Design Studio page
   ───────────────────────────────────────────── */

/* Active nav state */
.nav__links a.is-active { color: var(--blue-900); }
.nav__links a.is-active::after { width: 100%; }

/* ───────── Page hero ───────── */
.page-hero {
  padding: clamp(2.5rem, 6vw, 4.5rem) 0 clamp(1.5rem, 3vw, 2.5rem);
  text-align: left;
  background: var(--paper);
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.page-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 90% 0%, rgba(220,38,38,0.10), transparent 40%),
    radial-gradient(circle at 0% 100%, rgba(30,58,138,0.10), transparent 40%);
  z-index: -1;
}
.page-hero h1 {
  font-size: clamp(2.2rem, 4.4vw, 3.6rem);
  margin-top: 0.6rem;
  max-width: 18ch;
}
.page-hero h1 em { font-style: italic; color: var(--red-600); }
.page-hero__lede {
  margin-top: 1rem;
  color: var(--ink-soft);
  font-size: clamp(1rem, 1.2vw, 1.1rem);
  max-width: 60ch;
}

/* ───────── Designer grid ───────── */
.designer { padding: clamp(2rem, 4vw, 3rem) 0 clamp(4rem, 8vw, 6rem); background: var(--paper); }

.designer__grid {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 300px;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 1100px) {
  .designer__grid { grid-template-columns: 1fr; }
}

.designer__panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.designer__panel-head {
  padding: 1.1rem 1.3rem 0.9rem;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.designer__panel-head--row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.designer__panel-head--sub {
  padding: 0.9rem 1.3rem 0.7rem;
  background: transparent;
  border-bottom: 0;
  border-top: 1px dashed var(--line);
  margin-top: 0.5rem;
}
.designer__panel-head h2 {
  font-size: 0.78rem;
  font-family: var(--body);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--blue-900);
  letter-spacing: 0.14em;
}
.designer__panel-head h3 {
  font-size: 0.72rem;
  font-family: var(--body);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.designer__panel-meta {
  margin: 0.3rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}
.designer__note {
  padding: 0.8rem 1.3rem 1.2rem;
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

/* ───────── Templates panel ───────── */
.template-list {
  display: grid;
  gap: 0.45rem;
  padding: 0.9rem;
}
.template-list button {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.75rem 0.9rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.25s var(--ease), border-color 0.2s, background 0.2s, box-shadow 0.25s var(--ease);
}
.template-list button::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--red-600), var(--blue-700));
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 0.3s var(--ease);
}
.template-list button:hover {
  border-color: var(--blue-700);
  transform: translateX(2px);
  background: var(--white);
  box-shadow: 0 8px 18px rgba(11,30,63,0.08);
}
.template-list button:hover::before { transform: scaleY(1); }
.template-list button.is-active {
  background: var(--blue-900);
  color: var(--paper);
  border-color: var(--blue-900);
  box-shadow: 0 12px 24px -8px rgba(11,30,63,0.45);
}
.template-list button.is-active::before { transform: scaleY(1); background: var(--red-500); }
.template-list button.is-active .tpl-thumb { background: var(--paper); }
.template-list__head {
  font-family: var(--body);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.7rem 0.4rem 0.3rem;
}
.template-list__head:first-child { padding-top: 0; }
.tpl-thumb-wrap {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
.tpl-thumb {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  background: var(--white);
  border: 1px solid var(--line);
  box-shadow: 0 2px 4px rgba(11,30,63,0.08);
  flex-shrink: 0;
  transition: transform 0.3s var(--ease), border-color 0.3s var(--ease);
}
.tpl-thumb-icon {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(11,30,63,0.10));
  transition: transform 0.3s var(--ease);
}
.template-list button:hover .tpl-thumb { transform: rotate(-3deg); border-color: var(--blue-700); }
.template-list button:hover .tpl-thumb-icon { transform: rotate(8deg) scale(1.08); }
.template-list button.is-active .tpl-thumb { transform: rotate(2deg); }
.template-list button.is-active .tpl-thumb-icon { transform: rotate(-4deg); background: var(--paper); }
.tpl-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.tpl-meta strong { font-size: 0.92rem; font-weight: 600; }
.tpl-meta small { font-size: 0.74rem; color: var(--muted); margin-top: 2px; }
.template-list button.is-active .tpl-meta small { color: rgba(255,255,255,0.6); }

/* ───────── Toolbar ───────── */
.designer__toolbar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.designer__toolbar button,
.designer__toolbar .tool-upload {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.7rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s, transform 0.2s;
}
.designer__toolbar button svg,
.designer__toolbar .tool-upload svg {
  width: 16px;
  height: 16px;
  color: var(--blue-700);
}
.designer__toolbar button:hover,
.designer__toolbar .tool-upload:hover {
  border-color: var(--blue-700);
  background: var(--paper);
  transform: translateY(-1px);
}
.tool-color {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.55rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
}
.tool-color input { width: 28px; height: 28px; padding: 0; border: 0; background: transparent; cursor: pointer; }
.toolbar-sep { width: 1px; height: 22px; background: var(--line); margin: 0 0.2rem; }
.tool-danger { color: var(--red-600) !important; }
.tool-danger svg { color: var(--red-500) !important; }
.toolbar-group { display: inline-flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }

/* Undo/redo + view toggles */
.designer__toolbar button:disabled { opacity: 0.4; cursor: not-allowed; }
.designer__toolbar button:disabled:hover { transform: none; border-color: var(--line); background: var(--white); }
.tool-toggle.is-active {
  background: var(--blue-900);
  border-color: var(--blue-900);
  color: var(--white);
}
.tool-toggle.is-active svg { color: var(--white); }
.tool-toggle:hover.is-active {
  background: var(--blue-700);
  border-color: var(--blue-700);
}

.autosave-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  margin-left: auto;
  min-height: 32px;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease);
}
.autosave-pill::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.25s var(--ease);
}
.autosave-pill.is-saved {
  color: #16A34A;
  border-color: #BBF7D0;
}
.autosave-pill.is-saved::before {
  background: #16A34A;
  animation: savePulse 1.6s var(--ease);
}
@keyframes savePulse {
  0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.6); }
  100% { box-shadow: 0 0 0 8px rgba(22, 163, 74, 0); }
}

/* ───────── Canvas ───────── */
.canvas-wrap {
  position: relative;
  padding: clamp(1rem, 3vw, 2rem);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 460px;
  background:
    repeating-conic-gradient(#f0eee5 0% 25%, #f6f4ec 0% 50%) 0 / 24px 24px;
}
#designCanvas {
  display: block;
  max-width: 100%;
  height: auto;
  background: #fff;
  box-shadow:
    0 1px 0 rgba(0,0,0,0.04),
    0 30px 50px -20px rgba(11,30,63,0.4);
  cursor: crosshair;
  border-radius: 2px;
  touch-action: none;
}
/* In-canvas text editor (contenteditable overlay). Positioned and styled
   on the fly by JS to match the underlying text element. */
.canvas-text-editor {
  position: absolute;
  background: rgba(255, 255, 255, 0.96);
  outline: 2px solid var(--blue-700);
  outline-offset: 1px;
  border-radius: 4px;
  padding: 0;
  margin: 0;
  z-index: 4;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  cursor: text;
  box-shadow: 0 12px 28px rgba(11, 30, 63, 0.18);
  caret-color: var(--blue-700);
}
.canvas-text-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  pointer-events: none;
}

.canvas-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  color: var(--muted);
  text-align: center;
  gap: 0.5rem;
  padding: 2rem;
}
.canvas-empty.is-hidden { display: none; }
.canvas-empty::before {
  content: '';
  width: 56px;
  height: 56px;
  margin-bottom: 0.6rem;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--blue-100) 30%, transparent 32%) center/100% 100% no-repeat,
    linear-gradient(var(--blue-700), var(--blue-700)) center/2px 28px no-repeat,
    linear-gradient(var(--blue-700), var(--blue-700)) center/28px 2px no-repeat;
  position: relative;
  animation: canvasReticle 3.2s var(--ease) infinite;
}
@keyframes canvasReticle {
  0%, 100% { transform: rotate(0); opacity: 0.7; }
  50%      { transform: rotate(45deg); opacity: 1; }
}
.canvas-empty__title {
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--blue-900);
}
.canvas-empty__hint { font-size: 0.9rem; max-width: 30ch; line-height: 1.5; }

/* ───────── Properties ───────── */
.props-empty {
  padding: 1.4rem 1.3rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.props-panel { padding: 1rem 1.3rem 0.5rem; display: grid; gap: 0.7rem; }
.props-panel .field { display: flex; flex-direction: column; gap: 0.3rem; }
.props-panel label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  color: var(--muted);
}
.props-panel input,
.props-panel select,
.props-panel textarea {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.88rem;
  background: var(--paper);
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.props-panel input:focus,
.props-panel select:focus,
.props-panel textarea:focus {
  border-color: var(--blue-700);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(30,58,138,0.12);
}
.props-panel input[type="color"] {
  height: 38px;
  padding: 2px;
  cursor: pointer;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }

.props-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--line);
  margin-top: 0.4rem;
}
.btn-mini {
  padding: 0.55rem 0.5rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.btn-mini:hover { border-color: var(--blue-700); background: var(--white); }
.btn-mini--danger { color: var(--red-600); border-color: var(--red-100); }
.btn-mini--danger:hover { background: var(--red-600); color: var(--white); border-color: var(--red-600); }

/* ───────── Layers ───────── */
.layer-list {
  padding: 0.5rem 0.9rem 1rem;
  display: grid;
  gap: 0.3rem;
}
.layer-list__empty {
  padding: 0.6rem 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.layer-list li.layer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.layer-list li.layer:hover { border-color: var(--blue-700); }
.layer-list li.layer.is-selected {
  background: var(--blue-100);
  border-color: var(--blue-700);
}
.layer__icon {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  background: var(--white);
  border: 1px solid var(--line);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--blue-700);
}
.layer__name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.layer__remove {
  width: 22px; height: 22px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  color: var(--muted);
  background: transparent;
  border: 0;
  cursor: pointer;
}
.layer__remove:hover { background: var(--red-100); color: var(--red-600); }

/* ───────── Quote section ───────── */
.design-quote {
  padding: clamp(3rem, 6vw, 5rem) 0;
  background: linear-gradient(135deg, var(--blue-900) 0%, var(--blue-800) 100%);
  color: var(--paper);
  position: relative;
  overflow: hidden;
}
.design-quote::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 90% 10%, rgba(220,38,38,0.18), transparent 40%),
    radial-gradient(circle at 10% 80%, rgba(30,58,138,0.4), transparent 50%);
  pointer-events: none;
}
.design-quote .container { position: relative; }
.design-quote__inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2rem, 4vw, 4rem);
  align-items: start;
}
@media (max-width: 900px) { .design-quote__inner { grid-template-columns: 1fr; } }

.design-quote__copy h2 {
  color: var(--paper);
  font-size: clamp(1.8rem, 3.2vw, 2.6rem);
  margin-top: 0.6rem;
}
.design-quote__copy h2 em { font-style: italic; color: var(--red-400); }
.design-quote__copy p { color: rgba(255,255,255,0.78); margin-top: 1rem; max-width: 50ch; }
.design-quote__copy .eyebrow { color: var(--red-400); }

.design-quote__preview {
  margin-top: 2rem;
  padding: 1rem;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.04);
  border: 1px dashed rgba(255,255,255,0.18);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 460px;
}
.design-quote__preview-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: rgba(255,255,255,0.55);
}
.design-quote__preview img {
  display: block;
  max-width: 100%;
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

/* Container only — let the global floating-label system style the fields */
.design-quote__form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 2rem;
  background: var(--white);
  color: var(--ink);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.design-quote__form .field--full { grid-column: 1 / -1; }
.design-quote__form .btn { grid-column: 1 / -1; justify-self: stretch; }
.design-quote__ok {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0.9rem 1rem;
  background: var(--blue-100);
  color: var(--blue-900);
  border-radius: var(--radius);
  font-weight: 500;
}
.design-quote__ok.is-error {
  background: rgba(191, 37, 25, 0.1);
  color: #8a1810;
}
@media (max-width: 540px) { .design-quote__form { grid-template-columns: 1fr; padding: 1.4rem; } }

/* ───────── Brand color palette ───────── */
.palette {
  margin-top: 0.5rem;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
}
.palette__sw {
  aspect-ratio: 1 / 1;
  border-radius: 4px;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 0.18s var(--ease), border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
  padding: 0;
}
.palette__sw:hover {
  transform: scale(1.18);
  border-color: var(--blue-700);
  box-shadow: 0 4px 12px rgba(11, 30, 63, 0.15);
  z-index: 1;
}

/* ───────── Segmented control (text alignment) ───────── */
.seg-control {
  display: inline-flex;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
  width: max-content;
}
.seg-control button {
  width: 38px;
  height: 32px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink-soft);
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.seg-control button svg { width: 16px; height: 16px; }
.seg-control button:hover { background: var(--white); color: var(--blue-900); }
.seg-control button.is-active { background: var(--blue-900); color: var(--white); }

/* ───────── Align-to-canvas grid ───────── */
.align-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.3rem;
}
.align-grid .btn-mini {
  padding: 0.55rem 0;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
}

/* ───────── Canvas legend (bleed/safe key) ───────── */
.canvas-legend {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  display: flex;
  gap: 1rem;
  font-size: 0.7rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(11, 30, 63, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  pointer-events: none;
  white-space: nowrap;
}
.canvas-legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.canvas-legend i {
  display: inline-block;
  width: 14px;
  height: 0;
  border-top: 1.5px dashed currentColor;
}
.canvas-legend__bleed { border-color: rgba(255, 110, 110, 0.95) !important; color: rgba(255, 110, 110, 0.95); }
.canvas-legend__safe  { border-color: rgba(140, 175, 245, 0.95) !important; color: rgba(140, 175, 245, 0.95); }
