/* LinksBuilder — editor (/crear). Chrome tokens and retro layer come from sinapsialab.css.
   Mobile-first: tabs (Editar / Vista previa) below 768px, two columns above.
   The preview iframe renders the user's theme and stays outside the retro layer. */

/* ── Topbar actions ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4375rem;
  min-height: 2.75rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn svg { flex-shrink: 0; }

.btn-ghost {
  background: var(--portfolio-accent);
  color: var(--portfolio-text);
}

.btn-ghost:hover {
  background: var(--portfolio-orange);
  color: var(--portfolio-dark);
}

.topbar-actions .btn span { display: none; }

/* ── Mobile tab bar ── */
.mobile-tabs {
  --mobile-tabs-height: 2.875rem;
  display: flex;
  position: sticky;
  top: var(--topbar-height);
  z-index: 99;
  height: var(--mobile-tabs-height);
  background: var(--portfolio-dark);
  border-bottom: var(--retro-border-width) solid var(--portfolio-accent);
}

.mobile-tab-btn {
  flex: 1;
  padding: 0 0.75rem;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--portfolio-text-muted);
  font-size: 0.8125rem;
  text-transform: capitalize;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  transition: color 0.15s, border-color 0.15s;
}

.mobile-tab-btn.active {
  color: var(--portfolio-text-light);
  font-weight: 500;
  border-bottom-color: var(--portfolio-orange);
}

/* ── Main layout ── */
.app-body {
  display: grid;
  grid-template-columns: 1fr;
  flex: 1;
  min-height: calc(100dvh - var(--topbar-height) - 2.875rem);
}

/* ── Form panel ── */
.form-panel {
  display: none;
  min-width: 0;
  flex-direction: column;
  gap: 1.75rem;
  padding: 1.25rem 1rem;
  background: var(--portfolio-dark);
}

.form-panel.tab-active { display: flex; }

.form-panel::-webkit-scrollbar { width: 6px; }
.form-panel::-webkit-scrollbar-track { background: var(--portfolio-dark); }
.form-panel::-webkit-scrollbar-thumb { background: rgb(139 92 246 / 0.5); border-radius: 4px; }

.section-label {
  font-size: 0.75rem;
  font-weight: var(--font-retro-weight-display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--portfolio-light);
  margin-bottom: 0.875rem;
}

.field { display: flex; flex-direction: column; gap: 0.375rem; margin-bottom: 0.875rem; }
.field:last-child { margin-bottom: 0; }
.field label { font-size: 0.8125rem; color: var(--portfolio-text-light); }
.field label span.opt { color: var(--portfolio-text-faint); font-size: 0.75rem; }

/* Retro inputs (clone of .input-retro) — applies to JS-generated link fields too. */
input[type="text"],
input[type="url"],
textarea {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  background: var(--portfolio-base);
  color: var(--portfolio-text);
  border: var(--retro-border-width) solid var(--portfolio-accent);
  border-radius: var(--retro-radius);
  box-shadow: var(--retro-shadow);
  outline: none;
  transition: border-color 0.15s;
}

input[type="text"]:focus,
input[type="url"]:focus,
textarea:focus { border-color: var(--portfolio-orange); }

textarea { resize: vertical; min-height: 4.375rem; }
input::placeholder, textarea::placeholder { color: var(--portfolio-text-faint); }

.slug-input-wrap {
  display: flex;
  align-items: stretch;
  background: var(--portfolio-base);
  border: var(--retro-border-width) solid var(--portfolio-accent);
  border-radius: var(--retro-radius);
  box-shadow: var(--retro-shadow);
  overflow: hidden;
  transition: border-color 0.15s;
}

.slug-input-wrap:focus-within { border-color: var(--portfolio-orange); }
.slug-input-wrap.is-ok,
.slug-input-wrap.is-ok:focus-within { border-color: var(--status-success); }
.slug-input-wrap.is-error,
.slug-input-wrap.is-error:focus-within { border-color: var(--status-error); }

.slug-prefix {
  display: inline-flex;
  align-items: center;
  padding: 0 0.625rem;
  font-size: 0.8125rem;
  color: var(--portfolio-orange);
  background: var(--portfolio-medium);
  border-right: var(--retro-border-width) solid var(--portfolio-accent);
  white-space: nowrap;
}

