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

:root {
  --bg: #0f0f13;
  --surface: #1a1a24;
  --surface2: #22222f;
  --border: #2e2e3e;
  --accent: #8b5cf6;
  --accent-dim: #6d28d9;
  --text: #e2e2f0;
  --text-muted: #7878a0;
  --text-dim: #4a4a6a;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --font-size-base: 14px;
}

:root.light header {
  background: rgba(245, 245, 247, 0.92);
}

:root.light {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface2: #ebebef;
  --border: #d1d1db;
  --accent: #7c3aed;
  --accent-dim: #6d28d9;
  --text: #111118;
  --text-muted: #52526e;
  --text-dim: #a0a0b8;
  --green: #16a34a;
  --red: #dc2626;
  --yellow: #d97706;
}

/* Settings button in header */
.settings-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 15px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}
.settings-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Settings modal */
.settings-modal-content {
  max-width: 480px;
  width: 100%;
}
.settings-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 20px;
  color: var(--text);
}
.settings-section {
  margin-bottom: 28px;
}
.settings-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
}
.settings-label {
  font-size: 14px;
  color: var(--text);
}

.settings-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
}
.settings-select:focus { border-color: var(--accent); }

.idle-status {
  font-size: 12px;
  color: var(--accent);
  margin-top: 6px;
  min-height: 16px;
}

/* Font size control */
.font-size-control {
  display: flex;
  align-items: center;
  gap: 4px;
}
.font-size-btn {
  width: 26px;
  height: 26px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}
.font-size-btn:hover { border-color: var(--accent); color: var(--accent); }
.font-size-input {
  width: 52px;
  text-align: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  font-size: 13px;
  outline: none;
  -moz-appearance: textfield;
}
.font-size-input::-webkit-inner-spin-button,
.font-size-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.font-size-input:focus { border-color: var(--accent); }
.font-size-unit {
  font-size: 12px;
  color: var(--text-muted);
}

/* Theme toggle switch */
.theme-toggle-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  padding: 0;
}
.theme-toggle-track {
  width: 36px;
  height: 20px;
  background: var(--accent);
  border-radius: 10px;
  position: relative;
  display: inline-block;
  transition: background 0.2s;
}
:root.light .theme-toggle-track { background: var(--border); }
.theme-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: var(--font-size-base);
  line-height: 1.5;
}

/* Global hidden utility (for header / main which lack element-specific rules) */
header.hidden,
main.hidden { display: none !important; }

/* Login screen */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 0%, rgba(139,92,246,0.15) 0%, transparent 70%);
}

.login-screen.hidden { display: none; }

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,0.4);
}

.login-logo {
  font-size: 48px;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 16px rgba(139,92,246,0.6));
}

.login-card h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.login-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
  line-height: 1.6;
}

.login-input-wrap {
  margin-bottom: 12px;
}

.login-input-wrap input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  outline: none;
  font-family: monospace;
  transition: border-color 0.2s;
}
.login-input-wrap input:focus { border-color: var(--accent); }
.login-input-wrap input::placeholder { color: var(--text-dim); font-family: inherit; }

.login-error {
  margin-top: 8px;
  font-size: 12px;
  color: var(--red);
  text-align: left;
}
.login-error.hidden { display: none; }

.login-card .btn-primary {
  font-size: 15px;
  padding: 11px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.login-note {
  font-size: 12px;
  color: var(--text-dim);
}

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 15, 19, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.relay-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar-sm {
  width: 28px !important;
  height: 28px !important;
  font-size: 11px !important;
}

.header-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background 0.3s;
}
.status-dot.connected { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.connecting { background: var(--yellow); animation: pulse 1.2s infinite; }
.status-dot.error { background: var(--red); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Layout */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 24px;
  align-items: start;
}

/* デスクトップではヘッダー検索・ハンバーガー非表示 */
@media (min-width: 769px) {
  .header-search { display: none; }
  .hamburger-btn { display: none !important; }
  .mobile-filter-bar { display: none !important; }
  .drawer-user-section,
  .drawer-actions,
  .drawer-section-label { display: none; }
}

/* ---- Header search ---- */
.header-search {
  flex: 1;
  max-width: 320px;
  margin: 0 16px;
  position: relative;
  display: flex;
  align-items: center;
}
.header-search input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
.header-search input {
  padding-right: 28px;
}
.header-search input:focus { border-color: var(--accent); }
.header-search input::placeholder { color: var(--text-dim); }

/* ---- Hamburger ---- */
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  width: 32px;
  height: 32px;
}
.hamburger-btn span {
  display: block;
  height: 2px;
  background: var(--text-muted);
  border-radius: 2px;
  transition: background 0.2s;
}
.hamburger-btn:hover span { background: var(--text); }

