/* ============================================================
   Hidook Builder — app.css  (S71: paper / ink / terracotta)
   Art direction from Awwwards research DESIGN.md — not indigo SaaS
   Mobile-first, Newsreader + Inter, zero framework
   ============================================================ */

/* ---------- CSS Variables ---------- */
:root {
  --accent:        #9A4030;
  --accent-hover:  #7C3226;
  --accent-light:  #F3E6E1;
  --accent-muted:  #D4A89A;
  --bg:            #F3EFE8;
  --surface:       #FFFcf7;
  --border:        #D9D2C6;
  --border-focus:  #1E3A32;
  --text:          #14120F;
  --text-muted:    #5C564E;
  --text-light:    #8A8378;
  --forest:        #1E3A32;
  --ink:           #14120F;
  --paper:         #F3EFE8;
  --error:         #DC2626;
  --error-bg:      #FEF2F2;
  --success:       #16A34A;
  --success-bg:    #DCFCE7;
  --warning:       #D97706;
  --warning-bg:    #FFFBEB;
  --radius:        8px;
  --radius-sm:     2px;
  --radius-md:     8px;
  --radius-lg:     12px;
  --radius-xl:     12px;
  --shadow-sm:     0 1px 2px rgba(20,18,15,.04);
  --shadow-md:     0 8px 24px rgba(20,18,15,.06);
  --shadow-lg:     0 12px 40px rgba(20,18,15,.08);
  --shadow-feature: 0 12px 40px rgba(20,18,15,.08);
  --header-h:      56px;
  --topbar-h:      52px;
  --transition:    0.16s ease;
  --transition-md: 0.18s ease;
  --font-display:  "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-ui:       "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --content-max:   1200px;
}

