:root {
  --bg: #ffffff;
  --ink: #0f1419;
  --muted: #536471;
  --line: #eff3f4;
  --line-strong: #cfd9de;
  --hover: rgba(15, 20, 25, 0.03);
  --accent: #1d9bf0;
  --accent-hover: #1a8cd8;
  --like: #f91880;
  --repost: #00ba7c;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Hiragino Sans", "Noto Sans JP", sans-serif;
  --col: 598px;
  --rail: 88px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--ink);
  font-family: var(--font);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, a { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }

.layout {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, var(--col));
  justify-content: center;
  min-height: 100vh;
  max-width: 920px;
  margin: 0 auto;
}

.rail {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 8px;
  border-right: 1px solid var(--line);
}
.rail-logo {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  margin: 0 auto 4px;
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
}
.rail-logo:hover { background: var(--hover); }
.rail-nav { display: grid; gap: 4px; }
.rail-item {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 50px;
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--ink);
  font-size: 20px;
  font-weight: 400;
}
.rail-item span { display: none; }
.rail-item:hover { background: var(--hover); }
.rail-item.is-active { font-weight: 700; }

.column {
  min-width: 0;
  border-right: 1px solid var(--line);
  padding-bottom: 72px;
}
.column-top {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid var(--line);
}
.column-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 53px;
  padding: 0 16px;
}
.ops-toggle {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.ops-toggle.is-on {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}
.ops-public-link {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}
.ops-public-link:hover { background: var(--hover); }
.ops-auth {
  display: grid;
  gap: 12px;
  padding: 24px 16px;
}
.ops-auth p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 15px;
}
.ops-auth label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.ops-auth input {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
}
.ops-auth button {
  justify-self: start;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  color: #fff;
  background: var(--ink);
  font-weight: 700;
}
.column-top h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.tab {
  position: relative;
  min-height: 53px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
}
.tab:hover { background: var(--hover); }
.tab.is-active {
  color: var(--ink);
  font-weight: 700;
}
.tab.is-active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 56px;
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
  transform: translateX(-50%);
}

.back-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin: 10px 12px 0;
  border-radius: 999px;
}
.back-btn:hover { background: var(--hover); }

.feed-list { display: block; }
.post-card {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background .12s ease;
}
.post-card.is-detail { cursor: default; }
.post-card:hover { background: var(--hover); }
.post-card.is-detail:hover { background: transparent; }
/* Thread replies stay left-aligned with root (no connector line through avatars). */
.post-card.is-thread-reply {
  position: relative;
}
.thread-stack .post-card + .post-card {
  border-top: 0;
}
.thread-stack .post-card.is-thread-reply {
  border-bottom: 1px solid var(--line);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(135deg, #1d9bf0, #0a66a8);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.post-main { min-width: 0; display: grid; gap: 4px; }
.post-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 6px;
  min-width: 0;
  line-height: 1.3;
}
.post-head a {
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.post-head .name { font-weight: 700; font-size: 15px; }
.post-head .name:hover { text-decoration: underline; }
.post-head .meta { color: var(--muted); font-size: 15px; }
.post-head .dot::before { content: "·"; margin-right: 6px; }

.post-body {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
  font-size: 15px;
}
.post-body.hashtags,
.hashtags { color: var(--accent); }

.post-images {
  margin-top: 8px;
  display: grid;
  gap: 2px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
}
.post-images.count-1 { grid-template-columns: 1fr; }
.post-images.count-2 { grid-template-columns: 1fr 1fr; }
.post-images.count-3,
.post-images.count-4 { grid-template-columns: 1fr 1fr; }
.post-images img {
  width: 100%;
  height: 100%;
  max-height: 510px;
  object-fit: cover;
  display: block;
  background: #cfd9de;
}
.post-images.count-1 img { max-height: 510px; }
.post-images.count-2 img,
.post-images.count-3 img,
.post-images.count-4 img { aspect-ratio: 1 / 1; max-height: none; }

/* One-image-per-page carousel (swipe on mobile, arrows on desktop) */
.post-image-carousel {
  position: relative;
  margin-top: 8px;
  min-width: 0;
}
.post-image-track {
  position: relative;
  display: flex;
  gap: 0;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.post-image-track::-webkit-scrollbar { display: none; }
.post-image-slide {
  flex: 0 0 100%;
  width: 100%;
  min-width: 100%;
  max-width: 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  overflow: hidden;
  background: #cfd9de;
}
.post-image-slide img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}
.post-image-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 34px;
  height: 34px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 999px;
  color: #0f1419;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 4px rgba(15, 20, 25, 0.18);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.post-image-nav.prev { left: 8px; }
.post-image-nav.next { right: 8px; }
.post-image-nav:hover { background: #fff; }
.post-image-nav:disabled {
  opacity: 0.35;
  cursor: default;
}
.post-image-dots {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-top: 8px;
}
.post-image-dots .dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #cfd9de;
}
.post-image-dots .dot.is-active { background: var(--accent); }
/* Peek next image (Fan_aff-like), with correct per-slide paging */
.post-image-carousel.is-peek .post-image-track {
  gap: 8px;
  border: 0;
  border-radius: 0;
  scroll-padding-left: 0;
}
.post-image-carousel.is-peek .post-image-slide {
  flex: 0 0 86%;
  width: 86%;
  min-width: 86%;
  max-width: 86%;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  scroll-snap-align: start;
}
@media (max-width: 560px) {
  .post-image-nav { display: none; }
  .post-image-carousel.is-peek .post-image-slide {
    flex-basis: 88%;
    width: 88%;
    min-width: 88%;
    max-width: 88%;
  }
}

.actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  max-width: 425px;
  margin-top: 8px;
  margin-left: -8px;
}
.action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 34px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}
.action svg { flex: 0 0 auto; }
.action:hover { color: var(--accent); background: rgba(29, 155, 240, 0.1); }
.action.like:hover { color: var(--like); background: rgba(249, 24, 128, 0.1); }
.action.repost:hover { color: var(--repost); background: rgba(0, 186, 124, 0.1); }
.action.cta {
  color: var(--accent);
  font-weight: 700;
}
.action.cta:hover { background: rgba(29, 155, 240, 0.1); }