.slug-input-wrap input {
  flex: 1;
  min-width: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

.slug-hint {
  font-size: 0.75rem;
  color: var(--portfolio-text-muted);
  line-height: 1.35;
  margin-top: 0.25rem;
}

.slug-status {
  min-height: 1.125rem;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--portfolio-text-muted);
  overflow-wrap: anywhere;
}

.publish-hint {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  line-height: 1.35;
  text-align: center;
  color: var(--portfolio-text-muted);
}

.publish-hint:empty { display: none; }

.slug-status.ok { color: var(--status-success); }
.slug-status.warn { color: var(--status-warn); }
.slug-status.error { color: var(--status-error); }

/* ── Logo upload ── */
.logo-upload-area {
  position: relative;
  padding: 1.25rem;
  text-align: center;
  cursor: pointer;
  background: var(--portfolio-base);
  border: var(--retro-border-width) dashed var(--portfolio-gradient-4);
  border-radius: var(--retro-radius);
  transition: border-color 0.15s, background-color 0.15s;
}

.logo-upload-area:hover {
  border-color: var(--portfolio-orange);
  background: var(--portfolio-orange-soft);
}

.logo-upload-area.has-image { padding: 0.75rem; }

.logo-upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.logo-preview-img {
  display: block;
  width: 4.5rem;
  height: 4.5rem;
  margin: 0 auto 0.5rem;
  border-radius: 50%;
  object-fit: cover;
  border: var(--retro-border-width) solid var(--portfolio-accent);
}

.logo-upload-text { font-size: 0.8125rem; color: var(--portfolio-text-muted); line-height: 1.5; }
.logo-upload-text strong { color: var(--portfolio-orange); font-weight: 500; }
.logo-upload-icon { display: block; font-size: 1.5rem; margin-bottom: 0.375rem; }

