/* ── Fonts ────────────────────────────────────────── */
@font-face {
  font-family: 'Permanent Marker';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/static/PermanentMarker.ttf') format('truetype');
}

/* ── Tokens (light — GitHub Primer Light) ─────────── */
:root {
  --bg: #f6f8fa;
  --bg-alt: #eaeef2;
  --surface: #ffffff;
  --header-bg: #d0d7de;
  --header-border: #b8c0cc;
  --header-fg: #24292f;
  --header-link: rgba(36,41,47,0.6);
  --header-link-hover-bg: rgba(36,41,47,0.1);
  --header-sep: rgba(36,41,47,0.35);
  --border: #d0d7de;
  --text: #24292f;
  --text-muted: #57606a;
  --accent: #0969da;
  --accent-hover: #0550ae;
  --danger: #d1242f;
  --danger-bg: #ffebe9;
  --focus-ring: rgba(9,105,218,0.3);
  --radius: 6px;
  --shadow: 0 1px 3px rgba(31,35,40,0.08);
  --shadow-md: 0 8px 24px rgba(140,149,159,0.2);
}

/* ── Tokens (dark — GitHub Primer Dark) ───────────── */
[data-theme="dark"] {
  --bg: #0d1117;
  --bg-alt: #010409;
  --surface: #161b22;
  --header-bg: #161b22;
  --header-border: #21262d;
  --header-fg: #c9d1d9;
  --header-link: rgba(201,209,217,0.7);
  --header-link-hover-bg: rgba(177,186,196,0.12);
  --header-sep: rgba(201,209,217,0.4);
  --border: #30363d;
  --text: #c9d1d9;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --danger: #f85149;
  --danger-bg: #490202;
  --focus-ring: rgba(31,111,235,0.4);
  --shadow: 0 1px 3px rgba(1,4,9,0.3);
  --shadow-md: 0 8px 24px rgba(1,4,9,0.4);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; }

/* ── Header ───────────────────────────────────────── */
header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  padding: 0 4px 0 20px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}

.header-title {
  font-family: 'Permanent Marker', cursive;
  font-size: 1.2rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: none;
  text-decoration: none;
  color: var(--header-fg);
}

.header-home { text-decoration: none; }
.header-home:hover { opacity: 0.75; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-label {
  font-size: 0.7rem;
  color: var(--header-link);
  opacity: 0.5;
  user-select: none;
  letter-spacing: 0.03em;
}

.nav-sep {
  color: var(--header-sep);
  font-size: 0.75rem;
  padding: 0 2px;
  user-select: none;
}

.header-search-form {
  display: flex;
  align-items: center;
}
.header-search-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.78rem;
  height: 22px;
  padding: 0 6px;
  width: 110px;
  outline: none;
  transition: width 0.15s ease;
}
.header-search-input:focus {
  border-color: var(--accent);
  width: 180px;
}

.header-nav-link {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--header-link);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 5px;
  transition: background 0.12s, color 0.12s;
  position: relative;
}
.header-nav-link:hover, .header-nav-link.active {
  background: var(--header-link-hover-bg);
  color: var(--header-fg);
}
.header-nav-link[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 3px 7px;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
  z-index: 100;
}
.header-nav-link[data-tooltip]:hover::after {
  opacity: 1;
}

.user-menu {
  position: relative;
}

.user-menu-btn {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--header-link);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 5px;
  font-family: inherit;
  transition: background 0.12s, color 0.12s;
}
.user-menu-btn:hover { background: var(--header-link-hover-bg); color: var(--header-fg); }

.user-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 160px;
  z-index: 200;
  padding: 4px 0;
}

.menu-item {
  display: block;
  width: 100%;
  padding: 7px 14px;
  text-align: left;
  font-size: 0.82rem;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  box-sizing: border-box;
}
.menu-item:hover { background: var(--bg-alt); }
.menu-item-danger { color: var(--danger); }
.menu-item-danger:hover { background: var(--danger-bg); }

.menu-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}
.menu-search-form {
  display: none;
  padding: 6px 12px 2px;
}
.menu-search-input {
  width: 100%;
  padding: 6px 8px;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}
