:root {
  --bg: #F3EEE6;
  --surface: #FFFBF6;
  --ink: #1B1814;
  --muted: #6E675D;
  --line: #E4DCD2;
  --accent: #B44828;
  --accent-soft: #F6E4DC;
  --chip: #EFE8DE;
  --ok: #2F4A3C;
  --shadow: 0 1px 2px rgba(27, 24, 20, 0.04), 0 8px 24px rgba(27, 24, 20, 0.05);
  --radius: 18px;
  --tap: 48px;
  --font: "DM Sans", "Segoe UI", sans-serif;
  --serif: "Newsreader", "Georgia", serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  background: #d8d0c6;
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100%;
}

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

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

[hidden] { display: none !important; }

img { display: block; max-width: 100%; }

.app {
  min-height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  box-shadow: 0 0 0 1px rgba(27, 24, 20, 0.06), 0 20px 60px rgba(27, 24, 20, 0.12);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid transparent;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin-bottom: 14px;
}

.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }

.wordmark {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
}

.demo-pill {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--chip);
  border-radius: 999px;
  padding: 4px 8px;
  flex-shrink: 0;
}

.btn-text {
  min-height: var(--tap);
  padding: 0 12px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
}

.btn-text:hover, .btn-text:focus-visible { background: var(--chip); }

.segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--chip);
  border-radius: 16px;
}

.segment-btn {
  min-height: 52px;
  border-radius: 12px;
  font-weight: 650;
  font-size: 16px;
  color: var(--muted);
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.segment-btn.is-on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.meta-row {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 10px;
}

.counter {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.counter-caption { color: var(--muted); font-size: 14px; }

.progress {
  flex: 1 1 100%;
  height: 4px;
  background: var(--chip);
  border-radius: 99px;
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ok);
  border-radius: inherit;
  transition: width 0.3s ease;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: 999px;
  background: var(--chip);
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  border: 2px solid transparent;
}

.chip.is-on {
  background: var(--ink);
  color: var(--surface);
}

.hint {
  margin: 8px 16px 0;
  padding: 16px 16px 14px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.hint p { color: var(--ink); font-size: 15px; margin-bottom: 12px; }

.hint em { font-style: normal; font-weight: 650; }

.btn-primary, .btn-ghost, .btn-follow, .btn-unfollow, .btn-like, .btn-comment, .btn-send {
  min-height: var(--tap);
  border-radius: 12px;
  font-weight: 650;
  padding: 0 16px;
}

.btn-primary {
  background: var(--ink);
  color: var(--surface);
}

.btn-primary:hover { filter: brightness(1.08); }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-ghost.full { width: 100%; }

.view { padding: 12px 16px calc(28px + var(--safe-bottom)); }

.feed { display: flex; flex-direction: column; gap: 12px; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 10px;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--chip);
  flex-shrink: 0;
}

.avatar.initials {
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--ok);
  background: #e4ebe6;
}

.who { min-width: 0; flex: 1; }

.name { font-weight: 700; font-size: 15px; }

.handle, .time { color: var(--muted); font-size: 13px; }

.topic-tag {
  font-size: 12px;
  font-weight: 650;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 4px 8px;
  flex-shrink: 0;
}

.card-body { padding: 0 16px 12px; font-size: 16px; }

.card-body p { white-space: pre-wrap; }

.card-image {
  margin: 0 0 12px;
  background: #e8e2d8;
}

.card-image img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.actions {
  display: flex;
  gap: 8px;
  padding: 0 10px 12px;
  border-top: 0;
}

.btn-like, .btn-comment {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  background: transparent;
  font-weight: 600;
  font-size: 15px;
  padding: 0 10px;
}

.btn-like.is-on { color: var(--accent); }

.btn-like svg, .btn-comment svg { width: 22px; height: 22px; }

.comments {
  border-top: 1px solid var(--line);
  padding: 10px 14px 14px;
}

.comment {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 14px;
}

.comment .avatar { width: 28px; height: 28px; font-size: 10px; }

.comment strong { font-weight: 650; margin-right: 6px; }

.composer {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.composer input {
  flex: 1;
  min-height: var(--tap);
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 12px;
  padding: 0 14px;
  outline: none;
}

.composer input:focus { border-color: var(--ink); }

.btn-send { background: var(--ink); color: var(--surface); flex-shrink: 0; }

.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
}

.empty h2 {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 8px;
}

.people-head { margin-bottom: 18px; }

.people-head h1 {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.03em;
  margin: 8px 0 6px;
}

.lede { color: var(--muted); margin-bottom: 16px; }

.search-label {
  display: block;
  font-size: 13px;
  font-weight: 650;
  margin-bottom: 6px;
}

.search {
  width: 100%;
  min-height: var(--tap);
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 0 14px;
  outline: none;
  margin-bottom: 8px;
}

.search:focus { border-color: var(--ink); }

.section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 18px 0 8px;
}

.person {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  min-height: 64px;
  border-bottom: 1px solid var(--line);
}

.person .who { flex: 1; min-width: 0; }

.person .bio { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn-follow, .btn-unfollow {
  flex-shrink: 0;
  min-width: 118px;
}

.btn-follow { background: var(--ink); color: var(--surface); }

.btn-unfollow {
  background: var(--chip);
  color: var(--ink);
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: end center;
}

.modal-root[hidden] { display: none; }

.backdrop {
  position: absolute;
  inset: 0;
  background: rgba(27, 24, 20, 0.45);
}

.modal {
  position: relative;
  width: min(430px, 100%);
  max-height: 88dvh;
  overflow: auto;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 22px 18px calc(18px + var(--safe-bottom));
  box-shadow: 0 -12px 40px rgba(27, 24, 20, 0.18);
}

.modal h2 {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 500;
  margin-bottom: 8px;
}

.modal p { color: var(--muted); margin-bottom: 14px; }

.modal-list { max-height: 42dvh; overflow: auto; margin-bottom: 12px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--surface);
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  z-index: 60;
  max-width: calc(100% - 32px);
  box-shadow: var(--shadow);
}

.toast[hidden] { display: none; }

@media (min-width: 500px) {
  body { padding: 24px 0; }
  .app { min-height: calc(100dvh - 48px); border-radius: 24px; overflow: hidden; }
  .modal { border-radius: 24px; margin-bottom: 24px; }
}