/* Round × on the corner of the upload area (above the invisible file input). */
.logo-remove-btn {
  position: absolute; top: -0.5rem; right: -0.5rem; z-index: 1;
  width: 1.5rem; height: 1.5rem; padding: 0;
  display: grid; place-items: center;
  border: 1px solid var(--portfolio-border, #444); border-radius: 50%;
  background: var(--portfolio-dark, #1a1a1a); color: var(--portfolio-text-light);
  font-size: 1rem; line-height: 1; cursor: pointer;
}
.logo-remove-btn:hover { background: var(--status-error, #e5484d); color: var(--portfolio-dark, #1a1a1a); }

/* ── Themes (swatches render the user's theme colors) ── */
.themes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.625rem;
}

.theme-card {
  overflow: hidden;
  cursor: pointer;
  border: var(--retro-border-width) solid var(--portfolio-accent);
  border-radius: var(--retro-radius);
  box-shadow: var(--retro-shadow);
  transition: box-shadow 0.15s, border-color 0.15s;
}

.theme-card:hover { box-shadow: var(--retro-shadow), var(--retro-glow); }

.theme-card.active {
  border-color: var(--portfolio-orange);
  box-shadow: var(--retro-shadow-hover);
}

.theme-card.locked { opacity: 0.45; cursor: not-allowed; }
.theme-card.locked:hover { box-shadow: var(--retro-shadow); }

.theme-swatch {
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.theme-dot { width: 0.625rem; height: 0.625rem; border-radius: 50%; }

.theme-label {
  padding: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 500;
  text-align: center;
  letter-spacing: 0.03em;
}

/* ── Custom colors ── */
.custom-colors-section { display: none; }
.custom-colors-section.visible { display: block; }

.color-pickers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.color-picker-item { display: flex; flex-direction: column; gap: 0.3125rem; }
.color-picker-item label { font-size: 0.75rem; color: var(--portfolio-text-muted); }

.color-picker-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3125rem 0.5rem;
  background: var(--portfolio-base);
  border: var(--retro-border-width) solid var(--portfolio-accent);
  border-radius: var(--retro-radius);
  box-shadow: var(--retro-shadow);
}

.color-picker-row:focus-within { border-color: var(--portfolio-orange); }

input[type="color"] {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  padding: 2px;
  border: none;
  border-radius: 3px;
  background: none;
  cursor: pointer;
}

.color-hex-input {
  width: 4.5rem;
  padding: 0;
  background: none;
  border: none;
  outline: none;
  color: var(--portfolio-text);
  font-size: 0.75rem;
}

/* ── Links ── */
.links-header {
  display: flex;
  align-items: center;
  margin-bottom: 0.875rem;
}

.links-header .section-label { margin-bottom: 0; }

.links-list { display: flex; flex-direction: column; gap: 0.875rem; }

.link-card {
  padding: 0.875rem;
  background: var(--portfolio-base);
  border: var(--retro-border-width) solid var(--portfolio-accent);
  border-radius: var(--retro-radius);
  box-shadow: var(--retro-shadow);
  transition: border-color 0.15s;
}

.link-card:focus-within { border-color: var(--portfolio-gradient-4); }

.link-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.625rem;
}

.link-number {
  padding: 0.125rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: var(--font-retro-weight-display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--portfolio-text-light);
  background: var(--portfolio-gradient-3);
  border-radius: var(--retro-radius);
}

.link-drag {
  flex: none;
  width: 2rem;
  min-height: 2.75rem;
  margin: -0.5rem 0.25rem -0.5rem -0.5rem;
  padding: 0;
  background: none;
  border: none;
  color: var(--portfolio-text-muted);
  font-size: 1.125rem;
  line-height: 1;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.link-drag:active { cursor: grabbing; }
.link-card.is-dragging {
  border-color: var(--portfolio-orange);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  opacity: 0.92;
}

.link-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
  min-height: 2.75rem;
  margin: -0.5rem 0;
  padding: 0;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.link-summary {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.75rem;
  color: var(--portfolio-text-muted);
}
.link-chevron { color: var(--portfolio-text-muted); transition: transform 0.15s; }
.link-card.is-collapsed .link-chevron { transform: rotate(-90deg); }
.link-card.is-collapsed .link-fields { display: none; }
.link-card.is-collapsed .link-card-header { margin-bottom: 0; }

.link-remove-btn {
  min-width: 2.75rem;
  min-height: 2.75rem;
  margin: -0.5rem -0.5rem -0.5rem 0;
  background: none;
  border: none;
  color: var(--portfolio-text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s;
}

.link-remove-btn:hover { color: var(--status-error); }

.link-fields { display: flex; flex-direction: column; gap: 0.625rem; }
.link-fields input, .link-fields textarea { font-size: 0.8125rem; box-shadow: none; }

.add-link-btn {
  width: 100%;
  min-height: 2.75rem;
  margin-top: 0.875rem;
  padding: 0.625rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  cursor: pointer;
  background: var(--portfolio-accent);
  color: var(--portfolio-text-light);
}

.add-link-btn:hover {
  background: var(--portfolio-orange);
  color: var(--portfolio-dark);
}

.add-link-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.add-link-btn:disabled:hover {
  background: var(--portfolio-accent);
  color: var(--portfolio-text-light);
  box-shadow: var(--retro-shadow);
}

.links-count-badge {
  margin-left: auto;
  padding: 0.125rem 0.5rem;
  font-size: 0.6875rem;
  color: var(--portfolio-text-muted);
  background: var(--portfolio-base);
  border: var(--retro-border-width) solid var(--portfolio-accent);
  border-radius: var(--retro-radius);
}

/* ── Section divider ── */
.section-divider {
  border: none;
  border-top: var(--retro-border-width) dashed var(--portfolio-medium);
  margin: 0;
}

/* ── Publish ── */
.form-actions {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  padding: 1rem 0 0.25rem;
}

.form-actions .cta-glow { width: 100%; }

.publish-btn {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: 3rem;
  padding: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  background: var(--portfolio-gradient-3);
  color: var(--portfolio-text-light);
}

.publish-btn:hover {
  background: var(--portfolio-orange);
  color: var(--portfolio-dark);
  text-shadow: none;
}

.publish-btn[disabled] {
  cursor: not-allowed;
  opacity: 0.65;
}

.publish-btn[disabled]:hover {
  background: var(--portfolio-gradient-3);
  color: var(--portfolio-text-light);
  box-shadow: var(--retro-shadow);
}

.publish-status {
  display: none;
  padding: 0.875rem;
  line-height: 1.35;
  background: var(--portfolio-base);
  border: var(--retro-border-width) solid var(--portfolio-accent);
  border-radius: var(--retro-radius);
  box-shadow: var(--retro-shadow);
}

.publish-status.show { display: block; }

.publish-status.info {
  color: var(--portfolio-text-light);
  border-color: var(--portfolio-orange);
}

.publish-status.success {
  color: var(--portfolio-text-light);
  background: var(--portfolio-gradient-1);
  border-color: var(--portfolio-gradient-4);
}

.publish-status.error {
  color: var(--portfolio-text-light);
  border-color: var(--status-error);
}

.publish-status-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.publish-status-icon {
  flex-shrink: 0;
  width: 2.375rem;
  height: 2.375rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--portfolio-dark);
  background: var(--portfolio-orange);
  border-radius: var(--retro-radius);
}

.publish-status.success .publish-status-icon { background: var(--status-success); }
.publish-status.error .publish-status-icon { background: var(--status-error); }

.publish-status-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.publish-status-kicker {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--portfolio-orange);
}

.publish-status.success .publish-status-kicker { color: var(--portfolio-light); }
.publish-status.error .publish-status-kicker { color: var(--status-error); }

.publish-status-title { font-size: 0.9375rem; font-weight: 700; line-height: 1.2; }
.publish-status-text { font-size: 0.75rem; color: var(--portfolio-text); }

.publish-status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.publish-status-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.5rem 0.875rem;
  font-size: 0.75rem;
  text-decoration: none;
  word-break: break-word;
  background: var(--portfolio-orange);
  color: var(--portfolio-dark);
}

.publish-status-link:hover {
  background: var(--portfolio-text-light);
  color: var(--portfolio-dark);
}

.form-note .gradient-link { display: inline-flex; align-items: center; min-height: 2.75rem; }

.form-note {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: var(--portfolio-text);
  text-align: center;
}

/* ── Preview panel ── */
.preview-panel {
  display: none;
  flex-direction: column;
  height: calc(100dvh - var(--topbar-height) - 2.875rem);
  overflow: hidden;
  background: var(--portfolio-deep);
}

.preview-panel.tab-active { display: flex; }

.preview-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  background: var(--portfolio-dark);
  border-bottom: var(--retro-border-width) solid var(--portfolio-accent);
}

