:root {
  --text: #0f1419;
  --muted: #536471;
  --line: #eff3f4;
  --line-strong: #cfd9de;
  --blue: #1d9bf0;
  --blue-dark: #1a8cd8;
  --green: #00ba7c;
  --pink: #f91880;
  --bg: #fff;
  --soft: #f7f9f9;
}

* {
  box-sizing: border-box;
}

html {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
}

button,
a,
input,
textarea {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
}

a {
  text-decoration: none;
}

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  display: grid;
  grid-template-columns: 182px 600px 380px;
  justify-content: center;
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 10px 18px 84px 0;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 30px;
  font-weight: 500;
  letter-spacing: 0;
  font-family: Arial, Helvetica, sans-serif;
}

.x-mark {
  display: inline-block;
  font-family: "Cambria Math", "Segoe UI Symbol", "Noto Sans Math", Georgia, serif;
  font-size: 30px;
  font-weight: 400;
  line-height: 1;
}

.rail-nav {
  display: grid;
  gap: 7px;
}

.rail-item,
.compose,
.icon-button,
.round-action {
  display: grid;
  place-items: center;
  border-radius: 999px;
  transition: background 0.15s ease;
}

.rail-item {
  width: 48px;
  height: 48px;
}

.rail-item svg {
  width: 28px;
  height: 28px;
  stroke-width: 1.9;
}

.rail-x {
  color: currentColor;
  font-size: 29px;
}

.rail-item:hover,
.brand-mark:hover,
.icon-button:hover,
.round-action:hover {
  background: #e7e7e8;
}

.compose {
  width: 50px;
  height: 50px;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 6px 16px rgba(29, 155, 240, 0.24);
}

.compose:hover {
  background: var(--blue-dark);
}

.timeline {
  min-width: 0;
  border-right: 1px solid var(--line);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 44px 44px;
  align-items: center;
  height: 53px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 20px;
  line-height: 24px;
}

.icon-button,
.round-action {
  width: 38px;
  height: 38px;
}

.community-hero {
  border-bottom: 1px solid var(--line);
}

