/* =============================================
 * Chirp Theme - Twitter/X 风格主题样式
 * ============================================= */

/* ---- CSS 变量 ---- */
:root {
  --primary: #1DA1F2;
  --primary-hover: #1a8cd8;
  --danger: #f4212e;
  --success: #00ba7c;
  --bg-primary: #ffffff;
  --bg-secondary: #f7f9fa;
  --bg-hover: #f0f0f0;
  --text-primary: #0f1419;
  --text-secondary: #536471;
  --text-link: #1DA1F2;
  --border-color: #eff3f4;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --card-radius: 16px;
  --sidebar-width: 275px;
  /* 右侧栏已移除 */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", monospace;
}

/* ---- 暗色模式 ---- */
body.dark-mode {
  --primary: #1d9bf0;
  --primary-hover: #1a8cd8;
  --bg-primary: #000000;
  --bg-secondary: #16181c;
  --bg-hover: #1d1f23;
  --text-primary: #e7e9ea;
  --text-secondary: #71767b;
  --text-link: #1d9bf0;
  --border-color: #2f3336;
  --shadow-sm: 0 1px 2px rgba(255,255,255,0.03);
}

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

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-y: scroll;
}

a {
  color: var(--text-link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
  border-radius: 16px;
}

/* ---- App Layout ---- */
.app-wrapper {
  display: flex;
  justify-content: center;
  max-width: 1265px;
  margin: 0 auto;
  min-height: 100vh;
}

/* ---- Left Sidebar ---- */
.sidebar-left {
  width: var(--sidebar-width);
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
}

.sidebar-left-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0 12px;
  overflow-y: auto;
}

/* Logo */
.logo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  color: var(--text-primary);
  margin: 2px 0;
  transition: background-color 0.2s;
}

.logo-link:hover {
  background-color: var(--bg-hover);
  text-decoration: none;
}

/* Navigation */
.main-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 12px;
  border-radius: 9999px;
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 400;
  transition: background-color 0.2s;
  white-space: nowrap;
}

.nav-item:hover {
  background-color: var(--bg-hover);
  text-decoration: none;
}

.nav-item.active {
  font-weight: 700;
}

.nav-icon {
  font-size: 1.35rem;
  width: 26px;
  text-align: center;
  flex-shrink: 0;
}

.nav-label {
  font-size: 1.1rem;
}

/* Tweet button */
.tweet-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 16px;
  border-radius: 9999px;
  margin: 4px 0;
  transition: background-color 0.2s;
}

.tweet-btn:hover {
  background-color: var(--primary-hover);
  color: #fff;
  text-decoration: none;
}