.preview-title {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--portfolio-light);
}

.preview-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--status-success);
}

.preview-modes { display: flex; gap: 0.5rem; }

.preview-mode-btn {
  min-height: 2.25rem;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  cursor: pointer;
  background: var(--portfolio-accent);
  color: var(--portfolio-text);
}

.preview-open-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  padding: 0.25rem 0.5rem;
}

.preview-mode-btn:hover {
  background: var(--portfolio-orange);
  color: var(--portfolio-dark);
}

.preview-mode-btn.active {
  background: var(--portfolio-gradient-3);
  color: var(--portfolio-text-light);
  font-weight: 500;
}

.preview-container {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow: hidden;
}

/* The stage takes the scaled size of the device (set by fitPreview in builder.js),
   so the real-size frame inside can be shrunk with transform without leaving empty space. */
.phone-stage {
  position: relative;
  flex-shrink: 0;
}

/* Device frame: real device proportions, scaled to fit. Chrome around the preview (retro). */
.phone-frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 25rem;
  height: 50rem;
  transform-origin: top left;
  overflow: hidden;
  background: var(--portfolio-deep);
  border: 10px solid var(--portfolio-medium);
  border-radius: 2.25rem;
  box-shadow: var(--retro-shadow-lg);
}

.phone-frame.desktop-mode {
  width: 80rem;
  height: 50rem;
  border-radius: var(--retro-radius-lg);
}

.preview-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}

.preview-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  font-size: 0.875rem;
  color: var(--portfolio-text-muted);
}

.preview-empty svg { opacity: 0.3; }

.phone-notch {
  position: absolute;
  top: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  width: 3.75rem;
  height: 0.3125rem;
  border-radius: 0.625rem;
  background: var(--portfolio-medium);
  pointer-events: none;
}

/* ── ≥ 768px: two columns ── */
@media (min-width: 768px) {
  .topbar-actions .btn { padding: 0.5rem 1rem; font-size: 0.8125rem; }
  .topbar-actions .btn span { display: inline; }

  .mobile-tabs { display: none; }

  .app-body {
    flex: none;
    grid-template-columns: 24rem 1fr;
    grid-template-rows: minmax(0, 1fr);
    min-height: 0;
    height: calc(100dvh - var(--topbar-height));
  }

  .form-panel,
  .form-panel.tab-active {
    display: flex;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 1.5rem;
    border-right: var(--retro-border-width) solid var(--portfolio-accent);
  }

  .preview-panel,
  .preview-panel.tab-active {
    display: flex;
    height: auto;
  }

  .preview-topbar { padding: 0.75rem 1.25rem; }
  .preview-container { padding: 1.5rem; }

}

