/* ============================================
   Seonology Pedia - Global Styles (Dark Theme)
   StackFever 색상 팔레트 계승 + Pedia 전용 컴포넌트
   ============================================ */

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

:root {
  --bg-main: #0d1117;
  --bg-card: #161b22;
  --bg-code: #1c2128;
  --border: #30363d;
  --text: #e6edf3;
  --text-secondary: #8b949e;
  --text-emphasis: #f0f6fc;
  --accent: #58a6ff;
  --success: #3fb950;
  --warning: #d29922;
  --error: #f85149;
  --tag-bg: rgba(88, 166, 255, 0.12);
  --tag-text: #58a6ff;
  --category-bg: rgba(63, 185, 80, 0.12);
  --category-text: #3fb950;
  --version-bg: rgba(210, 153, 34, 0.12);
  --version-text: #d29922;
  --search-highlight: rgba(210, 153, 34, 0.25);
  --sidebar-width: 260px;
  --header-height: 56px;
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background-color: var(--bg-main);
}

::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 6px;
  border: 2px solid var(--bg-main);
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-secondary);
}

::-webkit-scrollbar-corner {
  background-color: var(--bg-main);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--bg-main);
}

/* --- Custom Select --- */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

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

select option {
  background-color: var(--bg-card);
  color: var(--text);
  padding: 8px;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Pretendard', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg-main);
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  text-decoration: underline;
}

/* --- Header --- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 100;
  gap: 16px;
}

.site-header__logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-emphasis);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.site-header__logo:hover {
  text-decoration: none;
  opacity: 0.9;
}

.site-header__logo span {
  color: var(--accent);
}

/* --- Search Bar (Header) --- */
.search-container {
  flex: 1;
  max-width: 560px;
  position: relative;
}

.search-bar {
  width: 100%;
  height: 36px;
  background-color: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px 0 36px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease;
}

.search-bar::placeholder {
  color: var(--text-secondary);
}

.search-bar:focus {
  border-color: var(--accent);
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
  pointer-events: none;
}

.search-shortcut {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  pointer-events: none;
}

/* --- Header Stats --- */
.site-header__stats {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.site-header__stat {
  display: flex;
  align-items: center;
  gap: 4px;
}

.site-header__stat-value {
  color: var(--text-emphasis);
  font-weight: 600;
}

/* --- Hamburger (mobile) --- */
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}

.hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background-color: var(--text);
  margin: 5px 0;
  transition: transform 0.3s ease;
}

/* --- Layout --- */
.layout {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background-color: var(--bg-card);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.sidebar__section {
  padding: 0 16px;
  margin-bottom: 24px;
}

.sidebar__title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar__title-count {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: none;
}

.sidebar__nav {
  list-style: none;
}

.sidebar__nav li a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  transition: background-color 0.15s ease;
  cursor: pointer;
}

.sidebar__nav li a:hover {
  background-color: rgba(88, 166, 255, 0.1);
  text-decoration: none;
}

.sidebar__nav li a.active {
  background-color: rgba(88, 166, 255, 0.15);
  color: var(--accent);
}

.sidebar__nav-count {
  font-size: 11px;
  color: var(--text-secondary);
  background-color: var(--bg-main);
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

/* --- Sidebar Tags --- */
.sidebar__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 8px;
}

.sidebar__tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--tag-text);
  background-color: var(--tag-bg);
  padding: 4px 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sidebar__tag:hover {
  opacity: 0.8;
  text-decoration: none;
  transform: translateY(-1px);
}

.sidebar__tag.active {
  background-color: var(--accent);
  color: var(--bg-main);
}

.sidebar__tag-count {
  font-size: 10px;
  opacity: 0.7;
  font-weight: 500;
}

/* Tag Cloud Size Variants */
.sidebar__tag--xl {
  font-size: 16px;
  padding: 6px 12px;
}

.sidebar__tag--lg {
  font-size: 14px;
  padding: 5px 10px;
}

.sidebar__tag--md {
  font-size: 12px;
  padding: 4px 8px;
}

.sidebar__tag--sm {
  font-size: 11px;
  padding: 3px 7px;
}

.sidebar__tag--xs {
  font-size: 10px;
  padding: 2px 6px;
}

