/* CaptionMe — shared styles */
:root {
  --bg: #14161c;
  --panel: #1d2027;
  --panel-2: #262a33;
  --border: #343a46;
  --text: #e8eaf0;
  --muted: #9aa3b2;
  --accent: #5b8cff;
  --accent-2: #7c5bff;
  --danger: #ff5b6a;
  --ok: #37c871;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

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

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar .brand { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.topbar .spacer { flex: 1; }
.topbar nav { display: flex; gap: 12px; align-items: center; }
.topbar nav .link { color: var(--muted); }
.topbar nav .link.active { color: var(--text); }
.user-chip { color: var(--muted); font-size: 13px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.grid { display: grid; gap: 16px; }
.cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }

input, select, textarea, .file-drop {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font: inherit;
}
input[type="checkbox"], input[type="radio"] { width: auto; }
textarea { resize: vertical; font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); }

button.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 14px;
  font: inherit;
  cursor: pointer;
}
button.btn:hover { border-color: var(--muted); }
button.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: none; color: #fff; }
button.btn.primary:hover { filter: brightness(1.08); }
button.btn.danger { color: var(--danger); }
button.btn.small { padding: 5px 9px; font-size: 12px; }
button.btn:disabled { opacity: .45; cursor: default; }

.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }

.chip {
  font-size: 11px; padding: 2px 8px; border-radius: 99px;
  border: 1px solid var(--border); color: var(--muted);
}
.chip.owner { color: var(--accent); border-color: var(--accent); }
.chip.editor { color: var(--ok); border-color: var(--ok); }
.chip.live { background: var(--ok); color: #06281a; border: none; }
.chip.danger { color: var(--danger); border-color: var(--danger); }

.badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; }
.badge.pub { background: #2a5a3b; color: #b5f0cd; }
.badge.slug { background: var(--panel-2); color: var(--muted); }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.alert.error { background: #3a1d24; color: #ffb3ba; border: 1px solid #5b2631; }
.alert.info { background: #1e2a44; color: #bcd1ff; border: 1px solid #31456e; }
.alert.success { background: #1a3325; color: #a3e6b8; border: 1px solid #235438; }
.alert.warning { background: #3b2d13; color: #fce196; border: 1px solid #664d1f; }

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 22px 2px 10px; }

/* Auth */
.auth-wrap { max-width: 900px; margin: 60px auto; padding: 0 16px; }
.auth-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 760px) { .auth-cols { grid-template-columns: 1fr; } }
.auth-card h2 { margin-top: 0; }
.auth-card .field { margin-bottom: 12px; }

/* Landing (index.html) */
.lp-top { display: flex; align-items: center; gap: 16px; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--border); }
.lp-link { color: var(--muted); margin-right: 12px; }
.lp-wrap { max-width: 880px; margin: 0 auto; padding: 8px 16px 40px; }
.lp-hero { text-align: center; padding: 22px 0 8px; }
.lp-h1 {
  font-size: clamp(44px, 9vw, 88px); margin: 0; letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lp-sub { max-width: 620px; margin: 12px auto 18px; color: var(--muted); font-size: 17px; line-height: 1.5; }
.lp-cta { display: inline-block; font-size: 15px; padding: 11px 22px; text-decoration: none; }
.lp-fine { margin-top: 12px; font-size: 12px; color: var(--muted); }

.lp-demo { position: relative; max-width: 480px; margin: 30px auto 0; }
.lp-photo {
  aspect-ratio: 4/3; border-radius: var(--radius); position: relative;
  overflow: visible; border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 16px 44px rgba(0,0,0,.6); background: #181b22;
}
.lp-hero-img {
  width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius); display: block;
}
.lp-bubble {
  position: absolute; top: -16px; right: -18px; max-width: 240px;
  background: #ffffff; color: #111111; border-radius: 16px; padding: 11px 16px;
  font-size: 14px; font-weight: 800; box-shadow: 0 10px 30px rgba(0,0,0,.5);
  line-height: 1.35; z-index: 2; transform-origin: bottom left;
  transition: transform .2s ease;
}
.lp-bubble::after {
  content: ""; position: absolute; left: 24px; bottom: -11px;
  width: 0; height: 0; border-top: 12px solid #ffffff; border-left: 12px solid transparent;
}

.lp-band { margin: 40px 0 0; }
.lp-band-title { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); margin-bottom: 14px; text-align: center; font-weight: 800; }
.lp-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.lp-card { padding: 16px; }
.lp-num { font-size: 12px; color: var(--accent-2); font-weight: 800; letter-spacing:.2px; }
.lp-op { font-size: 16px; font-weight: 700; margin: 6px 0; }
.lp-body { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 6px 0 0; }

.lp-tiltrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; padding: 10px 0; }
.lp-tilt { padding: 12px; transition: transform .2s ease, box-shadow .2s ease; cursor: default; }
.lp-tilt:hover { transform: rotate(0deg) scale(1.02) !important; box-shadow: 0 12px 32px rgba(0,0,0,.45); }
.lp-thumb {
  aspect-ratio: 1/1; border-radius: 10px; position: relative; overflow: hidden;
  box-shadow: 0 6px 20px rgba(0,0,0,.4); background: #20242e;
}
.lp-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s ease;
}
.lp-tilt:hover .lp-thumb img {
  transform: scale(1.06);
}
.lp-th-cap {
  position: absolute; left: 8px; right: 8px; bottom: 8px; text-align: center;
  font-size: 12px; font-weight: 800; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.9);
  line-height: 1.25; background: rgba(14, 17, 24, 0.78); backdrop-filter: blur(6px);
  padding: 6px 8px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.15);
}
.lp-tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 99px; background: var(--panel-2); color: var(--muted); margin: 10px 4px 0 0; }
.lp-meta { font-size: 12px; color: var(--muted); margin-top: 8px; font-weight: 500; }