/* ---- Drawer ---- */
.drawer { position: fixed; inset: 0; z-index: 250; }
.drawer.hidden { display: none; }
.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
}
.drawer-panel {
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 300px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  animation: slideIn 0.22s ease;
}
@keyframes slideIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.drawer-header button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
}
.drawer-header button:hover { color: var(--text); }
.drawer-user-section {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.drawer-user-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.drawer-username {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.drawer-user-about {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.drawer-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.drawer-action-btn {
  text-align: left;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.drawer-action-btn:hover { background: var(--surface2); color: var(--text); }
.drawer-logout:hover { color: var(--red); }

.drawer-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 12px 16px 4px;
}

.drawer-panel .ranking-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* ---- Mobile bottom filter bar ---- */
.mobile-filter-bar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  gap: 8px;
  align-items: center;
  backdrop-filter: blur(12px);
}
.mobile-filter-bar.hidden { display: none !important; }
.mobile-kind-filter {
  display: flex;
  gap: 6px;
  flex: 1;
}
.mobile-kind-filter .kind-btn {
  flex: 1;
  padding: 7px 0;
  font-size: 12px;
}
.mobile-refresh-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 18px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.mobile-refresh-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  main {
    grid-template-columns: 1fr;
    padding: 12px 12px 72px; /* bottom padding for filter bar */
  }
  .sidebar { display: none !important; }
  .hamburger-btn { display: flex; }
  .header-search { max-width: none; margin: 0 8px; }
  .relay-status { display: none; }
  .mobile-filter-bar { display: flex; }
  /* ヘッダーからテーマ・ユーザー情報を隠す */
  .settings-btn { display: none; }
  .user-info { display: none; }
}

/* Drag handle */
.drag-handle {
  display: inline-block;
  margin-right: 6px;
  color: var(--text-dim);
  cursor: grab;
  font-size: 14px;
  line-height: 1;
  vertical-align: middle;
  user-select: none;
}
.drag-handle:active { cursor: grabbing; }

/* Drag states */
.sidebar section.dragging {
  opacity: 0.35;
}
.sidebar section.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 72px;
}

.sidebar-panels {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.sidebar-version {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 4px 4px;
  margin-top: 12px;
  font-size: 11px;
  color: var(--text3);
  border-top: 1px solid var(--border);
  opacity: 0.6;
}

.relay-panel, .filter-panel, .search-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.relay-panel h2, .filter-panel h2, .search-panel h2 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.relay-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.relay-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
}

.relay-item .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-dim);
}
.relay-item.ok .dot { background: var(--green); }
.relay-item.connecting .dot { background: var(--yellow); animation: pulse 1.2s infinite; }
.relay-item.error .dot { background: var(--red); }