/* --- Sidebar Footer --- */
.sidebar__footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.sidebar__footer-copyright {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.sidebar__footer-author {
  margin-bottom: 2px;
}

.sidebar__footer-email {
  margin-bottom: 8px;
}

.sidebar__footer-email a {
  color: var(--accent);
  font-size: 11px;
  text-decoration: none;
}

.sidebar__footer-email a:hover {
  text-decoration: underline;
}

.sidebar__footer-version {
  font-size: 10px;
  color: var(--text-secondary);
  opacity: 0.7;
  font-family: 'JetBrains Mono', monospace;
}

/* --- Sidebar TOC (Entry page) --- */
.sidebar__toc {
  list-style: none;
}

.sidebar__toc li a {
  display: block;
  padding: 4px 8px;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 13px;
  transition: color 0.15s ease;
}

.sidebar__toc li a:hover {
  color: var(--text);
  text-decoration: none;
}

.sidebar__toc li a.current {
  color: var(--accent);
  background-color: rgba(88, 166, 255, 0.1);
}

/* --- Sidebar Recent Updates --- */
.sidebar__recent {
  list-style: none;
}

.sidebar__recent-item {
  padding: 8px;
  border-radius: 6px;
  margin-bottom: 8px;
  transition: background-color 0.15s ease;
  cursor: pointer;
}

.sidebar__recent-item:hover {
  background-color: rgba(88, 166, 255, 0.08);
  text-decoration: none;
}

.sidebar__recent-item:last-child {
  margin-bottom: 0;
}

.sidebar__recent-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.sidebar__recent-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
}

.sidebar__recent-category {
  color: var(--category-text);
  background-color: var(--category-bg);
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 600;
}

.sidebar__recent-date {
  color: var(--text-secondary);
}

/* --- Sidebar Bookmarks --- */
.sidebar__bookmarks {
  list-style: none;
}

.sidebar__bookmark-item {
  padding: 8px;
  border-radius: 6px;
  margin-bottom: 8px;
  transition: background-color 0.15s ease;
  cursor: pointer;
  position: relative;
}

.sidebar__bookmark-item:hover {
  background-color: rgba(88, 166, 255, 0.08);
  text-decoration: none;
}

.sidebar__bookmark-item:last-child {
  margin-bottom: 0;
}

.sidebar__bookmark-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  padding-right: 20px;
}

.sidebar__bookmark-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
}

.sidebar__bookmark-category {
  color: var(--category-text);
  background-color: var(--category-bg);
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 600;
}

.sidebar__bookmark-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}

.sidebar__bookmark-item:hover .sidebar__bookmark-remove {
  opacity: 1;
}

.sidebar__bookmark-remove:hover {
  color: var(--error);
}

.sidebar__bookmarks-empty {
  padding: 12px 8px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.sidebar__bookmarks-empty-icon {
  font-size: 24px;
  opacity: 0.3;
  margin-bottom: 8px;
}

/* --- Main Content --- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 40px 48px;
  max-width: 960px;
}

.main-content h1 {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-emphasis);
  margin-bottom: 8px;
}

.main-content h2 {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-emphasis);
  margin-top: 48px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.main-content h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-emphasis);
  margin-top: 32px;
  margin-bottom: 12px;
}

.main-content p {
  margin-bottom: 16px;
  color: var(--text);
}

.page-description {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 32px;
}

/* --- Entry Cards Grid --- */
.entry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.entry-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  transition: border-color 0.2s ease, transform 0.2s ease;
  display: block;
  cursor: pointer;
}

.entry-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
}

.entry-card__header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.entry-card__category {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #3fb950 !important;
  background-color: rgba(63, 185, 80, 0.12) !important;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  text-decoration: none !important;
  transition: all 0.15s ease;
  cursor: pointer;
}

.entry-card__category:hover {
  opacity: 0.8;
  text-decoration: none;
  transform: translateY(-1px);
}

.entry-card__type {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  background-color: var(--bg-main);
  padding: 2px 8px;
  border-radius: 4px;
  text-decoration: none;
  transition: all 0.15s ease;
  cursor: pointer;
}

.entry-card__type:hover {
  color: var(--accent);
  background-color: rgba(88, 166, 255, 0.1);
  text-decoration: none;
  transform: translateY(-1px);
}

.entry-card__title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-emphasis);
  margin-bottom: 6px;
}

.entry-card__summary {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.entry-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
  overflow: hidden;
}

.entry-card__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.entry-card__date {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.entry-card__tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--tag-text);
  background-color: var(--tag-bg);
  padding: 1px 6px;
  border-radius: 10px;
  white-space: nowrap;
  transition: all 0.15s ease;
  cursor: pointer;
}

.entry-card__tag:hover {
  background-color: var(--accent);
  color: var(--bg-main);
  text-decoration: none;
  transform: translateY(-1px);
}

