@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700;900&family=Inter:wght@300;400;500;600&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  --bg:        #f0fafa;
  --surface:   #ffffff;
  --surface2:  #e8f7f7;
  --border:    #b2e0e0;
  --border2:   #7ecece;
  --text:      #0d3340;
  --muted:     #4a8fa0;
  --dim:       #cceaea;

  --teal:      #0d9488;
  --teal-lt:   #14b8a6;
  --cyan:      #0891b2;
  --cyan-lt:   #06b6d4;
  --green:     #059669;
  --green-lt:  #10b981;
  --mint:      #a7f3d0;

  --accent:    #0d9488;
  --accent-lt: #14b8a6;
  --glow:      rgba(13,148,136,0.15);
  --glow2:     rgba(8,145,178,0.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(6,182,212,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(16,185,129,0.06) 0%, transparent 60%);
}

/* ── HEADER ── */
header {
  background: linear-gradient(90deg, #e0f7f7 0%, #f0fffe 40%, #e8fafa 100%);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex; align-items: center; gap: 14px;
  position: relative; overflow: hidden;
}
header::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(20,184,166,0.04), transparent);
  pointer-events: none;
}
header::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--teal), var(--cyan), var(--teal), transparent);
  opacity: 0.6;
}
header h1 {
  font-family: 'Playfair Display', serif;
  font-size: 21px; color: var(--teal); font-weight: 700;
  letter-spacing: 0.3px;
}
header p { font-size: 12px; color: var(--muted); margin-top: 2px; letter-spacing: 0.3px; }
.dragon-badge {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, #0e7490, #14b8a6);
  border-radius: 12px; display: flex; align-items: center;
  justify-content: center; font-size: 21px; flex-shrink: 0;
  box-shadow: 0 0 16px rgba(20,184,166,0.3);
}

/* ── LAYOUT ── */
.layout { display: flex; height: calc(100vh - 65px); }

/* ── SIDEBAR ── */
.sidebar {
  width: 290px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto; display: flex; flex-direction: column;
  height: 100%;
}
.post-list { overflow-y: visible; }
.sidebar-section { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.sidebar-label {
  font-size: 9px; letter-spacing: 2.5px; text-transform: uppercase;
  color: var(--muted); margin-bottom: 10px; font-weight: 600;
}

.api-input {
  width: 100%; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; color: var(--text);
  font-size: 13px; font-family: 'Space Grotesk', sans-serif;
  outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.api-input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--glow); }
.api-hint { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.api-hint a { color: var(--teal-lt); }

.server-status { display: flex; align-items: center; gap: 7px; padding: 7px 10px; border-radius: 7px; font-size: 11px; margin-top: 8px; font-weight: 500; }
.server-status.ok  { background: rgba(16,185,129,0.12); color: var(--green); border: 1px solid rgba(16,185,129,0.25); }
.server-status.err { background: rgba(220,38,38,0.08); color: #dc2626; border: 1px solid rgba(220,38,38,0.2); }
.server-status.checking { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* ── LANGUAGE BUTTONS ── */
.lang-btn {
  flex: 1; padding: 8px 4px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface2);
  color: var(--muted); font-size: 11px; font-weight: 600;
  cursor: pointer; font-family: 'Space Grotesk', sans-serif;
  transition: all 0.15s; text-align: center;
}
.lang-btn:hover { border-color: var(--teal); color: var(--teal-lt); }
.lang-btn.active {
  border-color: var(--teal); background: rgba(20,184,166,0.12);
  color: var(--teal-lt); box-shadow: 0 0 10px var(--glow);
}

/* ── BULK ACTIONS ── */
.bulk-panel { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.bulk-title { font-size: 9px; letter-spacing: 2.5px; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; font-weight: 600; }
.bulk-btn {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface2);
  color: var(--text); font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: 'Space Grotesk', sans-serif;
  transition: all 0.15s; margin-bottom: 7px;
}
.bulk-btn:hover { border-color: var(--teal); color: var(--teal-lt); background: rgba(20,184,166,0.06); }
.bulk-btn:last-child { margin-bottom: 0; }
.bulk-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.bulk-progress { margin-top: 10px; display: none; }
.bulk-progress-bar-wrap { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; margin-bottom: 6px; }
.bulk-progress-bar { height: 100%; background: linear-gradient(90deg, var(--cyan), var(--teal), var(--green)); border-radius: 2px; transition: width 0.3s; }
.bulk-progress-label { font-size: 11px; color: var(--muted); line-height: 1.5; }
.bulk-progress-label strong { color: var(--text); }

/* ── POST LIST ── */
.post-list { flex: 1; overflow-y: auto; }
.post-item {
  padding: 11px 16px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s; display: flex; flex-direction: column; gap: 3px;
}
.post-item:hover { background: var(--surface2); }
.post-item.active {
  background: rgba(20,184,166,0.08);
  border-left: 3px solid var(--teal);
}
.post-item-day { font-size: 9px; letter-spacing: 2px; text-transform: uppercase; color: var(--teal); font-weight: 700; }
.post-item-title { font-size: 13px; color: var(--text); font-weight: 600; }
.post-item-meta { font-size: 11px; color: var(--muted); }
.series-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }

/* ── MAIN ── */
.main { flex: 1; min-width: 0; overflow-y: auto; overflow-x: hidden; padding: 28px 32px; display: flex; flex-direction: column; gap: 22px; }

/* ── POST HEADER ── */
.post-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.post-header-left { flex: 1; }
.post-day-label { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--teal); font-weight: 700; margin-bottom: 5px; }
.post-title { font-family: 'Playfair Display', serif; font-size: 30px; color: var(--text); font-weight: 700; line-height: 1.15; }
.post-series-tag { display: inline-block; margin-top: 8px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: 0.3px; }