/* ---------- Reset / Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--forest);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
button { cursor: pointer; font-family: inherit; border: none; background: none; }
img { max-width: 100%; display: block; }
input, textarea, select {
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
}

/* ---------- Loading overlay ---------- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 9999;
  font-size: 0.92rem;
  color: var(--text-muted);
  transition: opacity var(--transition-md);
}
.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ---------- Spinners ---------- */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.spinner--sm { width: 22px; height: 22px; border-width: 2px; }
.spinner--xs { width: 14px; height: 14px; border-width: 2px; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Header (visible on non-edit screens) ---------- */
.app-header {
  position: sticky;
  top: 0;
  height: var(--header-h);
  background: rgba(255, 252, 247, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 0.75rem;
  z-index: 200;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}
.logo:hover { text-decoration: none; opacity: 0.82; }
.logo-mark {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1;
}
.logo-word { font-weight: 600; }
@media (max-width: 420px) {
  .logo-word-full { display: none; }
}

.header-nav {
  display: flex;
  gap: 0.1rem;
  flex: 1;
  min-width: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.header-nav::-webkit-scrollbar { display: none; }
.header-nav a {
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color var(--transition);
  /* S111: never shred «Cum e» / «Proiectele mele» mid-word at 390. */
  white-space: nowrap;
  flex-shrink: 0;
}
.header-nav a:hover { color: var(--text); text-decoration: none; }
.header-nav a.active {
  color: var(--text);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.35em;
  text-decoration-thickness: 1.5px;
}
@media (max-width: 420px) {
  .app-header {
    padding: 0 0.65rem;
    gap: 0.35rem;
  }
  .header-nav a {
    padding: 0.3rem 0.45rem;
    font-size: 0.8rem;
  }
}

/* Beat .btn-primary { display: inline-flex } (same single-class specificity, later in file) */
.app-header a.header-cta,
.app-header .header-cta {
  display: none;
  margin-left: 0.35rem;
}
@media (min-width: 640px) {
  .app-header a.header-cta,
  .app-header .header-cta {
    display: inline-flex;
  }
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}
.user-badge {
  font-size: 0.8rem;
  color: var(--text-muted);
  /* S111: keep email one token — ellipsis if tight, never letter-shred (break-word). */
  max-width: min(220px, 36vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
  line-height: 1.25;
  flex-shrink: 1;
  min-width: 0;
}
@media (max-width: 420px) {
  .user-badge {
    max-width: min(148px, 34vw);
    font-size: 0.72rem;
  }
}

/* ---------- Editor Topbar ---------- */
.editor-topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  gap: 0.5rem;
  z-index: 200;
}

.editor-topbar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.editor-topbar-center {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.editor-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  justify-content: flex-end;
}

.editor-tpl-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-topbar-back-label {
  display: none;
}
@media (min-width: 480px) {
  .editor-topbar-back-label { display: inline; }
}

.btn-topbar {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  white-space: nowrap;
}
.btn-topbar:hover { background: var(--surface); color: var(--text); border-color: #D1D5DB; }
.btn-topbar[aria-expanded="true"] { background: var(--accent-light); color: var(--accent); border-color: var(--accent-muted); }

.btn-topbar-label {
  display: none;
}
@media (min-width: 540px) {
  .btn-topbar-label { display: inline; }
}

.btn-publish-top {
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  white-space: nowrap;
}
.btn-publish-top span { display: none; }
@media (min-width: 420px) {
  .btn-publish-top span { display: inline; }
}

/* Checklist indicator */
.checklist-indicator {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-light);
  padding: 0.3rem 0.55rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: default;
  flex-shrink: 0;
}
.checklist-indicator.checklist-ok { color: var(--success); border-color: var(--success-bg); background: var(--success-bg); }
.checklist-indicator.checklist-warn { color: var(--warning); border-color: #FDE68A; background: var(--warning-bg); }
.checklist-indicator svg { flex-shrink: 0; }

/* ---------- Buttons ---------- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--ink);
  color: var(--surface);
  border: none;
  border-radius: var(--radius-md);
  padding: 0.75rem 1.35rem;
  min-height: 44px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.3;
  letter-spacing: 0.01em;
}
.btn-primary:hover { background: var(--accent); text-decoration: none; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; pointer-events: none; }
.btn-primary.loading { pointer-events: none; opacity: 0.8; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem;
  min-height: 44px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  text-decoration: none;
  line-height: 1.3;
}
.btn-ghost:hover { background: var(--surface); color: var(--text); border-color: var(--text-light); text-decoration: none; }
.btn-ghost:disabled { opacity: 0.5; pointer-events: none; }
.btn-text {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 0.28em;
  cursor: pointer;
  padding: 0.35rem 0.15rem;
  min-height: 44px;
}
.btn-text:hover { color: var(--accent); }

.btn-whatsapp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  background: #25D366;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.65rem 1.25rem;
  font-size: 0.93rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-whatsapp:hover { background: #1EBE59; }

.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.82rem; }
.btn-full { width: 100%; }

.btn-icon-back {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.3rem 0.55rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.btn-icon-back:hover { background: var(--bg); color: var(--text); }

.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.btn-copy:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent-muted); }
.btn-copy.copied { color: var(--success); border-color: var(--success-bg); background: var(--success-bg); }

/* ---------- Screens ---------- */
.screen {
  min-height: calc(100dvh - var(--header-h));
}
.screen-edit {
  min-height: calc(100dvh - var(--topbar-h));
}

/* ============================================================
   SCREEN: TEMPLATES — premium catalog fold
   ============================================================ */

.hero-section {
  text-align: left;
  padding: 3.5rem 1.25rem 1.25rem;
  max-width: var(--content-max);
  margin: 0 auto;
  display: grid;
  gap: 2rem;
}
@media (min-width: 960px) {
  .hero-section {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    align-items: center;
    padding: 4.5rem 1.5rem 2rem;
    gap: 2.5rem;
  }
}

.hero-copy {
  max-width: 34rem;
}
.hero-kicker {
  display: none; /* no tech badge — price lives in the sentence */
}
.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.25rem, 5.5vw, 3.5rem);
  font-weight: 500;
  line-height: 1.05;
  color: var(--text);
  letter-spacing: -0.03em;
  max-width: 14ch;
}
.hero-title em {
  font-style: italic;
  font-weight: 500;
  color: var(--accent);
}
.hero-sub {
  margin-top: 1.1rem;
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1.6;
  max-width: 38ch;
}
.hero-sub strong { color: var(--text); font-weight: 600; }
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem 1.25rem;
  margin-top: 1.5rem;
}

/* Overlapping owned template previews (Squarespace / Awwwards fold) */
.hero-stage {
  position: relative;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1200px;
}
@media (min-width: 960px) {
  .hero-stage { min-height: 420px; }
}
.hero-stage-stack {
  position: relative;
  width: min(100%, 520px);
  height: clamp(240px, 42vw, 380px);
  margin: 0 auto;
}
.hero-stage-card {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-feature);
}
.hero-stage-card iframe {
  position: absolute;
  top: 0; left: 0;
  width: 400%;
  height: 400%;
  border: none;
  pointer-events: none;
  transform: scale(0.25);
  transform-origin: top left;
  background: #fff;
}
.hero-stage-card--side {
  width: 72%;
  height: 86%;
  top: 7%;
  opacity: 0.72;
  box-shadow: none;
}
.hero-stage-card--left {
  left: 0;
  transform: translateX(-8%) rotate(-2.5deg);
  z-index: 1;
}
.hero-stage-card--right {
  right: 0;
  left: auto;
  transform: translateX(8%) rotate(2.5deg);
  z-index: 1;
}
.hero-stage-card--center {
  width: 78%;
  height: 100%;
  left: 11%;
  z-index: 3;
  box-shadow: var(--shadow-feature);
}
@media (max-width: 719px) {
  .hero-stage-card--side { display: none; }
  .hero-stage-card--center {
    width: 100%;
    left: 0;
  }
  .hero-stage-stack { height: 300px; }
}