.entry-card__version {
  font-size: 11px;
  font-weight: 600;
  color: var(--version-text);
  background-color: var(--version-bg);
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* --- Code Block --- */
pre {
  background-color: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  overflow-x: auto;
  margin: 16px 0;
  font-size: 14px;
  line-height: 1.5;
}

/* --- Active Filters --- */
.active-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background-color: rgba(88, 166, 255, 0.08);
  border: 1px solid var(--accent);
  border-radius: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.active-filters__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.active-filters__items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.active-filters__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background-color: rgba(88, 166, 255, 0.15);
  padding: 4px 10px;
  border-radius: 12px;
}

.active-filters__item-remove {
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s ease;
}

.active-filters__item-remove:hover {
  opacity: 1;
}

.active-filters__clear {
  font-size: 12px;
  font-weight: 600;
  color: var(--error);
  cursor: pointer;
  transition: opacity 0.15s ease;
  white-space: nowrap;
}

.active-filters__clear:hover {
  opacity: 0.8;
  text-decoration: underline;
}

/* --- Sort Options --- */
.sort-options {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.sort-options__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sort-options__buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sort-option {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.sort-option:hover {
  background-color: rgba(88, 166, 255, 0.08);
  border-color: var(--accent);
  color: var(--accent);
}

.sort-option.active {
  background-color: var(--accent);
  color: var(--bg-main);
  border-color: var(--accent);
}

.sort-option.active:hover {
  background-color: var(--accent);
  opacity: 0.9;
}

/* --- Code Block (continued) --- */
  overflow-x: auto;
  margin: 16px 0;
  font-size: 14px;
  line-height: 1.5;
}

pre code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  color: var(--text);
  background: none;
  padding: 0;
}

code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 14px;
  background-color: var(--bg-code);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent);
}

/* --- Table --- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
}

table th,
table td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
}

table thead th {
  background-color: var(--bg-code);
  color: var(--text-emphasis);
  font-weight: 600;
  white-space: nowrap;
}

table tbody tr {
  background-color: var(--bg-card);
}

table tbody tr:nth-child(even) {
  background-color: rgba(22, 27, 34, 0.6);
}

table tbody tr:hover {
  background-color: rgba(88, 166, 255, 0.05);
}

table td code {
  font-size: 13px;
}

/* --- Lists --- */
.main-content ul,
.main-content ol {
  margin: 8px 0 16px 24px;
  color: var(--text);
}

.main-content li {
  margin-bottom: 6px;
  line-height: 1.6;
}

/* --- Note Box --- */
.note {
  background-color: rgba(88, 166, 255, 0.08);
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  border-radius: 0 6px 6px 0;
  margin: 16px 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.note strong {
  color: var(--text);
}

.note--warning {
  background-color: rgba(210, 153, 34, 0.08);
  border-left-color: var(--warning);
}

.note--error {
  background-color: rgba(248, 81, 73, 0.08);
  border-left-color: var(--error);
}

/* --- Entry Meta (Entry page) --- */
.entry-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

/* --- Entry Actions --- */
.entry-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid var(--border);
  background-color: var(--bg-card);
  color: var(--text);
  text-decoration: none;
}

.btn:hover {
  background-color: rgba(88, 166, 255, 0.08);
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.btn__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn--bookmark.bookmarked {
  background-color: rgba(88, 166, 255, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

.btn--bookmark.bookmarked .btn__icon {
  fill: var(--accent);
}

.btn--bookmark.bookmarked:hover {
  background-color: rgba(248, 81, 73, 0.15);
  border-color: var(--error);
  color: var(--error);
}

.btn--secondary {
  background-color: var(--bg-main);
  border-color: var(--border);
}

.btn--secondary:hover {
  background-color: var(--bg-card);
  border-color: var(--accent);
}

.btn--text {
  background: none;
  border: none;
  color: var(--accent);
  padding: 4px 8px;
}

.btn--text:hover {
  background-color: rgba(88, 166, 255, 0.08);
  text-decoration: underline;
}

.entry-meta__breadcrumb {
  font-size: 14px;
  color: var(--text-secondary);
  width: 100%;
  margin-bottom: 4px;
}

.entry-meta__breadcrumb a {
  color: var(--text-secondary);
}

.entry-meta__breadcrumb a:hover {
  color: var(--accent);
}

.entry-meta__breadcrumb-sep {
  margin: 0 8px;
  color: var(--border);
}

.entry-meta__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.entry-meta__version {
  font-size: 12px;
  font-weight: 600;
  color: var(--version-text);
  background-color: var(--version-bg);
  padding: 2px 8px;
  border-radius: 4px;
}

.entry-meta__date {
  font-size: 13px;
  color: var(--text-secondary);
}

/* --- Related Entries --- */
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.related-card {
  display: block;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  transition: border-color 0.15s ease;
}

.related-card:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.related-card__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-emphasis);
  margin-bottom: 4px;
}

.related-card__category {
  font-size: 11px;
  color: var(--category-text);
}

/* --- Search Results --- */
.search-results {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.search-results.active {
  display: block;
}

.search-result-item {
  display: block;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.1s ease;
  cursor: pointer;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover,
.search-result-item.selected {
  background-color: rgba(88, 166, 255, 0.08);
  text-decoration: none;
}

.search-result-item__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-emphasis);
  margin-bottom: 4px;
  line-height: 1.4;
}

.search-result-item__summary {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.search-result-item__meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.search-result-item__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.search-result-item__tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--tag-text);
  background-color: var(--tag-bg);
  padding: 2px 6px;
  border-radius: 10px;
}