.cover-art {
  position: relative;
  height: 240px;
  overflow: hidden;
  background:
    radial-gradient(circle at 45% 65%, #f8d8d1 0 5%, transparent 5.5%),
    linear-gradient(180deg, #fff 0%, #fafafa 58%, #f7f9f9 58%);
  background-size: cover;
  background-position: center;
}

.cover-art.has-image .cover-character,
.cover-art.has-image .speech {
  display: none;
}

.cover-character {
  position: absolute;
  left: 190px;
  top: 26px;
  width: 174px;
  height: 194px;
}

.hair {
  position: absolute;
  left: 42px;
  top: 0;
  width: 108px;
  height: 126px;
  border-radius: 54px 54px 40px 40px;
  background: #4c3b45;
  box-shadow: inset 16px 0 0 rgba(255, 255, 255, 0.07);
}

.face {
  position: absolute;
  left: 60px;
  top: 43px;
  width: 72px;
  height: 78px;
  border-radius: 32px 32px 38px 38px;
  background: #f6d9d0;
  box-shadow: inset -8px -4px 0 #edc5be;
}

.face::before,
.face::after {
  content: "";
  position: absolute;
  top: 31px;
  width: 9px;
  height: 13px;
  border-radius: 50%;
  background: #3a252f;
}

.face::before {
  left: 18px;
}

.face::after {
  right: 19px;
}

.hood {
  position: absolute;
  left: 18px;
  top: 106px;
  width: 144px;
  height: 88px;
  border-radius: 52px 52px 18px 18px;
  background: #26313c;
}

.hood::before {
  content: "";
  position: absolute;
  left: 48px;
  top: 0;
  width: 48px;
  height: 30px;
  border-radius: 0 0 24px 24px;
  background: #de9aa9;
}

.speech {
  position: absolute;
  left: 340px;
  top: 30px;
  display: grid;
  place-items: center;
  width: 88px;
  height: 105px;
  border: 3px solid #1f2328;
  border-radius: 50%;
  background: #fff;
  font-size: 34px;
  font-weight: 800;
  line-height: 1.08;
}

.community-info {
  padding: 14px 16px 12px;
}

.community-info h2 {
  margin: 0 0 8px;
  overflow-wrap: anywhere;
  font-size: 31px;
  line-height: 36px;
  letter-spacing: 0;
}

.pill {
  height: 25px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  font-size: 14px;
  font-weight: 700;
}

.community-info p {
  margin: 11px 0 14px;
  font-size: 15px;
  line-height: 20px;
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar-stack {
  display: flex;
  width: 50px;
}

.avatar {
  width: 28px;
  height: 28px;
  border: 2px solid #fff;
  border-radius: 50%;
}

.avatar + .avatar {
  margin-left: -9px;
}

.avatar.pink {
  background: linear-gradient(135deg, #c15c73, #f5b3b8);
}

.avatar.blue {
  background: linear-gradient(135deg, #76b3ca, #d7eff5);
}

.member-count {
  color: var(--muted);
  font-size: 15px;
}

.member-count strong {
  color: var(--text);
}

.spacer {
  flex: 1;
}

.round-action {
  border: 1px solid var(--line-strong);
}

.join,
.admin-panel button,
.primary {
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  font-weight: 800;
}

.join {
  min-width: 86px;
  height: 38px;
  padding: 0 18px;
}

.admin-panel {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #f4f9ff;
}

.admin-panel div {
  flex: 1 0 100%;
  min-width: 0;
}

.admin-panel strong,
.admin-panel span {
  display: block;
}

.admin-panel span {
  color: var(--muted);
  font-size: 13px;
}

.admin-panel button {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 14px;
  white-space: nowrap;
}

.admin-panel button:nth-of-type(2) {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line-strong);
}

.admin-panel button:nth-of-type(3) {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line-strong);
}

.admin-panel button:nth-of-type(4) {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line-strong);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: 54px;
  border-bottom: 1px solid var(--line);
}

.tab {
  position: relative;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}

.tab:hover {
  background: rgba(15, 20, 25, 0.04);
}

.tab.active {
  color: var(--text);
  font-weight: 800;
}

.tab.active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 88px;
  height: 4px;
  border-radius: 999px;
  background: var(--blue);
  transform: translateX(-50%);
}

.post {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.reply-post {
  margin-left: calc(var(--depth) * 18px);
  padding-left: 0;
  border-bottom: 0;
}

.reply-tree {
  position: relative;
  margin-top: 10px;
}

.reply-tree::before {
  content: "";
  position: absolute;
  left: -36px;
  top: -10px;
  bottom: 12px;
  width: 2px;
  background: var(--line-strong);
}

.post-avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.post-avatar.generated {
  background: linear-gradient(135deg, #1d9bf0, #794bc4);
}

.post-avatar.image-avatar {
  display: block;
  object-fit: cover;
  border: 0;
  background: var(--soft);
}

.post-body {
  min-width: 0;
}

.pin-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.post-head {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 4px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 15px;
}

.post-head strong {
  color: var(--text);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.admin-post-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 100%;
}

.admin-post-tools button {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  background: #fff;
}

.admin-post-tools .danger {
  border-color: #ffd5dd;
  color: #b00020;
}

.post-body p {
  margin: 3px 0 10px;
  font-size: 15px;
  line-height: 21px;
  white-space: pre-wrap;
}

.post-media,
.uploaded-image,
.post-image-grid {
  width: min(100%, 420px);
  min-height: 210px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  overflow: hidden;
}

.uploaded-image {
  display: block;
  height: auto;
  max-height: 520px;
  object-fit: cover;
}

.post-image-grid {
  display: grid;
  gap: 2px;
  aspect-ratio: 16 / 10;
  background: var(--line-strong);
}

.image-tile {
  display: block;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  background: var(--soft);
}

.post-image-grid img,
.image-tile img {
  width: 100%;
  height: 100%;
  min-width: 0;
  object-fit: cover;
  display: block;
  background: var(--soft);
}

.post-image-grid.image-count-1 {
  display: block;
  aspect-ratio: auto;
  min-height: 0;
  background: transparent;
}

.post-image-grid.image-count-1 img {
  height: auto;
  max-height: 520px;
}

.post-image-grid.image-count-1 .image-tile {
  background: transparent;
}

.post-image-grid.image-count-2 {
  grid-template-columns: repeat(2, 1fr);
}

.post-image-grid.image-count-3 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(2, 1fr);
}

.post-image-grid.image-count-3 img:first-child {
  grid-row: 1 / 3;
}

.post-image-grid.image-count-4 {
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
}

.media-photo {
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(29, 155, 240, 0.16), transparent 35%),
    linear-gradient(180deg, #f5d6db, #e9f4fb);
}

.media-photo span {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  font-weight: 800;
}

.actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(54px, 1fr)) 36px 36px;
  max-width: 500px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.text-link {
  color: var(--blue);
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

.actions button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  color: inherit;
  text-align: left;
}

.actions svg {
  width: 19px;
  height: 19px;
  stroke-width: 1.8;
  flex: 0 0 auto;
}

.actions .active-action:nth-child(2) {
  color: var(--green);
  font-weight: 800;
}

.actions .active-action:nth-child(3) {
  color: var(--pink);
  font-weight: 800;
}

.about-panel {
  display: grid;
  gap: 12px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--line);
}

