/* =============================================================
   botchitter-blog — スタイル (style.css)
   並び（タイムライン・カード）は botchitter（style.css / timeline.css / detail.css）にそろえ、
   色とフォントは気づきのこみち（komichi の app/globals.css）にそろえている。
   ページは /notes の下にあり、ヘッダーは「気づきのこみち / つぶやき」。
   テーマの切り替えボタンは無く、OS の設定に従う（komichi と同じ）。
============================================================= */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* komichi: --background / --foreground / --block-bg / --text-link と、枠線の gray-200 */
:root {
  --bg: #FFFFFF;
  --card: #FFFFFF;
  --quote-bg: #EEEEEE;
  --quote-hover: #E6E6E6;
  --reply-bg: #F4F4F4;
  --text-primary: #505252;
  --text-secondary: #6F7171;
  --text-tertiary: #8B8D8D;
  --line: #E5E7EB;
  --header-bg: rgba(255, 255, 255, 0.92);
  --tag: #447AE6;
  --hover-overlay: rgba(0, 0, 0, 0.04);
  --font-sans: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #434545;
    --card: #4A4C4C;
    --quote-bg: #3A3A3A;
    --quote-hover: #353535;
    --reply-bg: #3C3E3E;
    --text-primary: #EDEDED;
    --text-secondary: #CFD1D1;
    --text-tertiary: #A9ABAB;
    --line: #626464;
    --header-bg: rgba(67, 69, 69, 0.92);
    --tag: #6EE1FF;
    --hover-overlay: rgba(255, 255, 255, 0.06);
  }
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

.viewport {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 calc(16px + env(safe-area-inset-right, 0px)) calc(40px + env(safe-area-inset-bottom, 0px)) calc(16px + env(safe-area-inset-left, 0px));
}

