/* Mirrors the current twitter.com web UI. Sizes were measured from the live site (Japanese locale, 1300px wide);
   the dark theme is twitter's "Dim" (#15202B). TwitterChirp is not redistributable, so its fallback stack is used. */

:root {
  --bg: #fff;
  --text: #0f1419;
  --sub: #536471;
  --action: #536471;
  --border: #eff3f4;
  --line: #cfd9de;
  --hover: rgba(15, 20, 25, 0.03);
  --topbar: rgba(255, 255, 255, 0.85);
  --input-border: #cfd9de;
  --media-bg: #f7f9f9;
  --accent: #1d9bf0;
  --accent-hover: rgba(29, 155, 240, 0.1);
  --like: #f91880;
  --retweet: #00ba7c;
  --logo: #1d9bf0;
  color-scheme: light;
}
/* Dim */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #15202b;
    --text: #f7f9f9;
    --sub: #8b98a5;
    /* icon strokes in --sub read stronger than twitter's; this matches their contrast (about 4.6:1) */
    --action: #7f8b98;
    --border: #38444d;
    --line: #425364;
    --hover: rgba(247, 249, 249, 0.03);
    --topbar: rgba(21, 32, 43, 0.75);
    --input-border: #38444d;
    --media-bg: #1e2732;
    --logo: #f7f9f9;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #15202b;
  --text: #f7f9f9;
  --sub: #8b98a5;
  --action: #7f8b98;
  --border: #38444d;
  --line: #425364;
  --hover: rgba(247, 249, 249, 0.03);
  --topbar: rgba(21, 32, 43, 0.75);
  --input-border: #38444d;
  --media-bg: #1e2732;
  --logo: #f7f9f9;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  /* UI chrome stack used by twitter.com in the Japanese locale */
  font-family: 'Segoe UI', Meiryo, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 20px;
  overflow-wrap: anywhere;
}
/* tweet bodies use Chirp's fallback stack */
.text, .bio { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, 'Hiragino Sans', Meiryo, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { fill: currentColor; }
/* Lucide outline icons */
.icon { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---- frame ---- */

.app { display: flex; justify-content: center; min-height: 100vh; }

.nav {
  position: sticky; top: 0; height: 100vh;
  width: 88px; padding: 0 12px;
  display: flex; flex-direction: column; align-items: flex-end;
}
.nav a { color: var(--text); text-decoration: none; }
.nav-logo { display: block; padding: 2px 0 4px; }
.nav-logo span { display: flex; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 9999px; color: var(--logo); }
.nav-logo:hover span { background: var(--hover); }
.nav-logo svg { width: 30px; height: 30px; }
.nav-item { display: flex; padding: 4px 0; }
.nav-item > div { display: flex; align-items: center; padding: 12px; border-radius: 9999px; transition: background-color 0.2s; }
.nav-item:hover > div { background: var(--hover); }
.nav-item svg { width: 26.25px; height: 26.25px; flex: none; }
.nav-item span { display: none; margin: 0 16px 0 20px; font-size: 20px; line-height: 24px; }
.nav-item[aria-current] span { font-weight: 700; }
.nav-item[aria-current] .icon { stroke-width: 2.5; }
.nav-account {
  display: flex; align-items: center; gap: 12px;
  margin: auto 0 12px; padding: 12px; border-radius: 9999px;
}
.nav-account:hover { background: var(--hover); }
.nav-account .who { display: none; flex-direction: column; min-width: 0; line-height: 20px; }
.nav-account .name { font-weight: 700; }
.nav-account .handle { color: var(--sub); }
@media (min-width: 1265px) {
  .nav { width: 275px; align-items: stretch; }
  .nav-logo { align-self: flex-start; }
  .nav-item span { display: inline; }
  .nav-account { width: 100%; }
  .nav-account .who { display: flex; }
}

.primary {
  width: 600px; max-width: 100%; min-width: 0;
  border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  min-height: 100vh;
}

.topbar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center;
  height: 53px; padding: 0 16px;
  background: var(--topbar);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.topbar h1 { margin: 0; padding: 2px 0; font-size: 20px; line-height: 24px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { color: var(--sub); font-size: 13px; line-height: 16px; }
.topbar { cursor: pointer; }
.topbar-title { min-width: 0; }
.back { display: flex; flex: none; width: 56px; margin-left: -8px; }
.back span { display: flex; padding: 8px; border-radius: 9999px; color: var(--text); }
.back:hover span { background: var(--hover); }
.back svg { width: 20px; height: 20px; }

.sidebar {
  width: 350px; margin: 0 10px 0 30px; padding-bottom: 64px;
  position: sticky; top: 0; align-self: flex-start; max-height: 100vh; overflow-y: auto;
  scrollbar-width: none;
}
.sidebar-search { position: sticky; top: 0; z-index: 1; background: var(--bg); padding: 8px 0 12px; }
.searchbox {
  display: flex; align-items: center;
  height: 40px; padding-left: 12px;
  border: 1px solid var(--input-border); border-radius: 9999px; color: var(--sub);
}
.searchbox:focus-within { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent); }
.searchbox svg { width: 16px; height: 16px; flex: none; margin: 0 4px; }
.searchbox input { flex: 1; min-width: 0; height: 100%; padding: 0 16px 0 4px; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 14px; }
.searchbox input::placeholder { color: var(--sub); }

.foot { color: var(--sub); font-size: 13px; line-height: 16px; padding: 0 16px; margin: 0; }


@media (max-width: 1000px) {
  .sidebar { display: none; }
}
@media (max-width: 700px) {
  .app { display: block; padding-bottom: 53px; }
  .primary { border: 0; width: 100%; }
  .nav {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 3;
    width: auto; height: 53px; padding: 0;
    flex-direction: row; justify-content: space-around; align-items: center;
    background: var(--bg); border-top: 1px solid var(--border);
  }
  .nav-logo, .nav-account { display: none; }
}

/* ---- avatars ---- */

.avatar { display: block; width: 40px; height: 40px; border-radius: 9999px; object-fit: cover; flex: none; background: var(--media-bg); }
.avatar.small { width: 20px; height: 20px; }
.avatar.letter {
  display: flex; align-items: center; justify-content: center;
  background: hsl(var(--hue, 203) 45% 50%); color: #fff; font-weight: 700; font-size: 17px;
}
.avatar.small.letter { font-size: 11px; }

/* ---- profile ---- */

.banner { aspect-ratio: 3 / 1; background: var(--line); overflow: hidden; }
.banner a { display: block; height: 100%; }
.banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* the link carries the avatar's size so that its percentage width resolves against the profile, not itself */
/* The avatar overlaps the banner. Being positioned, it paints above the banner picture (otherwise its ring, drawn in
   the earlier border phase, ends up under the banner's pixels). As on twitter, hovering darkens only the picture;
   the ring keeps the page colour. */
.avatar-link {
  position: relative; display: block; width: 25%; min-width: 48px; max-width: 133.5px;
  margin-top: calc(max(-12.5%, -66.75px) - 12px); margin-bottom: 14px; border-radius: 9999px;
}
.avatar-link .avatar.large { width: 100%; min-width: 0; max-width: none; margin: 0; }
.avatar-link::after { content: ''; position: absolute; inset: 4px; border-radius: 9999px; transition: background-color 0.2s; }
.avatar-link:hover::after { background: rgba(0, 0, 0, 0.15); }
.profile-body { padding: 12px 16px 0; }
.avatar.large {
  position: relative;
  width: 25%; min-width: 48px; max-width: 133.5px; height: auto; aspect-ratio: 1;
  margin-top: calc(max(-12.5%, -66.75px) - 12px); margin-bottom: 14px;
  border: 4px solid var(--bg);
}
.profile .names { margin: 4px 0 12px; }
.profile .name { font-size: 20px; line-height: 24px; font-weight: 800; }
.profile .handle { color: var(--sub); }
.profile .bio { margin: 0 0 12px; white-space: pre-wrap; }
.profile .facts { display: flex; flex-wrap: wrap; gap: 0 12px; color: var(--sub); margin-bottom: 12px; }
.profile .facts span { display: inline-flex; align-items: center; }
.profile .facts svg { width: 18.75px; height: 18.75px; margin-right: 4px; }
.profile .counts { display: flex; gap: 20px; color: var(--sub); margin-bottom: 12px; }
.profile .counts b { color: var(--text); font-weight: 700; }
.profile .notice { margin: 0 0 12px; color: var(--sub); }

/* ---- tabs ---- */

.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tabs a { flex: 1; display: flex; justify-content: center; height: 53px; padding: 0 16px; color: var(--sub); font-weight: 500; text-decoration: none; }
.tabs a:hover { background: var(--hover); }
.tabs a span { position: relative; display: flex; align-items: center; }
.tabs a[aria-current] { color: var(--text); font-weight: 700; }
.tabs a[aria-current] span::after {
  content: ''; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; min-width: 56px; height: 4px; border-radius: 9999px; background: var(--accent);
}

/* ---- tweet ---- */

.tweet { padding: 0 16px; border-bottom: 1px solid var(--border); }
.tweet[data-href] { cursor: pointer; transition: background-color 0.2s; }
.tweet[data-href]:hover { background: var(--hover); }
.tweet .row { display: flex; padding: 12px 0; }
.tweet .side { display: flex; flex-direction: column; align-items: center; flex: none; width: 40px; margin-right: 8px; }
.tweet .content { flex: 1; min-width: 0; }
/* twitter centres the 20px name line in a 21px row, which puts the name half a pixel below the avatar's top edge */
.tweet .head { display: flex; align-items: center; min-height: 21px; white-space: nowrap; overflow: hidden; }
/* twitter leaves 2px between the name row and what follows it */
.tweet .content > .head + * { margin-top: 2px; }
.tweet .name { font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; flex-shrink: 1; }
.tweet a.handle:hover { text-decoration: none; }
.side-avatar { display: block; border-radius: 9999px; }
.side-avatar:hover .avatar { filter: brightness(0.85); }
.social a { color: inherit; }
.tweet .handle, .tweet .dot, .tweet .time { color: var(--sub); }
.tweet .handle { margin-left: 4px; overflow: hidden; text-overflow: ellipsis; flex-shrink: 1; }
.tweet .dot { padding: 0 4px; }
.tweet .time { flex: none; }
.tweet .text { white-space: pre-wrap; }
.reply-to { color: var(--sub); }

.social {
  display: flex; align-items: center;
  color: var(--sub); font-size: 13px; line-height: 16px; font-weight: 700;
  padding-top: 8px; margin-bottom: -8px;
}
/* the icon sits flush right in the avatar column and the label starts on the name column, as on twitter */
.social svg { width: 16px; height: 16px; flex: none; margin: 0 8px 0 24px; }

.thread-up { border-bottom: 0; }
.thread-up .row { padding-bottom: 0; }
.thread-up .content { padding-bottom: 12px; }
.thread-up .side::after { content: ''; flex: 1; width: 2px; margin-top: 4px; background: var(--line); }

.actions { display: flex; align-items: center; height: 20px; margin-top: 12px; color: var(--action); font-size: 13px; line-height: 20px; }
.action { display: inline-flex; align-items: center; flex: 1; max-width: 117px; }
.action-icon { position: relative; display: flex; }
.action-icon::before { content: ''; position: absolute; inset: -8px; border-radius: 9999px; transition: background-color 0.2s; }
/* a touch smaller and lighter than twitter's 18.75px glyphs, by preference */
.action svg { position: relative; width: 17px; height: 17px; }
.actions .icon { stroke-width: 1.5; }
.action > span:last-child { padding: 0 12px 0 4px; transition: color 0.2s; }
/* the icon and count read as a button wherever the row appears (timeline cells are pointer throughout anyway) */
.action-icon, .action > span:last-child { cursor: pointer; }
.action { transition: color 0.2s; }
.action.reply:hover { color: var(--accent); }
.action.reply:hover .action-icon::before { background: rgba(29, 155, 240, 0.1); }
.action.retweet:hover { color: var(--retweet); }
.action.retweet:hover .action-icon::before { background: rgba(0, 186, 124, 0.1); }
.action.like:hover { color: var(--like); }
.action.like:hover .action-icon::before { background: rgba(249, 24, 128, 0.1); }
/* media */
.media {
  display: grid; gap: 2px; margin-top: 12px;
  border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
}
.media.n2, .media.n3, .media.n4 { grid-template-columns: 1fr 1fr; aspect-ratio: 16 / 9; }
.media.n3, .media.n4 { grid-template-rows: 1fr 1fr; }
.media.n3 .media-item:first-child { grid-row: span 2; }
.media-item { position: relative; display: block; min-height: 0; overflow: hidden; background: var(--media-bg); }
.media.n1.tall { width: fit-content; max-width: 100%; }
.media.n1.tall .media-item { max-width: 100%; }
.media-item img, .media-item video { display: block; width: 100%; height: 100%; object-fit: cover; }
.media.n1 video { object-fit: contain; background: #000; }
.media-item.photo { cursor: pointer; }
.media-item.missing { display: flex; align-items: center; justify-content: center; color: var(--sub); padding: 24px; }
/* hidden media carry no size: a lone one gets a fixed 16:9 frame, several fill the usual grid cells */
.media-item.hidden-media { display: flex; align-items: center; justify-content: center; color: var(--sub); }
.media.n1 .media-item.hidden-media { aspect-ratio: 16 / 9; }
.media-item.hidden-media svg { width: 28px; height: 28px; }
a.media-item.hidden-media:hover { background: var(--hover); color: var(--accent); }
.badge {
  position: absolute; left: 12px; bottom: 12px; padding: 0 4px; border-radius: 4px;
  background: rgba(0, 0, 0, 0.77); color: #fff; font-size: 13px; font-weight: 700; line-height: 20px;
}

/* quote */
.quote {
  display: block; margin-top: 12px; overflow: hidden;
  border: 1px solid var(--line); border-radius: 16px; color: var(--text); text-decoration: none;
}
.quote:hover { background: var(--hover); text-decoration: none; }
.quote .head { padding: 12px 12px 0; align-items: center; }
.quote .avatar.small { margin-right: 4px; }
.quote .text { padding: 4px 12px 12px; }
.quote .media { margin-top: 0; border: 0; border-radius: 0; }
.quote.unavailable .text { color: var(--sub); }

/* detail (status page, embed) */
.tweet.detail .row { align-items: center; padding-bottom: 0; }
.head.stacked { flex-direction: column; align-items: flex-start; }
.head.stacked .handle { margin-left: 0; }
.tweet.detail .reply-to { margin-top: 12px; }
.tweet.detail .text { font-size: 17px; line-height: 24px; margin-top: 12px; }
.tweet.detail .meta { margin: 16px 0; color: var(--sub); }
.tweet.detail .meta a { color: var(--sub); }
.tweet.detail .meta .dot { padding: 0 4px; }
.tweet.detail .actions { height: 48px; margin: 0; padding: 0 4px; border-top: 1px solid var(--border); justify-content: space-around; }
.tweet.detail .action { flex: none; max-width: none; }
.tweet.detail .action svg { width: 20px; height: 20px; }
.tweet.detail .action span { font-size: 13px; }

/* misc */
.pager a { display: block; padding: 16px; text-align: center; }
.pager a:hover { background: var(--hover); text-decoration: none; }
.help, .empty, .result-count { margin: 0; padding: 16px; color: var(--sub); }
.result-count { padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.help code { border: 1px solid var(--border); padding: 0 4px; border-radius: 4px; }

/* ---- about (Markdown) ---- */

.prose { padding: 4px 16px 32px; }
.prose h2 { margin: 28px 0 8px; font-size: 20px; line-height: 24px; font-weight: 800; }
.prose h3 { margin: 20px 0 4px; font-size: 17px; line-height: 24px; font-weight: 700; }
.prose p, .prose ul, .prose ol { margin: 12px 0; }
.prose ul, .prose ol { padding-left: 24px; }
.prose li + li { margin-top: 4px; }
.prose img { max-width: 100%; border-radius: 16px; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }
.prose code { border: 1px solid var(--border); padding: 0 4px; border-radius: 4px; }
.prose blockquote { margin: 12px 0; padding-left: 12px; border-left: 4px solid var(--border); color: var(--sub); }

/* ---- embed ---- */

body.embed { background: transparent; }
.embed-card {
  max-width: 550px; overflow: hidden;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
}
.embed-card .tweet:last-child { border-bottom: 0; }
/* embeds show the tweet only; the (inert) reply / retweet / like row is left out */
.embed-card .actions { display: none; }
.embed-card .tweet.detail .meta { margin-bottom: 12px; }

/* ---- photo viewer (twitter's media modal) ---- */

.viewer-open, .viewer-open body { overflow: hidden; }
.viewer { position: fixed; inset: 0; z-index: 100; display: flex; background: rgba(0, 0, 0, 0.9); }
.viewer-stage { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; }
.viewer-media { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.viewer-img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; }
.viewer-bar { display: flex; justify-content: center; height: 48px; flex: none; }
.viewer-bar .actions { margin: 0; justify-content: center; align-items: center; color: #e7e9ea; }
.viewer-bar .action { flex: none; width: 130px; max-width: none; }
.viewer-bar .action:last-child { width: auto; }
.viewer-btn {
  position: absolute; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; border: 0; border-radius: 9999px;
  background: rgba(15, 20, 25, 0.75); color: #fff; cursor: pointer;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.viewer-btn:hover { background: rgba(39, 44, 48, 0.75); }
.viewer-btn svg { width: 20px; height: 20px; }
.viewer-btn[hidden] { display: none; }
.viewer-close { top: 12px; left: 12px; }
.viewer-prev, .viewer-next { top: 50%; transform: translateY(-50%); }
.viewer-prev { left: 12px; }
.viewer-next { right: 12px; }
.viewer-toggle { top: 12px; right: 12px; }
.viewer-side-hidden .viewer-side { display: none; }
.viewer-side { flex: none; width: 350px; overflow-y: auto; background: var(--bg); border-left: 1px solid var(--border); }
.viewer-side .tweet.detail .media { display: none; }
.viewer-side .loading { padding: 16px; color: var(--sub); }
.viewer-avatar .viewer-img { width: min(400px, 80vw); height: min(400px, 80vw); object-fit: cover; border-radius: 9999px; }
.viewer-avatar .viewer-bar, .viewer-header .viewer-bar { display: none; }
/* phone widths: twitter switches to an opaque full-screen viewer with no side panel to toggle */
@media (max-width: 700px) {
  .viewer { background: #000; }
  .viewer-side, .viewer-toggle { display: none; }
}
.viewer-avatar .viewer-toggle, .viewer-header .viewer-toggle { display: none; }