.about-panel h3 {
  margin: 0;
  font-size: 20px;
}

.about-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 22px;
}

.about-panel dl {
  display: grid;
  gap: 12px;
  margin: 8px 0 0;
}

.about-panel div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.about-panel dt {
  color: var(--muted);
}

.about-panel dd {
  margin: 0;
  font-weight: 700;
  text-align: right;
}

.sidebar {
  padding: 12px 0 96px 28px;
}

.side-card {
  width: 350px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.side-card h2 {
  margin: 0 0 8px;
  font-size: 22px;
  line-height: 26px;
}

.side-card p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 18px;
}

.oauth,
.create-account {
  display: block;
  width: 100%;
  height: 40px;
  margin-bottom: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  font-weight: 800;
}

.oauth.google::before {
  content: "G";
  margin-right: 12px;
  color: #4285f4;
  font-weight: 900;
}

.oauth.apple::before {
  content: "●";
  margin-right: 12px;
  color: #111;
}

.signup small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

.trends {
  padding: 0;
  overflow: hidden;
}

.trends h2 {
  padding: 14px 16px 4px;
}

.trends a {
  display: block;
  padding: 12px 16px;
}

.trends a:hover {
  background: var(--soft);
}

.trends span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.trends strong {
  display: block;
  margin-top: 2px;
  font-size: 15px;
}

.login-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 650px) 96px 138px;
  justify-content: center;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 10px 18px;
  background: var(--blue);
  color: #fff;
}

.login-banner strong,
.login-banner span {
  display: block;
}

.login-banner strong {
  font-size: 23px;
  line-height: 28px;
}

.login-banner span {
  font-size: 14px;
}

.login-banner button {
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 999px;
  color: #fff;
  font-weight: 800;
}

.login-banner .light {
  background: #fff;
  color: var(--text);
}

.modal {
  width: min(92vw, 520px);
  padding: 0;
  border: 0;
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(15, 20, 25, 0.22);
}

.modal::backdrop {
  background: rgba(91, 112, 131, 0.38);
}

.image-viewer {
  width: min(96vw, 1100px);
  height: min(92vh, 820px);
  padding: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.94);
  overflow: hidden;
}

.image-viewer::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.image-viewer img {
  position: absolute;
  inset: 50% auto auto 50%;
  max-width: calc(100% - 120px);
  max-height: calc(100% - 96px);
  transform: translate(-50%, -50%);
  object-fit: contain;
}

.viewer-close,
.viewer-nav {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
}

.viewer-close {
  top: 18px;
  right: 18px;
  width: 42px;
  height: 42px;
  font-size: 30px;
}

