:root {
  --bg: #e6ecf0;
  --card: #ffffff;
  --line: #e6ecf0;
  --ink: #14171a;
  --ink-2: #657786;
  --ink-3: #8899a6;
  --accent: #19cf86;      /* 当時のプロフィールのテーマカラー */
  --accent-ink: #0b7a4e;  /* 白背景で読める濃さのリンク色 */
  --accent-soft: #e8faf2;
  --h0: #ebedf0; --h1: #b4ecd2; --h2: #5fd8a6; --h3: #19b877; --h4: #0b7a4e;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10171e;
    --card: #15202b;
    --line: #253341;
    --ink: #e7ecf0;
    --ink-2: #8899a6;
    --ink-3: #6e7f8d;
    --accent-ink: #4be3a6;
    --accent-soft: #17352b;
    --h0: #1f2c38; --h1: #0f4a33; --h2: #127a52; --h3: #19b877; --h4: #6ff0be;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
.card {
  background: var(--card);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.card h2 { font-size: 16px; margin: 0 0 10px; }
.btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 18px;
  font-weight: bold;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---- 年齢確認 ---- */
.age-gate {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(16, 23, 30, .92);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.age-box {
  background: var(--card); border-radius: 14px; padding: 28px 24px;
  max-width: 420px; text-align: center;
}
.age-box h1 { margin: 0 0 12px; font-size: 20px; }
.age-q { font-weight: bold; font-size: 16px; }
.age-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.age-denied { color: #d0364c; margin-top: 16px; }
body.locked { overflow: hidden; }

/* ---- 上部バー ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1190px; margin: 0 auto; padding: 8px 14px;
  display: flex; align-items: center; gap: 12px;
}
.brand { color: var(--ink); font-weight: bold; font-size: 16px; white-space: nowrap; }
.brand span { color: var(--ink-2); font-weight: normal; }
.brand:hover { text-decoration: none; }
.unofficial {
  font-size: 11px; color: var(--accent-ink); border: 1px solid var(--accent);
  border-radius: 4px; padding: 1px 6px; white-space: nowrap;
}
.search {
  margin-left: auto; width: 240px; max-width: 45vw;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg); color: var(--ink); padding: 7px 14px;
}
.search:focus { outline: 2px solid var(--accent); background: var(--card); }

/* ---- ヘッダー画像・プロフィール ---- */
.banner {
  height: 280px; background: linear-gradient(120deg, #19cf86, #0b7a4e);
  overflow: hidden;
}
.banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.banner img[src=""], .banner img:not([src]) { display: none; }
.profile-bar { background: var(--card); box-shadow: var(--shadow); margin-bottom: 12px; }
.profile-bar-inner {
  max-width: 1190px; margin: 0 auto; padding: 0 14px;
  display: flex; align-items: flex-end; min-height: 60px;
}
.avatar-lg {
  width: 200px; height: 200px; border-radius: 50%;
  border: 5px solid var(--card); background: var(--card);
  margin-top: -150px; margin-bottom: -60px; position: relative; z-index: 2;
  object-fit: cover;
}
.tabs { display: flex; margin-left: 40px; overflow-x: auto; }
.tabs button {
  background: none; border: 0; border-bottom: 3px solid transparent;
  padding: 10px 16px 7px; color: var(--ink-2); text-align: center; white-space: nowrap;
}
.tabs button span { display: block; font-size: 12px; font-weight: bold; }
.tabs button b { display: block; font-size: 18px; color: var(--ink-2); }
.tabs button:hover, .tabs button.active { border-bottom-color: var(--accent); }
.tabs button.active b, .tabs button:hover b { color: var(--accent-ink); }

/* ---- 3カラム ---- */
.layout {
  max-width: 1190px; margin: 0 auto; padding: 0 14px;
  display: grid; grid-template-columns: 260px minmax(0, 1fr) 290px; gap: 12px;
  align-items: start;
}
.col-left { padding-top: 64px; }
.col-left, .col-right { position: sticky; top: 64px; max-height: calc(100vh - 70px); overflow-y: auto; }
.profile-card h1 { font-size: 21px; margin: 0; }
.handle { color: var(--ink-2); margin: 0 0 10px; }
.p-note { font-size: 13px; }
.p-meta { list-style: none; padding: 0; margin: 0; color: var(--ink-2); font-size: 13px; }

/* ---- フィルター ---- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; }
.filters select {
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px;
  background: var(--card); color: var(--ink);
}
.chip {
  background: var(--accent-soft); color: var(--accent-ink);
  border-radius: 999px; padding: 3px 10px; font-size: 13px; cursor: pointer;
}
.chip::after { content: " ×"; }
.f-count { margin-left: auto; color: var(--ink-2); font-size: 13px; }

/* ---- ツイート ---- */
.tweets { background: var(--card); border-radius: 8px; box-shadow: var(--shadow); overflow: hidden; }
.tweet { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.tweet:hover { background: color-mix(in srgb, var(--bg) 40%, var(--card)); }
.tweet .av { width: 48px; height: 48px; border-radius: 50%; flex: none; object-fit: cover; background: var(--line); }
.tweet .body { min-width: 0; flex: 1; }
.t-head { display: flex; gap: 4px; align-items: baseline; min-width: 0; }
.t-name { font-weight: bold; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-handle, .t-date { color: var(--ink-2); white-space: nowrap; font-size: 13px; }
.t-date::before { content: "· "; }
.t-reply { color: var(--ink-2); font-size: 13px; }
.t-text { white-space: pre-wrap; word-break: break-word; margin: 2px 0 0; font-size: 15px; }
.t-text .mention, .t-text .tag { color: var(--accent-ink); }
.t-text .tag { cursor: pointer; }
.t-text mark { background: #fff3a8; color: inherit; border-radius: 2px; }
.t-foot { margin-top: 6px; font-size: 12px; color: var(--ink-3); display: flex; gap: 14px; }
.t-foot a { color: var(--ink-3); }

.media { display: grid; gap: 2px; margin-top: 8px; border-radius: 12px; overflow: hidden; max-width: 506px; }
.media.n1 { grid-template-columns: 1fr; }
.media.n2, .media.n4 { grid-template-columns: 1fr 1fr; }
.media.n3 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.media.n3 .m:first-child { grid-row: span 2; }
.media .m { position: relative; background: var(--line); cursor: zoom-in; aspect-ratio: 16 / 9; }
.media.n1 .m { aspect-ratio: auto; max-height: 500px; }
.media.n3 .m { aspect-ratio: auto; height: 100%; min-height: 140px; }
.media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media.n1 img { max-height: 500px; object-fit: contain; background: #000; }
.media .m.broken { cursor: default; display: flex; align-items: center; justify-content: center; aspect-ratio: 16 / 9; color: var(--ink-3); font-size: 12px; }
.media .badge {
  position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.7); color: #fff;
  font-size: 11px; padding: 1px 6px; border-radius: 4px;
}

.more { text-align: center; padding: 14px 0 4px; }
.more .btn { min-width: 200px; }
.more-status { color: var(--ink-2); font-size: 13px; }

.empty { text-align: center; color: var(--ink-2); padding: 40px 16px; }

/* ---- メディア一覧 ---- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px; }
.gallery .g {
  aspect-ratio: 1; background: var(--line); cursor: zoom-in; overflow: hidden; border-radius: 4px;
}
.gallery .g.broken { display: none; }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.gallery .g:hover img { transform: scale(1.04); }

/* ---- カレンダー ---- */
.year-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.year-tabs button {
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  border-radius: 999px; padding: 1px 9px; font-size: 12px;
}
.year-tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.heatmap svg { display: block; width: 100%; height: auto; }
.heatmap rect { cursor: pointer; }
.heatmap rect:hover { stroke: var(--ink); stroke-width: 1; }
.heatmap text { fill: var(--ink-3); font-size: 8px; }
.h0 { fill: var(--h0); background: var(--h0); } .h1 { fill: var(--h1); background: var(--h1); }
.h2 { fill: var(--h2); background: var(--h2); } .h3 { fill: var(--h3); background: var(--h3); }
.h4 { fill: var(--h4); background: var(--h4); }
.heat-legend { display: flex; align-items: center; gap: 3px; justify-content: flex-end; font-size: 11px; color: var(--ink-3); margin-top: 6px; }
.heat-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* ---- ランキング ---- */
.ranked { list-style: none; margin: 0; padding: 0; }
.ranked li {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 5px 0;
  border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px;
}
.ranked li:last-child { border-bottom: 0; }
.ranked .lbl { color: var(--accent-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranked .val { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ranked .bar { grid-column: 1 / -1; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.ranked .bar i { display: block; height: 100%; background: var(--h3); border-radius: 2px; }

/* ---- 統計 ---- */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 10px; }
.stat-tiles .card { margin: 0; }
.stat-tiles .k { color: var(--ink-2); font-size: 12px; }
.stat-tiles .v { font-size: 26px; font-weight: bold; font-variant-numeric: tabular-nums; }
.stat-tiles .s { color: var(--ink-3); font-size: 12px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--line); }
.chart .axis text { fill: var(--ink-3); font-size: 10px; }
.chart .bar { fill: var(--h3); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart g:hover > .bar { fill: var(--h4); }
.emoji-list { display: flex; flex-wrap: wrap; gap: 8px; }
.emoji-list span { background: var(--bg); border-radius: 8px; padding: 4px 10px; font-size: 13px; color: var(--ink-2); }
.emoji-list b { font-size: 20px; font-weight: normal; margin-right: 4px; color: var(--ink); }
details.table-view { margin-top: 8px; font-size: 12px; color: var(--ink-2); }
details.table-view table { border-collapse: collapse; margin-top: 6px; }
details.table-view td, details.table-view th { padding: 2px 10px 2px 0; text-align: right; }

/* ---- 名前の変遷 ---- */
.names-list { list-style: none; margin: 0; padding: 0; }
.names-list li { display: flex; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.names-list li:last-child { border-bottom: 0; }
.names-list time { color: var(--ink-2); white-space: nowrap; font-size: 13px; min-width: 96px; font-variant-numeric: tabular-nums; }
.names-list .nm { font-weight: bold; word-break: break-word; }

/* ---- この日のツイート ---- */
.link-btn { background: none; border: 0; color: var(--accent-ink); padding: 0; font-size: 13px; }

/* ---- ライトボックス・ツールチップ ---- */
.lightbox {
  position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.9);
  display: flex; align-items: center; justify-content: center;
}
/* 拡大表示: 左に画像、右にそのツイートの本文（スマホでは画像の下） */
.lightbox { align-items: stretch; justify-content: stretch; }
.lb-stage { position: relative; flex: 1; min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 48px 60px; }
.lb-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-stage button { position: absolute; background: none; border: 0; color: #fff; font-size: 44px; line-height: 1; padding: 10px 16px; opacity: .8; }
.lb-stage button:hover { opacity: 1; }
.lb-close { top: 4px; left: 4px; }
.lb-toggle { top: 4px; right: 4px; font-size: 28px !important; }
.lb-prev { left: 4px; } .lb-next { right: 4px; }
.lb-count { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; color: #fff; opacity: .7; font-size: 13px; }
.lb-side { width: 360px; flex: none; overflow-y: auto; overflow-x: hidden; background: var(--card); color: var(--ink); padding: 16px; border-left: 1px solid var(--line); }
.lb-side .lb-user { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.lb-side .av { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--line); }
.lb-side .lb-user > div { min-width: 0; }
.lb-side .t-name { display: block; }
.lb-side .t-handle { display: block; }
.lb-side .t-text { font-size: 16px; line-height: 1.6; }
.lb-side .lb-time { margin: 12px 0 0; padding-bottom: 12px; border-bottom: 1px solid var(--line); color: var(--ink-2); font-size: 13px; }
.lb-side .lb-acts { margin-top: 10px; }
.lightbox.lb-noside .lb-side { display: none; }
.lightbox.lb-noside .lb-toggle { transform: scaleX(-1); }
.tooltip {
  position: fixed; z-index: 95; pointer-events: none;
  background: var(--ink); color: var(--card); font-size: 12px;
  padding: 4px 8px; border-radius: 4px; white-space: nowrap;
}

.footer { max-width: 760px; margin: 30px auto; padding: 0 16px; color: var(--ink-2); font-size: 12px; text-align: center; }

/* ---- レスポンシブ ---- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 240px minmax(0, 1fr); }
  .col-right { display: none; }
}
@media (max-width: 760px) {
  .lightbox { flex-direction: column; }
  .lb-stage { padding: 44px 8px 28px; }
  .lb-stage .lb-prev, .lb-stage .lb-next { font-size: 36px; padding: 10px 6px; }
  .lb-side { width: auto; max-height: 38vh; border-left: 0; border-top: 1px solid var(--line); }
  .lb-toggle { transform: rotate(90deg); }
  .lightbox.lb-noside .lb-toggle { transform: rotate(-90deg); }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 0 8px; }
  .col-left { position: static; max-height: none; padding-top: 0; overflow: visible; min-width: 0; }
  .banner { height: 140px; }
  .profile-bar-inner { flex-direction: column; align-items: flex-start; }
  .avatar-lg { width: 96px; height: 96px; margin: -50px 0 0; }
  .tabs { margin-left: 0; width: 100%; }
  .tabs button { padding: 6px 10px; }
  .unofficial { display: none; }
  .search { width: auto; flex: 1; }
}
