:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-strong: #f0f3f7;
  --text: #151923;
  --muted: #667085;
  --line: #d8dee8;
  --brand: #1767e8;
  --brand-2: #f15c44;
  --accent: #0f9f84;
  --warning: #e39b18;
  --shadow: 0 16px 48px rgba(38, 49, 75, 0.12);
}

:root.dark {
  color-scheme: dark;
  --bg: #111318;
  --surface: #1a1d24;
  --surface-strong: #232833;
  --text: #f4f6fa;
  --muted: #a6afbf;
  --line: #333948;
  --brand: #6aa2ff;
  --brand-2: #ff765f;
  --accent: #43c7ad;
  --warning: #f2ba4f;
  --shadow: 0 18px 56px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px 18px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand,
.mini-profile,
.message-preview,
.person-row,
.post-author,
.clip-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  font-size: 1.2rem;
  font-weight: 800;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: white;
}

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

.nav-item,
.mobile-nav button {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.nav-item span {
  width: 24px;
  text-align: center;
  font-size: 1.25rem;
}

.nav-item.active,
.mobile-nav button.active {
  color: var(--text);
  background: var(--surface-strong);
}

.create-button,
.primary {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--brand);
  color: white;
  font-weight: 800;
}

.mini-profile {
  margin-top: auto;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-strong);
}

.mini-profile span,
.message-preview p,
.person-row span,
.post-meta,
.post-text,
.panel p {
  margin: 0;
  color: var(--muted);
}

.main-area {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px);
}

.search-box {
  width: min(680px, 100%);
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

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

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

.icon-button,
.avatar.compact {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}

.has-dot {
  position: relative;
}

.has-dot::after {
  content: "";
  position: absolute;
  right: 8px;
  top: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-2);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 760px) 340px;
  gap: 24px;
  align-items: start;
  padding: 24px 28px 72px;
}

.feed-column {
  min-width: 0;
  display: grid;
  gap: 16px;
}

