:root {
  --bg: #0b0d12;
  --surface: #161a23;
  --surface-2: #1e2430;
  --border: #2a3140;
  --text: #eef1f7;
  --muted: #8b95a7;
  --accent: #ff9f1c;
  --coral: #ff5a5f;
  --grid-gap: 10px;
  --grid-pad: 14px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

button {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
button:hover { border-color: var(--accent); }
button.active { background: var(--accent); color: #0b0d12; border-color: var(--accent); font-weight: 600; }

.icon { width: 15px; height: 15px; flex-shrink: 0; }

.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.tab-bar {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px;
  background: #0f1219; border-bottom: 1px solid var(--border); overflow-x: auto;
}
.tab-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px;
  border-radius: 8px; background: var(--surface); border: 1px solid var(--border);
  font-size: 12px; white-space: nowrap; cursor: pointer;
}
.tab-pill.active { border-color: var(--accent); color: var(--accent); }

.top-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.search-form { display: flex; flex: 1; min-width: 200px; max-width: 380px; gap: 6px; }
.search-input {
  flex: 1; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; font-size: 13px;
}
.controls-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.workspace { display: flex; flex: 1; }
.sidebar {
  width: 230px; background: var(--surface); border-right: 1px solid var(--border);
  padding: 12px; display: flex; flex-direction: column; gap: 12px; flex-shrink: 0;
}
@media (max-width: 768px) { .sidebar { display: none; } }

.main-pane { flex: 1; padding: 0 var(--grid-pad); position: relative; min-width: 0; }

.masonry-viewport { position: relative; width: 100%; margin: 12px 0 80px; }
.grid-card {
  position: absolute; top: 0; left: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; contain: layout style paint; transition: opacity 0.15s;
}
.grid-card.seen { opacity: 0.58; }
.card-media {
  position: relative; width: 100%; background: #10131b; overflow: hidden; cursor: pointer;
}
.card-media img, .card-media video {
  width: 100%; height: 100%; display: block;
}
.mode-flexible .card-media img { object-fit: cover; }
.mode-crop .card-media img { object-fit: cover; }
.mode-fit .card-media img { object-fit: contain; }

.serial-badge {
  position: absolute; top: 6px; left: 6px; background: rgba(11,13,18,0.78);
  color: var(--accent); font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 6px;
}
.reblog-btn-float {
  position: absolute; top: 6px; right: 6px; background: rgba(11,13,18,0.78);
  border: 1px solid rgba(255,255,255,0.12); border-radius: 999px; padding: 5px;
}
.reblog-btn-float.done { color: var(--coral); border-color: var(--coral); }

.reblog-pop {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none; background: rgba(11,13,18,0.35);
  animation: popFade 250ms ease-out forwards;
}
@keyframes popFade {
  0% { opacity: 0; transform: scale(0.7); }
  40% { opacity: 1; transform: scale(1.15); }
  100% { opacity: 0; transform: scale(1.25); }
}

.card-footer {
  padding: 6px 8px; font-size: 11px; color: var(--muted);
  display: flex; flex-direction: column; gap: 3px; height: 64px; justify-content: center;
}
.caption-line {
  font-size: 11px; color: var(--text); opacity: 0.85;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.footer-row {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0;
}
.blog-chip {
  display: inline-flex; align-items: center; gap: 4px; color: var(--text);
  font-weight: 500; cursor: pointer; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.blog-chip:hover { color: var(--accent); }
.blog-dp {
  width: 16px; height: 16px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--surface-2);
}
.blog-link { color: var(--text); font-weight: 500; cursor: pointer; text-decoration: none; }
.blog-link:hover { color: var(--accent); }

.resume-pill {
  position: fixed; bottom: 20px; right: 20px; z-index: 30;
  background: var(--accent); color: #0b0d12; font-weight: 700;
  padding: 9px 14px; border-radius: 999px; box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}

.undo-toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 40;
  background: var(--surface-2); border: 1px solid var(--accent); border-radius: 10px;
  padding: 10px 14px; display: flex; align-items: center; gap: 10px;
}

.hover-preview {
  position: fixed; z-index: 9999; width: 244px; background: var(--surface);
  border: 1px solid var(--accent); border-radius: 12px; padding: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.6); pointer-events: auto; cursor: pointer;
}
.zen-toggle-float {
  position: fixed; top: 12px; right: 12px; z-index: 60;
  background: rgba(22,26,35,0.88); backdrop-filter: blur(6px);
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; font-size: 12px;
}
.preview-3x3 {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 8px 0;
  max-height: 220px; overflow-y: auto;
}
.preview-3x3 img { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 4px; pointer-events: none; }
.larger-preview-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; overflow-y: auto;
  flex: 1; min-height: 0; padding: 4px;
}
.larger-preview-grid img { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 8px; }
.tag-chip {
  display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--accent);
  font-size: 11px; cursor: pointer;
}
.tag-chip:hover { border-color: var(--accent); }

dialog.post-modal {
  width: min(92vw, 1180px); height: min(88vh, 860px); max-width: none; max-height: none;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px; margin: auto; overflow: hidden;
}
dialog.post-modal::backdrop { background: rgba(0,0,0,0.78); }
.modal-grid {
  display: grid; grid-template-columns: 1.45fr 1fr; gap: 16px; height: 100%; min-height: 0;
}
.modal-media-pane {
  background: var(--bg); border-radius: 10px; padding: 12px;
  display: flex; align-items: center; justify-content: center; height: 100%; min-height: 0; overflow: hidden;
}
.modal-media-pane img, .modal-media-pane video {
  width: 100%; height: 100%; object-fit: contain; border-radius: 8px;
}
@media (max-width: 768px) {
  dialog.post-modal { width: 96vw; height: 92vh; padding: 10px; }
  .modal-grid { grid-template-columns: 1fr; grid-template-rows: 1.2fr 1fr; }
}

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 92vw); z-index: 45;
  background: var(--surface); border-left: 1px solid var(--border); padding: 16px;
  overflow-y: auto; box-shadow: -8px 0 28px rgba(0,0,0,0.5);
}

.discover-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; padding: 16px 0;
}
.discover-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px;
}