/* Quiet vertical chips */
.catalog-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.5rem 1.25rem 0.25rem;
  max-width: var(--content-max);
  margin: 0 auto;
}
.catalog-chip {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  min-height: 36px;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.catalog-chip:hover { color: var(--text); border-color: var(--text-light); }
.catalog-chip[aria-pressed="true"] {
  color: var(--surface);
  background: var(--ink);
  border-color: var(--ink);
}

/* True proof only */
.proof-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1.25rem;
  max-width: var(--content-max);
  margin: 1.75rem auto 0.5rem;
  padding: 0 1.25rem;
}
@media (min-width: 720px) {
  .proof-row { grid-template-columns: repeat(4, 1fr); }
}
.proof-item {
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}
.proof-value {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.15;
}
.proof-label {
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* How it works */
.how-section {
  max-width: var(--content-max);
  margin: 3rem auto 0;
  padding: 0 1.25rem;
}
.how-section h2 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
}
.how-grid {
  display: grid;
  gap: 1rem;
}
@media (min-width: 720px) {
  .how-grid { grid-template-columns: repeat(4, 1fr); gap: 1.25rem; }
}
.how-step {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 1.1rem 1rem 1.15rem;
  min-height: 100%;
}
.how-step-num {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 0.55rem;
}
.how-step h3 {
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 0.35rem;
}
.how-step p {
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Landing footer */
.landing-footer {
  max-width: var(--content-max);
  margin: 4rem auto 0;
  padding: 2rem 1.25rem 3rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.82rem;
}
.landing-footer strong { color: var(--text); font-weight: 600; }
.landing-footer a { color: var(--text-muted); }
.landing-footer a:hover { color: var(--accent); }

/* Templates grid */
.templates-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  padding: 1.25rem 1.25rem 1rem;
  max-width: var(--content-max);
  margin: 0 auto;
}
@media (min-width: 720px) {
  .templates-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.75rem;
  }
}
@media (min-width: 1100px) {
  .templates-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.template-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  box-shadow: none;
  transition: transform var(--transition-md), border-color var(--transition);
  overflow: hidden;
  cursor: pointer;
}
.template-card:hover {
  transform: scale(1.015);
  border-color: var(--text-light);
  box-shadow: var(--shadow-md);
}
.template-card[hidden] { display: none !important; }