.relay-item .url {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.relay-item .btn-remove-relay {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.2s;
}
.relay-item .btn-remove-relay:hover { color: var(--red); }

.relay-add {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.relay-add input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 11px;
  font-family: monospace;
  outline: none;
  min-width: 0;
}
.relay-add input:focus { border-color: var(--accent); }
.relay-add input::placeholder { color: var(--text-dim); font-family: inherit; }

.relay-add button {
  flex-shrink: 0;
  padding: 5px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.relay-add button:hover { border-color: var(--accent); color: var(--accent); }

.relay-add-error {
  margin-top: 6px;
  font-size: 11px;
  color: var(--red);
}
.relay-add-error.hidden { display: none; }

.kind-filter {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}

.kind-btn {
  flex: 1;
  padding: 5px 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.kind-btn:hover { border-color: var(--accent); color: var(--text); }
.kind-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.filter-panel label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
}

select:focus { border-color: var(--accent); }

.btn-primary {
  width: 100%;
  padding: 8px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary:hover { background: var(--accent-dim); }
.btn-primary:active { transform: scale(0.98); }

/* Ranking panel */
.ranking-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.ranking-panel h2 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ranking-item {
  cursor: pointer;
}
.ranking-item:hover .ranking-bar-fill { filter: brightness(1.2); }

.ranking-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

.ranking-rank {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  width: 14px;
  flex-shrink: 0;
  text-align: right;
}

.ranking-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-count {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.ranking-bar-track {
  height: 4px;
  background: var(--surface2);
  border-radius: 2px;
  overflow: hidden;
}

.ranking-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.4s ease;
}

.ranking-empty {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  padding: 8px 0;
}

.search-box {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.search-box input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 6px 24px 6px 10px;
  font-size: 13px;
  outline: none;
}
.search-box input:focus { border-color: var(--accent); }
.search-box input::placeholder { color: var(--text-dim); }

#searchBtn {
  padding: 6px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  white-space: nowrap;
}
#searchBtn:hover { border-color: var(--accent); color: var(--accent); }

.search-clear-btn {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.search-clear-btn:hover { color: var(--text); }

/* Feed */
.feed {
  min-width: 0;
}

.feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.feed-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.author-filter-banner.hidden { display: none; }
.author-filter-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text);
}

.author-filter-clear {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.author-filter-clear:hover { border-color: var(--accent); color: var(--accent); }

/* New posts banner */
.new-posts-banner.hidden { display: none; }
.new-posts-banner {
  position: sticky;
  top: 72px;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 8px 20px;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.45);
  transition: transform 0.15s, box-shadow 0.15s;
  width: fit-content;
  align-self: center;
  margin-left: auto;
  margin-right: auto;
}
.new-posts-banner:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
}
.new-posts-banner:active { transform: translateY(0); }

/* Follow change toast */
.follow-change-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 13px;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 900;
}
.follow-change-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Bottom loading */
.feed-bottom-sentinel { height: 1px; }
.bottom-loading.hidden { display: none; }
.bottom-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px 0;
  color: var(--text-muted);
  font-size: 13px;
}
.spinner-sm {
  width: 18px;
  height: 18px;
  border-width: 2px;
}

.ranking-item-active {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: var(--radius-sm);
}

.post-count {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 99px;
}

/* Loading */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 0;
  color: var(--text-muted);
  gap: 16px;
}

.loading.hidden { display: none; }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Post list */
.post-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.v-placeholder {
  flex-shrink: 0;
  border-radius: var(--radius);
  background: transparent;
}

/* Post card */
.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.1s;
  animation: fadeIn 0.3s ease;
}

.post-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.post-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #ec4899);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-meta {
  flex: 1;
  min-width: 0;
}