.profile-list { display: block; }
.profile-item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}
.profile-item:hover { background: var(--hover); }
.profile-item .avatar { width: 48px; height: 48px; font-size: 18px; }
.profile-item strong { display: block; font-size: 15px; }
.profile-item span { color: var(--muted); font-size: 14px; }
.profile-bio-preview {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-header { border-bottom: 1px solid var(--line); }
.profile-banner {
  height: 133px;
  background: linear-gradient(120deg, #1d9bf0 0%, #0a66a8 55%, #536471 100%);
  background-size: cover;
  background-position: center;
}
.profile-banner.has-image { background-color: #cfd9de; }
.profile-body { padding: 0 16px 16px; }
.profile-avatar-row { margin-top: -40px; margin-bottom: 8px; }
.profile-avatar-row .avatar {
  width: 80px;
  height: 80px;
  border: 4px solid var(--bg);
  font-size: 28px;
}
.profile-body h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}
.profile-body .handle {
  margin: 2px 0 10px;
  color: var(--muted);
  font-size: 15px;
}
.profile-body .bio {
  margin: 0 0 12px;
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 15px;
}
.profile-body .stats {
  color: var(--muted);
  font-size: 14px;
}
.profile-body .stats strong { color: var(--ink); }

.load-more {
  display: block;
  width: 100%;
  min-height: 52px;
  color: var(--accent);
  font-size: 15px;
  font-weight: 500;
  border-bottom: 1px solid var(--line);
}
.load-more:hover { background: var(--hover); }
.scroll-sentinel {
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
}
.scroll-loading {
  margin: 8px 16px 24px;
  text-align: center;
}

.status {
  margin: 0;
  padding: 16px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}
.empty {
  margin: 0;
  padding: 40px 24px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
  font-size: 15px;
}

.mobile-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
}
.mobile-nav button {
  min-height: 52px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.mobile-nav button.is-active { color: var(--ink); }

@media (min-width: 1100px) {
  :root { --rail: 275px; }
  .layout { max-width: 980px; justify-content: start; margin-left: max(24px, calc(50vw - 490px)); }
  .rail-item span { display: inline; }
  .rail-logo { margin: 0 0 4px 8px; }
}

@media (max-width: 700px) {
  .layout { grid-template-columns: 1fr; }
  .rail { display: none; }
  .column { border-right: 0; }
  .mobile-nav { display: grid; }
}
