/* =========================================================
   PULSE — create-post.css
   Phase 1: Instagram-style post creation flow (picker/editor/details)
   ========================================================= */

.create-flow {
  position: relative;
  min-height: calc(100dvh - var(--top-h, 64px) - var(--nav-h, 72px));
  background: var(--bg);
}
body.create-open .topbar,
body.create-open .bottom-nav,
body.create-open .fab { display: none !important; }
body.create-open .app-main {
  padding: 0 !important;
  max-width: 100% !important;
}

.cp-screen {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
}
.cp-screen.hidden { display: none !important; }

.cp-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 90px 1fr 90px;
  align-items: center;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 12px 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.cp-topbar-title {
  text-align: center;
  font-weight: 700;
  font-size: 17px;
}
.cp-topbar .cp-nav-btn {
  min-height: 40px;
  padding: 8px 4px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  background: none;
  border: none;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.cp-topbar .cp-nav-btn.primary { color: var(--primary); font-weight: 700; }
.cp-topbar .cp-nav-btn:disabled { opacity: .4; cursor: not-allowed; }
.cp-topbar .cp-nav-left { justify-self: start; }
.cp-topbar .cp-nav-right { justify-self: end; }

.cp-picker-body, .cp-editor-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.cp-preview-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 52vh;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.cp-preview-stage.ratio-1-1 { aspect-ratio: 1 / 1; }
.cp-preview-stage.ratio-4-5 { aspect-ratio: 4 / 5; }
.cp-preview-stage.ratio-16-9 { aspect-ratio: 16 / 9; max-height: 46vh; }
.cp-preview-stage.ratio-original { aspect-ratio: auto; min-height: 260px; max-height: 52vh; }
.cp-preview-stage img,
.cp-preview-stage video {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.cp-preview-empty {
  color: rgba(255,255,255,.85);
  text-align: center;
  padding: 24px;
  font-size: 14px;
}
.cp-preview-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
}

.cp-picker-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.cp-picker-toolbar-left, .cp-picker-toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cp-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}
.cp-pill-btn.active { background: var(--primary); color: #fff; border-color: transparent; }
.cp-pill-btn svg { width: 16px; height: 16px; }

.cp-gallery-area {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
}
.cp-gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}
.cp-gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
@media (min-width: 480px) { .cp-gallery-grid { grid-template-columns: repeat(5, 1fr); } }
@media (min-width: 720px) { .cp-gallery-grid { grid-template-columns: repeat(6, 1fr); } }
.cp-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border: none;
  padding: 0;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-2);
  cursor: pointer;
}
.cp-thumb img, .cp-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cp-thumb.selected::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid var(--primary);
  border-radius: 6px;
  pointer-events: none;
}
.cp-thumb-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,.7);
}
.cp-thumb-type {
  position: absolute;
  left: 4px;
  bottom: 4px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 4px;
  font-weight: 600;
}
.cp-thumb-add {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  border: 1px dashed var(--border);
  background: var(--bg-2);
}
.cp-thumb-remove {
  position: absolute;
  left: 4px;
  top: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  display: grid; place-items: center;
}
.cp-type-chooser {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.cp-type-chooser::-webkit-scrollbar { display: none; }
.cp-type-chip {
  flex: 0 0 auto;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}
.cp-type-chip.active { color: #fff; background: var(--primary); border-color: transparent; }

.cp-editor-body { background: var(--bg); }
.cp-editor-tools {
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.cp-tool-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 8px 10px;
  scrollbar-width: none;
}
.cp-tool-tabs::-webkit-scrollbar { display: none; }
.cp-tool-tab {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  background: transparent;
}
.cp-tool-tab.active { background: var(--bg-2); color: var(--text); }
.cp-tool-panel { padding: 8px 12px 12px; }
.cp-tool-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.cp-tool-row label { min-width: 84px; font-size: 13px; color: var(--text-2); font-weight: 600; }
.cp-tool-row input[type="range"] { flex: 1; }
.cp-tool-row .cp-val { min-width: 42px; text-align: right; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.cp-filter-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.cp-filter-strip::-webkit-scrollbar { display: none; }
.cp-filter-item {
  flex: 0 0 auto;
  width: 72px;
  text-align: center;
  cursor: pointer;
}
.cp-filter-thumb {
  width: 72px; height: 72px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-2);
  border: 2px solid transparent;
  margin-bottom: 4px;
}
.cp-filter-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cp-filter-item.active .cp-filter-thumb { border-color: var(--primary); }
.cp-filter-item span { font-size: 11px; color: var(--text-2); font-weight: 600; }
.cp-aspect-row { display: flex; gap: 8px; flex-wrap: wrap; }
.cp-aspect-btn {
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--text);
}
.cp-aspect-btn.active { background: var(--primary); color: #fff; border-color: transparent; }
.cp-rotate-row { display: flex; gap: 8px; }

.cp-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  scrollbar-width: none;
}
.cp-strip::-webkit-scrollbar { display: none; }
.cp-strip-item {
  position: relative;
  flex: 0 0 56px;
  width: 56px; height: 56px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  padding: 0;
  background: var(--bg-2);
}
.cp-strip-item.active { border-color: var(--primary); }
.cp-strip-item img, .cp-strip-item video { width: 100%; height: 100%; object-fit: cover; }
.cp-strip-item .cp-strip-num {
  position: absolute; right: 2px; top: 2px;
  min-width: 16px; height: 16px; font-size: 10px;
  background: var(--primary); color:#fff; border-radius: 999px;
  display:inline-flex; align-items:center; justify-content:center; font-weight:700;
}

.cp-details-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 12px calc(90px + env(safe-area-inset-bottom));
}
.cp-details-top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.cp-details-preview {
  width: 72px; height: 72px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-2);
  flex: 0 0 auto;
  position: relative;
}
.cp-details-preview img, .cp-details-preview video { width: 100%; height: 100%; object-fit: cover; }
.cp-details-preview .cp-count-badge {
  position: absolute; right: 4px; bottom: 4px;
  background: rgba(0,0,0,.6); color:#fff; font-size: 10px; font-weight:700;
  padding: 2px 5px; border-radius: 999px;
}
.cp-caption-wrap { flex: 1; min-width: 0; }
.cp-caption-wrap textarea { min-height: 72px; resize: vertical; }
.cp-details-section {
  border-top: 1px solid var(--border);
}
.cp-details-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.cp-details-row.static { cursor: default; }
.cp-details-row-left { min-width: 0; }
.cp-details-row-left strong { display: block; font-size: 15px; font-weight: 600; color: var(--text); }
.cp-details-row-left span { display: block; font-size: 13px; color: var(--text-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-details-row-right { color: var(--text-2); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }
.cp-inline-input { margin-top: 8px; }
.cp-tag-people-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cp-user-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: 999px;
  background: var(--bg-2); border: 1px solid var(--border);
  font-size: 13px;
}
.cp-user-chip button { border:none; background:none; color:var(--text-2); font-size:16px; line-height:1; padding:0; }

.cp-publish-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
}
.cp-publish-bar .clay-btn { width: 100%; }
.cp-progress-wrap {
  margin-bottom: 8px;
  display: none;
}
.cp-progress-wrap.show { display: block; }
.cp-progress-bar {
  height: 6px;
  background: var(--bg-2);
  border-radius: 999px;
  overflow: hidden;
}
.cp-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  transition: width 120ms linear;
}
.cp-progress-text { font-size: 12px; color: var(--text-2); margin-top: 4px; text-align: center; }

