:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #f5f5f5;
  background: #000;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --surface: #121212;
  --border: #262626;
  --muted: #a8a8a8;
  --blue: #0095f6;
  --danger: #ff5c70;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: #000;
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  width: 100%;
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: rgb(0 0 0 / 94%);
  padding: 9px max(16px, calc((100vw - 720px) / 2));
  backdrop-filter: blur(12px);
}

.profile-lockup {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
  text-decoration: none;
}

.story-ring {
  display: grid;
  width: 43px;
  height: 43px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(35deg, #ffb700 8%, #ff3040 45%, #c52bdb 75%, #ffb700);
  padding: 2px;
}

.avatar {
  display: block;
  width: 100%;
  height: 100%;
  place-items: center;
  border: 2px solid #000;
  border-radius: inherit;
  background: #262626;
  object-fit: cover;
  font-size: 20px;
}

.profile-copy {
  display: grid;
  gap: 2px;
}

.profile-copy strong {
  font-size: 14px;
  font-weight: 650;
}

.profile-copy > span,
.muted,
.section-caption {
  color: var(--muted);
  font-size: 12px;
}

.site-views {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #f5f5f5;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.site-views > span:first-child {
  color: var(--muted);
  font-size: 16px;
}

.page-shell {
  width: min(100% - 32px, 680px);
  margin: 0 auto;
}

.bio-panel {
  border-bottom: 1px solid var(--border);
  padding: 25px 4px 22px;
}

.bio-panel h1,
.admin-shell h1 {
  margin: 0 0 9px;
  font-size: 21px;
  letter-spacing: -0.35px;
}

.bio-panel p {
  max-width: 510px;
  margin: 0 0 17px;
  color: #e8e8e8;
  font-size: 14px;
  line-height: 1.55;
}

.community-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}

.community-actions .chat-button {
  border-color: #344b61;
  color: #d9edff;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  transition: background-color 120ms ease, opacity 120ms ease;
}

.primary-button {
  background: var(--blue);
  color: #fff;
  padding: 0 17px;
}

.primary-button:hover {
  background: #1877d2;
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 4px 11px;
}

.section-heading h2,
.panel h2,
.admin-posts-section h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
}

.post-feed {
  display: grid;
  gap: 16px;
}

.post-card,
.panel,
.admin-post-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.post-card {
  overflow: hidden;
}

.post-card.is-pinned,
.admin-post-card.is-pinned {
  border-color: #59451b;
}

.post-card.is-pinned .post-meta {
  background: #17140e;
}

.post-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  padding: 12px 15px;
}

.post-author {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.post-avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 1px solid #3a3a3a;
  border-radius: 50%;
  object-fit: cover;
}

.post-label {
  color: #f5f5f5;
  font-weight: 600;
}

.feed-pin-badge {
  border-radius: 999px;
  background: #332a16;
  color: #f5c451;
  font-size: 10px;
  padding: 4px 7px;
}

.post-content {
  min-height: 140px;
  margin: 0;
  padding: 26px 22px;
  color: #f5f5f5;
  font-size: 16px;
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.comments-section {
  border-top: 1px solid var(--border);
}

.comments-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  color: #b7dfff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 12px 16px;
  text-align: left;
}

.comments-toggle:hover {
  background: #171717;
}

.comments-thread {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--border);
  padding: 14px 16px 16px;
}

.comment-item,
.chat-message {
  min-width: 0;
}

.comment-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 9px;
}

.comment-header strong {
  color: #f5f5f5;
  font-size: 12px;
}

.comment-header time {
  color: var(--muted);
  font-size: 10px;
}

.chat-message.is-admin .comment-header strong {
  color: #ff4d5a;
}