header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 56px;
  margin: 0 -16px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
}
/* アイコンは黒い線画なので、komichi と同じく白い丸の上に置く（暗い背景に溶けないように） */
.logo-mark {
  width: 26px;
  height: 26px;
  padding: 2px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #FFFFFF;
  object-fit: contain;
}
.logo-sep {
  margin: 0 8px;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* 自己紹介（トップの1ページ目。komichi の AuthorProfile と同じく、左に画像・右に名前と紹介） */
.profile {
  margin: 24px 0 8px;
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.profile-avatar-link {
  flex-shrink: 0;
}
.profile-avatar {
  display: block;
  width: 80px;
  height: 80px;
  padding: 6px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #FFFFFF;
  object-fit: contain;
}
.profile-body {
  flex: 1;
  min-width: 0;
}
.profile-name {
  font-size: 18px;
  font-weight: 700;
}
.profile-handle {
  margin-left: 8px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-tertiary);
}
.profile-bio {
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
}
.profile-links {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.profile-links a {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  transition: background-color 0.15s;
}
.profile-links a:hover {
  background: var(--hover-overlay);
}

.list-title {
  padding: 24px 0 8px;
  font-size: 18px;
  font-weight: 600;
  color: var(--tag);
}

/* タイムライン・カード */
.timeline {
  display: flex;
  flex-direction: column;
}

.tweet-item {
  padding: 16px 0 12px;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 64px;
}

.tweet-header {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.tweet-author {
  font-weight: 600;
  color: var(--text-primary);
}
.tweet-dot {
  margin: 0 5px;
}

.tweet-date-link:hover,
.reply-meta a:hover {
  color: var(--text-primary);
}

.tweet-content {
  font-size: 15px;
  line-height: 1.75;
  margin-bottom: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

.tweet-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}

.action-btn {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 6px;
  border-radius: 999px;
  min-width: 28px;
  height: 28px;
  transition: color 0.15s, background-color 0.15s;
}
.action-btn:hover {
  color: var(--text-primary);
  background: var(--hover-overlay);
}
.action-btn svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 1.75;
  fill: none;
}
.action-count {
  font-weight: 500;
}
.action-count:empty {
  display: none;
}

.edited-mark {
  display: inline-flex;
  margin-left: 6px;
  vertical-align: -1px;
}
.edited-mark svg {
  width: 10px;
  height: 10px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

/* 画像（1枚は元の比率のまま大きく。2〜4枚は並べて切りそろえる） */
.post-images {
  display: grid;
  gap: 4px;
  margin: 4px 0 10px;
  border-radius: 8px;
  overflow: hidden;
}
.post-images:not(.count-1) {
  grid-template-columns: 1fr 1fr;
}
.post-images.count-3 .post-image:first-child {
  grid-row: span 2;
}
.post-image {
  display: block;
  background: var(--quote-bg);
}
.post-image img {
  display: block;
  width: 100%;
  height: auto;
}
.post-images.count-1 img {
  max-height: 560px;
  object-fit: contain;
}
.post-images:not(.count-1) img {
  height: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}
.post-images.count-3 .post-image:first-child img {
  aspect-ratio: auto;
}

/* 本文中のタグ・リンクとリンクカード */
.tag,
.link {
  color: var(--tag);
}
.tag:hover,
.link:hover {
  text-decoration: underline;
}

.link-card {
  display: block;
  margin: 4px 0 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: background-color 0.15s;
}
.link-card:hover {
  background: var(--hover-overlay);
}
.reply-item .link-card {
  margin: 2px 0;
}
.link-card-title {
  font-size: 13px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.link-card-site {
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-tertiary);
}

/* 引用カード */
.quoted-card {
  display: block;
  background: var(--quote-bg);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 6px 0 10px;
  border-left: 2px solid var(--text-secondary);
  transition: background 0.15s;
}
a.quoted-card:hover {
  background: var(--quote-hover);
}
.quoted-card.is-private {
  color: var(--text-tertiary);
  font-size: 12px;
  border-left-color: var(--line);
}
.quoted-card-header {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.quoted-card-date {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.quoted-card svg {
  width: 11px;
  height: 11px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}
.quoted-card-comments-badge {
  font-size: 10px;
  background: var(--hover-overlay);
  padding: 2px 7px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}
.quoted-card-body {
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* コメント（スレッド） */
.replies-thread {
  margin-top: 10px;
  padding-left: 14px;
  border-left: 1.5px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.reply-item {
  background: var(--reply-bg);
  border-radius: 6px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-margin-top: 72px;
}
.reply-item:target {
  outline: 2px solid var(--tag);
}
.reply-meta {
  font-size: 10px;
  color: var(--text-tertiary);
}
.reply-text {
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 日付の区切り */
.timeline-day-divider {
  display: flex;
  justify-content: center;
  position: relative;
  margin: 28px 0 16px;
}
.timeline-day-divider:first-child {
  margin-top: 16px;
}
.timeline-day-divider::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: var(--line);
}
.timeline-day-divider span {
  position: relative;
  background: var(--bg);
  padding: 2px 12px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-tertiary);
  border-radius: 999px;
  border: 1px solid var(--line);
}
.tweet-item:has(+ .timeline-day-divider) {
  border-bottom: none;
}

.timeline-empty {
  padding: 60px 0;
  text-align: center;
  font-size: 14px;
  line-height: 2;
  color: var(--text-secondary);
}
.timeline-empty a {
  color: var(--tag);
}

/* ポストのページ */
.detail-focus-card {
  padding: 20px 0 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.detail-author {
  font-size: 14px;
  margin-bottom: 10px;
}
.detail-text {
  font-size: 18px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 12px;
}
.detail-focus-card .quoted-card {
  margin-bottom: 14px;
}
.detail-meta {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.detail-section-title {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  margin: 24px 0 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
  scroll-margin-top: 72px;
}
.detail-section-title svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}
.detail-section-title + .replies-thread {
  margin-top: 0;
}

.detail-quote-children {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.quote-child-card {
  display: block;
  background: var(--quote-bg);
  border-radius: 8px;
  padding: 12px 14px;
  border-left: 2px solid var(--text-primary);
  transition: background 0.15s;
}
.quote-child-card:hover {
  background: var(--quote-hover);
}
.quote-child-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.quote-child-text {
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 前後・ページ送り */
.detail-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 36px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.btn-detail-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-tertiary);
  font-size: 12px;
  letter-spacing: 0.02em;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.btn-detail-nav:hover {
  color: var(--text-primary);
  background: var(--hover-overlay);
}
.btn-detail-nav svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.tag-count {
  margin-left: 8px;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.site-footer {
  margin-top: 40px;
  display: flex;
  justify-content: center;
  gap: 16px;
  font-size: 11px;
  color: var(--text-tertiary);
}
.site-footer a:hover {
  color: var(--text-primary);
}

/* 共有で URL をコピーしたときの知らせ（static/share.js） */
.share-toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  padding: 8px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--text-primary);
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 100;
}
