/* Twitter 图库 — 纯静态前端样式 */

:root {
  --bg: #000000;
  --panel: #16181c;
  --panel-2: #1d1f23;
  --border: #2f3336;
  --text: #e7e9ea;
  --muted: #71767b;
  --accent: #1d9bf0;
  --accent-soft: rgba(29, 155, 240, 0.12);
  --like: #f91880;
  --rt: #00ba7c;
  --reply: #1d9bf0;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  --radius: 16px;
  --topbar-h: 52px;
}

[data-theme="light"] {
  --bg: #ffffff;
  --panel: #f7f9f9;
  --panel-2: #eff3f4;
  --border: #e1e8ed;
  --text: #0f1419;
  --muted: #536471;
  --accent: #1d9bf0;
  --accent-soft: rgba(29, 155, 240, 0.1);
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.16);
}

* { box-sizing: border-box; }

/* 关键：确保 hidden 属性永远生效（避免被 display:flex/block 覆盖） */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

button { font: inherit; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 800;
  font-size: 19px;
  white-space: nowrap;
  background: linear-gradient(120deg, #1d9bf0, #7856ff 70%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.search-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 460px;
  padding: 8px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.search-wrap:focus-within { border-color: var(--accent); }
.search-icon { opacity: 0.55; display: flex; align-items: center; }
#search {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
}

.view-toggle {
  display: flex;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}
.view-toggle button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 5px 16px;
  border-radius: 999px;
}
.view-toggle button.active { background: var(--accent); color: #fff; }

.icon-btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
}
.icon-btn svg { display: block; }
.icon-btn:hover { background: var(--panel-2); }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: calc(100vh - var(--topbar-h)); }

.sidebar {
  width: 280px;
  flex: 0 0 280px;
  border-right: 1px solid var(--border);
  padding: 12px;
  overflow-y: auto;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
}
.sidebar-head {
  display: flex;
  justify-content: space-between;
  padding: 4px 8px 10px;
  font-weight: 700;
}

.account-list { display: flex; flex-direction: column; gap: 2px; }
.acct {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.acct:hover { background: var(--panel-2); }
.acct.active { background: var(--accent-soft); }

.acct .avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--panel-2);
  flex: 0 0 40px;
}
.avatar-fallback {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1d9bf0, #7856ff);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  flex: 0 0 40px;
}
.acct .acct-body { min-width: 0; flex: 1; }
.acct .acct-nick { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct .acct-name { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct .acct-count { color: var(--muted); font-size: 12px; }

/* ---------- 内容 ---------- */
.content { flex: 1; max-width: 720px; margin: 0 auto; padding: 0 16px 60px; }

/* 资料头 */
.profile {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 16px 0;
  background: var(--panel);
}
.profile .banner { width: 100%; height: 150px; object-fit: cover; background: var(--panel-2); }
.profile .banner-fallback { width: 100%; height: 150px; background: linear-gradient(120deg, #1d9bf0, #7856ff); }
.profile .p-body { padding: 0 16px 16px; }
.profile .p-row { display: flex; align-items: flex-end; gap: 12px; margin-top: -40px; }
.profile .p-avatar {
  width: 82px; height: 82px; border-radius: 50%; object-fit: cover;
  border: 4px solid var(--panel); background: var(--panel-2);
}
.profile .p-nick { font-size: 20px; font-weight: 800; }
.profile .p-name { color: var(--muted); }
.profile .p-desc { margin: 10px 0; white-space: pre-wrap; }
.profile .p-stats { display: flex; gap: 20px; color: var(--muted); font-size: 13px; }
.profile .p-stats b { color: var(--text); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; color: var(--muted); border: 1px solid var(--border); }
.badge .ic { flex: 0 0 auto; }
.vbadge { display: inline-flex; align-items: center; color: var(--accent); margin-left: 4px; vertical-align: -2px; }
.vbadge.muted { color: var(--muted); }

/* 推文卡片 */
.feed { display: flex; flex-direction: column; gap: 1px; }
.tweet {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  background: var(--panel);
  transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;
  content-visibility: auto;
  contain-intrinsic-size: auto 320px;
}
.tweet:hover { background: var(--panel-2); border-color: var(--accent); box-shadow: 0 6px 22px rgba(29, 155, 240, 0.08); }

.tweet-head { display: flex; gap: 10px; }
.tweet-head .avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: 0 0 44px; background: var(--panel-2); }
.tweet-head .avatar-fallback { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; flex: 0 0 44px; background: linear-gradient(135deg, #1d9bf0, #7856ff); }
.tweet-user { min-width: 0; flex: 1; }
.tweet-user .t-nick { font-weight: 700; }
.tweet-user .t-name, .tweet-user .t-time { color: var(--muted); font-size: 13px; }
.tweet-user .t-name::before { content: " "; }
.tweet-user .t-time::before { content: " · "; }
.tweet-badges { margin-top: 2px; display: flex; gap: 6px; flex-wrap: wrap; }

.tweet-body { margin: 8px 0 0 54px; overflow-wrap: break-word; white-space: pre-wrap; }
.tweet-body .hashtag, .tweet-body .mention { color: var(--accent); }

/* 媒体（推文内） */
.tw-media {
  margin: 10px 0 0 54px;
  display: grid;
  gap: 2px;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
}
.tw-media .tw-cell { position: relative; min-height: 0; background: #000; }
.tw-media img, .tw-media video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.tw-media .more {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(0,0,0,0.55); color: #fff; font-size: 22px; font-weight: 700;
}
.tw-media .cell-play {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #fff; pointer-events: none;
}
.tw-media .cell-play .ic { filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6)); }
.tw-media.n1 { grid-template-columns: 1fr; }
.tw-media.n1 img, .tw-media.n1 video { max-height: 520px; object-fit: contain; }
.tw-media.n2 { grid-template-columns: repeat(2, 1fr); aspect-ratio: 2 / 1; }
.tw-media.n3 { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); aspect-ratio: 1 / 1; }
.tw-media.n3 .tw-cell:first-child { grid-row: 1 / 3; }
.tw-media.n4 { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); aspect-ratio: 1 / 1; }

/* 转推/引用/回复标记 */
.tweet-kind { margin: 0 0 8px 54px; color: var(--muted); font-size: 13px; font-weight: 600; }

/* 互动 */
.tweet-actions {
  display: flex;
  gap: 28px;
  margin: 10px 0 0 54px;
  color: var(--muted);
  font-size: 13px;
}
.tweet-actions .act { display: flex; align-items: center; gap: 5px; transition: color 0.15s; }
.tweet-actions .act .ic { flex: 0 0 auto; }
.tweet-actions .act.reply:hover { color: var(--reply); }
.tweet-actions .act.rt:hover { color: var(--rt); }
.tweet-actions .act.like:hover { color: var(--like); }
.tweet-actions .act.quote:hover { color: var(--reply); }
.tweet-actions .act.view:hover { color: var(--accent); }

/* 媒体墙 */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
  padding: 16px 0;
}
.media-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel-2);
  cursor: zoom-in;
  border: 1px solid var(--border);
  content-visibility: auto;
  contain-intrinsic-size: 170px;
}
.media-tile img, .media-tile video {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform 0.25s ease;
}
.media-tile:hover img, .media-tile:hover video { transform: scale(1.05); }
.media-tile .play {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #fff; pointer-events: none;
}
.media-tile .play .ic { filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6)); }
.media-tile .tile-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 20px 8px 6px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: #fff; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 按钮 */
.btn-load {
  display: block;
  margin: 16px auto;
  padding: 9px 26px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-weight: 600;
}
.btn-load:hover { background: var(--panel-2); }