.template-card-preview {
  position: relative;
  width: 100%;
  height: 360px;
  background: var(--bg);
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
@media (max-width: 719px) {
  .template-card-preview { height: 300px; }
}
.template-card-preview-frame {
  position: absolute;
  top: 0; left: 0;
  width: 400%; height: 400%;
  border: none;
  background: #fff;
  pointer-events: none;
  transform: scale(0.25);
  transform-origin: top left;
}
.template-card-preview-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--bg) 0%, #ebe6dc 50%, var(--bg) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
}
.template-card-preview-shimmer.loaded { display: none; }

.template-card-body {
  padding: 1rem 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}
.template-card-badge {
  display: inline-block;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0;
  border-radius: 0;
  text-transform: none;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  align-self: flex-start;
}
.template-card-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.template-card-desc { font-size: 0.875rem; color: var(--text-muted); flex: 1; line-height: 1.5; }
.template-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.45rem;
  flex-wrap: wrap;
  align-items: center;
}
.template-card-actions .btn-primary { flex: 1; font-size: 0.86rem; padding: 0.6rem 0.85rem; min-height: 44px; }
.template-card-actions .btn-ghost { font-size: 0.82rem; padding: 0.5rem 0.75rem; min-height: 44px; }

/* Skeleton cards */
.card-skeleton {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.skeleton-preview {
  height: 360px;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
.skeleton-preview::after,
.skeleton-line::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.55) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
}
.skeleton-line { position: relative; overflow: hidden; }
.skeleton-body { padding: 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.skeleton-line { height: 14px; background: var(--bg); border-radius: 4px; }
.skeleton-line--short { width: 40%; }
.skeleton-line--med { width: 65%; }
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   SCREEN: EDITOR — Inline editing canvas
   ============================================================ */

.screen-edit {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--topbar-h));
  overflow: hidden;
}

.editor-canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #E8E2D6; /* paper frame */
}

/* Desktop: iframe fills the frame with a max-width "window" look */
.preview-iframe--edit {
  border: none;
  background: #fff;
  display: block;
  width: 100%;
  height: 100%;
  transition: width var(--transition-md), box-shadow var(--transition-md), border-radius var(--transition-md);
}

/* Constrained "window" frame on large screens */
@media (min-width: 900px) {
  .editor-canvas-wrap:not(.mode-mobile) .preview-iframe--edit {
    max-width: 1100px;
    box-shadow: 0 0 0 1px rgba(0,0,0,.08), var(--shadow-lg);
    border-radius: var(--radius);
  }
}

/* Mobile mode */
.editor-canvas-wrap.mode-mobile .preview-iframe--edit {
  width: 390px;
  max-width: calc(100vw - 24px);
  height: calc(100% - 24px);
  border-radius: var(--radius-lg);
  box-shadow: 0 0 0 6px #1F2937, 0 16px 48px rgba(0,0,0,.35);
}

/* Skeleton / spinner on canvas */
.preview-skeleton {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.preview-shimmer {
  width: 80%; max-width: 600px;
  height: 60%;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--border) 0%, rgba(255,255,255,.8) 50%, var(--border) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
}
.preview-skeleton.hidden { display: none; }

.preview-spinner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  background: rgba(255,255,255,.55);
  pointer-events: none;
}

/* ============================================================
   COLOR PICKER POPOVER
   ============================================================ */

.color-popover {
  position: fixed;
  z-index: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1rem;
  min-width: 220px;
  animation: fadeIn .12s ease;
}