/* User panel (bottom) */
.user-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  margin-top: auto;
  margin-bottom: 8px;
  border-radius: 9999px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.user-panel:hover {
  background-color: var(--bg-hover);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-handle {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.theme-toggle {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.theme-toggle:hover {
  background-color: var(--bg-hover);
}

/* ---- Main Content ---- */
.main-content {
  flex: 1;
  max-width: 820px;
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  min-height: 100vh;
}

.main-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: var(--bg-primary);
  backdrop-filter: blur(12px);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.main-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.main-timeline {
  /* Timeline container */
}

/* ---- Tweet Cards (Timeline) — 两列网格 ---- */
.timeline-feed {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.tweet-card {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  transition: background-color 0.15s;
}

.tweet-card:hover {
  background-color: rgba(0,0,0,0.01);
}

body.dark-mode .tweet-card:hover {
  background-color: rgba(255,255,255,0.01);
}

/* 两列网格中偶数卡片去掉右边框避免重复 */
.timeline-feed .tweet-card:nth-child(even) {
  border-right: none;
}

/* 最后两行的底部边框管理 */
.timeline-feed .tweet-card:nth-last-child(2):nth-child(odd),
.timeline-feed .tweet-card:last-child {
  border-bottom: 1px solid var(--border-color);
}

.tweet-avatar {
  flex-shrink: 0;
}

.avatar-placeholder {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.3rem;
}

.avatar-placeholder.small {
  width: 40px;
  height: 40px;
  font-size: 1rem;
}

.tweet-body {
  flex: 1;
  min-width: 0;
}

.tweet-header {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.9rem;
  margin-bottom: 2px;
  flex-wrap: wrap;
}

.tweet-author {
  font-weight: 700;
  color: var(--text-primary);
}

.tweet-handle {
  color: var(--text-secondary);
}

.tweet-dot {
  color: var(--text-secondary);
}

.tweet-time {
  color: var(--text-secondary);
}

.tweet-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 4px 0;
  line-height: 1.3;
}

.tweet-title a {
  color: var(--text-primary);
}

.tweet-title a:hover {
  color: var(--primary);
  text-decoration: none;
}

.tweet-text {
  color: var(--text-primary);
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 4px 0;
  word-wrap: break-word;
}

.tweet-media {
  margin: 8px 0;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
}

.tweet-media img {
  display: block;
  width: 100%;
  object-fit: cover;
  max-height: 300px;
}

.tweet-actions {
  display: flex;
  justify-content: space-between;
  max-width: 425px;
  margin-top: 8px;
}

.tweet-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  padding: 4px 8px;
  border-radius: 9999px;
  transition: color 0.15s, background-color 0.15s;
}

.tweet-action i {
  font-size: 1.1rem;
}

.tweet-action:hover {
  color: var(--primary);
  background-color: rgba(29, 161, 242, 0.1);
  text-decoration: none;
}

.tweet-action-like:hover {
  color: var(--danger);
  background-color: rgba(244, 33, 46, 0.1);
}

.tweet-action-share:hover {
  color: var(--success);
  background-color: rgba(0, 186, 124, 0.1);
}

/* ---- Empty State ---- */
.empty-timeline {
  padding: 60px 32px;
  text-align: center;
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
  color: var(--text-secondary);
}

.empty-text {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-hint {
  font-size: 0.9rem;
}

/* ---- Pagination ---- */
.pagination {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.page-btn {
  padding: 8px 16px;
  border-radius: 9999px;
  color: var(--primary);
  font-size: 0.9rem;
  transition: background-color 0.2s;
  white-space: nowrap;
}

.page-btn:hover {
  background-color: rgba(29, 161, 242, 0.1);
  text-decoration: none;
}

.page-numbers {
  display: flex;
  gap: 4px;
  align-items: center;
}

.page-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: background-color 0.2s;
  flex-shrink: 0;
}

.page-num:hover {
  background-color: var(--bg-hover);
  text-decoration: none;
}

.page-num.active {
  background-color: var(--primary);
  color: #fff;
  font-weight: 700;
}

.page-ellipsis {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  user-select: none;
}

/* ---- Post Detail ---- */
.tweet-detail {
  /* Detail page wrapper */
}

.detail-header {
  padding: 16px 16px 0;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.detail-author-info {
  display: flex;
  flex-direction: column;
}

.detail-author {
  font-weight: 700;
  font-size: 1rem;
}

.detail-handle {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.detail-time {
  color: var(--text-secondary);
  font-size: 0.85rem;
  padding: 4px 0 12px;
  border-bottom: 1px solid var(--border-color);
}

.detail-body {
  padding: 16px;
}

.detail-title {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 16px;
}

.detail-cover {
  margin-bottom: 16px;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
}

.detail-cover img {
  display: block;
  width: 100%;
}

.detail-content {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
}

.detail-content p {
  margin-bottom: 1em;
}

.detail-content img {
  border-radius: 12px;
  margin: 12px 0;
}

.detail-content blockquote {
  border-left: 4px solid var(--primary);
  padding-left: 16px;
  margin: 16px 0;
  color: var(--text-secondary);
}

.detail-content pre, .detail-content code {
  font-family: var(--font-mono);
  background-color: var(--bg-secondary);
  border-radius: 4px;
}

.detail-content pre {
  padding: 16px;
  overflow-x: auto;
  margin: 16px 0;
  border: 1px solid var(--border-color);
}

.detail-content code {
  padding: 2px 4px;
  font-size: 0.9em;
}

.detail-content a {
  color: var(--primary);
}

.detail-category {
  margin: 16px 0;
  padding: 12px 0;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.detail-category a {
  color: var(--primary);
  font-size: 0.9rem;
}

.detail-stats {
  display: flex;
  gap: 24px;
  padding: 12px 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-color);
}

.detail-stats i {
  margin-right: 4px;
}

.detail-actions {
  display: flex;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: 9999px;
  transition: color 0.15s, background-color 0.15s;
  font-size: 0.9rem;
}

.action-btn:hover {
  color: var(--primary);
  background-color: rgba(29, 161, 242, 0.1);
  text-decoration: none;
}

/* ---- Comments ---- */
.comments-section {
  padding: 16px;
}

.comments-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.comments-count {
  color: var(--text-secondary);
  font-weight: 400;
}

.comment-msg {
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.comment-msg.success {
  background-color: rgba(0, 186, 124, 0.1);
  color: var(--success);
  border: 1px solid var(--success);
}

.comment-msg.error {
  background-color: rgba(244, 33, 46, 0.1);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.comment-form-wrapper {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.comment-form {
  flex: 1;
}

.comment-form-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.comment-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.comment-input:focus {
  border-color: var(--primary);
}

.comment-textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.95rem;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
  font-family: var(--font-sans);
  margin-bottom: 8px;
}

.comment-textarea:focus {
  border-color: var(--primary);
}

.comment-submit {
  display: inline-flex;
  align-items: center;
  padding: 8px 20px;
  background-color: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.comment-submit:hover {
  background-color: var(--primary-hover);
}

.comments-list {
  /* Comments list */
}

.comment-card {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.comment-body {
  flex: 1;
  min-width: 0;
}

.comment-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.comment-author {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.comment-date {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.comment-text {
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.5;
}

.comments-empty {
  text-align: center;
  padding: 32px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ---- 右侧栏已移除（用户要求） ---- */

/* ---- Category/Tag Header ---- */
.category-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.category-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: var(--primary);
}

.category-info {
  flex: 1;
}

.category-name {
  font-size: 1.2rem;
  font-weight: 800;
}

.category-count {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ---- Archive Page ---- */
.archive-page {
  padding: 8px 16px;
}

.archive-stats {
  padding: 12px 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-color);
}

.archive-stats strong {
  color: var(--text-primary);
}

.archive-year {
  font-size: 1.2rem;
  font-weight: 700;
  padding: 16px 0 8px;
  color: var(--primary);
}

.archive-month {
  font-size: 0.95rem;
  font-weight: 600;
  padding: 8px 0 4px;
  color: var(--text-secondary);
}

.archive-item {
  display: flex;
  gap: 12px;
  padding: 6px 0 6px 16px;
  border-left: 2px solid var(--border-color);
  margin-left: 4px;
}

.archive-date {
  color: var(--text-secondary);
  font-size: 0.85rem;
  flex-shrink: 0;
  min-width: 24px;
}

.archive-link {
  color: var(--text-primary);
  font-size: 0.95rem;
}

.archive-link:hover {
  color: var(--primary);
}

/* ---- Mobile Bottom Nav ---- */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  z-index: 100;
  padding: 4px 0;
  justify-content: space-around;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-secondary);
  font-size: 0.7rem;
  padding: 6px 12px;
  border-radius: 8px;
  transition: color 0.15s;
}

.mobile-nav-item i {
  font-size: 1.3rem;
}

.mobile-nav-item:hover {
  color: var(--primary);
  text-decoration: none;
}

.mobile-nav-item.mobile-logo {
  color: var(--primary);
}

/* ---- Responsive ---- */
@media (max-width: 1280px) {
  .main-content {
    max-width: 720px;
  }
}

@media (max-width: 900px) {
  .timeline-feed {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .sidebar-left {
    width: 72px;
  }
  .sidebar-left-inner {
    padding: 0 4px;
  }
  .nav-label, .user-info, .tweet-btn span {
    display: none;
  }
  .nav-item {
    justify-content: center;
    padding: 12px;
    gap: 0;
  }
  .nav-icon {
    margin: 0;
  }
  .tweet-btn {
    width: 52px;
    height: 52px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
    font-size: 1.3rem;
  }
  .tweet-btn::before {
    content: '+';
  }
  .user-panel {
    justify-content: center;
    padding: 8px;
  }
  .main-content {
    max-width: 100%;
  }
  .mobile-bottom-nav {
    display: flex;
  }
  .main-content {
    padding-bottom: 60px;
  }
}

@media (max-width: 500px) {
  .sidebar-left {
    display: none;
  }
  .main-content {
    border: none;
  }
  .tweet-card {
    padding: 10px 12px;
  }
  .tweet-actions {
    max-width: 100%;
  }
  .detail-title {
    font-size: 1.2rem;
  }
  .detail-content {
    font-size: 0.95rem;
  }
}