.loading { padding: 40px; text-align: center; color: var(--muted); }
.empty { padding: 60px 20px; text-align: center; color: var(--muted); font-size: 15px; }

/* ---------- 灯箱 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  flex-direction: column;
}
.lightbox .lb-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  color: #fff;
}
.lb-meta { font-size: 14px; color: #d6d9db; }
.lb-btn {
  border: 0; background: rgba(255,255,255,0.12); color: #fff;
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
}
.lb-btn:hover { background: rgba(255,255,255,0.25); }
.lb-stage {
  flex: 1;
  display: grid;
  place-items: center;
  position: relative;
  padding: 0 64px 24px;
  min-height: 0;
}
.lb-stage img { max-width: 100%; max-height: calc(100vh - 160px); border-radius: 6px; }
.lb-stage video { max-width: 100%; max-height: calc(100vh - 160px); border-radius: 6px; }
.lb-caption {
  max-width: 640px; margin-top: 14px; color: #d6d9db; text-align: center;
  overflow-wrap: break-word; white-space: pre-wrap; font-size: 14px;
}
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px; height: 48px;
  border: 0; border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: #fff;
  display: grid; place-items: center;
  z-index: 10;
}
.lb-nav:hover { background: rgba(255,255,255,0.28); }
.lb-prev { left: 14px; }
.lb-next { right: 14px; }

/* ---------- 响应式 ---------- */
@media (max-width: 780px) {
  .sidebar {
    position: fixed;
    left: 0; top: var(--topbar-h); bottom: 0;
    z-index: 40;
    background: var(--bg);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .content { max-width: 100%; }
  .tweet-body, .tw-media, .tweet-actions, .tweet-kind { margin-left: 0; }
  .tweet-head .avatar, .tweet-head .avatar-fallback { width: 38px; height: 38px; flex-basis: 38px; }
}

/* ---------- 访问鉴权 ---------- */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.auth-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  width: 320px;
  max-width: 90vw;
  text-align: center;
  box-shadow: var(--shadow);
}
.auth-title { margin: 0 0 4px; font-size: 20px; font-weight: 800; }
.auth-sub { color: var(--muted); margin: 0 0 16px; font-size: 13px; }
#auth-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  outline: 0;
}
#auth-input:focus { border-color: var(--accent); }
#auth-btn {
  margin-top: 12px;
  width: 100%;
  padding: 10px;
  border-radius: 999px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}
#auth-btn:hover { filter: brightness(1.08); }
.auth-msg { color: var(--like); min-height: 18px; margin: 8px 0 0; font-size: 13px; }