.comment-item > p,
.chat-message > p {
  margin: 4px 0 0;
  color: #e8e8e8;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.comment-form,
.chat-form {
  display: flex;
  gap: 8px;
}

.comment-form input,
.chat-form input {
  min-width: 0;
  min-height: 38px;
  flex: 1 1 auto;
  border: 1px solid #363636;
  border-radius: 7px;
  outline: none;
  background: #0b0b0b;
  color: #f5f5f5;
  padding: 8px 10px;
}

.comment-form input:focus,
.chat-form input:focus {
  border-color: var(--blue);
}

.comment-form .primary-button,
.chat-form .primary-button {
  min-height: 38px;
  flex: 0 0 auto;
  padding: 0 12px;
}

.comment-item .delete-button {
  min-height: 26px;
  margin-top: 6px;
  font-size: 10px;
}

.app-dialog {
  width: min(100% - 28px, 480px);
  max-width: 480px;
  max-height: min(85vh, 760px);
  overflow: hidden;
  border: 1px solid #333;
  border-radius: 14px;
  background: #121212;
  color: #f5f5f5;
  padding: 20px;
}

.app-dialog::backdrop {
  background: rgb(0 0 0 / 75%);
  backdrop-filter: blur(3px);
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.dialog-heading h2 {
  margin: 0 0 5px;
  font-size: 18px;
}

.dialog-heading p {
  margin: 0;
  line-height: 1.5;
}

.dialog-close {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 1px solid #383838;
  border-radius: 50%;
  background: #1b1b1b;
  color: #eee;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.identity-current {
  margin: 0 0 14px;
  color: #9ad8ff;
  font-size: 13px;
}

.identity-logout {
  width: 100%;
  margin-top: 11px;
}

.dialog-note {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.chat-dialog {
  display: none;
  grid-template-rows: auto minmax(180px, 1fr) auto auto auto;
  width: min(100% - 24px, 540px);
  height: min(82vh, 680px);
  max-height: 680px;
}

.chat-dialog[open] {
  display: grid;
}

.chat-messages {
  display: grid;
  align-content: start;
  gap: 13px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #090909;
  padding: 14px;
}

.chat-empty {
  align-self: center;
  text-align: center;
}

.chat-form {
  margin-top: 12px;
}

.chat-dialog .dialog-note {
  margin-top: 10px;
}

.admin-comment-moderation {
  display: grid;
  grid-column: 1 / -1;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.post-image {
  display: block;
  width: 100%;
  max-height: 640px;
  border-top: 1px solid var(--border);
  background: #080808;
  object-fit: contain;
}

.post-footer {
  display: flex;
  align-items: center;
  gap: 7px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  padding: 11px 15px;
}

.status-message,
.empty-state {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  padding: 18px;
}

.site-footer {
  padding: 27px 0 32px;
  text-align: center;
}

.site-footer a,
.text-link {
  color: #777;
  font-size: 11px;
  text-decoration: none;
}

.site-footer a:hover,
.text-link:hover {
  color: #d8d8d8;
}

.admin-shell {
  padding-top: 30px;
  padding-bottom: 48px;
}

.panel {
  padding: 19px;
}

.login-panel {
  max-width: 460px;
  margin: 34px auto 0;
}

.login-panel > p {
  margin: 0 0 21px;
}

.form-stack {
  display: grid;
  gap: 9px;
}

.form-stack label,
.form-row label {
  color: #e4e4e4;
  font-size: 13px;
  font-weight: 550;
}

.form-stack input,
.form-stack textarea,
.form-row input {
  width: 100%;
  min-height: 42px;
  border: 1px solid #363636;
  border-radius: 7px;
  outline: none;
  background: #0b0b0b;
  color: #f5f5f5;
  padding: 10px 11px;
}

.form-stack textarea {
  min-height: 116px;
  resize: vertical;
}

.image-field {
  display: grid;
  gap: 8px;
}

.image-field > small,
.image-help {
  color: var(--muted);
  font-size: 11px;
}

.form-stack input[type="file"],
.inline-edit-form input[type="file"] {
  min-height: 42px;
  padding: 7px;
  font-size: 12px;
}

.form-stack input[type="file"]::file-selector-button,
.inline-edit-form input[type="file"]::file-selector-button {
  min-height: 27px;
  margin-right: 9px;
  border: 1px solid #383838;
  border-radius: 5px;
  background: #1c1c1c;
  color: #f5f5f5;
  cursor: pointer;
  padding: 0 9px;
}

.image-preview {
  width: min(100%, 360px);
  max-height: 260px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #080808;
  object-fit: contain;
}

.form-stack input:focus,
.form-stack textarea:focus,
.form-row input:focus {
  border-color: var(--blue);
}

.form-stack .primary-button {
  margin-top: 8px;
}

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 12px;
  margin-top: 5px;
}

.form-row > div {
  display: grid;
  align-content: start;
  gap: 9px;
}

.admin-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 21px;
}

.admin-heading p {
  margin: 0;
}

.admin-heading-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.secondary-button {
  flex: 0 0 auto;
  border: 1px solid #383838;
  background: #181818;
  color: #f5f5f5;
  padding: 0 13px;
}

.secondary-button:hover {
  background: #262626;
}

.admin-posts-section {
  margin-top: 28px;
}

.admin-posts-section h2 {
  margin: 0;
}

.admin-list-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 14px;
  margin-bottom: 13px;
}

.post-count {
  color: var(--muted);
  font-size: 12px;
}

.post-filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, auto);
  gap: 10px;
  margin-bottom: 13px;
}

.post-filters input,
.post-filters select,
.inline-edit-form input,
.inline-edit-form textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid #363636;
  border-radius: 7px;
  outline: none;
  background: #0b0b0b;
  color: #f5f5f5;
  padding: 9px 11px;
}