.menu-search-input:focus { border-color: var(--accent); }
.menu-search-divider { display: none; }

/* ── Page layout ──────────────────────────────────── */
.page-main {
  max-width: 860px;
  margin: 0 auto;
  padding: 20px 16px;
}

/* ── Post list ────────────────────────────────────── */
.post-list {
  list-style: none;
  padding: 0;
}

.post-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 7px 4px;
  /* disabled - border-bottom: 1px solid var(--border); */
}
.post-item:last-child { border-bottom: none; }

.post-rank {
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 16px;
  text-align: right;
  flex-shrink: 0;
  padding-top: 1px;
}

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

.post-title-row {
  display: flex;
  align-items: baseline;
  gap: 5px;
  flex-wrap: nowrap;
  overflow: hidden;
}

.upvote-btn {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0;
  min-width: 14px;
  text-align: right;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.12s;
  font-family: inherit;
}
.upvote-btn:hover { color: var(--accent); }
.upvote-btn.voted { color: var(--accent); }
.upvote-btn:disabled { cursor: default; opacity: 0.4; }

.post-title {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.post-title:hover { color: var(--accent); }
.post-title:visited { color: var(--text-muted); }

.post-title[data-summary] {
  position: relative;
}
.post-title[data-summary]::after {
  content: attr(data-summary);
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 340px;
  max-width: 90vw;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.45;
  white-space: normal;
  padding: 7px 10px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 200;
  overflow: hidden;
  text-overflow: initial;
}
.post-title[data-summary]:hover::after {
  opacity: 1;
}

.post-summary {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 6px 0 4px 32px;
  font-style: italic;
}

.post-domain {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.post-meta {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.post-score { font-weight: 600; color: var(--text-muted); }
.post-user { text-decoration: underline; color: var(--text-muted); }
.post-user:hover { color: var(--accent); text-decoration: underline; }
.post-age { color: var(--text-muted); }
.post-link { text-decoration: underline; color: var(--text-muted); }
.post-link:hover { color: var(--accent); }

.post-empty {
  padding: 32px 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  list-style: none;
  text-align: center;
}
.post-empty a { color: var(--accent); }

.post-item.no-rank { padding-left: 0; }

/* ── Discuss page ─────────────────────────────────── */
.discuss-list { display: flex; flex-direction: column; gap: 0; }
.discuss-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.discuss-item:last-child { border-bottom: none; }
.discuss-item-meta {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex-wrap: wrap;
}
.discuss-title-link {
  color: var(--text);
  text-decoration: none;
  font-style: italic;
}
.discuss-title-link:hover { text-decoration: underline; }

/* ── Item page ────────────────────────────────────── */
.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}

.item-title-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.item-title {
  font-size: 1.05rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
}
.item-title:hover { color: var(--accent); }

/* ── Buttons ──────────────────────────────────────── */
.btn-primary {
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: white;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s;
  font-family: inherit;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-small {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.12s;
  font-family: inherit;
  white-space: nowrap;
}
.btn-small:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }

/* ── Forms ────────────────────────────────────────── */
.page-heading {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  max-width: 540px;
  box-shadow: var(--shadow);
}

.form-title {
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 20px;
  color: var(--text-muted);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 16px;
}

.form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.form-hint { font-weight: 400; text-transform: none; letter-spacing: 0; }

.form-group input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.url-row {
  display: flex;
  gap: 8px;
}
.url-row input { flex: 1; }

/* ── Login page ───────────────────────────────────── */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--surface);
  padding: 36px 32px;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  width: 320px;
  text-align: center;
}

.login-logo {
  font-family: 'Permanent Marker', cursive;
  font-size: 2.8rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: none;
  margin-bottom: 12px;
  color: var(--text);
}

.login-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.login-forgot {
  display: block;
  margin-top: 14px;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  text-align: center;
}
.login-forgot:hover { color: var(--accent); }

.login-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }

.login-card input {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.login-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.login-card button[type="submit"] {
  padding: 10px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: white;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s;
}
.login-card button[type="submit"]:hover { background: var(--accent-hover); }

/* ── Profile ──────────────────────────────────────── */
.profile-top {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

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

.avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.avatar-wrap.uploadable {
  cursor: pointer;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.avatar-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  font-size: 0.68rem;
  color: white;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
}

.avatar-wrap.uploadable:hover .avatar-overlay {
  opacity: 1;
}

.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

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

.profile-name {
  font-size: 1.2rem;
  font-weight: 700;
}

.admin-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--accent);
  color: white;
  padding: 2px 7px;
  border-radius: 4px;
}

.profile-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Admin ────────────────────────────────────────── */
.admin-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

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

.section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.token-box {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.82rem;
  margin-bottom: 14px;
  word-break: break-all;
}
.token-value { font-family: monospace; font-weight: 600; }
.token-link a { color: var(--accent); }

.invite-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.invite-table th {
  text-align: left;
  padding: 6px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.invite-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  font-family: monospace;
  font-size: 0.78rem;
}
.invite-table tr:last-child td { border-bottom: none; }
.invite-table tr.used td { opacity: 0.5; }
.invite-table td:not(:first-child) { font-family: inherit; }

.success { color: #1a7f37; font-size: 0.82rem; margin-top: 6px; }
[data-theme="dark"] .success { color: #3fb950; }
.muted { color: var(--text-muted); }
.admin-item .post-meta { gap: 6px; }

/* ── Pagination ───────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 20px 0 4px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.12s, color 0.12s;
}
.page-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: white; cursor: default; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

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

/* ── Video grid ───────────────────────────────────── */
.page-main-wide {
  max-width: 1100px;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
/* ── Feed tabs ────────────────────────────────────── */
.feed-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.feed-tab {
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 16px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.feed-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.feed-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 600;
}

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 860px) { .video-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .video-grid { grid-template-columns: 1fr; } }

@media (max-width: 600px) {
  header { padding: 0 12px; }

  .page-main { padding: 12px; }

  .post-item {
    gap: 4px;
  }

  .post-title { font-size: 0.9rem; }

  .profile-card { padding: 14px 16px; }

  .profile-avatar { width: 56px; height: 56px; }

  .item-card { padding: 14px 16px; }

  .nav-sep { display: none; }

  .header-search-form { display: none; }
  .menu-search-form { display: block; }
  .menu-search-divider { display: block; }

  .user-menu-btn { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

.video-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow 0.15s;
}
.video-card:hover { box-shadow: var(--shadow-md); }

.video-thumb {
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-alt);
}
.video-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.15s;
}
.video-card:hover .video-thumb img { opacity: 0.88; }

.video-info { padding: 10px 12px 12px; }

.video-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  margin-bottom: 6px;
}
.video-title:hover { color: var(--accent); }

.video-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.video-vote-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.1s;
}
.video-vote-btn:hover { color: var(--accent); }
.video-vote-btn.voted { color: var(--accent); }
.video-score { font-weight: 600; color: var(--text); }

