/* =========================================================
   NIVA EDITOR — Light Romantic Theme
   Fonts: Playfair Display + Cormorant Garamond + Inter
   ========================================================= */

:root {
  color-scheme: light;

  --bg-cream:     #fdf8f3;
  --bg-blush:     #faf0ea;
  --bg-rose:      #f9e8e4;
  --bg-white:     #ffffff;

  --panel:        #fffaf6;
  --panel-2:      #fff5ef;
  --panel-3:      #fef0e8;

  --rose:         #d4878e;
  --rose-deep:    #b76e79;
  --rose-light:   #f0c4c8;
  --blush:        #e8b4b8;
  --champagne:    #d4b896;
  --champagne-light: #eddbc8;
  --sage:         #a8b5a0;
  --sage-light:   #d6dfd0;
  --gold:         #c9a961;
  --gold-light:   #e8d9b8;

  --text:         #3d2c2e;
  --text-2:       #6b5557;
  --text-muted:   #9e8588;
  --text-soft:    #b8a5a7;

  --line:         #f0dfd8;
  --line-soft:    #f7ebe5;
  --line-rose:    #e8c4c8;
  --line-gold:    #e8d9b8;

  --success:      #6b8e6b;
  --danger:       #c75b65;

  --display:      'Playfair Display', Georgia, serif;
  --serif:        'Cormorant Garamond', Georgia, serif;
  --sans:         'Inter', system-ui, sans-serif;

  --shadow-sm:    0 4px 16px rgba(183, 110, 121, 0.08);
  --shadow-md:    0 12px 40px rgba(183, 110, 121, 0.12);
  --shadow-lg:    0 24px 70px rgba(183, 110, 121, 0.18);

  --radius:       20px;
  --radius-sm:    12px;

  --ease:         cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-out:     cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- RESET ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(ellipse at 15% 0%, rgba(212, 135, 142, 0.08) 0%, transparent 40%),
    radial-gradient(ellipse at 85% 100%, rgba(212, 184, 150, 0.06) 0%, transparent 40%),
    var(--bg-cream);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
::selection { background: rgba(212, 135, 142, 0.25); color: var(--text); }
img { max-width: 100%; display: block; }

/* ---------- LOGO ---------- */
.brand-logo {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  border: 1px solid var(--line-gold);
  border-radius: 50%;
  background: linear-gradient(145deg, var(--bg-rose), var(--bg-white));
  color: var(--rose-deep);
  font: 500 18px/1 var(--display);
  box-shadow: 0 4px 16px rgba(183, 110, 121, 0.12);
  transition: transform 0.4s var(--ease);
  position: relative;
  overflow: hidden;
  object-fit: cover;
}

.brand-logo:active { transform: rotate(6deg) scale(0.95); }

@media (min-width: 720px) {
  .brand-logo { width: 46px; height: 46px; flex-basis: 46px; font-size: 20px; }
  .brand-logo:hover { transform: rotate(6deg) scale(1.05); }
}

/* ---------- TOPBAR ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: rgba(253, 248, 243, 0.94);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex-shrink: 1; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-name { font-family: var(--display); font-weight: 500; font-size: 1.2rem; letter-spacing: 0.16em; color: var(--text); }
.brand-tagline { margin-top: 3px; color: var(--rose-deep); font-size: 0.46rem; letter-spacing: 0.22em; font-weight: 500; text-transform: uppercase; font-family: var(--sans); }

.topbar-right { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-shrink: 0; }
.save-status { display: none; font-size: 12px; color: var(--text-2); font-style: italic; }

@media (min-width: 720px) {
  .topbar { padding: 15px clamp(16px, 4vw, 54px); padding-top: 15px; gap: 20px; }
  .brand { gap: 12px; }
  .brand-name { font-size: 26px; letter-spacing: 0.08em; }
  .brand-tagline { margin-top: 4px; font-size: 9px; letter-spacing: 0.28em; }
  .topbar-right { gap: 12px; }
  .save-status { display: inline; }
}

/* ---------- BUTTONS ---------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 12px 20px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s var(--ease), background 0.25s var(--ease);
  touch-action: manipulation;
  font-family: var(--sans);
}

.button:active { transform: scale(0.97); }

.button-primary {
  background: linear-gradient(110deg, var(--rose-deep), var(--rose));
  color: #fff;
  border-color: var(--rose);
  box-shadow: 0 6px 20px rgba(183, 110, 121, 0.25);
}

.button-primary:hover { box-shadow: 0 10px 28px rgba(183, 110, 121, 0.35); transform: translateY(-2px); }

.button-secondary {
  background: var(--panel);
  border-color: var(--line-rose);
  color: var(--rose-deep);
}

.button-secondary:hover { border-color: var(--rose); background: var(--panel-2); }

.topbar .button { min-height: 40px; padding: 9px 14px; font-size: 11px; }

@media (min-width: 720px) {
  .button { padding: 12px 22px; font-size: 13px; }
  .topbar .button { min-height: 44px; padding: 11px 18px; font-size: 12px; }
}

/* ---------- WORKSPACE ---------- */
.workspace {
  width: 100%;
  margin: auto;
  padding: 20px 14px 48px;
  padding-bottom: calc(48px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 20px;
  max-width: 800px;
}

.editor-panel, .preview-panel {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.editor-panel { padding: 22px 18px; order: 1; }
.preview-panel { order: 2; }

@media (min-width: 980px) {
  .workspace {
    width: min(1500px, 100%);
    padding: 36px clamp(16px, 3vw, 46px) 64px;
    grid-template-columns: minmax(0, 1fr) minmax(380px, 0.9fr);
    gap: 30px;
    max-width: none;
  }
  .editor-panel { padding: clamp(22px, 3vw, 38px); border-radius: var(--radius); }
  .editor-panel, .preview-panel { box-shadow: var(--shadow-md); }
}

/* ---------- HEADING ---------- */
.heading { padding: 4px 0 22px; border-bottom: 1px solid var(--line-soft); position: relative; }
.heading::after { content: ""; position: absolute; bottom: -1px; left: 0; width: 60px; height: 2px; background: linear-gradient(90deg, var(--rose-deep), transparent); }

.eyebrow { margin: 0 0 8px; color: var(--rose-deep); font-size: 0.64rem; font-weight: 600; letter-spacing: 0.24em; text-transform: uppercase; }

.heading h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.9rem, 6vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text);
}

.heading h1 span { color: var(--rose-deep); font-style: italic; }

.description { max-width: 520px; margin: 14px 0 0; color: var(--text-2); font-size: 0.88rem; line-height: 1.7; font-family: var(--serif); }

@media (min-width: 720px) {
  .heading { padding: 4px 0 28px; }
  .heading::after { width: 90px; }
  .eyebrow { margin-bottom: 10px; font-size: 10px; letter-spacing: 0.28em; }
  .heading h1 { font-size: clamp(38px, 4.5vw, 58px); }
  .description { margin-top: 16px; font-size: 15px; line-height: 1.8; }
}

/* ---------- TEMPLATE INFO ---------- */
.template-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  padding: 14px;
  border: 1px solid var(--line-rose);
  border-radius: 16px;
  background: linear-gradient(110deg, var(--bg-rose), var(--panel));
}