/* ── SLIDES ── */
.slides-label { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); margin-bottom: 14px; font-weight: 600; }
.slides-grid { display: flex; gap: 14px; flex-wrap: wrap; }
.slide-card { display: flex; flex-direction: column; gap: 8px; flex: 0 0 auto; }
.slide-card-label { font-size: 10px; color: var(--muted); text-align: center; letter-spacing: 0.5px; }

.canvas-wrap {
  position: relative; width: 380px; height: 380px;
  border-radius: 10px; overflow: hidden;
  background: var(--surface2);
  border: 1px solid var(--border); cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.canvas-wrap:hover { border-color: var(--teal); box-shadow: 0 0 20px var(--glow); }
.text-slide-wrap {
  position: relative; width: 360px; height: 360px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--border); box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}
/* Reel (9:16) images and slides */
.canvas-wrap.is-tall { width: 270px; height: 480px; }
.canvas-wrap.is-tall canvas { width: 100%; height: 100%; }
.text-slide-wrap.is-tall { width: 225px; height: 400px; }

/* Progress of each post in the list */
.post-item-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.post-status { font-size: 10px; font-weight: 600; white-space: nowrap; padding: 1px 7px; border-radius: 10px; }
.post-status-todo  { color: var(--muted); border: 1px dashed var(--border2); }
.post-status-image { color: var(--teal); background: rgba(20,184,166,0.10); }
.post-status-done  { color: #047857; background: rgba(16,185,129,0.16); }
.post-header-actions { display: flex; gap: 8px; align-items: flex-start; flex-shrink: 0; }
.canvas-wrap canvas { display: block; width: 380px; height: 380px; }
.canvas-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(2,13,18,0.7); opacity: 0; transition: opacity 0.2s;
  flex-direction: column; gap: 8px; backdrop-filter: blur(2px);
}
.canvas-wrap:hover .canvas-overlay { opacity: 1; }
.canvas-placeholder {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; color: var(--muted);
}
.canvas-placeholder span { font-size: 13px; text-align: center; padding: 0 20px; line-height: 1.5; }
.canvas-overlay-btn {
  background: rgba(20,184,166,0.15); border: 1px solid rgba(20,184,166,0.4);
  color: var(--teal-lt); border-radius: 8px; padding: 8px 14px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  font-family: 'Space Grotesk', sans-serif; transition: background 0.15s;
}
.canvas-overlay-btn:hover { background: rgba(20,184,166,0.28); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; border: none;
  font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: 'Space Grotesk', sans-serif; transition: all 0.15s; white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, var(--cyan), var(--teal)); color: #ffffff; }