/* ── Modal ────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 480px;
  padding: 24px 28px;
}

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

.modal-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.12s, color 0.12s;
  font-family: inherit;
}
.modal-close:hover { background: var(--bg-alt); color: var(--text); }

/* ── Comments ─────────────────────────────────────── */
.comments-header {
  margin: 24px 0 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.comments-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.comment {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.comment:last-child { border-bottom: none; }

.comment-meta {
  font-size: 0.73rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.comment-body {
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text);
  word-break: break-word;
}

.comment-empty {
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 16px 0;
}

.comment-form {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}
.comment-form > * {
  width: 100%;
}
.comment-form > button[type="submit"] {
  width: auto;
}

.comment-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: inherit;
  resize: vertical;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
  line-height: 1.5;
}
.comment-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* ── Markdown editor ──────────────────────────────── */
.md-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 4px 8px;
}
.md-tabs {
  display: flex;
  gap: 2px;
}
.md-tab {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.78rem;
  padding: 2px 10px;
}
.md-tab.md-tab-active {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
.md-btn-group {
  display: flex;
  align-items: center;
  gap: 1px;
}
.md-toolbar-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: monospace;
  font-size: 0.75rem;
  line-height: 1;
  padding: 3px 6px;
}
.md-toolbar-btn:hover {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
.md-sep {
  display: inline-block;
  width: 1px;
  height: 14px;
  background: var(--border);
  margin: 0 4px;
}
.md-textarea {
  border-top: none !important;
  border-radius: 0 0 var(--radius) var(--radius) !important;
}
.md-preview {
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--bg);
  min-height: 80px;
  padding: 10px 12px;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text);
  word-break: break-word;
}
.md-preview > *:first-child { margin-top: 0; }
.md-preview > *:last-child  { margin-bottom: 0; }
.md-preview p  { margin: 0 0 0.6em; }
.md-preview h1,.md-preview h2,.md-preview h3 { margin: 0.8em 0 0.3em; font-size: 1em; font-weight: 700; }
.md-preview ul,.md-preview ol { margin: 0 0 0.6em; padding-left: 1.4em; }
.md-preview li { margin-bottom: 0.2em; }
.md-preview blockquote {
  border-left: 3px solid var(--border);
  color: var(--text-muted);
  margin: 0 0 0.6em;
  padding: 2px 0 2px 12px;
}
.md-preview code {
  background: var(--bg-alt);
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.85em;
  padding: 1px 5px;
}
.md-preview pre {
  background: var(--bg-alt);
  border-radius: var(--radius);
  overflow-x: auto;
  padding: 10px 12px;
  margin: 0 0 0.6em;
}
.md-preview pre code { background: none; padding: 0; }
.md-preview a { color: var(--accent); }
.md-preview hr { border: none; border-top: 1px solid var(--border); margin: 0.8em 0; }

/* Rendered comment bodies (same styles as preview) */
.comment-body p  { margin: 0 0 0.5em; }
.comment-body p:last-child { margin-bottom: 0; }
.comment-body ul,.comment-body ol { margin: 0 0 0.5em; padding-left: 1.4em; }
.comment-body blockquote {
  border-left: 3px solid var(--border);
  color: var(--text-muted);
  margin: 0 0 0.5em;
  padding: 2px 0 2px 12px;
}
.comment-body code {
  background: var(--bg-alt);
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.85em;
  padding: 1px 5px;
}
.comment-body pre {
  background: var(--bg-alt);
  border-radius: var(--radius);
  overflow-x: auto;
  padding: 8px 12px;
  margin: 0 0 0.5em;
}
.comment-body pre code { background: none; padding: 0; }
.comment-body a { color: var(--accent); }

/* ── Follow ───────────────────────────────────────── */
.follow-btn {
  font-size: 0.78rem;
  padding: 4px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.12s;
  margin-left: auto;
}
.follow-btn:hover { border-color: var(--accent); color: var(--accent); }
.follow-btn.following {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.follow-btn.following:hover {
  background: var(--danger);
  border-color: var(--danger);
}

.follow-stats {
  display: flex;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 8px;
}
.follow-stats strong { color: var(--text); }

/* ── Invites ──────────────────────────────────────── */
.invite-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  font-size: 0.82rem;
}
.invite-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.invite-count { color: var(--text-muted); }
.invite-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.invite-row { color: var(--text-muted); padding: 6px 0; border-bottom: 1px solid var(--border); }
.invite-row:last-child { border-bottom: none; }
.invite-use-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.invite-link-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.invite-link-text {
  font-size: 0.78rem;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}
.muted { color: var(--text-muted); font-size: 0.78rem; }

/* ── Analytics ────────────────────────────────────── */
.analytics-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.analytics-range {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 6px;
}