.template-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  border-radius: 14px;
  background: var(--bg-white);
  border: 1px solid var(--line-rose);
  color: var(--rose-deep);
  font-size: 20px;
}

.template-info h2 { margin: 0; font-family: var(--display); font-size: 1.1rem; font-weight: 500; color: var(--text); }
.template-info p { margin: 3px 0 0; color: var(--text-muted); font-size: 0.72rem; letter-spacing: 0.04em; }

.draft-badge {
  margin-left: auto;
  padding: 5px 10px;
  border: 1px solid var(--line-gold);
  border-radius: 999px;
  color: var(--rose-deep);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.14em;
  background: var(--bg-white);
  flex-shrink: 0;
}

@media (min-width: 720px) {
  .template-info { gap: 14px; margin: 26px 0; padding: 18px; border-radius: 18px; }
  .template-icon { width: 50px; height: 50px; flex-basis: 50px; border-radius: 16px; font-size: 24px; }
  .template-info h2 { font-size: 22px; }
  .template-info p { margin-top: 4px; font-size: 12px; }
}

/* ---------- FORM SECTIONS ---------- */
form { display: block; }

.form-section {
  margin: 0 0 18px;
  padding: 18px 16px;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: var(--bg-blush);
  animation: section-in 0.5s var(--ease-out) both;
}

@keyframes section-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.section-title { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }

.step-number {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  border-radius: 10px;
  background: var(--bg-white);
  border: 1px solid var(--line-rose);
  color: var(--rose-deep);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.section-title h2 { margin: 0; font-family: var(--display); font-size: 1.2rem; font-weight: 500; line-height: 1.2; color: var(--text); }
.section-title p { margin: 4px 0 0; color: var(--text-muted); font-size: 0.74rem; line-height: 1.5; font-family: var(--serif); }

@media (min-width: 720px) {
  .form-section { margin-bottom: 22px; padding: 24px; border-radius: 18px; }
  .section-title { gap: 14px; margin-bottom: 22px; }
  .step-number { width: 38px; height: 38px; flex-basis: 38px; border-radius: 12px; font-size: 11px; letter-spacing: 0.08em; }
  .section-title h2 { font-size: 24px; }
  .section-title p { font-size: 13px; line-height: 1.6; }
}

/* ---------- LABELS + INPUTS ---------- */
label:not(.upload-box):not(.theme-option) {
  display: block;
  margin: 16px 0 8px;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

input[type=text],
input[type=date],
input[type=password],
input[type=url],
textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  background: var(--bg-white);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
  -webkit-appearance: none;
  appearance: none;
}

textarea { min-height: 140px; resize: vertical; line-height: 1.7; }
input::placeholder, textarea::placeholder { color: var(--text-soft); }
input:focus, textarea:focus { border-color: var(--rose); box-shadow: 0 0 0 3px rgba(212, 135, 142, 0.12); }
input[type=date] { color-scheme: light; }

.field-footer { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; color: var(--text-muted); font-size: 0.7rem; }
.field-help { margin: 9px 0 0; color: var(--text-muted); font-size: 0.72rem; line-height: 1.6; font-style: italic; font-family: var(--serif); }

@media (min-width: 720px) {
  label:not(.upload-box):not(.theme-option) { margin: 18px 0 9px; font-size: 13px; }
  input[type=text], input[type=date], input[type=password], input[type=url], textarea { padding: 12px 16px; font-size: 14px; min-height: 48px; }
  textarea { min-height: 160px; }
  .field-footer { font-size: 12px; }
  .field-help { font-size: 12px; line-height: 1.65; }
}

/* ---------- UPLOAD ---------- */
.upload-box {
  position: relative;
  display: flex;
  min-height: 140px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  border: 1px dashed var(--line-rose);
  border-radius: 16px;
  background: var(--bg-white);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease), box-shadow 0.25s var(--ease);
  touch-action: manipulation;
}

.upload-box:hover { border-color: var(--rose); background: var(--panel-2); box-shadow: 0 0 30px rgba(212, 135, 142, 0.1); }

.upload-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--bg-rose);
  color: var(--rose-deep);
  font-size: 24px;
}

.upload-box strong { font-size: 0.86rem; color: var(--text); }
.upload-box > span:last-of-type { color: var(--text-muted); font-size: 0.72rem; }
.upload-box input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

@media (min-width: 720px) {
  .upload-box { min-height: 155px; padding: 22px; }
  .upload-icon { width: 44px; height: 44px; font-size: 26px; }
  .upload-box strong { font-size: 14px; }
  .upload-box > span:last-of-type { font-size: 12px; }
}

/* ---------- PHOTO GRID ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px; margin-top: 12px; }
.photo-grid:empty { display: none; }
[data-photo-grid] video { pointer-events: none; }

/* ---------- THEME SWATCHES ---------- */
.theme-options { display: flex; flex-wrap: wrap; gap: 10px; }

.theme-option {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 !important;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-white);
  color: var(--text-2) !important;
  font-size: 0.8rem !important;
  cursor: pointer;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease);
  touch-action: manipulation;
  min-height: 44px;
}

.theme-option:has(input:checked) { border-color: var(--rose); background: var(--bg-rose); color: var(--text) !important; }
.theme-option:hover { border-color: var(--line-rose); }