.btn-primary:hover { filter: brightness(1.1); box-shadow: 0 0 18px var(--glow); }
.btn-primary:disabled { background: var(--surface2); color: var(--muted); filter: none; box-shadow: none; cursor: not-allowed; }
.btn-gold { background: linear-gradient(135deg, var(--teal), var(--green)); color: #ffffff; }
.btn-gold:hover { filter: brightness(1.1); box-shadow: 0 0 16px rgba(16,185,129,0.25); }
.btn-ghost { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--teal); color: var(--teal-lt); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ── PROMPT / FIELDS ── */
#promptsSection { display: flex; flex-direction: column; gap: 18px; }
.fields-group {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
}
.fields-group-title {
  font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--muted); font-weight: 700;
}
.fields-grid-short {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
.prompt-field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.prompt-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.prompt-title { font-size: 12px; font-weight: 600; color: var(--text); }
textarea.prompt-text {
  width: 100%; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 11px 12px; color: var(--text); font-size: 12px;
  font-family: 'Space Grotesk', sans-serif; line-height: 1.6;
  resize: vertical; min-height: 90px; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
textarea.prompt-text-sm { min-height: 56px; }
textarea.prompt-text:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--glow); }
textarea.prompt-text::placeholder { color: var(--muted); opacity: 0.7; }

/* ── PROGRESS ── */
.progress-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 20px;
}
.progress-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.progress-meta span { font-size: 13px; color: var(--muted); }
.progress-bar-wrap { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--cyan), var(--teal), var(--green)); border-radius: 2px; transition: width 0.4s ease; }

/* ── STATUS BADGES ── */
.status-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.status-loading { background: rgba(6,182,212,0.15); color: var(--cyan); border: 1px solid rgba(6,182,212,0.3); }
.status-done    { background: rgba(16,185,129,0.12); color: var(--green); border: 1px solid rgba(16,185,129,0.25); }
.status-error   { background: rgba(220,38,38,0.08); color: #dc2626; border: 1px solid rgba(220,38,38,0.2); }

/* ── REEL INSPIRATION ── */
.runway-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px;
}
.runway-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.runway-badge {
  background: rgba(6,182,212,0.1); color: var(--cyan-lt);
  border: 1px solid rgba(6,182,212,0.2);
  padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700;
}
.video-card { display: flex; flex-direction: column; gap: 10px; flex: 0 0 auto; }
.video-wrap {
  position: relative; border-radius: 8px; overflow: hidden;
  background: var(--surface2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.motion-text {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; color: var(--text);
  font-size: 12px; font-family: 'Space Grotesk', sans-serif;
  line-height: 1.6; resize: vertical; min-height: 70px; outline: none;
  transition: border-color 0.2s;
}
.motion-text:focus { border-color: var(--teal); }

/* ── SPINNER ── */
.spinner {
  width: 11px; height: 11px; border: 2px solid transparent;
  border-top-color: currentColor; border-radius: 50%;
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--surface); border: 1px solid var(--teal);
  border-radius: 10px; padding: 11px 18px;
  font-size: 13px; color: var(--text);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 20px var(--glow);
  transform: translateY(80px); opacity: 0; transition: all 0.3s;
  z-index: 1000; pointer-events: none; font-family: 'Space Grotesk', sans-serif;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ── LOGIN ── */
#loginScreen {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at 30% 40%, rgba(6,182,212,0.12) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 60%, rgba(16,185,129,0.08) 0%, transparent 60%),
              var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px; padding: 44px 40px; width: 380px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.6), 0 0 40px var(--glow2);
  position: relative; overflow: hidden;
}
.login-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--cyan), var(--teal), var(--green));
}
.login-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 32px; }
.login-logo-badge {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, #0e7490, #14b8a6);
  border-radius: 14px; display: flex; align-items: center;
  justify-content: center; font-size: 26px;
  box-shadow: 0 0 20px rgba(20,184,166,0.35);
}
.login-logo h1 { font-family: 'Playfair Display', serif; font-size: 22px; color: var(--teal-lt); font-weight: 700; }
.login-logo p { font-size: 11px; color: var(--muted); margin-top: 3px; }
.login-field { margin-bottom: 16px; }
.login-label { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 7px; display: block; }
.login-input {
  width: 100%; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 9px;
  padding: 12px 14px; color: var(--text); font-size: 14px;
  font-family: 'Space Grotesk', sans-serif; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.login-input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--glow); }
