*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface2: #1e1e1e;
  --border: #2a2a2a;
  --ink: #f0f0f0;
  --muted: #555;
  --accent: #e8c547;
  --accent-dim: rgba(232, 197, 71, 0.12);
}

html, body {
  height: 100%;
}

body {
  font-family: 'Space Grotesk', sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  height: 52px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  flex-shrink: 0;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--ink);
}

.count-badge {
  font-size: 0.65rem;
  font-weight: 500;
  background: var(--accent-dim);
  color: var(--accent);
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(232, 197, 71, 0.25);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.ver-link {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.ver-link:hover { color: var(--ink); background: var(--surface2); }
.ver-link.active { color: var(--accent); }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: var(--surface);
}

.sidebar-loading {
  padding: 2rem 1.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.sidebar-item:hover {
  background: var(--surface2);
}

.sidebar-item.active {
  background: var(--accent-dim);
}

.sidebar-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.item-num {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted);
  width: 1.5rem;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.sidebar-item.active .item-num {
  color: var(--accent);
}

.item-info {
  min-width: 0;
}

.item-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-date {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.item-arrow {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.75rem;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.sidebar-item:hover .item-arrow,
.sidebar-item.active .item-arrow {
  opacity: 1;
  color: var(--accent);
}

/* Viewer */
.viewer {
  overflow-y: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2.5rem 2rem;
  background: var(--bg);
}

.viewer-placeholder {
  text-align: center;
  color: var(--muted);
  margin-top: 6rem;
}

.placeholder-icon {
  font-size: 2rem;
  margin-bottom: 1rem;
  opacity: 0.3;
}

.viewer-placeholder p {
  font-size: 0.85rem;
}

.viewer-content {
  width: 100%;
  max-width: 540px;
}

.viewer-meta {
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.viewer-num {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.viewer-ig-link {
  font-size: 0.75rem;
  color: var(--muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: color 0.15s;
}
.viewer-ig-link:hover { color: var(--ink); }

.embed-shell {
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

.embed-shell .instagram-media {
  min-width: 0 !important;
  max-width: 100% !important;
  margin: 0 !important;
  border-radius: 0 !important;
}

/* Mobile */
@media (max-width: 640px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-y: hidden;
    overflow-x: auto;
    display: flex;
    flex-direction: row;
    max-height: 72px;
  }

  .sidebar-item {
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    border-bottom: none;
    border-right: 1px solid var(--border);
    min-width: 80px;
    flex-shrink: 0;
    text-align: center;
  }

  .sidebar-item.active::before {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 2px;
    border-radius: 2px 2px 0 0;
  }

  .item-date, .item-arrow { display: none; }

  .viewer { padding: 1.5rem 1rem; }
}