.search-result-item mark {
  background-color: var(--search-highlight);
  color: var(--text-emphasis);
  border-radius: 2px;
  padding: 0 2px;
  font-weight: 600;
}

.search-result-item mark.highlight-exact {
  background-color: var(--search-highlight);
  color: var(--text-emphasis);
  font-weight: 700;
}

.search-result-item mark.highlight-fuzzy {
  background-color: rgba(210, 153, 34, 0.15);
  color: var(--warning);
  font-weight: 600;
}

.search-no-results {
  padding: 20px 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

/* --- Search History --- */
.search-history {
  padding: 8px 0;
}

.search-history__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.search-history__clear {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.search-history__clear:hover {
  background-color: rgba(88, 166, 255, 0.08);
}

.search-history__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.2s;
}

.search-history__item:last-child {
  border-bottom: none;
}

.search-history__item:hover {
  background-color: rgba(88, 166, 255, 0.08);
}

.search-history__item svg {
  flex-shrink: 0;
  color: var(--text-secondary);
}

.search-history__item span {
  font-size: 14px;
}

/* --- Changelog --- */
.changelog {
  list-style: none;
  margin: 12px 0;
}

.changelog li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.changelog li:last-child {
  border-bottom: none;
}

.changelog__version {
  font-size: 12px;
  font-weight: 600;
  color: var(--version-text);
  background-color: var(--version-bg);
  padding: 1px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.changelog__date {
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.changelog__note {
  color: var(--text);
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-secondary);
}

.empty-state__icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state__title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state__desc {
  font-size: 14px;
  max-width: 400px;
  margin: 0 auto;
}

/* --- Section Header (with count) --- */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 48px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.section-header:first-child {
  margin-top: 0;
}

.section-header h2 {
  margin: 0;
  padding: 0;
  border: none;
}

.section-header__count {
  font-size: 13px;
  color: var(--text-secondary);
}

/* --- Responsive (768px) --- */
@media (max-width: 768px) {
  body {
    font-size: 14px;
  }

  .hamburger {
    display: block;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    padding: 24px 16px;
  }

  .search-container {
    max-width: none;
  }

  .search-shortcut {
    display: none;
  }

  .site-header__stats {
    display: none;
  }

  pre {
    font-size: 13px;
    padding: 12px 14px;
  }

  .main-content h1 {
    font-size: 24px;
  }

  .main-content h2 {
    font-size: 20px;
  }

  .entry-grid {
    grid-template-columns: 1fr;
  }

  .related-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Sidebar overlay on mobile --- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 40;
}

.sidebar-overlay.active {
  display: block;
}

/* ============================================
   Version History Viewer
   ============================================ */

.version-item {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 0.2s;
}

.version-item:hover {
  background-color: rgba(88, 166, 255, 0.05);
}

.version-item--current {
  background-color: var(--version-bg);
  cursor: default;
}

.version-item--current:hover {
  background-color: var(--version-bg);
}

.version-item--action {
  cursor: default;
  border-bottom: none;
  padding: 8px;
}

.version-item--action:hover {
  background-color: transparent;
}

.version-item__version {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-emphasis);
  margin-bottom: 4px;
}

.version-item__date {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.version-item__note {
  display: block;
  font-size: 12px;
  color: var(--text);
  font-style: italic;
}

/* Version Viewer Modal */

.version-viewer {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  height: 70vh;
  min-height: 500px;
}

.version-viewer__list {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding-right: 16px;
}

.version-viewer__content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.version-viewer__toolbar {
  display: flex;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.version-viewer__display {
  flex: 1;
  overflow-y: auto;
  padding-right: 8px;
}

.version-list-item {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.version-list-item:hover {
  border-color: var(--accent);
  background-color: rgba(88, 166, 255, 0.05);
}

.version-list-item--active {
  border-color: var(--accent);
  background-color: rgba(88, 166, 255, 0.1);
}

.version-list-item--current {
  background-color: var(--version-bg);
  border-color: var(--version-text);
}

.version-list-item--current:hover {
  background-color: var(--version-bg);
  border-color: var(--version-text);
}

.version-list-item__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.version-list-item__version {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-emphasis);
}

.version-list-item__badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--version-text);
  background-color: var(--version-bg);
  padding: 2px 8px;
  border-radius: 4px;
}

.version-list-item__date {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.version-list-item__note {
  font-size: 13px;
  color: var(--text);
  font-style: italic;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.version-content {
  padding: 16px;
  background-color: var(--bg-card);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.version-content__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.version-content__header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-emphasis);
  margin: 0;
}

.version-content__date {
  font-size: 13px;
  color: var(--text-secondary);
}

.version-content__note {
  padding: 12px;
  background-color: var(--bg-code);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--text);
  font-style: italic;
}

/* Diff View */

.diff-view {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.6;
  background-color: var(--bg-code);
  border-radius: 4px;
  padding: 16px;
  overflow-x: auto;
}

.diff-line {
  display: flex;
  padding: 2px 0;
  white-space: pre-wrap;
  word-break: break-all;
}

.diff-line__marker {
  flex-shrink: 0;
  width: 24px;
  text-align: center;
  font-weight: 600;
  user-select: none;
}

.diff-line__content {
  flex: 1;
  padding-left: 8px;
}

.diff-line--unchanged {
  color: var(--text-secondary);
}

.diff-line--removed {
  background-color: rgba(248, 81, 73, 0.15);
  color: #ff7b72;
}

.diff-line--removed .diff-line__marker {
  color: #ff7b72;
}

.diff-line--added {
  background-color: rgba(63, 185, 80, 0.15);
  color: #3fb950;
}

.diff-line--added .diff-line__marker {
  color: #3fb950;
}

/* Modal Large Variant */

.modal__content--large {
  max-width: 1200px;
  width: 95%;
}

/* Responsive */

@media (max-width: 768px) {
  .version-viewer {
    grid-template-columns: 1fr;
    height: auto;
  }

  .version-viewer__list {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    padding-bottom: 16px;
    max-height: 200px;
  }

  .modal__content--large {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    border-radius: 0;
  }
}

/* ============================================
   Backlinks
   ============================================ */

.backlinks-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.backlink-card {
  display: block;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  transition: all 0.2s ease;
  text-decoration: none;
}

.backlink-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  text-decoration: none;
}