.lp-last { text-align: center; margin: 44px 0 12px; }
.lp-cta-row { display: flex; gap: 14px; justify-content: center; margin-top: 16px; }
.lp-foot { text-align: center; color: var(--muted); font-size: 12px; padding: 24px 16px 40px; }
@media (max-width: 600px) {
  .lp-demo { max-width: 100%; }
  .lp-bubble { right: -6px; top: -14px; max-width: 190px; font-size: 12px; padding: 8px 12px; }
  .lp-cta-row { flex-direction: column; align-items: center; }
}

/* Dashboard / Library */
.proj-card { cursor: pointer; position: relative; }
.proj-card img { width: 100%; aspect-ratio: 4/3; object-fit: contain; border-radius: 8px; background: var(--panel-2); display: block; }
.proj-card .proj-name { font-weight: 600; margin: 8px 2px 2px; display: flex; align-items: center; justify-content: space-between; }
.proj-card .proj-meta { color: var(--muted); font-size: 12px; margin: 0 2px 6px; }
.proj-actions { display: flex; gap: 6px; margin-top: 6px; }
.thumb-empty { width: 100%; aspect-ratio: 4/3; border-radius: 8px; background: var(--panel-2); display: grid; place-items: center; color: var(--muted); }

.workspace-head { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.workspace-head h3 { margin: 0; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.member-row .email { flex: 1; }

.share-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.share-row input { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 11px; background: rgba(0, 0, 0, 0.4); color: #e2e8f0; border: 1px solid var(--border); padding: 7px 10px; border-radius: 6px; }
.vis-row { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 6px; cursor: pointer; }
.vis-row input { width: auto; }

/* Editor */
#editor-page { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.ed-top { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--border); }
.ed-top input[name="name"] { width: 220px; background: transparent; border: 1px solid transparent; }
.ed-top input[name="name"]:hover, .ed-top input[name="name"]:focus { border-color: var(--border); background: var(--panel-2); }
.ed-body { display: flex; flex: 1; min-height: 0; }
.ed-left { width: 64px; background: var(--panel); border-right: 1px solid var(--border); padding: 10px 8px; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.ed-left .tbtn { width: 48px; height: 44px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); cursor: pointer; font-size: 19px; }
.ed-left .tbtn.small2 { font-size: 15px; height: 38px; }
.ed-left .tbtn.active { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.ed-left .sep { height: 1px; width: 36px; background: var(--border); margin: 4px 0; }

.ed-canvas-wrap { flex: 1; position: relative; overflow: hidden; background: #0d0e12; }
#editor-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
.ed-zoom {
  position: absolute; right: 14px; bottom: 12px; display: flex; gap: 4px; align-items: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 4px;
}
.ed-zoom button { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); width: 28px; height: 26px; border-radius: 6px; cursor: pointer; }
.ed-zoom span { min-width: 56px; text-align: center; font-size: 12px; color: var(--muted); }

.ed-side { width: 300px; background: var(--panel); border-left: 1px solid var(--border); overflow-y: auto; padding: 14px; }
.ed-side .field { margin-bottom: 12px; }
.ed-side label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.ed-status { height: 26px; background: var(--panel); border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 16px; padding: 0 14px; }
.ed-status .st-dirty { color: #e0b34a; }
.ed-status .st-conflict { color: var(--danger); }
#toast {
  position: fixed;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  padding: 8px 18px;
  border-radius: 20px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  font-weight: 600;
  font-size: 13px;
  pointer-events: none;
  animation: toastFadeIn 0.2s ease-out;
}
@keyframes toastFadeIn {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.color-input { display: flex; align-items: center; gap: 8px; }
.color-input input[type="color"] { width: 36px; height: 32px; border: 1px solid var(--border); border-radius: 6px; background: transparent; padding: 2px; }
#empty-hint { color: var(--muted); position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; font-size: 15px; }

.float-text {
  position: absolute; z-index: 6; background: var(--panel-2); border: 1px solid var(--accent);
  border-radius: 8px; padding: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.5); min-width: 260px;
}
.float-text textarea { min-height: 46px; }

/* Comic Typography */
.font-bangers { font-family: 'Bangers', sans-serif; letter-spacing: 1px; }
.font-comic { font-family: 'Comic Neue', cursive; font-weight: 700; }
.font-luckiest { font-family: 'Luckiest Guy', cursive; }
.font-marker { font-family: 'Permanent Marker', cursive; }
.font-anton { font-family: 'Anton', sans-serif; }
.font-bungee { font-family: 'Bungee', cursive; }
.font-impact { font-family: 'Impact', sans-serif; }

/* Sticker Tray & Props */
.sticker-tray {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px 2px;
  margin-bottom: 10px;
}
.sticker-item {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 4px;
  text-align: center;
  cursor: pointer;
  color: #e8eaf0;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
  user-select: none;
}
.sticker-item:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: #313642;
  color: #ffffff;
}
.sticker-item .sticker-icon { font-size: 22px; display: block; line-height: 1; }
.sticker-item .sticker-label,
.sticker-item .sticker-name {
  font-size: 11px;
  font-weight: 600;
  color: #e8eaf0;
  line-height: 1.2;
}
.sticker-item:hover .sticker-label,
.sticker-item:hover .sticker-name {
  color: #ffffff;
}

/* Remix Lineage Badge */
.remix-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(124, 91, 255, 0.18);
  border: 1px solid var(--accent-2);
  color: #c4b5fd;
  text-decoration: none;
}
.remix-badge:hover { text-decoration: underline; }

/* Animation Sequence & Layers */
.layer-seq-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  margin-top: 8px;
  padding: 2px;
}
.layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.layer-item:hover {
  background: #313642;
  border-color: var(--accent);
}
.layer-item.active {
  background: rgba(91, 140, 255, 0.18);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.layer-badge {
  font-size: 10px;
  font-weight: 700;
  background: var(--border);
  color: var(--text);
  padding: 2px 6px;
  border-radius: 99px;
  min-width: 22px;
  text-align: center;
}
.layer-item.active .layer-badge {
  background: var(--accent);
  color: #ffffff;
}
.layer-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.layer-icon {
  font-size: 15px;
  flex-shrink: 0;
}
.layer-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.layer-actions {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}
.layer-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10px;
  cursor: pointer;
  line-height: 1.2;
  transition: all 0.1s ease;
}
.layer-btn:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
.layer-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

/* Template Starters Modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 680px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.6);
}
.starters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.starter-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.starter-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
.starter-card .st-title { font-weight: 700; font-size: 14px; margin: 4px 0; color: var(--text); }
.starter-card .st-desc { font-size: 12px; color: var(--muted); line-height: 1.4; margin: 0 0 10px; }
.starter-preview {
  aspect-ratio: 4/3;
  background: #0d0e12;
  border-radius: 6px;
  border: 1px dashed var(--border);
  display: grid;
  place-items: center;
  font-size: 28px;
  margin-bottom: 8px;
}

/* Moderation, Voting, and Sort Tabs */
.sort-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 16px 0 20px;
}
.sort-pill {
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.sort-pill:hover {
  color: var(--text);
  border-color: var(--muted);
}
.sort-pill.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #ffffff;
  border-color: transparent;
  font-weight: 600;
}

.vote-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.25);
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
}
.vote-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all 0.12s ease;
}
.vote-btn:hover {
  color: var(--text);
  transform: scale(1.15);
}
.vote-btn.up.active {
  color: var(--ok);
  font-weight: bold;
}
.vote-btn.down.active {
  color: var(--danger);
  font-weight: bold;
}
.score-pill {
  font-size: 12px;
  font-weight: 700;
  min-width: 18px;
  text-align: center;
}
.score-pill.positive { color: var(--ok); }
.score-pill.negative { color: var(--danger); }
.score-pill.neutral { color: var(--muted); }

.report-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  opacity: 0.7;
  transition: all 0.12s ease;
}
.report-btn:hover {
  color: var(--danger);
  opacity: 1;
}

.trust-card {
  background: rgba(91, 140, 255, 0.08);
  border: 1px solid rgba(91, 140, 255, 0.3);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.trust-progress-bar {
  height: 6px;
  background: var(--panel-2);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}
.trust-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--ok));
  border-radius: 3px;
  transition: width 0.3s ease;
}