@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg: #f9fafb;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #f97316;
  --agent-bg: #f5f3ff;
  --agent-text: #6d28d9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.view.hidden {
  display: none;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.topbar {
  position: sticky;
  top: 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.topbar .container {
  padding: 1rem 1.25rem;
}

h1 {
  font-size: 1.6rem;
  margin: 0;
}

.subhead {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.beta-banner {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin: 2rem 0 2.5rem;
}

.beta-banner h2 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.beta-banner p {
  margin: 0;
  color: #1e3a8a;
  font-size: 0.9rem;
}

.borough {
  margin-bottom: 2.5rem;
}

.borough h2 {
  margin: 0 0 1rem;
  font-size: 1.2rem;
}

.hood-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.hood-card {
  background: var(--card);
  border: 2px solid var(--border);
  padding: 1rem;
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.hood-card.disabled {
  cursor: not-allowed;
  background: #f3f4f6;
  color: var(--muted);
}

.hood-card.active:hover {
  border-color: var(--primary);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.12);
}

.hood-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-weight: 600;
}

.badge.active {
  background: #dcfce7;
  color: #15803d;
}

.badge.coming {
  background: #e5e7eb;
  color: #6b7280;
}

.feed-header,
.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.feed-title {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-badge {
  font-size: 0.85rem;
  color: var(--muted);
}

.button {
  border: none;
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
}

.button.primary {
  background: var(--primary);
  color: #fff;
}

.button.primary:hover {
  background: var(--primary-dark);
}

.button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.button.full-width {
  width: 100%;
}

.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
}

.sort-tabs {
  display: flex;
  gap: 0.5rem;
  margin: 1.5rem 0 1rem;
}

.tab {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.tab.active {
  color: var(--primary);
  border-color: var(--primary);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.auth-panel {
  margin-bottom: 2rem;
}

.auth-header h2 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
}

.auth-header p {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.auth-tab {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.auth-tab.active {
  border-color: var(--primary);
  color: var(--primary);
}

.auth-panels {
  display: grid;
  gap: 1rem;
}

.auth-form {
  display: grid;
  gap: 0.75rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.stack {
  display: grid;
  gap: 0.75rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

input,
select,
textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  font-family: inherit;
  font-size: 0.9rem;
}

.hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.feed-meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.post-list {
  display: grid;
  gap: 0.75rem;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.post-new {
  animation: slideIn 0.4s ease-out;
  background: linear-gradient(135deg, #f0fdf4 0%, var(--card) 100%);
  border-color: #86efac;
}

.post-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem;
  display: flex;
  gap: 0.75rem;
}

.vote-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding-top: 0.25rem;
}

.vote-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-size: 1rem;
  min-width: 32px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vote-btn.active.up {
  color: var(--accent);
}

.vote-btn.active.down {
  color: var(--primary);
}

.vote-score {
  font-weight: 700;
  font-size: 0.9rem;
}

.post-main {
  flex: 1;
  min-width: 0;
}

.feed-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.admin-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--muted);
  user-select: none;
}

.admin-toggle input {
  accent-color: var(--primary);
}

.post-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.75rem;
  color: var(--muted);
}

.agent-badge {
  background: var(--agent-bg);
  color: var(--agent-text);
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
}

.review-badge {
  background: #fff7ed;
  color: #b45309;
  border: 1px solid #fdba74;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
}

.mod-row {
  display: flex;
  gap: 0.5rem;
  margin: 0.35rem 0 0.1rem;
}

.mod-btn {
  border: none;
  background: #111827;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
}

.mod-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.post-title-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.4rem 0 0.35rem;
}

.post-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.post-body {
  margin: 0 0 0.4rem;
  color: #374151;
  font-size: 0.9rem;
}

.post-content-row {
  display: flex;
  gap: 0.75rem;
  margin: 0.35rem 0;
}

.post-thumb {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: #f3f4f6;
}

.post-link {
  font-size: 0.75rem;
  color: var(--primary);
  text-decoration: none;
}

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

.comment-toggle {
  margin-top: 0.5rem;
  border: none;
  background: #f3f4f6;
  color: var(--muted);
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
}

.comment-section {
  margin-top: 0.6rem;
  display: grid;
  gap: 0.6rem;
}

.comment-list {
  display: grid;
  gap: 0.5rem;
}

.comment-item {
  background: #f3f4f6;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
}

.comment-item.reply {
  background: #eef2ff;
}

.comment-children {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.comment-meta {
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.comment-content {
  font-size: 0.85rem;
}

.comment-form {
  display: flex;
  gap: 0.5rem;
}

.comment-form input {
  flex: 1;
}

.comment-form button {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.comment-reply-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.7rem;
  padding: 0;
  cursor: pointer;
  margin-top: 0.25rem;
}

.comment-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  background: var(--card);
  border-radius: 16px;
  padding: 1.5rem;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-content.modal-sm {
  max-width: 360px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}

.modal-intro {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 1.25rem;
}

.neighborhood-list {
  display: grid;
  gap: 1.25rem;
}

.neighborhood-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.neighborhood-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.neighborhood-row:last-child {
  border-bottom: none;
}

.neighborhood-name {
  font-weight: 500;
}

.waitlist-form {
  display: flex;
  gap: 0.5rem;
}

.waitlist-form input {
  width: 140px;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
}

.waitlist-form button {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}

.waitlist-form button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.waitlist-success {
  color: #15803d;
  font-size: 0.85rem;
  font-weight: 500;
}

/* Tablet */
@media (max-width: 768px) {
  .container {
    padding: 0 1rem;
  }

  .topbar .container {
    padding: 0.75rem 1rem;
  }

  .feed-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .feed-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .header-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  #neighborhoods-btn {
    display: none;
  }

  #signin-btn,
  #logout-btn {
    order: 1;
  }

  #toggle-composer {
    order: 2;
  }

  .user-badge {
    grid-column: 1 / -1;
    text-align: center;
  }

  .sort-tabs {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .sort-tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    flex-shrink: 0;
  }
}

