/* ── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; line-height: 1.5; }

body {
  font-family: sans-serif;
  color: #1a1b1c;
  background: #fff;
  padding: 0 0 4rem;
}

a { color: #00f; text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ── Layout wrapper ────────────────────────────────────────────────────────── */
.tw-wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ── Header ────────────────────────────────────────────────────────────────── */
.tw-header {
  padding: 2rem 0 1rem;
  border-bottom: 3px solid #1a1b1c;
  margin-bottom: 1.5rem;
}

.tw-header-top {
  text-align: right;
  font-size: 14px;
  margin-bottom: 0.5rem;
}
.tw-header-top a { color: #b0b8c1; text-decoration: none; }
.tw-header-top a:hover { color: #73808c; }

.tw-header h1 {
  font-size: 2.5rem;
  line-height: 1.1;
  margin-bottom: 0.75rem;
}

/* ── Search ────────────────────────────────────────────────────────────────── */
.tw-search-wrap { position: relative; }

#tw-search {
  width: 100%;
  max-width: 480px;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  border: 2px solid #1a1b1c;
  border-radius: 0;
  background: #fff;
  outline: none;
  appearance: none;
}

#tw-search:focus { border-color: #00f; }

/* ── Layout: list + sidebar ─────────────────────────────────────────────────── */
.tw-layout {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.tw-main { flex: 1; min-width: 0; }

.tw-sidebar {
  flex: 0 0 180px;
  padding-top: 0.25rem;
}

@media (max-width: 600px) {
  .tw-layout { flex-direction: column; }
  .tw-sidebar { flex: none; width: 100%; order: -1; }
}

/* ── Tabs ──────────────────────────────────────────────────────────────────── */
.tw-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
  border-bottom: 2px solid #1a1b1c;
}

.tw-tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  padding: 0.5rem 0.9rem;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  color: #73808c;
}

.tw-tab:hover { color: #1a1b1c; }

.tw-tab.active {
  color: #1a1b1c;
  border-bottom-color: #00f;
  font-weight: 600;
}

/* ── Tweet card ────────────────────────────────────────────────────────────── */
.tw-card {
  border: 2px solid #e8e8e8;
  padding: 1rem;
  margin-bottom: 1rem;
  background: #fff;
  transition: border-color 0.1s;
}

.tw-card:hover { border-color: #1a1b1c; }

.tw-card[data-type="retweet"] { background: #fafafa; }

.tw-card-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.tw-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.tw-identity {
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}

.tw-name {
  display: block;
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tw-handle {
  font-size: 0.85rem;
  color: #73808c;
}

.tw-date {
  font-size: 0.85rem;
  color: #73808c;
  white-space: nowrap;
  flex-shrink: 0;
}

.tw-date:hover { color: #00f; text-decoration: underline; }

/* ── Badge (RT label) ──────────────────────────────────────────────────────── */
.tw-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.1em 0.4em;
  border: 1.5px solid;
  border-radius: 3px;
  margin-bottom: 0.4rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tw-rt { color: #2e7d32; border-color: #2e7d32; }

/* ── Reply context line ─────────────────────────────────────────────────────── */
.tw-reply-ctx {
  display: block;
  font-size: 0.85rem;
  color: #73808c;
  margin-bottom: 0.4rem;
}

/* ── Tweet body text ───────────────────────────────────────────────────────── */
.tw-body {
  font-size: 1rem;
  line-height: 1.55;
  margin-bottom: 0.75rem;
  word-break: break-word;
}

.tw-body a {
  color: #00f;
  background: linear-gradient(180deg, rgba(0,0,0,0) 70%, #fff5c4 0);
}

.tw-body a:hover { text-decoration: underline; }

/* ── Media grid ────────────────────────────────────────────────────────────── */
.tw-media {
  display: grid;
  gap: 3px;
  margin-bottom: 0.75rem;
  border-radius: 2px;
  overflow: hidden;
}

.tw-media-1 { grid-template-columns: 1fr; }
.tw-media-2 { grid-template-columns: 1fr 1fr; }
.tw-media-3 { grid-template-columns: 1fr 1fr; }
.tw-media-4 { grid-template-columns: 1fr 1fr; }

.tw-media-img {
  width: 100%;
  height: 240px;
  object-fit: cover;
  display: block;
}

.tw-media-1 .tw-media-img { height: auto; max-height: 480px; object-fit: contain; }

.tw-video-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tw-play-btn {
  position: absolute;
  font-size: 2.5rem;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
  pointer-events: none;
}

/* ── Stats (RT / like count) ────────────────────────────────────────────────── */
.tw-stats {
  display: flex;
  gap: 1.2rem;
  font-size: 0.85rem;
  color: #73808c;
  border-top: 1px solid #e8e8e8;
  padding-top: 0.5rem;
  margin-top: 0.25rem;
}

/* ── Sidebar filters ────────────────────────────────────────────────────────── */
.tw-sidebar strong {
  display: block;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
  color: #73808c;
}

.tw-filter-group {
  border: 2px solid #e8e8e8;
  padding: 0.75rem;
  margin-bottom: 1rem;
}

.tw-filter-group label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
  cursor: pointer;
}

.tw-filter-group input { margin-right: 0.3rem; }

/* ── Search results overlay ─────────────────────────────────────────────────── */
.tw-search-results {
  margin-top: 1rem;
}

.tw-search-results[hidden] { display: none; }

.tw-search-result {
  border-left: 3px solid #00f;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  background: #f9f9ff;
}

.tw-search-result p {
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
  color: #1a1b1c;
}

.tw-search-result a {
  font-size: 0.8rem;
  color: #73808c;
}

.tw-search-result a:hover { color: #00f; }

.tw-search-no-results {
  color: #73808c;
  font-size: 0.95rem;
  padding: 1rem 0;
}

/* ── Pagination ────────────────────────────────────────────────────────────── */
.tw-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 0;
  border-top: 2px solid #e8e8e8;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.tw-pager {
  color: #00f;
  font-weight: 600;
}

.tw-pager:hover { text-decoration: underline; }

.tw-page-info { color: #73808c; }

/* ── Single tweet page ──────────────────────────────────────────────────────── */
.tw-single .tw-wrap { max-width: 600px; }

.tw-back {
  padding: 1.5rem 0 1rem;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
}

.tw-back a { color: #73808c; text-decoration: none; }
.tw-back a:hover { color: #00f; }

.tw-single-footer {
  text-align: right;
  font-size: 0.8rem;
}
.tw-single-footer a { color: #b0b8c1; text-decoration: none; }
.tw-single-footer a:hover { color: #73808c; }

/* ── Hidden cards (filtered out) ───────────────────────────────────────────── */
.tw-card[hidden] { display: none; }