.post-filters input:focus,
.post-filters select:focus,
.inline-edit-form input:focus,
.inline-edit-form textarea:focus {
  border-color: var(--blue);
}

.admin-post-list {
  display: grid;
  gap: 10px;
}

.admin-post-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 14px;
}

.admin-post-card > div:first-child {
  min-width: 0;
}

.admin-post-thumbnail {
  display: block;
  width: 88px;
  height: 68px;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #080808;
  object-fit: cover;
}

.admin-post-card .pin-badge {
  display: inline-block;
  margin-bottom: 7px;
  border-radius: 999px;
  background: #332a16;
  color: #f5c451;
  font-size: 11px;
  padding: 4px 8px;
}

.admin-post-card .pin-badge-hidden {
  display: none;
}

.admin-post-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.admin-post-actions .secondary-button,
.admin-post-actions .delete-button {
  min-height: 34px;
  font-size: 12px;
  padding: 0 10px;
}

.inline-edit-form {
  display: grid;
  gap: 9px;
}

.inline-edit-form label {
  display: grid;
  gap: 5px;
  color: #e4e4e4;
  font-size: 12px;
}

.inline-edit-form textarea {
  min-height: 90px;
  resize: vertical;
}

.remove-image-option {
  display: flex !important;
  align-items: center;
  gap: 7px !important;
}

.remove-image-option input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--blue);
}

.edit-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 3px;
}

.admin-post-card p {
  display: -webkit-box;
  margin: 0 0 8px;
  overflow: hidden;
  color: #f5f5f5;
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.admin-post-card small {
  color: var(--muted);
  font-size: 11px;
}

.delete-button {
  min-height: 34px;
  border: 1px solid #5a2930;
  border-radius: 7px;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font-size: 12px;
  padding: 0 11px;
}

.delete-button:hover {
  background: #271216;
}

.error-message,
.form-status {
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.5;
}

.form-status {
  color: #79d69c;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

[hidden] {
  display: none !important;
}

@media (min-width: 760px) {
  .bio-panel {
    padding: 36px 8px 28px;
  }

  .bio-panel h1 {
    font-size: 24px;
  }

  .bio-panel p {
    font-size: 15px;
  }

  .section-heading {
    padding-top: 25px;
  }

  .post-card,
  .panel,
  .admin-post-card {
    border-radius: 14px;
  }

  .post-meta {
    padding: 14px 18px;
  }

  .post-footer {
    padding: 12px 18px;
  }

  .admin-shell {
    padding-top: 42px;
  }
}

@media (max-width: 480px) {
  .topbar {
    min-height: 61px;
    gap: 10px;
    padding-right: max(14px, env(safe-area-inset-right));
    padding-left: max(14px, env(safe-area-inset-left));
  }

  .profile-lockup {
    gap: 8px;
  }

  .story-ring {
    width: 40px;
    height: 40px;
  }

  .profile-copy strong {
    font-size: 13px;
  }

  .profile-copy > span {
    font-size: 11px;
  }

  .site-views {
    flex: 0 0 auto;
    font-size: 12px;
  }

  .page-shell {
    width: min(100% - 24px, 680px);
  }

  .bio-panel h1 {
    font-size: 19px;
  }

  .bio-panel p {
    font-size: 13px;
  }

  .bio-panel .primary-button {
    width: 100%;
  }

  .community-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .community-actions > .primary-button {
    grid-column: 1 / -1;
  }

  .community-actions > .secondary-button {
    width: 100%;
    padding: 0 8px;
  }

  .section-caption {
    font-size: 11px;
  }

  .post-meta {
    padding: 10px 11px;
  }

  .post-author {
    gap: 6px;
  }

  .post-avatar {
    width: 27px;
    height: 27px;
  }

  .post-label {
    font-size: 11px;
  }

  .feed-pin-badge {
    font-size: 9px;
    padding: 3px 5px;
  }

  .section-heading {
    align-items: baseline;
    padding-right: 2px;
    padding-left: 2px;
  }

  .post-content {
    min-height: 112px;
    padding: 20px 16px;
    font-size: 15px;
  }

  .panel {
    padding: 16px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .admin-heading {
    align-items: flex-start;
  }

  .admin-post-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .post-filters {
    grid-template-columns: 1fr;
  }

  .admin-post-actions {
    justify-content: flex-start;
  }

  .delete-button {
    justify-self: start;
  }
}

@media (max-width: 360px) {
  .profile-copy strong {
    font-size: 12px;
  }

  .topbar {
    padding-right: 10px;
    padding-left: 10px;
  }

  .page-shell {
    width: calc(100% - 20px);
  }

  .site-views {
    gap: 4px;
    font-size: 11px;
  }
}