.post-author {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-author .handle {
  color: var(--text-muted);
  font-weight: 400;
}

.post-time {
  font-size: 12px;
  color: var(--text-dim);
}

.post-body {
  font-size: var(--font-size-base);
  line-height: 1.7;
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
}

.post-body.truncated {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.post-kind {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: 99px;
}

/* Repost card (kind:6) */
.repost-card {
  border-left: 3px solid var(--green);
}

.repost-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.repost-icon {
  font-size: 13px;
}

.repost-time {
  margin-bottom: 8px !important;
}

.repost-preview {
  border: 1px solid var(--border);
  border-left: 2px solid var(--green);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.repost-preview:hover { border-color: var(--accent); }
.repost-preview .reaction-preview-loading {
  font-size: 11px;
  color: var(--text-dim);
}

/* Reaction card (kind:7) */
.reaction-card {
  border-left: 3px solid var(--accent);
  opacity: 0.85;
}
.reaction-card:hover { opacity: 1; }

.reaction-body {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  flex-wrap: wrap;
}

.reaction-emoji {
  font-size: 22px;
  line-height: 1;
}

.reaction-target {
  font-size: 13px;
  color: var(--text-muted);
}

.reaction-preview {
  margin-top: 8px;
  border-left: 2px solid var(--border);
  padding-left: 10px;
}

.reaction-preview.has-content {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
}

.reaction-preview-loading {
  font-size: 11px;
  color: var(--text-dim);
}

.reaction-preview-author {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.avatar-xs {
  width: 20px !important;
  height: 20px !important;
  font-size: 9px !important;
  flex-shrink: 0;
  cursor: pointer;
}
.avatar-xs:hover { outline: 2px solid var(--accent); outline-offset: 1px; }

.avatar-xs ~ .nip05-dot,
.avatar-wrap:has(.avatar-xs) .nip05-dot {
  width: 9px;
  height: 9px;
  font-size: 6px;
  top: -2px;
  right: -2px;
  border-width: 1px;
}

.reaction-preview-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.reaction-preview-img {
  margin-top: 6px !important;
}

/* Reply quote (返信元) */
.reply-quote-wrap {
  margin-bottom: 10px;
}

/* Profile embed (nostr:npub1 / nostr:nprofile1) */
.profile-embed-wrap {
  margin: 8px 0;
}

.profile-embed {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.profile-embed:hover {
  background: var(--surface3, var(--surface2));
  border-left-color: var(--accent);
}

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

.profile-embed-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-embed-bio {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-quote {
  background: var(--surface2);
  border-left: 3px solid var(--text-dim);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 8px 12px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.reply-quote:hover { border-left-color: var(--accent); }
.reply-quote.loading { cursor: default; }
.reply-quote.not-found {
  cursor: default;
  color: var(--text-dim);
  font-size: 12px;
  font-style: italic;
}

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

.reply-quote-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.reply-quote-text {
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.reply-quote-img-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Reply preview on card */
.post-reply-preview {
  margin-top: 8px;
}

.reply-count-bar {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.reply-preview-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: var(--surface2);
  border-left: 2px solid var(--border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 8px 10px;
}

.reply-bubble {
  flex: 1;
  min-width: 0;
}

.reply-bubble-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 6px;
}

.reply-bubble-text {
  font-size: 12px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 2px;
}

.reply-preview-media {
  margin-top: 6px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-height: 120px;
}

.reply-preview-media img {
  max-height: 120px;
  width: 100%;
  object-fit: cover;
}

.reply-preview-yt-thumb {
  display: block;
  width: 100%;
  max-height: 120px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-top: 6px;
}

/* Thread in modal */
.thread-section {
  margin-bottom: 16px;
}

.thread-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.thread-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--accent);
  margin-bottom: 6px;
}

.thread-item-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.thread-item-name {
  font-size: 12px;
  font-weight: 600;
  flex: 1;
}

.thread-item-time {
  font-size: 11px;
  color: var(--text-dim);
}

.thread-item-body {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Post reaction chips (now lives inside .post-footer) */
.post-footer .post-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  margin: 0;
}

.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px 8px;
  font-size: 13px;
  cursor: default;
  transition: border-color 0.15s;
}
.reaction-chip:hover { border-color: var(--accent); }
.reaction-chip:hover .reaction-chip-img {
  transform: scale(2);
  transition: transform 0.15s ease;
  z-index: 1;
}

.reaction-chip-img {
  width: 16px;
  height: 16px;
  object-fit: contain;
  vertical-align: middle;
  transition: transform 0.15s ease;
}

.reaction-emoji-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  vertical-align: middle;
  transition: transform 0.15s ease;
}
.custom-emoji {
  height: 2em;
  width: auto;
  object-fit: contain;
  vertical-align: middle;
}
.reaction-emoji-img:hover {
  transform: scale(2);
  z-index: 1;
}

/* Tweet embeds */
.tweet-embeds {
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tweet-embeds .twitter-tweet {
  margin: 0 !important;
  max-width: 100% !important;
}

/* YouTube embed */
.youtube-embeds {
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.youtube-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
}

.youtube-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.youtube-lazy-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 9;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
}

/* Image grid */
.post-images {
  display: grid;
  gap: 4px;
  margin: 10px 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.post-images.count-1 { grid-template-columns: 1fr; }
.post-images.count-2 { grid-template-columns: 1fr 1fr; }
.post-images.count-3 { grid-template-columns: 1fr 1fr; }
.post-images.count-3 .post-image-wrap:first-child { grid-column: span 2; }
.post-images.count-4 { grid-template-columns: 1fr 1fr; }

.post-image-wrap {
  aspect-ratio: 16/9;
  overflow: hidden;
  background: var(--surface2);
  cursor: zoom-in;
  position: relative;
}

/* GIF 静止表示中のバッジ */
.gif-badge {
  position: absolute;
  bottom: 6px;
  left: 6px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  padding: 2px 5px;
  border-radius: 3px;
  pointer-events: none;
  line-height: 1.4;
}
.gif-badge.gif-play {
  cursor: pointer;
  pointer-events: auto;
}
.gif-badge.gif-play:hover {
  background: rgba(0,0,0,.8);
}
.post-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s;
  display: block;
}
.post-image-wrap:hover img { transform: scale(1.03); }

/* Image viewer */
.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.image-viewer.hidden { display: none; }

.image-viewer img {
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}

.image-viewer-close {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.15);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.image-viewer-close:hover { background: rgba(0,0,0,0.9); }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s;
}
.modal-close:hover { border-color: var(--accent); color: var(--text); }

.modal-detail-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-top: 16px;
  margin-bottom: 4px;
}

.modal-detail-value {
  font-size: 12px;
  font-family: monospace;
  color: var(--text-muted);
  background: var(--surface2);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  word-break: break-all;
}

.empty-state {
  text-align: center;
  padding: 60px 0;
  color: var(--text-muted);
}

.empty-state p { margin-top: 8px; font-size: 13px; color: var(--text-dim); }

/* NIP-05 badge */
.nip05-badge {
  display: inline-flex;
  align-items: center;
  background: rgba(139, 92, 246, 0.15);
  color: var(--accent);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 99px;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  margin-left: 4px;
  vertical-align: middle;
  white-space: nowrap;
  cursor: default;
}

.nip05-badge-lg {
  font-size: 12px;
  padding: 2px 8px;
  margin-left: 6px;
  vertical-align: middle;
}

/* Avatar with NIP-05 dot */
.avatar-wrap {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.nip05-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--bg);
  pointer-events: none;
  z-index: 1;
}

/* Mention tags */
.mention-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 4px;
  padding: 1px 6px 1px 2px;
  cursor: pointer;
  vertical-align: middle;
  line-height: 1.4;
}
.mention-tag:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.mention-name {
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
}

