:root {
  --bg: #ffffff;
  --fg: #0f1419;
  --muted: #536471;
  --line: #eff3f4;
  --hover: rgba(15, 20, 25, 0.03);
  --panel: #f7f9f9;
  --accent: #1d9bf0;
  --like: #f91880;
  --contrast-bg: #0f1419;
  --contrast-fg: #ffffff;
  --bar: rgba(255, 255, 255, 0.85);
  --banner: linear-gradient(135deg, #cfd9de, #8899a6);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --fg: #e7e9ea;
    --muted: #71767b;
    --line: #2f3336;
    --hover: rgba(231, 233, 234, 0.03);
    --panel: #16181c;
    --contrast-bg: #eff3f4;
    --contrast-fg: #0f1419;
    --bar: rgba(0, 0, 0, 0.65);
    --banner: linear-gradient(135deg, #333639, #1d1f23);
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; background: var(--bg); }

body {
  color: var(--fg);
  font: 15px/20px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
p a, .text a, .context a { color: var(--accent); }
p a:hover, .text a:hover, .context a:hover { text-decoration: underline; }
code { font: 13px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
h1, h2 { margin: 0; }

svg { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg .fill { fill: currentColor; stroke: none; }

/* The three columns */

.app {
  display: grid;
  grid-template-columns: 275px 600px 350px;
  justify-content: center;
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 4px 12px;
}
.rail .logo, .rail .item {
  display: inline-flex;
  align-items: center;
  gap: 20px;
  padding: 12px;
  border-radius: 9999px;
  font-size: 20px;
  line-height: 24px;
  transition: background-color 0.2s;
}
.rail .logo svg { width: 32px; height: 32px; stroke-width: 2.2; }
.rail .item svg { width: 26px; height: 26px; }
.rail .item span { padding-right: 16px; }
.rail .logo:hover, .rail .item:hover { background: var(--hover); background: color-mix(in srgb, var(--fg) 10%, transparent); }

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 9999px;
  padding: 0 16px;
  min-height: 36px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, background-color 0.2s;
}
.pill:hover { opacity: 0.9; }
.pill.dark, .pill.post { background: var(--contrast-bg); color: var(--contrast-fg); }
.pill.accent { background: var(--accent); color: #ffffff; }
.pill.accent:disabled { opacity: 0.5; cursor: default; }
.pill.outline { border-color: var(--line); background: transparent; color: var(--fg); }
.pill.outline:hover { background: var(--hover); }
.pill.small { min-height: 32px; font-size: 14px; }
.pill.post { width: 90%; min-height: 52px; margin-top: 16px; font-size: 17px; }
.pill.post svg { display: none; }

.column {
  min-height: 100vh;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.sidebar {
  padding: 12px 0 64px 30px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.panel {
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
}
.panel h2 { font-size: 20px; line-height: 24px; font-weight: 800; margin-bottom: 12px; }
.panel p { margin: 0 0 12px; color: var(--fg); }
.fineprint { margin: 0 16px; color: var(--muted); font-size: 13px; }
.fineprint a { color: var(--muted); }

.person { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.person .who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.person .who strong:hover { text-decoration: underline; }
.person .who span { color: var(--muted); }
.person .who strong, .person .who span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.avatar { border-radius: 50%; background: var(--line); display: block; flex: none; object-fit: cover; }
.avatar.ghost { width: 40px; height: 40px; }

/* Sticky headers and tabs */

.bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 32px;
  min-height: 53px;
  padding: 0 16px;
  background: var(--bar);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.bar h1 { font-size: 20px; line-height: 24px; font-weight: 800; }
.bar .sub { margin: 0; color: var(--muted); font-size: 13px; line-height: 16px; }
.back { display: inline-flex; padding: 8px; margin-left: -8px; border-radius: 50%; }
.back:hover { background: var(--hover); background: color-mix(in srgb, var(--fg) 10%, transparent); }

.tabs { display: flex; gap: 0; padding: 0; }
.tab {
  flex: 1;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 53px;
  color: var(--muted);
  font-weight: 500;
}
.tab.active { color: var(--fg); font-weight: 700; }
.tab.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 56px;
  height: 4px;
  border-radius: 9999px;
  background: var(--accent);
}
.tab.muted { font-weight: 400; font-size: 13px; }

/* Composer */

.compose {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.compose form { flex: 1; min-width: 0; }
.compose textarea {
  width: 100%;
  padding: 12px 0;
  border: 0;
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  font-size: 20px;
  line-height: 24px;
  resize: none;
  outline: none;
}
.compose textarea::placeholder { color: var(--muted); }
.compose .command { margin: 0 0 12px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.compose .command code { color: var(--accent); }
.compose-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.counter { color: var(--muted); font-size: 13px; }
.counter.over { color: #f4212e; }
.compose.reply { align-items: center; }
.compose.reply .command { margin: 0; }

/* Chirps */

.chirp {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background-color 0.2s;
}
.chirp:hover { background: var(--hover); }
.chirp .portrait { flex: none; margin-right: 4px; }
.chirp .body { flex: 1; min-width: 0; }
.chirp header { display: flex; gap: 4px; align-items: baseline; white-space: nowrap; overflow: hidden; }
.chirp .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.chirp .name:hover, .chirp .when:hover { text-decoration: underline; }
.chirp .handle, .chirp .dot, .chirp .when, .context { color: var(--muted); }
.chirp .handle { overflow: hidden; text-overflow: ellipsis; }
.context { margin: 2px 0 0; }
.text { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.actions {
  display: flex;
  justify-content: space-between;
  max-width: 425px;
  margin-top: 12px;
  color: var(--muted);
}
.action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  line-height: 16px;
  transition: color 0.2s;
}
.action svg { width: 34px; height: 34px; padding: 8px; margin: -8px -4px -8px -8px; border-radius: 50%; transition: background-color 0.2s; }
.action.reply:hover { color: var(--accent); }
.action.reply:hover svg { background: rgba(29, 155, 240, 0.1); }
.action.like:hover { color: var(--like); }
.action.like:hover svg { background: rgba(249, 24, 128, 0.1); }
.action.commit:hover { color: #00ba7c; }
.action.commit:hover svg { background: rgba(0, 186, 124, 0.1); }
.action.commit span { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* One chirp, opened */

.focus { padding: 12px 16px 0; border-bottom: 1px solid var(--line); }
.focus header { display: flex; align-items: center; gap: 12px; }
.focus .who { display: flex; flex-direction: column; }
.focus .who span { color: var(--muted); }
.focus .text { margin-top: 12px; font-size: 17px; line-height: 24px; }
.focus .stamp { margin: 16px 0; color: var(--muted); }
.focus .stamp a { color: var(--muted); }
.focus .stats { display: flex; gap: 20px; margin: 0; padding: 16px 0; border-top: 1px solid var(--line); color: var(--muted); }
.focus .stats strong { color: var(--fg); }
.focus .stats a { color: var(--muted); }
.focus .stats a:hover { text-decoration: underline; }
.actions.wide { justify-content: space-around; max-width: none; margin: 0; padding: 12px 0; border-top: 1px solid var(--line); }
.actions.wide .action svg { width: 38px; height: 38px; }

/* Profiles */

.profile { border-bottom: 1px solid var(--line); }
.profile .banner { height: 200px; background: var(--banner); }
.profile .identity {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 16px 0;
  margin-bottom: 12px;
}
.avatar.large { width: 134px; height: 134px; margin-top: -79px; border: 4px solid var(--bg); }
.profile h2 { padding: 0 16px; font-size: 20px; line-height: 24px; font-weight: 800; }
.profile .handle { margin: 0 16px; color: var(--muted); }
.profile .bio { margin: 12px 16px 0; white-space: pre-wrap; }
.profile .meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 12px 16px 0; color: var(--muted); }
.profile .meta span { display: inline-flex; align-items: center; gap: 4px; }
.profile .counts { display: flex; gap: 20px; margin: 12px 16px; color: var(--muted); }
.profile .counts strong { color: var(--fg); }
.profile .counts a:hover { text-decoration: underline; }
.profile .tabs { border-top: 0; }

/* Narrower screens: lose the sidebar, then the labels, then the rail */

@media (max-width: 1265px) {
  .app { grid-template-columns: 88px 600px 350px; }
  .rail { align-items: center; }
  .rail .item span { display: none; }
  .pill.post { width: 52px; height: 52px; padding: 0; }
  .pill.post span { display: none; }
  .pill.post svg { display: block; width: 24px; height: 24px; }
}

@media (max-width: 1040px) {
  .app { grid-template-columns: 88px minmax(0, 600px); }
  .sidebar { display: none; }
}

@media (max-width: 600px) {
  .app { display: block; }
  .rail {
    position: fixed;
    top: auto;
    bottom: 0;
    z-index: 3;
    width: 100%;
    height: 53px;
    flex-direction: row;
    justify-content: space-around;
    padding: 0;
    background: var(--bg);
    border-top: 1px solid var(--line);
  }
  .rail .logo { display: none; }
  .pill.post { position: fixed; right: 16px; bottom: 69px; margin: 0; width: 56px; height: 56px; }
  .column { border: 0; padding-bottom: 53px; }
  .profile .banner { height: 120px; }
  .avatar.large { width: 88px; height: 88px; margin-top: -56px; }
}

/* Older chirps */

.older {
  display: block;
  padding: 16px;
  text-align: center;
  color: var(--accent);
  border-bottom: 1px solid var(--line);
  transition: background-color 0.2s;
}
.older:hover { background: var(--hover); }