.login-btn {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, var(--cyan), var(--teal));
  color: #ffffff; border: none; border-radius: 9px;
  font-size: 14px; font-weight: 700;
  font-family: 'Space Grotesk', sans-serif; cursor: pointer;
  margin-top: 8px; transition: all 0.15s; letter-spacing: 0.3px;
}
.login-btn:hover { filter: brightness(1.1); box-shadow: 0 0 24px var(--glow); }
.login-error { font-size: 12px; color: #f87171; margin-top: 10px; text-align: center; display: none; }

/* ── SCROLLBAR ── */
/* ── COLLAPSIBLE NAV ── */
.nav-section { border-bottom: 1px solid var(--border); }
.nav-header {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: none; border: none; cursor: pointer;
  color: var(--text); font-size: 13px; font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  transition: background 0.15s; text-align: left;
}
.nav-header:hover { background: var(--surface2); }
.nav-arrow { font-size: 11px; color: var(--muted); transition: transform 0.2s; }
.nav-arrow.open { transform: rotate(90deg); }
.nav-body { display: none; padding-bottom: 6px; }
.nav-body.open { display: block; }
.nav-item {
  width: 100%; display: block; padding: 8px 16px; background: none; border: none;
  color: var(--muted); font-size: 12px; font-weight: 500; cursor: pointer;
  font-family: 'Space Grotesk', sans-serif; text-align: left;
  transition: all 0.12s; border-radius: 0;
}
.nav-item:hover { background: var(--surface2); color: var(--teal); }
.nav-divider { height: 1px; background: var(--border); margin: 6px 12px; }

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--teal); }

.logout-btn {
  background: rgba(13,148,136,0.12); border: 1px solid var(--border2); color: var(--teal);
  border-radius: 8px; padding: 7px 14px; font-size: 12px; font-weight: 600; cursor: pointer;
  font-family: 'Space Grotesk', sans-serif; transition: all 0.15s;
}
.logout-btn:hover { background: rgba(13,148,136,0.22); }