.viewer-nav {
  top: 50%;
  width: 48px;
  height: 48px;
  font-size: 42px;
  transform: translateY(-50%);
}

.viewer-prev {
  left: 18px;
}

.viewer-next {
  right: 18px;
}

.viewer-count {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  font-size: 14px;
  font-weight: 700;
}

.modal-card {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 24px;
  background: #fff;
}

.modal-card h2 {
  margin: 0;
  font-size: 24px;
}

.modal-card p {
  margin: 0;
  color: var(--muted);
}

.modal-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.modal-card input,
.modal-card textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--text);
  background: #fff;
  resize: vertical;
}

.modal-card input:focus,
.modal-card textarea:focus {
  outline: 2px solid var(--blue);
  border-color: transparent;
}

.close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  font-size: 24px;
}

.close:hover {
  background: var(--soft);
}

.primary {
  height: 44px;
  padding: 0 22px;
}

.form-error {
  color: #b00020 !important;
  font-weight: 700;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 72px minmax(0, 600px);
    justify-content: center;
  }

  .sidebar {
    display: none;
  }
}

@media (max-width: 680px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden !important;
  }

  .app-shell {
    width: 100%;
    max-width: 100vw;
    grid-template-columns: 1fr;
    justify-content: stretch;
    overflow-x: hidden;
  }

  .rail {
    display: none;
  }

  .timeline {
    width: 100%;
    max-width: 100vw;
    border-right: 0;
    overflow-x: hidden;
    contain: inline-size;
  }

  .topbar,
  .community-hero,
  .admin-panel,
  .tabs,
  .feed {
    max-width: 100%;
    overflow-x: hidden;
  }

  .topbar {
    grid-template-columns: 36px minmax(0, 1fr) 36px 36px;
    padding: 0 8px;
  }

  .topbar h1 {
    font-size: 17px;
  }

  .cover-art {
    height: 200px;
  }

  .cover-character {
    left: 50%;
    transform: translateX(-48%);
  }

  .speech {
    left: calc(50% + 80px);
  }

  .community-info h2 {
    font-size: 26px;
    line-height: 31px;
    max-width: 100%;
  }

  .meta-row {
    gap: 6px;
  }

  .avatar-stack {
    width: 42px;
  }

  .member-count {
    font-size: 14px;
  }

  .join {
    min-width: 74px;
    padding: 0 14px;
  }

  .admin-panel {
    gap: 8px;
  }

  .admin-panel button {
    flex: 1 1 calc(50% - 8px);
    padding: 0 10px;
  }

  .tabs {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .tab {
    min-width: 0;
    padding: 0 4px;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .tab.active::after {
    width: min(72px, calc(100% - 12px));
  }

  .post {
    width: 100%;
    max-width: 100vw;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 8px;
    padding: 12px 12px;
    overflow-x: hidden;
  }

  .post-avatar {
    width: 38px;
    height: 38px;
  }

  .post-head {
    align-items: flex-start;
  }

  .admin-post-tools {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }

  .admin-post-tools button {
    flex: 1 1 calc(50% - 6px);
    padding: 0 8px;
  }

  .post-media,
  .uploaded-image,
  .post-image-grid {
    min-height: 178px;
  }

  .image-viewer {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
  }

  .image-viewer img {
    max-width: calc(100% - 28px);
    max-height: calc(100% - 120px);
  }

  .viewer-nav {
    width: 42px;
    height: 42px;
    font-size: 36px;
  }

  .actions {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    row-gap: 4px;
    column-gap: 2px;
    font-size: 12px;
    max-width: 100%;
    width: 100%;
    min-width: 0;
    overflow: hidden !important;
  }

  .actions button {
    gap: 4px;
    min-width: 0;
    width: 100%;
    overflow: hidden;
    justify-content: flex-start;
  }

  .actions button:nth-child(n + 5) {
    justify-content: center;
  }

  .actions svg {
    width: 17px;
    height: 17px;
  }

  .reply-post {
    margin-left: calc(var(--depth) * 10px);
  }

  .reply-tree::before {
    left: -28px;
  }

  .login-banner {
    display: none;
  }
}