.theme-swatch { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.1); flex-shrink: 0; }
.theme-swatch.rose     { background: linear-gradient(135deg, #ffb3c1, #b76e79); }
.theme-swatch.violet   { background: linear-gradient(135deg, #c4b5fd, #7c5cbf); }
.theme-swatch.midnight { background: linear-gradient(135deg, #93a5cf, #3b4a6b); }
.theme-swatch.letter   { background: linear-gradient(135deg, #f5e5b8, #c9a961); }

/* ---------- FORM ACTIONS ---------- */
.form-actions { display: flex; justify-content: space-between; gap: 10px; margin: 22px 0; }
.form-actions .button { flex: 1; padding: 12px 14px; font-size: 11px; }

@media (min-width: 720px) {
  .form-actions { gap: 14px; margin: 26px 0; }
  .form-actions .button { padding: 12px 22px; font-size: 13px; }
}

.notice {
  margin: 20px 2px 0;
  padding: 14px 16px;
  border-left: 2px solid var(--rose);
  background: var(--bg-rose);
  color: var(--text-2);
  font-size: 0.72rem;
  line-height: 1.7;
  border-radius: 0 10px 10px 0;
  font-family: var(--serif);
}

/* ---------- PUBLISH RESULT ---------- */
#publishStatus { margin: 14px 0 0; color: var(--text-2); font-size: 0.78rem; overflow-wrap: anywhere; }

#publishedGiftResult { margin-top: 16px; padding: 16px; border: 1px solid rgba(107, 142, 107, 0.3); border-radius: 14px; background: rgba(107, 142, 107, 0.06); }
#publishedGiftResult strong { color: var(--success); font-size: 0.9rem; }
#publishedGiftResult p { color: var(--text-2); font-size: 0.78rem; margin: 6px 0; }
#publishedGiftResult input[type=url] { font-size: 0.78rem; margin: 8px 0; }
#publishedGiftResult .button { width: 100%; margin-top: 8px; padding: 11px 14px; font-size: 0.8rem; }

/* ---------- PREVIEW PANEL ---------- */
.preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line-soft);
}

.preview-heading .eyebrow { margin: 0 0 4px; font-size: 0.6rem; letter-spacing: 0.22em; }
.preview-heading h2 { margin: 0; font-family: var(--display); font-size: 1.2rem; font-weight: 500; color: var(--text); }

.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid rgba(107, 142, 107, 0.3);
  border-radius: 999px;
  color: var(--success);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.live-indicator i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.preview-frame {
  position: relative;
  width: calc(100% - 24px);
  height: 62vh;
  min-height: 420px;
  max-height: 640px;
  margin: 12px;
  border: 1px solid var(--line-rose);
  border-radius: 16px;
  overflow: hidden;
  background: var(--bg-cream);
  box-shadow: var(--shadow-sm);
}

.preview-frame iframe { width: 100%; height: 100%; border: 0; display: block; background: var(--bg-cream); }

.preview-frame::before {
  content: "Loading preview…";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg-cream);
  color: var(--text-muted);
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  z-index: 2;
  transition: opacity 0.4s var(--ease);
  pointer-events: none;
}

.preview-frame.loaded::before { opacity: 0; }

.preview-caption {
  margin: 0;
  padding: 0 18px 18px;
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.6;
  font-style: italic;
  font-family: var(--serif);
}

@media (min-width: 720px) {
  .preview-heading { padding: 24px 26px; gap: 15px; }
  .preview-heading .eyebrow { margin-bottom: 8px; font-size: 0.64rem; }
  .preview-heading h2 { font-size: 26px; }
  .live-indicator { padding: 7px 12px; font-size: 9px; letter-spacing: 0.12em; gap: 7px; }
}

@media (min-width: 980px) {
  .preview-panel { position: sticky; top: 95px; overflow: hidden; }
  .preview-frame { width: calc(100% - 44px); height: calc(100vh - 230px); min-height: 520px; max-height: 920px; margin: 22px; border-radius: 18px; }
  .preview-caption { padding: 0 26px 24px; font-size: 12px; line-height: 1.7; }
}

/* ---------- TOAST ---------- */
.toast {
  position: fixed;
  z-index: 90;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  max-width: min(380px, calc(100vw - 32px));
  padding: 14px 18px;
  border: 1px solid var(--line-rose);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  font-size: 0.8rem;
  line-height: 1.5;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 720px) {
  .toast { left: auto; right: 22px; bottom: 22px; transform: translateY(10px); font-size: 13px; text-align: left; padding: 14px 20px; }
  .toast.show { transform: translateY(0); }
}

/* ---------- PROGRESS OVERLAY ---------- */
.editor-progress {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(253, 248, 243, 0.94);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.editor-progress.show { display: flex; }

.editor-progress-card {
  background: var(--panel);
  border: 1px solid var(--line-rose);
  border-radius: 20px;
  padding: 28px 24px;
  text-align: center;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.35s var(--ease-out);
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}

.editor-progress-card p { margin: 0 0 16px; color: var(--text-2); font-size: 0.82rem; line-height: 1.6; overflow-wrap: anywhere; }

.editor-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-rose);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}

.editor-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--rose-deep), var(--rose));
  transition: width 0.35s var(--ease);
  box-shadow: 0 0 12px rgba(212, 135, 142, 0.3);
}

.editor-progress-percent { color: var(--rose-deep); font-size: 0.84rem; font-weight: 600; letter-spacing: 0.08em; }

/* ---------- MISC ---------- */
[hidden] { display: none !important; }

.editor-loading {
  padding: 28px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-family: var(--serif);
  font-style: italic;
}

.editor-error {
  padding: 18px;
  border: 1px solid rgba(199, 91, 101, 0.3);
  border-radius: 12px;
  background: rgba(199, 91, 101, 0.06);
  color: var(--danger);
  font-size: 0.82rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

/* ---------- iOS zoom ---------- */
@media screen and (max-width: 767px) {
  input[type=text], input[type=date], input[type=password], input[type=url], textarea, select {
    font-size: 16px !important;
  }
}

/* ---------- LOGIN GATE ---------- */
.login-gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  padding-top: calc(20px + env(safe-area-inset-top));
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  background:
    radial-gradient(ellipse at 15% 0%, rgba(212, 135, 142, 0.15) 0%, transparent 40%),
    radial-gradient(ellipse at 85% 100%, rgba(212, 184, 150, 0.1) 0%, transparent 40%),
    var(--bg-cream);
  overflow-y: auto;
}

.login-gate[hidden] { display: none !important; }

.login-card {
  width: min(100%, 420px);
  padding: 34px 28px;
  border: 1px solid var(--line-rose);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow-lg);
  animation: login-in 0.5s var(--ease-out) both;
}