/* ── META PUBLISHING ── */
.meta-panel { padding: 6px 16px 10px; display: flex; flex-direction: column; gap: 8px; }
.meta-hint { font-size: 11px; color: var(--muted); line-height: 1.5; }
.meta-hint-inline { font-size: 11px; color: var(--muted); font-weight: 400; }
.meta-warn {
  font-size: 11px; line-height: 1.5; color: #92400e;
  background: #fef3c7; border: 1px solid #fcd34d; border-radius: 8px; padding: 7px 10px;
}
.meta-label { font-size: 11px; font-weight: 600; color: var(--text); }
.meta-subtitle {
  font-size: 9px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--muted); font-weight: 600; margin-top: 6px;
}
.meta-select, .meta-input {
  width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; color: var(--text); font-size: 12px; font-family: 'Space Grotesk', sans-serif;
}
.meta-select:focus, .meta-input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--glow); }
.meta-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.meta-danger { color: #dc2626; }
.meta-upcoming {
  display: flex; justify-content: space-between; align-items: center; gap: 6px; width: 100%;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 9px; font-size: 11px; color: var(--text); cursor: pointer; text-align: left;
  font-family: 'Space Grotesk', sans-serif;
}
.meta-upcoming:hover { border-color: var(--teal); }

.meta-chip {
  display: inline-flex; align-items: center; gap: 3px; white-space: nowrap;
  padding: 2px 8px; border-radius: 20px; font-size: 10px; font-weight: 600;
  background: var(--surface2); color: var(--muted); border: 1px solid var(--border);
}
.meta-chip-scheduled { background: rgba(6,182,212,0.12); color: #0e7490; border-color: rgba(6,182,212,0.3); }
.meta-chip-ok  { background: rgba(16,185,129,0.12); color: #047857; border-color: rgba(16,185,129,0.3); }
.meta-chip-bad { background: rgba(220,38,38,0.08); color: #b91c1c; border-color: rgba(220,38,38,0.25); }
.meta-view { display: flex; flex-direction: column; gap: 18px; }
.meta-list { display: flex; flex-direction: column; gap: 8px; }
.meta-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 12px;
}
.meta-row-thumb { width: 56px; height: 56px; border-radius: 6px; object-fit: cover; border: 1px solid var(--border); flex-shrink: 0; }
.meta-row-thumb-empty { display: flex; align-items: center; justify-content: center; background: var(--surface2); font-size: 20px; }
.meta-row-main { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 4px; }
.meta-row-error { color: #b91c1c; font-size: 11px; line-height: 1.5; }
.meta-row-actions { display: flex; gap: 6px; }

.meta-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.meta-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.meta-inline { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.meta-radio, .meta-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; cursor: pointer; }
.meta-radio input, .meta-check input { width: 16px; height: 16px; accent-color: var(--teal); }
.meta-check input:disabled + * { opacity: 0.6; }
.meta-over { color: #b91c1c; font-weight: 700; }
.meta-thumbs { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-start; }
.meta-thumb { width: 120px; display: flex; flex-direction: column; gap: 4px; }
.meta-thumb img { width: 120px; height: 120px; object-fit: contain; background: var(--surface2); border-radius: 8px; border: 1px solid var(--border); }
.meta-thumb-bad img { border: 2px solid #dc2626; }
.meta-thumb-bar { display: flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; color: var(--muted); }
.meta-thumb-bar span { flex: 1; }
.meta-thumb-bar button {
  width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; font-size: 11px;
}
.meta-thumb-bar button:hover:not(:disabled) { border-color: var(--teal); color: var(--teal); }
.meta-thumb-bar button:disabled { opacity: 0.35; cursor: default; }
.meta-thumb-problem { font-size: 10px; line-height: 1.4; color: #b91c1c; }
.meta-drop {
  width: 120px; height: 120px; border: 2px dashed var(--border2); border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  text-align: center; padding: 8px; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--teal);
}
.meta-drop:hover, .meta-drop-over { border-color: var(--teal); background: rgba(20,184,166,0.06); }
.meta-drop:focus-within { box-shadow: 0 0 0 3px var(--glow); }
.meta-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.meta-submit { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.btn-gold:disabled { opacity: 0.5; cursor: wait; filter: none; box-shadow: none; }
#metaFormBody { display: flex; flex-direction: column; gap: 18px; }
.meta-link { background: none; border: none; padding: 0; color: var(--teal); font: inherit; text-decoration: underline; cursor: pointer; }
.meta-log-platform { font-size: 12px; }
.meta-log-code { font-family: ui-monospace, Consolas, monospace; background: var(--surface2); color: var(--text); border-radius: 4px; padding: 0 4px; white-space: nowrap; }
.meta-log-platform a { color: var(--teal); font-weight: 600; }
.meta-log-caption {
  font-size: 11px; color: var(--muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.meta-drop-wide { width: 100%; max-width: 420px; height: 110px; position: relative; }
.meta-video { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.meta-video video { width: 220px; max-height: 390px; background: #000; border-radius: 8px; border: 1px solid var(--border); }
.meta-video-info { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.meta-cover { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; margin-top: 4px; }
.meta-cover img, .meta-cover-empty { width: 90px; height: 160px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); }
.meta-cover-empty { display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); }
.meta-cover-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; max-width: 320px; }
.meta-file-btn { position: relative; }
.meta-file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.meta-file-btn:focus-within { box-shadow: 0 0 0 3px var(--glow); }
.meta-drop { position: relative; }

/* ── CANVA IMPORT ── */
#canvaImportSlot:empty { display: none; }
.canva-dialog {
  width: min(860px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 20px; margin: auto;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text);
  box-shadow: 0 24px 60px rgba(0,0,0,0.25); font-family: "Space Grotesk", sans-serif;
}
.canva-dialog[open] { display: flex; flex-direction: column; gap: 14px; }
.canva-dialog::backdrop { background: rgba(2,13,18,0.45); }
.canva-head { display: flex; justify-content: space-between; align-items: center; }
.canva-head h2 { font-family: "Playfair Display", serif; font-size: 22px; color: var(--text); }
.canva-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px;
  overflow-y: auto; min-height: 120px; max-height: 46vh; padding: 2px;
}
.canva-design {
  display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 6px; cursor: pointer;
  border: 2px solid var(--border); border-radius: 10px; background: var(--surface); font-family: inherit; color: var(--text);
}
.canva-design:hover { border-color: var(--teal-lt); }
.canva-design:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--glow); }
.canva-selected { border-color: var(--teal); background: rgba(20,184,166,0.08); }
.canva-design img, .canva-noimg { width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--surface2); border-radius: 6px; }
.canva-noimg { display: flex; align-items: center; justify-content: center; font-size: 28px; }
.canva-title { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.canva-more { display: flex; justify-content: center; }
.canva-more:empty { display: none; }
.canva-foot { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.canva-chosen { font-size: 13px; }

/* ── PHONES & TOUCH ── */
.menu-btn, .nav-backdrop, .mobile-only { display: none; }

/* No hover on touch screens: show the image actions and the ✕ on posts all the time */
@media (hover: none) {
  .canvas-overlay {
    opacity: 1; inset: auto 0 0 0; flex-direction: row; flex-wrap: wrap; padding: 10px;
    background: linear-gradient(transparent, rgba(2,13,18,0.75)); backdrop-filter: none;
  }
  .canvas-overlay-btn { min-height: 40px; background: rgba(2,13,18,0.72); color: #ffffff; border-color: rgba(255,255,255,0.4); }
  .hover-hint { display: none; }
  .post-del { opacity: 1 !important; min-width: 40px; min-height: 40px; }
}

@media (max-width: 760px) {
  header { position: sticky; top: 0; z-index: 60; height: 60px; padding: 0 12px; gap: 10px; }
  header h1 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  header p, .dragon-badge { display: none; }
  .menu-btn {
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--border2);
    background: var(--surface); color: var(--teal); font-size: 20px; cursor: pointer;
  }
  .menu-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--glow); }
  .mobile-only { display: inline-flex; }

  /* The sidebar slides in under the header; the page itself scrolls */
  .layout { display: block; height: auto; }
  .sidebar {
    position: fixed; top: 60px; bottom: 0; left: 0; z-index: 50;
    width: min(340px, 88vw); height: auto;
    transform: translateX(-100%); visibility: hidden;
    transition: transform 0.22s ease, visibility 0s linear 0.22s;
    box-shadow: 8px 0 30px rgba(0,0,0,0.18);
  }
  body.nav-open .sidebar { transform: none; visibility: visible; transition: transform 0.22s ease; }
  .nav-backdrop { position: fixed; inset: 60px 0 0 0; z-index: 40; background: rgba(2,13,18,0.4); }
  body.nav-open .nav-backdrop { display: block; }
  body.nav-open { overflow: hidden; }

  .main { overflow: visible; padding: 16px; gap: 16px; min-height: calc(100vh - 60px); }
  .post-header { flex-wrap: wrap; }
  .post-header-actions { flex-wrap: wrap; flex-shrink: 1; }
  .post-title { font-size: 24px; }
  .fields-group { padding: 14px; }

  /* Square previews scale to the screen width */
  .slide-card { width: 100%; }
  .canvas-wrap, .text-slide-wrap { width: 100%; max-width: 380px; height: auto; aspect-ratio: 1; }
  .canvas-wrap.is-tall, .text-slide-wrap.is-tall { max-width: 270px; height: auto; aspect-ratio: 9 / 16; }
  .canvas-wrap canvas { width: 100%; height: 100%; }

  /* 16px text stops phones zooming in when a field is tapped */
  .api-input, .login-input, .meta-input, .meta-select, textarea.prompt-text { font-size: 16px; }

  .login-card { width: calc(100vw - 32px); max-width: 380px; padding: 32px 22px; }
  .toast { left: 16px; right: 16px; bottom: 16px; }
}

@media (max-width: 760px) and (prefers-reduced-motion: reduce) {
  .sidebar, body.nav-open .sidebar { transition: none; }
}