.analytics-stats {
  display: flex;
  gap: 24px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.analytics-stat {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.analytics-stat strong {
  color: var(--text);
  font-size: 1rem;
}

.analytics-chart-svg {
  display: block;
  width: 100%;
  height: 180px;
  margin-bottom: 20px;
}

#analytics-chart {
  position: relative;
}

.chart-tooltip {
  position: absolute;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 10px;
  font-size: 0.78rem;
  line-height: 1.6;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  z-index: 100;
}
.chart-tip-date {
  font-weight: 600;
  margin-bottom: 2px;
}

.analytics-tables {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.analytics-subtitle {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

@media (max-width: 600px) {
  .analytics-tables { grid-template-columns: 1fr; }
}

/* ── Flag button ──────────────────────────────────── */
.flag-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
}
.flag-btn:hover { color: var(--danger); }

/* ── Admin settings ───────────────────────────────── */
.settings-form { padding: 4px 0; }
.settings-form label { display: block; margin-bottom: 8px; font-size: 0.85rem; color: var(--text-muted); }
.settings-row { display: flex; align-items: center; gap: 8px; }

/* ── Menu karma ───────────────────────────────────── */
.menu-karma { font-size: 0.78rem; color: var(--text-muted); cursor: default; }
.menu-karma:hover { background: none; }

/* ── Bookmarklet ──────────────────────────────────── */
.bookmarklet-section {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.bookmarklet-label { font-size: 0.82rem; color: var(--text-muted); }
.bookmarklet-link {
  display: inline-block;
  padding: 4px 10px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  cursor: grab;
  background: var(--surface);
  white-space: nowrap;
  flex-shrink: 0;
}
.bookmarklet-link:hover { border-color: var(--accent); background: var(--bg-alt); }

/* ── RSS Reader ───────────────────────────────────── */

/* Split-pane layout: activated when an article is opened */
.page-main.rss-split-active {
  max-width: 100%;
  padding: 0;
  height: calc(100vh - 44px);
  overflow: hidden;
  display: flex;
}
.page-main.rss-split-active #rss-root {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: 100%;
}
.rss-left {
  overflow-y: auto;
}
.rss-sub-tabs {
  margin-bottom: 12px;
}
.rss-tab-panel {
  /* shown/hidden via JS */
}
.page-main.rss-split-active .rss-left {
  width: 360px;
  min-width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  height: 100%;
  overflow-y: auto;
}
.rss-frame-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
}
.rss-frame-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.rss-frame-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.rss-frame-actions { display: flex; gap: 6px; flex-shrink: 0; }
.rss-frame-note {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 4px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.rss-frame {
  flex: 1;
  border: none;
  width: 100%;
  background: #fff;
}

.rss-section { margin-bottom: 32px; }
.rss-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.rss-add-form {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.rss-url-input {
  flex: 1;
  padding: 6px 10px;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
  font-family: inherit;
}
.rss-url-input:focus { border-color: var(--accent); }

.rss-feed-list { display: flex; flex-direction: column; gap: 4px; }
.rss-feed-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-wrap: wrap;
}
.rss-feed-info {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}
.rss-feed-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}
.rss-feed-meta {
  font-size: 0.73rem;
  color: var(--text-muted);
}
.rss-feed-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.rss-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
}
.rss-error-tag {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 4px;
  padding: 1px 4px;
  cursor: help;
}

.rss-items-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.rss-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.rss-feed-select {
  padding: 4px 8px;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
}
.rss-unread-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
}

.rss-item-list { display: flex; flex-direction: column; }
.rss-item {
  padding: 9px 4px;
  border-bottom: 1px solid var(--border);
}
.rss-item:last-child { border-bottom: none; }
.rss-item-is-read { opacity: 0.6; }
.rss-item-title-row {
  display: flex;
  align-items: baseline;
  gap: 5px;
  flex-wrap: nowrap;
  overflow: hidden;
}
.rss-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  position: relative;
  top: -1px;
  display: inline-block;
}
.rss-dot-read { background: transparent; }
.rss-item-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
a.rss-item-title:hover { color: var(--accent); }
a.rss-item-title:visited { color: var(--text-muted); }
.rss-item-read { color: var(--text-muted) !important; font-weight: 400; }
.rss-item-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 3px;
  margin-left: 11px;
  line-height: 1.4;
}
.rss-item-meta {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-top: 3px;
  margin-left: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.rss-feed-name {
  color: var(--text-muted);
  font-style: italic;
}
.rss-on-jpx-tag {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}

/* ── Utilities ────────────────────────────────────── */
.hidden { display: none !important; }
.error { color: var(--danger); font-size: 0.82rem; margin-top: 6px; }
