:root {
  --bg: #fafafa;
  --fg: #111;
  --muted: #777;
  --line: #dbdbdb;
  --accent: #0095f6;
  --sidebar-w: 240px;
  --tile-gap: 4px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--fg); background: var(--bg); }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
img, video { display: block; max-width: 100%; }
.muted { color: var(--muted); font-size: 0.85rem; }

/* Sidebar */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: #fff; border-right: 1px solid var(--line);
  overflow-y: auto; padding: 16px 0;
}
.sidebar .title-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; margin-bottom: 2px;
}
.sidebar h1 { margin: 0; font-size: 1.5rem; }
.sidebar .total { margin: 0 16px 6px; color: var(--muted); font-size: 0.85rem; }
.sidebar .sync-status { margin: 0 16px 14px; font-size: 0.75rem; min-height: 1em; }
.sidebar nav ul { list-style: none; margin: 0; padding: 0; }
.sidebar nav li a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 16px; font-size: 0.9rem; border-left: 3px solid transparent;
}
.sidebar nav li a:hover { background: #f0f0f0; border-left-color: var(--accent); }
.sidebar nav .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 8px; }
.sidebar nav .n { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Sync icon button */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0;
  background: transparent; color: var(--accent);
  border: 1px solid var(--line); border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: #eaf6ff; border-color: var(--accent); }
.icon-btn:active { background: #d6ecff; }
.icon-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.icon-btn svg { display: block; }
.icon-btn.spinning svg { animation: spin 1.1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

main {
  margin-left: var(--sidebar-w);
  padding: 24px 32px 64px;
  max-width: 1200px;
}

.page-head { margin-bottom: 24px; }
.page-head h2 { margin: 0 0 4px; font-size: 1.6rem; font-weight: 600; }

/* Grids */
.grid { display: grid; gap: var(--tile-gap); }
.grid-collections { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.grid-posts { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.tile { position: relative; overflow: hidden; background: #eee; border-radius: 4px; }
.tile .thumb { position: relative; aspect-ratio: 1 / 1; overflow: hidden; }
.tile .thumb img,
.tile .thumb video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.tile .thumb .placeholder { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); }

.grid-collections .tile { background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.grid-collections .tile .meta { padding: 8px 12px; display: flex; justify-content: space-between; align-items: center; }
.grid-collections .tile .meta .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid-collections .tile .meta .n { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

.grid-posts .tile .badge {
  position: absolute; top: 6px; right: 8px; color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5); font-size: 1rem;
}
.grid-posts .tile .overlay {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 4px 8px; font-size: 0.75rem; color: #fff;
  background: linear-gradient(to top, rgba(0,0,0,0.55), transparent);
  opacity: 0; transition: opacity 0.15s;
}
.grid-posts .tile:hover .overlay { opacity: 1; }

/* Pager */
.pager { display: flex; gap: 16px; justify-content: center; margin: 32px 0 0; align-items: center; }
.pager a { padding: 6px 14px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.pager a:hover { border-color: var(--accent); }

/* Post detail */
.post { max-width: 700px; }
.post-head { display: flex; justify-content: space-between; margin-bottom: 16px; font-size: 0.9rem; }
.post-head .back { color: var(--muted); }
.post-head .ig { color: var(--accent); }
.post-head-actions { display: flex; align-items: center; gap: 14px; }
.delete-btn {
  background: transparent; color: #c0264a;
  border: 1px solid #f1c0cd; border-radius: 4px;
  padding: 4px 10px; font-size: 0.85rem; cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.delete-btn:hover { background: #fdecf0; border-color: #c0264a; }
.delete-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Share button — gradient to match the favicon and signal "outbound" */
.share-btn {
  background: linear-gradient(135deg, #f58529 0%, #dd2a7b 60%, #8134af 100%);
  color: #fff; border: 0;
  border-radius: 4px; padding: 4px 12px;
  font-size: 0.85rem; cursor: pointer;
  transition: filter 0.15s, transform 0.05s;
}
.share-btn:hover { filter: brightness(1.08); }
.share-btn:active { transform: translateY(1px); }
.share-btn.flashed {
  background: #2e8540;
  background-image: none;
}

/* Floating prev/next post nav (fixed to viewport edges) */
.nav-arrow {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.92);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  z-index: 50;
  transition: background 0.15s, color 0.15s, transform 0.15s;
  text-decoration: none;
}
.nav-arrow:hover {
  background: var(--accent);
  color: #fff;
  transform: translateY(-50%) scale(1.05);
}
.nav-arrow svg { display: block; }
.nav-prev { left: calc(var(--sidebar-w) + 16px); }
.nav-next { right: 16px; }

@media (max-width: 720px) {
  .nav-prev { left: 10px; }
  .nav-next { right: 10px; }
  .nav-arrow { width: 38px; height: 38px; }
}

.post-media { background: #000; border-radius: 4px; overflow: hidden; margin-bottom: 16px; }
.post-media img, .post-media video { width: 100%; max-height: 80vh; object-fit: contain; background: #000; }
.carousel { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; }
.carousel-item { flex: 0 0 100%; scroll-snap-align: start; }

.post-meta .poster { font-weight: 600; margin-bottom: 4px; }
.post-meta .stamps { margin-bottom: 12px; }
.post-meta .caption { white-space: pre-wrap; line-height: 1.5; }

.ideas { margin-top: 32px; border-top: 1px solid var(--line); padding-top: 24px; }
.ideas h3 { margin: 0 0 12px; font-size: 1.1rem; }
.ideas-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.idea { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; }
.idea-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; }
.idea-head strong { font-size: 1rem; }
.tag { font-size: 0.7rem; padding: 2px 8px; border-radius: 10px; background: #efefef; color: #333; }
.tag.pillar { background: #e0f0ff; color: #0066cc; }
.tag.status { background: #fff3cd; color: #856404; }
.tag.platforms { background: #f0e0ff; color: #6f42c1; }
.idea .hook { margin: 4px 0; color: #444; }
.idea .body { margin: 4px 0; line-height: 1.45; }
.idea-foot { margin-top: 6px; font-size: 0.75rem; }
.idea.idea-killed { opacity: 0.5; }

/* Comments */
.comments { margin-top: 32px; border-top: 1px solid var(--line); padding-top: 24px; }
.comments h3 { margin: 0 0 12px; font-size: 1.1rem; }
.comments-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.comment { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; }
.comment.pinned { background: #fffbe6; border-color: #f5d76e; }
.comment-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 4px; font-size: 0.85rem; }
.comment-head strong { font-size: 0.9rem; }
.comment-text { margin: 0; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.tag.likes { background: #ffe0e6; color: #c0264a; }
.tag.replies { background: #e6f0ff; color: #2c5fa0; }
.tag.pinned-tag { background: #fff3cd; color: #856404; }
.timestamp { margin-left: auto; }

/* Mobile */
@media (max-width: 720px) {
  :root { --sidebar-w: 0; }
  .sidebar { position: static; width: 100%; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar nav ul { display: flex; overflow-x: auto; }
  .sidebar nav li a { white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; }
  main { margin-left: 0; padding: 16px; }
  .grid-posts { grid-template-columns: repeat(3, 1fr); }
}