.stories-panel {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 132px;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.story {
  height: 176px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.story-photo {
  min-height: 112px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: white;
  font-size: 1.8rem;
  font-weight: 900;
  background:
    radial-gradient(circle at 28% 20%, #ffe08b, transparent 28%),
    linear-gradient(145deg, #e85242, #1767e8 58%, #111827);
}

.sunset {
  background:
    radial-gradient(circle at 24% 20%, #fff2a5, transparent 24%),
    linear-gradient(150deg, #e54b43, #f2a13a 52%, #32406e);
}

.city {
  background:
    linear-gradient(90deg, transparent 12%, rgba(255,255,255,.48) 12% 16%, transparent 16% 28%, rgba(255,255,255,.36) 28% 33%, transparent 33%),
    linear-gradient(145deg, #1b325f, #159a9c 52%, #f6c063);
}

.forest {
  background:
    radial-gradient(circle at 74% 20%, #f6d45c, transparent 20%),
    linear-gradient(160deg, #175b4d, #42a071 54%, #15292f);
}

.studio {
  background:
    radial-gradient(circle at 32% 28%, #ffffff, transparent 12%),
    linear-gradient(135deg, #292a4a, #7a4ac1 47%, #e87a54);
}

.story span {
  font-weight: 800;
}

.composer,
.post,
.panel,
.filter-tabs,
.dialog-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.composer {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-strong);
  color: var(--text);
  outline: 0;
}

.composer-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.composer-tools button,
.panel-heading button,
.trend-list button,
.tab,
.post-action,
.person-row button {
  min-height: 36px;
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface-strong);
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 700;
}

.filter-tabs {
  display: flex;
  gap: 8px;
  padding: 8px;
  box-shadow: none;
}

.tab.active {
  background: var(--text);
  color: var(--surface);
}

.feed {
  display: grid;
  gap: 16px;
}

.post {
  overflow: hidden;
}

.post-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
}

.avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: white;
  font-weight: 900;
  border: 0;
  background: linear-gradient(135deg, #1767e8, #f15c44);
}

.avatar-me {
  background: linear-gradient(135deg, #1767e8, #0f9f84);
}

.amber {
  background: linear-gradient(135deg, #e39b18, #e85242);
}

.teal {
  background: linear-gradient(135deg, #0f9f84, #1767e8);
}

.violet {
  background: linear-gradient(135deg, #7a4ac1, #f15c44);
}

.post-media {
  min-height: 280px;
  display: grid;
  align-items: end;
  padding: 16px;
  color: white;
}

.media-market {
  background:
    linear-gradient(90deg, rgba(255,255,255,.2) 0 18%, transparent 18% 24%, rgba(255,255,255,.28) 24% 42%, transparent 42%),
    linear-gradient(150deg, #173257, #0f9f84 52%, #e39b18);
}

.media-clip {
  background:
    radial-gradient(circle at 70% 18%, rgba(255,255,255,.88), transparent 12%),
    linear-gradient(135deg, #161926, #1767e8 45%, #f15c44);
}

.media-group {
  background:
    linear-gradient(120deg, rgba(255,255,255,.24) 0 16%, transparent 16% 24%, rgba(255,255,255,.18) 24% 40%, transparent 40%),
    linear-gradient(145deg, #113c3a, #0f9f84 48%, #f15c44);
}

.media-label {
  width: max-content;
  max-width: 100%;
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.45);
  font-weight: 800;
}

.post-content {
  padding: 14px;
}

.post-text {
  margin-top: 6px;
  line-height: 1.5;
}

.post-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 0 14px 14px;
}

.post-action.liked {
  background: color-mix(in srgb, var(--brand-2) 18%, var(--surface-strong));
  color: var(--brand-2);
}

.right-rail {
  display: grid;
  gap: 16px;
  position: sticky;
  top: 88px;
}

.panel {
  padding: 14px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 1rem;
}

.highlight {
  background: linear-gradient(145deg, var(--surface), color-mix(in srgb, var(--accent) 12%, var(--surface)));
}

.live-card {
  display: grid;
  gap: 10px;
}

.live-visual {
  min-height: 150px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 12px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 36% 32%, rgba(255,255,255,.7), transparent 14%),
    linear-gradient(145deg, #111827, #1767e8 48%, #e85242);
}

.live-visual span {
  border-radius: 8px;
  padding: 6px 8px;
  background: #e85242;
  color: white;
  font-size: .75rem;
  font-weight: 900;
}

.people-list {
  display: grid;
  gap: 10px;
}

.person-row {
  justify-content: space-between;
}

.person-row > div {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.person-row strong,
.person-row span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.person-row button.following {
  background: var(--text);
  color: var(--surface);
}

.message-preview + .message-preview {
  margin-top: 12px;
}

.trend-list {
  display: grid;
  gap: 8px;
}

.trend-list button {
  display: flex;
  justify-content: space-between;
  width: 100%;
}

.mobile-nav {
  display: none;
}

dialog {
  border: 0;
  padding: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(6, 10, 18, 0.56);
  backdrop-filter: blur(6px);
}

.dialog-card {
  width: min(560px, calc(100vw - 28px));
  padding: 16px;
}

.view-card {
  min-height: 560px;
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.view-card h1 {
  margin: 0;
  font-size: 1.55rem;
}

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

.feature-tile {
  min-height: 170px;
  display: grid;
  align-content: end;
  gap: 6px;
  padding: 14px;
  border-radius: 8px;
  color: white;
  background: linear-gradient(145deg, #1767e8, #0f9f84);
}

.feature-tile:nth-child(2) {
  background: linear-gradient(145deg, #e39b18, #e85242);
}

.feature-tile:nth-child(3) {
  background: linear-gradient(145deg, #16243d, #7a4ac1);
}

.feature-tile:nth-child(4) {
  background: linear-gradient(145deg, #0e4e42, #f15c44);
}

@media (max-width: 1120px) {
  .content-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .right-rail {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .topbar {
    padding: 12px;
  }

  .top-actions .icon-button:not(#themeToggle) {
    display: none;
  }

  .content-grid {
    padding: 14px 12px 86px;
  }

  .right-rail {
    grid-template-columns: 1fr;
  }

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

  .mobile-nav {
    position: fixed;
    inset: auto 10px 10px;
    z-index: 10;
    height: 58px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  .mobile-nav button {
    justify-content: center;
    padding: 0;
    font-size: 1.25rem;
  }

  .view-grid {
    grid-template-columns: 1fr;
  }
}