.cp-hidden-input { display: none !important; }
.cp-toast-inline { color: #ef4444; font-size: 13px; padding: 8px 4px; }
.cp-helper { font-size: 12px; color: var(--text-2); padding: 4px 0; }

@media (min-width: 900px) {
  .create-flow { max-width: 980px; margin: 0 auto; }
  .cp-screen { min-height: 100%; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
  .cp-picker-body, .cp-editor-body {
    flex-direction: row;
    align-items: stretch;
  }
  .cp-preview-stage { flex: 1 1 58%; max-height: calc(100dvh - 140px); aspect-ratio: auto; min-height: 420px; }
  .cp-gallery-area, .cp-editor-tools-wrap { flex: 1 1 42%; max-width: 420px; border-left: 1px solid var(--border); }
  .cp-editor-tools { border-top: none; height: 100%; overflow: auto; }
  .cp-strip { border-left: 1px solid var(--border); }
  .cp-details-body { max-width: 720px; margin: 0 auto; width: 100%; }
  .cp-publish-bar { left: 50%; right: auto; transform: translateX(-50%); width: min(720px, calc(100% - 2px)); border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

/* Feed/post carousel (shared display) */
.post-carousel {
  position: relative;
  margin-top: var(--s-3);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-2);
}
.post-carousel-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.post-carousel-track::-webkit-scrollbar { display: none; }
.post-carousel-slide {
  flex: 0 0 100%;
  scroll-snap-align: center;
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}
.post-carousel-slide img,
.post-carousel-slide video {
  width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: contain;
  display: block;
}
.post-carousel-dots {
  position: absolute;
  left: 0; right: 0; bottom: 8px;
  display: flex;
  justify-content: center;
  gap: 5px;
  pointer-events: none;
}
.post-carousel-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255,255,255,.45);
}
.post-carousel-dot.active { background: #fff; }
.post-carousel-count {
  position: absolute;
  top: 8px; right: 8px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
}
.post-carousel-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.9);
  color: #111;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.post-carousel-nav.prev { left: 8px; }
.post-carousel-nav.next { right: 8px; }
@media (hover: hover) and (pointer: fine) {
  .post-carousel:hover .post-carousel-nav { display: inline-flex; }
}