.color-popover-inner { display: flex; flex-direction: column; gap: 0.75rem; }
.color-popover-title { font-size: 0.82rem; font-weight: 700; color: var(--text); }

.color-presets {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.45rem;
}
.color-preset-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition);
  flex-shrink: 0;
}
.color-preset-dot:hover { transform: scale(1.15); }
.color-preset-dot.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px currentColor;
}

.color-custom-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.color-custom-input {
  flex: 1;
  font-size: 0.82rem;
  padding: 0.4rem 0.55rem;
}

/* ============================================================
   DETAILS DRAWER
   ============================================================ */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,18,15,.28);
  z-index: 450;
  animation: fadeIn .15s ease;
}

.details-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(360px, 92vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 460;
  animation: slideInRight .2s ease;
  overflow: hidden;
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.drawer-section-title {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.drawer-section { display: flex; flex-direction: column; gap: 0.75rem; }

/* ============================================================
   GALLERY MODAL
   ============================================================ */

.modal-box--gallery {
  max-width: 520px;
}

.gallery-modal-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 0.75rem;
  max-height: 60dvh;
  overflow-y: auto;
}

.gallery-path-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ============================================================
   SCREEN: DASHBOARD
   ============================================================ */

.dashboard-container {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3rem;
}
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.dashboard-header h2 {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  /* S111: «Proiectele mele» stays one phrase at 390. */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
@media (max-width: 420px) {
  .dashboard-header h2 { font-size: 1.1rem; }
  .dashboard-container { padding-left: 0.85rem; padding-right: 0.85rem; }
}

.sites-list { display: flex; flex-direction: column; gap: 1rem; }

.site-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-md), border-color var(--transition);
}
.site-card:hover { box-shadow: var(--shadow-md); border-color: var(--accent-muted); }

.site-card-preview-thumb {
  width: 80px; height: 64px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
  flex-shrink: 0;
  position: relative;
}
.site-card-preview-thumb iframe {
  width: 400%; height: 400%;
  border: none;
  pointer-events: none;
  transform: scale(0.25);
  transform-origin: top left;
}