@media (min-width: 1024px) {
  .app-body { grid-template-columns: 26.25rem 1fr; }
}

.custom-colors-field { margin-top: 0.75rem; }
.custom-colors-section.visible { margin-bottom: 0.25rem; }

/* Unchecked gradient: the second color is visible but clearly off. */
.check-row:has(input:not(:checked)) + .color-picker-row { opacity: 0.5; }

/* ── Style groups: link buttons, typography ── */
.style-group {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: var(--retro-border-width) dashed var(--portfolio-accent);
}

.style-group-title {
  margin-bottom: 0.75rem;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--portfolio-light);
}

.style-group .field { margin-bottom: 1rem; }
.style-group .chip-row { padding-bottom: 0.375rem; }

.button-colors { display: none; margin-bottom: 1rem; }
.button-colors.visible { display: block; }

/* Text color of the button only matters when the button is filled. */
.button-colors[data-mode='card'] .color-picker-item--text,
.button-colors[data-mode='outline'] .color-picker-item--text { opacity: 0.45; }

.button-hint {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--portfolio-text-muted);
}

/* Font picker: search + short scrollable list grouped by kind */
.font-search {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--portfolio-text);
  background: var(--portfolio-base);
  border: var(--retro-border-width) solid var(--portfolio-accent);
  border-radius: var(--retro-radius);
}

.font-search:focus { outline: none; border-color: var(--portfolio-orange); }

.font-current {
  margin: 0.5rem 0;
  font-size: 0.75rem;
  color: var(--portfolio-text-muted);
}

.font-current strong { color: var(--portfolio-light); }

.font-list {
  max-height: 13rem;
  overflow-y: auto;
  padding: 0.25rem 0.5rem 0.5rem;
  background: var(--portfolio-base);
  border: var(--retro-border-width) solid var(--portfolio-accent);
  border-radius: var(--retro-radius);
}

.font-group-title {
  margin: 0.5rem 0 0.25rem;
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--portfolio-text-faint);
}

.font-option {
  display: block;
  width: 100%;
  min-height: 2.5rem;
  padding: 0.375rem 0.625rem;
  font: inherit;
  font-size: 0.8125rem;
  text-align: left;
  color: var(--portfolio-text);
  background: transparent;
  border: var(--retro-border-width) solid transparent;
  border-radius: var(--retro-radius);
  cursor: pointer;
}

.font-option:hover { background: var(--portfolio-medium); }
.font-option.active { border-color: var(--portfolio-orange); color: var(--portfolio-light); }
.font-option.locked { opacity: 0.55; }

.font-option[hidden],
.font-group[hidden],
.font-empty[hidden] { display: none; }

.font-empty { margin: 0.75rem 0; font-size: 0.75rem; color: var(--portfolio-text-muted); }

/* ── Pro options: style chips, gradient, featured links ── */
.pro-badge {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0.0625rem 0.375rem;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--portfolio-dark);
  background: var(--portfolio-orange);
  border-radius: var(--retro-radius);
  vertical-align: middle;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.chip {
  min-height: 2.75rem;
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
  color: var(--portfolio-text);
  background: var(--portfolio-base);
  border: var(--retro-border-width) solid var(--portfolio-accent);
  border-radius: var(--retro-radius);
  cursor: pointer;
}

.chip.active { border-color: var(--portfolio-orange); box-shadow: var(--retro-shadow-hover); }
.chip.locked { opacity: 0.55; }

.pro-note {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--portfolio-text-muted);
}

.pro-note a { color: var(--portfolio-orange); }
.pro-note.flash { animation: pro-note-flash 0.9s ease; }

@keyframes pro-note-flash {
  0%, 60% { color: var(--portfolio-orange); }
  100% { color: var(--portfolio-text-muted); }
}

.check-row { display: flex; align-items: center; gap: 0.5rem; }