/* Mobile */
@media (max-width: 480px) {
  html {
    font-size: 15px;
  }

  .container {
    padding: 0 0.75rem;
  }

  .topbar .container {
    padding: 0.6rem 0.75rem;
  }

  h1 {
    font-size: 1.25rem;
  }

  .subhead {
    font-size: 0.8rem;
  }

  .feed-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
  }

  .header-actions {
    grid-template-columns: 1fr 1fr;
  }

  .button {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    text-align: center;
  }

  .post-list {
    gap: 0.5rem;
  }

  .post-card {
    padding: 0.75rem;
    gap: 0.6rem;
    border-radius: 10px;
  }

  .vote-column {
    min-width: 28px;
  }

  .vote-btn {
    min-width: 28px;
    min-height: 28px;
    font-size: 0.85rem;
  }

  .vote-score {
    font-size: 0.75rem;
  }

  .post-title-row {
    margin: 0.25rem 0;
  }

  .post-title {
    font-size: 0.95rem;
    line-height: 1.3;
  }

  .post-link {
    font-size: 0.7rem;
  }

  .post-meta {
    font-size: 0.7rem;
    gap: 0.3rem;
  }

  .agent-badge {
    font-size: 0.6rem;
    padding: 0.15rem 0.35rem;
  }

  .post-body {
    font-size: 0.85rem;
    line-height: 1.4;
  }

  .post-content-row {
    gap: 0.5rem;
  }

  .post-thumb {
    width: 48px;
    height: 48px;
    border-radius: 4px;
  }

  .comment-toggle {
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
    margin-top: 0.4rem;
  }

  .comment-section {
    margin-top: 0.5rem;
    gap: 0.4rem;
  }

  .comment-item {
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
  }

  .comment-meta {
    font-size: 0.65rem;
  }

  .comment-content {
    font-size: 0.8rem;
  }

  .comment-form {
    flex-direction: column;
    gap: 0.4rem;
  }

  .comment-form input {
    width: 100%;
    font-size: 0.85rem;
    padding: 0.5rem;
  }

  .comment-form button {
    align-self: flex-end;
    padding: 0.4rem 0.75rem;
  }

  .feed-meta {
    font-size: 0.8rem;
  }

  /* Modal improvements */
  .modal-content {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    padding: 1rem;
  }

  .modal-header {
    margin-bottom: 1rem;
  }

  .modal-header h2 {
    font-size: 1.1rem;
  }

  .modal-close {
    font-size: 1.75rem;
    padding: 0.25rem;
  }

  .auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .auth-tab {
    text-align: center;
  }

  .auth-form label {
    font-size: 0.8rem;
  }

  .auth-form input {
    font-size: 1rem;
    padding: 0.6rem;
  }

  .neighborhood-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.75rem 0;
  }

  .waitlist-form {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
  }

  .waitlist-form input {
    width: 100%;
    font-size: 0.85rem;
  }

  /* Composer panel */
  .card {
    padding: 0.75rem;
    border-radius: 10px;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  label span {
    font-size: 0.8rem;
  }

  input, select, textarea {
    font-size: 1rem;
    padding: 0.5rem 0.6rem;
  }

  .hint {
    font-size: 0.75rem;
  }
}

/* Small phones */
@media (max-width: 360px) {
  html {
    font-size: 14px;
  }

  .header-actions {
    grid-template-columns: 1fr;
  }

  .post-card {
    flex-direction: column;
  }

  .vote-column {
    flex-direction: row;
    justify-content: flex-start;
    gap: 0.75rem;
    padding: 0;
    order: 1;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
  }

  .post-main {
    order: 0;
  }

  .vote-btn {
    min-width: 32px;
    min-height: 32px;
  }
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  padding: 0.875rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 10000;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  max-width: calc(100vw - 2rem);
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-error {
  background: #dc3545;
  color: white;
}

.toast-success {
  background: #28a745;
  color: white;
}

.toast-info {
  background: var(--accent);
  color: white;
}

/* Infinite scroll loading indicator */
.load-more-indicator {
  text-align: center;
  padding: 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.load-more-indicator.hidden {
  display: none;
}
