:root {
  --bg: #FAF8F5; --card: #fff; --ink: #2B2623; --muted: #8A817B; --line: #EEE8E1;
  --accent: #F07B5E; --accent-soft: #FDEBE6; --radius: 16px;
  --shadow: 0 2px 14px rgba(60, 40, 30, .07);
  --header-h: 56px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.center { text-align: center; }
.pad { padding: 48px 20px; }
[hidden] { display: none !important; }

.topbar {
  height: var(--header-h); display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; position: sticky; top: 0; z-index: 20; background: var(--bg);
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
.ig-btn {
  height: 34px; padding: 0 14px 0 11px; border-radius: 999px; display: inline-flex; align-items: center; gap: 7px;
  background: var(--card); color: var(--accent); box-shadow: var(--shadow); text-decoration: none;
  font-size: 13px; font-weight: 600; white-space: nowrap; flex: none;
}
.ig-btn svg { flex: none; }
.pos-pill {
  background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 650;
  padding: 4px 12px; border-radius: 999px; white-space: nowrap; margin: 0 auto; font-variant-numeric: tabular-nums;
}
.topbar h1 { white-space: nowrap; }
@media (max-width: 480px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar h1 { font-size: 15px; }
  .ig-btn { padding: 0 10px 0 9px; font-size: 12px; gap: 5px; }
  .pos-pill { font-size: 12px; padding: 3px 9px; }
}
@media (max-width: 370px) { .topbar h1 { display: none; } }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.btn {
  border: 0; border-radius: 999px; padding: 9px 18px; background: var(--accent); color: #fff;
  cursor: pointer; font-weight: 600;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.danger { background: #fff; color: #C0463A; box-shadow: inset 0 0 0 1px #F1D4D0; }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px 0; font-size: 13px; }
.link-btn:hover { color: var(--accent); }
textarea, input[type=text], select {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; outline: none;
}
textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }
.msg-box { max-width: 420px; margin: 18vh auto 0; text-align: center; }
.error-text { color: #C0463A; font-size: 13px; }
.warn-text { color: #B7791F; font-size: 13px; }

/* ---------- criativo ---------- */
.creative { width: min(100%, calc((100dvh - 150px) * var(--ar, .8))); margin: 0 auto; }
.frame {
  position: relative; width: 100%; background: #EDE7E0; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
}
.frame img, .frame video { width: 100%; height: 100%; object-fit: cover; display: block; }

.carousel-track {
  display: flex; width: 100%; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: none; overscroll-behavior-x: contain;
}
.carousel-track::-webkit-scrollbar { display: none; }
.carousel-track.dragging { scroll-snap-type: none; cursor: grabbing; }
.carousel-track .slide { flex: 0 0 100%; height: 100%; scroll-snap-align: center; scroll-snap-stop: always; }
.carousel-track img { -webkit-user-drag: none; user-select: none; }
.car-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border-radius: 50%;
  border: 0; background: rgba(255,255,255,.9); box-shadow: var(--shadow); cursor: pointer; font-size: 16px; line-height: 1;
}
.car-arrow.prev { left: 8px; } .car-arrow.next { right: 8px; }
.car-arrow:disabled { opacity: 0; pointer-events: none; }
.car-count {
  position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,.55); color: #fff; font-size: 12px;
  padding: 2px 9px; border-radius: 999px;
}
.car-dots { position: absolute; bottom: 10px; left: 0; right: 0; display: flex; justify-content: center; gap: 5px; pointer-events: none; }
.car-dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.55); }
.car-dots i.on { background: #fff; box-shadow: 0 0 3px rgba(0,0,0,.4); }

.reel { position: relative; }
.reel-frame video { cursor: pointer; background: #000; }
.reel-controls {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 10px;
  padding: 22px 12px 10px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.5));
  border-radius: 0 0 var(--radius) var(--radius);
}
.reel-controls button {
  width: 32px; height: 32px; flex: none; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255,255,255,.92); color: var(--ink); font-size: 13px; line-height: 1;
}
.reel-bar { flex: 1; height: 22px; display: flex; align-items: center; cursor: pointer; touch-action: none; }
.reel-bar-track { width: 100%; height: 5px; border-radius: 3px; background: rgba(255,255,255,.4); overflow: hidden; }
.reel-bar-fill { height: 100%; width: 0; background: var(--accent); }
.reel-time { font-size: 12px; min-width: 66px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- thread ---------- */
.objective { background: var(--accent-soft); border-radius: 12px; padding: 10px 12px; margin: 0 0 14px; }
.obj-lbl { font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.obj-txt { white-space: pre-wrap; word-break: break-word; }
.caption { white-space: pre-wrap; word-break: break-word; margin: 0 0 14px; }
.thread { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.bubble { padding: 8px 12px; border-radius: 14px; background: #F4F0EB; max-width: 92%; align-self: flex-start; }
.bubble.mine { background: var(--accent-soft); align-self: flex-end; }
.bubble .who { font-size: 11px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.bubble .txt { white-space: pre-wrap; word-break: break-word; }
.hidden-comments { align-self: flex-start; }
.comment-form { display: flex; flex-direction: column; gap: 8px; }
.comment-form .row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- review ---------- */
.feed { height: calc(100dvh - var(--header-h)); overflow-y: auto; scroll-snap-type: y proximity; }
.rv-post {
  min-height: calc(100dvh - var(--header-h)); scroll-snap-align: start; padding: 8px 20px 24px;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: 28px; align-items: start;
  max-width: 1000px; margin: 0 auto;
}
.rv-side { display: flex; flex-direction: column; max-height: calc(100dvh - var(--header-h) - 24px); overflow-y: auto; }
.rv-next { margin-top: 12px; align-self: flex-start; }
@media (min-width: 769px) { .feed { scroll-snap-type: y mandatory; } }
@media (max-width: 768px) {
  .feed { overflow-x: hidden; }
  .rv-post { grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 8px 14px 20px; min-height: 0; width: 100%; max-width: 100%; }
  .rv-post > * { min-width: 0; max-width: 100%; }
  .creative { max-width: 100%; }
  .creative { width: min(100%, calc((100dvh - 190px) * var(--ar, .8))); }
  .rv-side { max-height: none; overflow: visible; width: 100%; }
  .reel-controls { position: static; background: none; color: var(--ink); padding: 10px 2px 0; }
  .reel-bar-track { background: #E4DDD5; }
}

/* ---------- criador ---------- */
.wrap { max-width: 760px; margin: 0 auto; padding: 8px 16px 60px; display: flex; flex-direction: column; gap: 20px; }
.wrap h2 { font-size: 16px; margin: 0 0 12px; }
.field { margin-bottom: 14px; }
.field > label, .field > .lbl { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.seg { display: inline-flex; background: #F4F0EB; border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 14px; border-radius: 999px; cursor: pointer; }
.seg button.on { background: #fff; color: var(--accent); font-weight: 600; box-shadow: var(--shadow); }
.previews { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.pv { width: 96px; }
.pv .th { width: 96px; height: 96px; border-radius: 10px; overflow: hidden; background: #EDE7E0; }
.pv .th img, .pv .th video { width: 100%; height: 100%; object-fit: cover; display: block; }
.pv .ctl { display: flex; justify-content: center; gap: 6px; margin-top: 4px; }
.pv .ctl button { border: 0; background: #F4F0EB; border-radius: 8px; padding: 2px 9px; cursor: pointer; }
.queue { display: flex; flex-direction: column; gap: 12px; }
.q-item { display: flex; gap: 14px; align-items: center; cursor: pointer; }
.q-thumb { width: 68px; height: 68px; border-radius: 12px; overflow: hidden; flex: none; background: #EDE7E0; }
.q-thumb img, .q-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.q-body { flex: 1; min-width: 0; }
.q-cap { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.q-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.q-actions { display: flex; flex-direction: column; gap: 6px; }
.detail { display: grid; grid-template-columns: 1fr; gap: 16px; }
.overlay {
  position: fixed; inset: 0; background: rgba(43,38,35,.45); z-index: 50; display: grid; place-items: center; padding: 16px;
}
.overlay .card { width: min(520px, 100%); max-height: 90dvh; overflow-y: auto; }
.actions-row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }

.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
.file-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.file-btn { display: inline-block; }
.file-count { font-size: 13px; }

/* edição de mídia */
.overlay .card.edit-card { width: min(640px, 100%); }
.edit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 12px; }
.edit-grid .th { position: relative; width: 100%; border-radius: 10px; overflow: hidden; background: #EDE7E0; }
.edit-grid .th img, .edit-grid .th video { width: 100%; height: 100%; object-fit: cover; display: block; }
.edit-grid .x { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border: 0; border-radius: 50%; background: rgba(43,38,35,.75); color: #fff; cursor: pointer; line-height: 1; font-size: 16px; }
.edit-grid .x:disabled { opacity: .35; cursor: not-allowed; }
.edit-grid .ctl { display: flex; justify-content: space-between; gap: 3px; margin-top: 4px; }
.edit-grid .ctl button { border: 0; background: #F4F0EB; border-radius: 8px; padding: 3px 6px; cursor: pointer; font-size: 12px; }
.edit-grid .ctl button:disabled { opacity: .4; cursor: not-allowed; }
.edit-grid .add { width: 100%; border: 2px dashed #D9CFC4; background: none; border-radius: 10px; color: var(--accent); cursor: pointer; font-weight: 600; }
.edit-grid .add:disabled { opacity: .4; cursor: not-allowed; }