/* Hashtag links */
.hashtag-link {
  color: var(--accent);
  cursor: pointer;
}
.hashtag-link:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Clickable author */
.clickable-author {
  cursor: pointer;
}
.clickable-author:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}
.avatar.clickable-author:hover {
  text-decoration: none;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Profile modal */
.profile-modal-content {
  max-width: 560px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.profile-modal-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.avatar-lg {
  width: 64px !important;
  height: 64px !important;
  font-size: 22px !important;
  flex-shrink: 0;
}

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

.profile-name {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 2px;
}

.profile-handle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.profile-about {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

.profile-pubkey {
  font-size: 11px;
  font-family: monospace;
  color: var(--text-dim);
}

.profile-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.profile-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}

.profile-link:hover {
  text-decoration: underline;
}

.profile-link-lightning {
  color: #f7a800;
}

.profile-tabs {
  display: flex;
  gap: 4px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 8px 0;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.profile-tab {
  flex: 1;
  padding: 5px 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.profile-tab:hover { border-color: var(--accent); color: var(--text); }
.profile-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.profile-modal-posts {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-posts-loading {
  display: flex;
  justify-content: center;
  padding: 32px 0;
}

.profile-empty {
  text-align: center;
  padding: 32px 0;
  color: var(--text-muted);
  font-size: 14px;
}

/* Mini card */
.mini-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.mini-card:hover { border-color: var(--accent); }

.mini-card-body {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
}

.mini-grid {
  margin: 6px 0 !important;
}

.mini-kind-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.mini-kind-label.repost { color: var(--green); }
.mini-kind-label.reaction { color: var(--accent); }

.mini-card-time {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ---- NIP-57 Zaps ---- */
.post-zaps { display: flex; align-items: center; }
.zap-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: color-mix(in srgb, var(--yellow) 15%, var(--surface2));
  border: 1px solid color-mix(in srgb, var(--yellow) 40%, transparent);
  border-radius: 99px;
  padding: 2px 8px;
  font-size: 13px;
  color: var(--yellow);
  cursor: default;
}

/* ---- NIP-36 Content Warning ---- */
.content-warning-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--surface2);
  border-radius: 8px;
  margin: 4px 0 2px;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.cw-label { flex: 1; }
.cw-toggle {
  padding: 2px 12px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 0.78rem;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.cw-toggle:hover { opacity: 0.85; }
.cw-body.cw-hidden { display: none; }