.site-card-info { flex: 1; min-width: 0; }
/* S111: full site name readable at 390 — wrap whole words, no qaliv… mid-clip. */
.site-card-name {
  font-weight: 700;
  font-size: 0.97rem;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.site-hosting-until {
  margin-top: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.site-card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.site-live-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.78rem;
  overflow: visible;
  white-space: normal;
  word-break: break-all;
  max-width: 100%;
}
.site-live-link:hover { color: var(--accent); text-decoration: underline; }

.site-card-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; flex-shrink: 0; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}
.status-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-live    { background: var(--success-bg); color: #15803D; }
.status-live::before { background: #22C55E; }
.status-unpaid   { background: #FEF9C3; color: #A16207; }
.status-unpaid::before { background: #F59E0B; animation: pulse-dot 1.8s ease infinite; }
.status-expired { background: var(--error-bg); color: var(--error); }
.status-expired::before { background: var(--error); }
.status-draft   { background: var(--bg); color: var(--text-muted); }
.status-draft::before { background: var(--text-light); }

@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.empty-state { text-align: center; padding: 4rem 1.5rem; color: var(--text-muted); }
.empty-state-icon { font-size: 2.5rem; margin-bottom: 0.85rem; line-height: 1; }
.empty-state p { margin-bottom: 1.25rem; font-size: 0.95rem; }

/* ============================================================
   MODALS
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,18,15,.48);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 1rem;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-overlay--wide { padding: 0.5rem; align-items: stretch; }

.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  width: 100%;
  max-width: 440px;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}
@keyframes slideUp {
  from { transform: translateY(14px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 1rem; right: 1rem;
  background: none;
  border: none;
  font-size: 1.35rem;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.4rem;
  line-height: 1;
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  padding-right: 2rem;
  margin-bottom: 0.25rem;
}
.modal-sub { font-size: 0.86rem; color: var(--text-muted); margin-bottom: 1rem; line-height: 1.5; }

/* Publish modal */
.modal-box--publish { max-width: 460px; }
.publish-step { display: flex; flex-direction: column; gap: 1rem; }
.publish-icon { margin-bottom: 0.25rem; }
.publish-icon svg { display: block; }

.publish-plan {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
}
.publish-plan li { display: flex; align-items: flex-start; gap: 0.6rem; font-size: 0.87rem; color: var(--text); line-height: 1.45; }
.publish-plan li strong { font-weight: 600; }
.publish-plan-icon { flex-shrink: 0; margin-top: 0.1rem; }

.slug-chooser { display: flex; flex-direction: column; gap: 0.35rem; }
.slug-input-row { position: relative; }
.slug-input-row .field-input { padding-right: 2.2rem; }
.slug-status-icon {
  position: absolute;
  right: 0.65rem; top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem; line-height: 1;
  pointer-events: none;
}
.slug-preview { font-size: 0.78rem; color: var(--text-muted); font-family: ui-monospace, "SF Mono", monospace; min-height: 1.2em; }
.slug-preview.valid { color: var(--accent); }

/* Auth inside publish */
.auth-sent { display: flex; flex-direction: column; align-items: center; gap: 0.65rem; text-align: center; padding: 0.75rem 0; }
.auth-sent-icon { width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; }
.auth-sent-title { font-size: 0.97rem; font-weight: 600; color: var(--text); }
.auth-sent-sub { font-size: 0.84rem; color: var(--text-muted); line-height: 1.5; }
.dev-link {
  font-size: 0.8rem; color: var(--text-muted);
  border: 1px dashed var(--border);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  text-align: center;
  display: inline-block;
}
.dev-link:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* Success modal */
.modal-box--success {
  max-width: 440px;
  display: flex; flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
  padding-top: 2rem;
}
.success-check { flex-shrink: 0; }
.success-title { font-size: 1.25rem; font-weight: 800; color: var(--text); letter-spacing: -0.02em; }

.success-url-block {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  background: var(--accent-light);
  border: 1px solid var(--accent-muted);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem 0.5rem 0.85rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.success-url-link {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  font-size: 0.85rem; font-weight: 600;
  color: var(--accent); text-decoration: none;
  /* Keep /live/<slug>/ intact: normal breaks only; block scrolls if needed. */
  overflow: visible;
  white-space: normal;
  word-break: normal;
  overflow-wrap: normal;
  display: flex; align-items: flex-start; gap: 0.3rem;
}
.success-url-link #success-url-text {
  /* Wrap only at path slashes (<wbr>); each segment stays one token (S99/S107). */
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
}
.success-url-link #success-url-text .success-url-seg {
  /* Path token (incl. long slug) never splits at hyphen. */
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
}
.success-url-block > .btn-copy {
  align-self: flex-end;
  flex-shrink: 0;
}
.success-url-link:hover { text-decoration: underline; }

.success-actions { width: 100%; display: flex; flex-direction: column; gap: 0.5rem; }

/* Wide modal */
.modal-box--wide {
  max-width: none; width: 100%; height: 100%;
  border-radius: var(--radius-lg);
  padding: 0;
  display: flex; flex-direction: column;
}
@media (min-width: 768px) {
  .modal-box--wide { max-width: 960px; height: 88dvh; margin: auto; }
  .modal-overlay--wide { align-items: center; }
}

.modal-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 0.75rem;
}
.modal-preview-title { font-size: 0.95rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-preview-controls { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.modal-close-btn {
  background: none; border: none;
  font-size: 1.35rem; color: var(--text-muted);
  cursor: pointer;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: background var(--transition), color var(--transition);
}
.modal-close-btn:hover { background: var(--bg); color: var(--text); }

.modal-preview-body {
  flex: 1; overflow: hidden;
  display: flex; flex-direction: column;
  background: var(--bg);
  align-items: center; justify-content: center;
}
.modal-preview-body.mode-mobile .preview-iframe--modal {
  width: 390px;
  height: calc(100% - 32px);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
  flex: none;
}
.preview-iframe--modal { width: 100%; flex: 1; border: none; }

/* Device toggle */
.preview-device-toggle {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
}
.device-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 28px;
  color: var(--text-light);
  background: none; border: none;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.device-btn:hover { color: var(--text-muted); }
.device-btn.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }

/* Versions list */
.versions-list { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.75rem; max-height: 360px; overflow-y: auto; }
.version-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  gap: 0.5rem;
  background: var(--bg);
}
.version-date { color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ============================================================
   FIELD COMPONENTS (used in drawer)
   ============================================================ */

.field-group { display: flex; flex-direction: column; gap: 0.35rem; }
.field-label { font-size: 0.8rem; font-weight: 600; color: var(--text); }
.field-label .required { color: var(--error); margin-left: 2px; }
.field-hint { font-size: 0.74rem; color: var(--text-muted); line-height: 1.4; }

.field-input,
.field-textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
  line-height: 1.4;
}
/* Detalii URL fields: full handle readable; scroll if tight — never mid-token shred. */
.field-input--url,
.field-textarea--url {
  white-space: pre-wrap;
  word-break: normal;
  overflow-wrap: normal;
  overflow-x: auto;
  text-overflow: clip;
  min-height: 2.6rem;
  resize: vertical;
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
}
.field-input:focus,
.field-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(30,58,50,.14);
}
.field-input.invalid { border-color: var(--error); }
.field-input.valid { border-color: var(--success); }
.field-textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.field-error { font-size: 0.77rem; color: var(--error); }

/* Color swatch */
.field-color-swatch {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  cursor: pointer;
  padding: 3px;
  background: none;
  -webkit-appearance: none;
  appearance: none;
  flex-shrink: 0;
}
.field-color-swatch::-webkit-color-swatch-wrapper { padding: 0; border-radius: 4px; }
.field-color-swatch::-webkit-color-swatch { border: none; border-radius: 4px; }

/* Photos */
.photos-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 0.4rem;
}
.photo-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1.5px solid var(--border);
  transition: transform var(--transition), border-color var(--transition);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb-del {
  position: absolute;
  top: 3px; right: 3px;
  background: rgba(17,24,39,.65);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px; height: 20px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  opacity: 0;
  transition: opacity var(--transition), background var(--transition);
}
.photo-thumb:hover .photo-thumb-del { opacity: 1; }
.photo-thumb-del:hover { background: var(--error); opacity: 1; }

