:root {
  color-scheme: light;
  --bg: #f7f4ef;
  --surface: #ffffff;
  --surface-strong: #fdfaf5;
  --text: #141414;
  --muted: #6b6f7a;
  --line: rgba(20, 20, 20, 0.1);
  --primary: #2f6bff;
  --primary-strong: #164ee6;
  --coral: #ff6b5f;
  --green: #2f9e66;
  --shadow: 0 24px 70px rgba(22, 28, 45, 0.12);
  --radius: 8px;
  --topbar: 72px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0f12;
  --surface: #181a20;
  --surface-strong: #20232b;
  --text: #f4f4f5;
  --muted: #a3a8b3;
  --line: rgba(255, 255, 255, 0.1);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

img,
svg {
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar);
  display: grid;
  grid-template-columns: minmax(150px, 230px) minmax(280px, 1fr) auto;
  align-items: center;
  gap: 20px;
  padding: 0 clamp(16px, 4vw, 42px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 22px;
}

.brand img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.top-search {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 680px;
  height: 44px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.top-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.top-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.button,
.icon-button,
.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
}

.button {
  padding: 0 16px;
}

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

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

.button-ghost {
  background: transparent;
}

.button-danger {
  color: #fff;
  background: #dc2626;
  border-color: #dc2626;
}

.icon-button {
  position: relative;
  width: 42px;
  padding: 0;
}

.has-badge span {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--coral);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.avatar-link img,
.sidebar-card img,
.post-author img,
.user-row img,
.comment img {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 50%;
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 28px;
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 28px clamp(16px, 3vw, 34px) 90px;
}

.sidebar {
  position: sticky;
  top: calc(var(--topbar) + 24px);
  height: calc(100vh - var(--topbar) - 48px);
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.side-nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 0 14px;
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 700;
}

.nav-item:hover,
.nav-item.is-active {
  color: var(--text);
  background: var(--surface);
}

.sidebar-card {
  margin-top: auto;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.sidebar-card strong,
.sidebar-card span,
.post-author strong,
.post-author small {
  display: block;
}

.sidebar-card span,
.post-author small,
.user-row small {
  color: var(--muted);
  font-size: 13px;
}

.app-main {
  min-width: 0;
  display: grid;
  gap: 20px;
}

.page-intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 0 4px;
}

.page-intro h1 {
  margin: 4px 0 0;
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1;
  letter-spacing: 0;
}

.page-intro p {
  max-width: 680px;
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.eyebrow {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.page-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

.flash-success {
  border-color: rgba(47, 158, 102, 0.4);
}

.flash-error,
.flash-warning {
  border-color: rgba(255, 107, 95, 0.45);
}

.grid {
  display: grid;
  gap: 18px;
}

.grid-2 {
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel,
.post-card,
.auth-card,
.landing-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  padding: clamp(16px, 3vw, 24px);
}

.panel h2,
.panel h3 {
  margin: 0 0 14px;
}

.stack {
  display: grid;
  gap: 14px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 46px;
  padding: 12px 14px;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: 0;
}

.field textarea {
  min-height: 118px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--primary);
}

.inline-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.checkbox-row {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-weight: 600;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.post-feed {
  display: grid;
  gap: 18px;
  max-width: 780px;
}

.post-card {
  overflow: hidden;
}

.post-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
}

.post-author,
.user-row-main {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.post-author span,
.user-row-main span {
  min-width: 0;
}

.post-header time {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.post-media {
  display: block;
  background: #111;
}

.post-media img {
  width: 100%;
  max-height: 720px;
  object-fit: cover;
}

.post-content {
  margin: 0;
  padding: 0 16px 16px;
  line-height: 1.7;
}

.post-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}

.action-button {
  min-height: 36px;
  padding: 0 12px;
  background: var(--surface-strong);
}

.action-button.is-liked {
  color: var(--coral);
}

.action-button.is-static {
  cursor: default;
}

.privacy-pill,
.status-pill {
  margin-left: auto;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
}

.comments {
  display: grid;
  gap: 10px;
  padding: 0 16px 16px;
}

.comment {
  display: flex;
  align-items: start;
  gap: 10px;
}

.comment img {
  width: 30px;
  height: 30px;
}

.comment p {
  margin: 0;
  padding: 9px 12px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  line-height: 1.45;
}

.comment-form {
  display: flex;
  gap: 8px;
}

.comment-form input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 0 12px;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.comment-form button {
  border: 0;
  border-radius: var(--radius);
  padding: 0 14px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.user-row-action {
  flex: 0 0 auto;
}

.empty-state {
  display: grid;
  gap: 10px;
  padding: 32px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.empty-state strong {
  font-size: 20px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.profile-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 24px;
}

.profile-header img {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}

.profile-header h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
}

.profile-header p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.stat {
  min-width: 96px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.stat strong,
.stat span {
  display: block;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tab {
  padding: 10px 14px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 800;
}

.tab.is-active {
  color: #fff;
  background: var(--text);
}

.auth-layout,
.landing-layout {
  width: min(1120px, 100%);
  min-height: calc(100vh - var(--topbar));
  margin: 0 auto;
  padding: clamp(24px, 5vw, 64px) clamp(16px, 4vw, 36px);
}

.auth-layout {
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(460px, 100%);
  padding: clamp(22px, 4vw, 34px);
}

.auth-card h1 {
  margin: 0 0 10px;
  font-size: 34px;
}

.auth-card p {
  color: var(--muted);
  line-height: 1.6;
}

.landing-hero {
  min-height: calc(100vh - var(--topbar) - 110px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.8fr);
  gap: clamp(24px, 6vw, 72px);
  align-items: center;
}

.landing-copy h1 {
  margin: 0;
  font-size: clamp(46px, 8vw, 92px);
  line-height: 0.95;
}

.landing-copy p {
  max-width: 620px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.landing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.landing-panel {
  overflow: hidden;
  background: var(--surface);
}

.landing-panel img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
}

.feature-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 28px;
}

.feature {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.feature strong {
  display: block;
  margin-bottom: 8px;
}

.feature p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.bottom-nav {
  display: none;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow);
  font-weight: 700;
}

@media (max-width: 920px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .top-search {
    order: 3;
    grid-column: 1 / -1;
    max-width: none;
    width: 100%;
  }

  .app-shell {
    grid-template-columns: 1fr;
    padding-bottom: 104px;
  }

  .sidebar {
    display: none;
  }

  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 8px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(18px);
  }

  .bottom-nav .nav-item {
    min-height: 54px;
    justify-content: center;
    padding: 0;
    font-size: 11px;
    gap: 4px;
    flex-direction: column;
  }

  .grid-2,
  .grid-3,
  .landing-hero,
  .feature-strip {
    grid-template-columns: 1fr;
  }

  .profile-header {
    grid-template-columns: 1fr;
    text-align: left;
  }

  .profile-header img {
    width: 86px;
    height: 86px;
  }
}

@media (max-width: 620px) {
  .topbar {
    height: auto;
    padding-top: 10px;
    padding-bottom: 10px;
    gap: 10px;
  }

  .brand span {
    display: none;
  }

  .top-actions .button {
    padding: 0 10px;
  }

  .page-intro {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-fields {
    grid-template-columns: 1fr;
  }

  .comment-form {
    flex-direction: column;
  }

  .post-header {
    align-items: flex-start;
    flex-direction: column;
  }
}