@keyframes login-in {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 22px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-gold);
  border-radius: 50%;
  background: linear-gradient(145deg, var(--bg-rose), var(--bg-white));
  color: var(--rose-deep);
  font: 500 28px/1 var(--display);
  box-shadow: 0 8px 24px rgba(183, 110, 121, 0.15);
  object-fit: cover;
}

.login-card h2 { margin: 0 0 8px; font-family: var(--display); font-weight: 500; font-size: 1.6rem; line-height: 1.2; text-align: center; color: var(--text); }
.login-card > div > p { margin: 0 0 22px; text-align: center; color: var(--text-2); font-size: 0.88rem; line-height: 1.6; font-family: var(--serif); }

.login-card label { display: block; margin: 16px 0 7px; color: var(--text); font-size: 0.8rem; font-weight: 500; }
.login-hint { color: var(--text-muted); font-weight: 400; font-size: 0.74rem; }

.login-card input {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  background: var(--bg-white);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.login-card input:focus { border-color: var(--rose); box-shadow: 0 0 0 3px rgba(212, 135, 142, 0.12); }
.login-card input::placeholder { color: var(--text-soft); }

.login-submit {
  display: block;
  width: 100%;
  margin-top: 20px;
  min-height: 48px;
  padding: 13px 22px;
  border: 1px solid var(--rose);
  border-radius: 999px;
  background: linear-gradient(110deg, var(--rose-deep), var(--rose));
  color: #fff;
  font-family: var(--sans);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
  box-shadow: 0 8px 24px rgba(183, 110, 121, 0.28);
}

.login-submit:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(183, 110, 121, 0.38); }
.login-submit:active:not(:disabled) { transform: scale(0.97); }
.login-submit:disabled { opacity: 0.6; cursor: wait; }

.login-error {
  margin: 12px 0 0;
  padding: 10px 14px;
  border: 1px solid rgba(199, 91, 101, 0.3);
  border-radius: 10px;
  background: rgba(199, 91, 101, 0.06);
  color: var(--danger);
  font-size: 0.82rem;
  line-height: 1.5;
  text-align: center;
}

.login-error:empty { display: none; }

.login-link {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 8px;
  border: 0;
  background: transparent;
  color: var(--rose-deep);
  font-family: var(--sans);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: color 0.2s;
}

.login-link:hover { color: var(--rose); }

/* ---------- PLAN SUMMARY ---------- */
.plan-summary { margin: 6px 0 16px; }

@media (max-width: 480px) {
  .plan-summary { flex-direction: column; align-items: flex-start !important; }
  #planSummaryPrice { font-size: 1.8rem !important; }
}

/* ---------- REDUCED MOTION ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}