.photos-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 1.25rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  color: var(--text-muted);
  font-size: 0.85rem;
  display: block;
}
.photos-dropzone:hover { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }
.photos-dropzone input[type=file] { display: none; }
.photos-dropzone-icon { font-size: 1.25rem; margin-bottom: 0.2rem; }

/* ============================================================
   TOAST
   ============================================================ */

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  font-size: 0.86rem;
  z-index: 1000;
  box-shadow: var(--shadow-md);
  max-width: calc(100vw - 2rem);
  text-align: center;
  animation: toastIn .18s ease;
  pointer-events: none;
  font-weight: 500;
}
.toast.toast-error   { background: var(--error); }
.toast.toast-success { background: var(--success); }

.ig-terms {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin: 1rem 0 0.75rem;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.45;
  cursor: pointer;
}
.ig-terms input { margin-top: 0.2rem; flex-shrink: 0; }
.ig-terms a { color: var(--accent); }
.ig-status {
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}
.ig-status.ig-error { color: var(--error); }

@keyframes toastIn {
  from { transform: translateX(-50%) translateY(10px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);   opacity: 1; }
}

/* ============================================================
   UTILITIES
   ============================================================ */

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border-width: 0;
}
.btn-loading-text { display: flex; align-items: center; gap: 0.4rem; }