.socials-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.75rem; }
.social-row { display: flex; align-items: center; gap: 0.5rem; }
.social-row .link-remove-btn { flex: none; min-width: 2.25rem; }
.social-row select {
  flex: 0 0 7.25rem;
  min-height: 2.75rem;
  padding: 0.625rem 1.75rem 0.625rem 0.75rem;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--portfolio-text);
  background-color: var(--portfolio-base);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23a79bb8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
  border: var(--retro-border-width) solid var(--portfolio-accent);
  border-radius: var(--retro-radius);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
.social-row select:focus { border-color: var(--portfolio-orange); }
.social-row select option { background: var(--portfolio-base); color: var(--portfolio-text); }
.social-row input { flex: 1; min-width: 0; min-height: 2.75rem; font-size: 0.8125rem; box-shadow: none; }
.social-row .link-remove-btn { margin: 0; }

.link-featured {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  font-size: 0.8125rem;
  color: var(--portfolio-text-light);
  cursor: pointer;
}

.link-image-row { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.link-image-thumb { position: relative; display: inline-flex; width: 2.75rem; height: 2.75rem; }
.link-image-thumb[hidden] { display: none; }
.link-image-preview { width: 100%; height: 100%; border-radius: 0.5rem; object-fit: cover; }
.link-image-btn {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 0.875rem;
  border: 1px dashed var(--portfolio-border, #444);
  border-radius: 0.5rem;
  background: transparent;
  color: var(--portfolio-text-light);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
}
/* Round × on the thumbnail corner: removing is a small, obvious gesture, not a second big button. */
.link-image-remove {
  position: absolute; top: -0.5rem; right: -0.5rem;
  width: 1.5rem; height: 1.5rem; padding: 0;
  display: grid; place-items: center;
  border: 1px solid var(--portfolio-border, #444); border-radius: 50%;
  background: var(--portfolio-dark, #1a1a1a); color: var(--portfolio-text-light);
  font-size: 1rem; line-height: 1; cursor: pointer;
}
.link-image-remove:hover { background: var(--status-error, #e5484d); color: var(--portfolio-dark, #1a1a1a); }
.link-image-btn.is-busy { opacity: 0.5; pointer-events: none; }

/* Upload feedback, next to the image it belongs to. */
.upload-status { flex-basis: 100%; margin: 0.5rem 0 0; font-size: 0.8125rem; color: var(--portfolio-text-muted); }
.link-image-row .upload-status { margin: 0; }
.upload-status[hidden] { display: none; }
.upload-status[data-type="error"] { color: var(--status-error); }
.upload-status[data-type="loading"]::before {
  content: ''; display: inline-block; width: 0.75em; height: 0.75em; margin-right: 0.5em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  vertical-align: -0.1em; animation: upload-spin 0.8s linear infinite;
}
@keyframes upload-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .upload-status[data-type="loading"]::before { animation: none; } }
.is-uploading .link-image-preview,
.is-uploading .logo-preview-img { opacity: 0.4; }

.link-featured.locked { opacity: 0.55; cursor: not-allowed; }


/* Link address validation */
.link-fields input.invalid { border-color: var(--status-error); }

.field-error {
  margin: -0.25rem 0 0;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--status-error);
}

.field-error[hidden] { display: none; }

/* Starting templates */
.template-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.625rem;
  margin-bottom: 0.5rem;
}

.template-card {
  min-width: 0;
  min-height: 2.75rem;
  padding: 0 0.75rem;
  overflow-wrap: anywhere;
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  color: var(--portfolio-text);
  background: var(--portfolio-medium);
}

.template-card:hover {
  background: var(--portfolio-orange);
  color: var(--portfolio-dark);
}

#templatesSection[hidden],
#templatesDivider[hidden] { display: none; }

/* Four columns only while the form takes the whole width (tab layout, 640-767px). From 768px the form is a
   24rem side column, where four columns overflow it and add a horizontal scrollbar. */
@media (min-width: 40rem) and (max-width: 47.99rem) {
  .template-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Layout blocks (section title, divider) */
.add-block-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.625rem;
  margin-top: 0.625rem;
}

.add-block-btn {
  min-height: 2.5rem;
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  color: var(--portfolio-text);
  background: var(--portfolio-medium);
}

.add-block-btn:hover:not(:disabled) {
  background: var(--portfolio-orange);
  color: var(--portfolio-dark);
}

.add-block-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.block-note {
  margin: 0;
  font-size: 0.75rem;
  color: var(--portfolio-text-muted);
}