.backlink-card__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  gap: 12px;
}

.backlink-card__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-emphasis);
  flex: 1;
}

.backlink-card__category {
  font-size: 12px;
  font-weight: 600;
  color: var(--category-text);
  background-color: var(--category-bg);
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.backlink-card__summary {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 8px;
}

.backlink-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.backlink-card__tags .tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--tag-text);
  background-color: var(--tag-bg);
  padding: 2px 6px;
  border-radius: 10px;
}

/* ============================================
   Delete Confirmation Modal
   ============================================ */

.delete-warning {
  display: flex;
  gap: 16px;
  padding: 16px;
  background-color: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.3);
  border-radius: 8px;
}

.delete-warning__icon {
  font-size: 32px;
  flex-shrink: 0;
}

.delete-warning__text {
  flex: 1;
}

.delete-warning__text p {
  margin: 0 0 12px 0;
  color: var(--text);
  line-height: 1.6;
}

.delete-warning__text p:last-child {
  margin-bottom: 0;
}

.delete-warning__entry-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-emphasis);
  padding: 8px 12px;
  background-color: var(--bg-code);
  border-radius: 4px;
  border-left: 3px solid var(--error);
}

.delete-warning__note {
  font-size: 14px;
  color: var(--text-secondary);
  font-style: italic;
}

.delete-warning__version-note {
  font-size: 13px;
  color: var(--success);
  padding: 8px 12px;
  background-color: rgba(63, 185, 80, 0.1);
  border-radius: 4px;
  border-left: 3px solid var(--success);
}

.btn--danger {
  background-color: var(--error);
  color: var(--text-emphasis);
  border: 1px solid var(--error);
}

.btn--danger:hover {
  background-color: #ff4d4d;
  border-color: #ff4d4d;
}

.btn--danger:disabled {
  background-color: rgba(248, 81, 73, 0.5);
  border-color: rgba(248, 81, 73, 0.5);
  cursor: not-allowed;
  opacity: 0.6;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid var(--border);
}
