@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,300;0,14..32,400;0,14..32,500;0,14..32,600;1,14..32,400&family=JetBrains+Mono:wght@400&display=swap');

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

:root {
  --bg: #FDFCFB;
  --text: #1A1A1A;
  --text-muted: #737373;
  --text-light: #A3A3A3;
  --border: #E5E5E5;
  --border-hover: #A3A3A3;
  --white: #FFFFFF;
  --black: #000000;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --radius: 16px;
  --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
}

html {
  font-size: 16px;
  /* Smooth font rendering — eliminates pixelation */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-optical-sizing: auto;
  line-height: 1.6;
  min-height: 100vh;
}

::selection {
  background: var(--black);
  color: var(--white);
}

/* Layout — wider container */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 64px 32px 80px;
}

@media (min-width: 768px) {
  .container {
    padding: 96px 48px 96px;
  }
}

/* Header */
header {
  margin-bottom: 48px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-logo {
  height: 48px;
  width: auto;
  flex-shrink: 0;
}

.header-text {
  flex: 1;
  min-width: 0;
}

header h1 {
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.4;
}

header h1 .sep {
  color: var(--text-light);
  font-weight: 300;
  margin: 0 6px;
}

header p.subtitle {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.875rem;
  margin-top: 6px;
}

/* Tags bar — align with header */
.tags-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 48px;
  align-items: center;
}

.tags-bar-icon {
  color: var(--text-light);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 0.6;
}

.tags-bar-icon svg {
  width: 18px;
  height: 18px;
}

.tag-btn {
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-family: var(--font-sans);
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  line-height: 1;
}

.tag-btn:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

/* Single active tag (all) */
.tag-btn.active-all {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
}

/* Multi-selected tag */
.tag-btn.active {
  background: var(--text);
  color: var(--white);
  border-color: var(--text);
}

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

/* Article block */
.article-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  transition: border-color 0.2s, box-shadow 0.2s;
  overflow: hidden;
}

.article-block:not(.expanded) {
  cursor: pointer;
}

.article-block:not(.expanded):hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

.article-block.expanded {
  box-shadow: var(--shadow-md);
  border-color: var(--border);
}

/* Article header row */
.article-header {
  padding: 20px 24px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.article-title-wrap {
  flex: 1;
  min-width: 0;
}

.article-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.15s;
  line-height: 1.4;
}

.article-block:not(.expanded):hover .article-title {
  color: var(--text);
}

.article-block.expanded .article-title {
  color: var(--text);
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.article-date {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-light);
  white-space: nowrap;
}

.share-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-top: 6px;
  font-size: 0.75rem;
  font-family: var(--font-sans);
  color: var(--text-light);
  transition: color 0.15s;
}

.share-link-btn:hover {
  color: var(--text-muted);
}

.close-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}

.close-btn:hover {
  background: #F5F5F5;
  color: var(--text);
}

/* Article preview (collapsed) */
.article-preview {
  padding: 0 24px 18px;
  font-size: 0.875rem;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Article content (expanded) */
.article-content {
  display: none;
  padding: 0 24px 24px;
}

.article-block.expanded .article-content {
  display: block;
}

.article-block.expanded .article-preview {
  display: none;
}

/* Markdown prose */
.prose {
  font-size: 0.9375rem;
  color: #404040;
  line-height: 1.75;
  font-weight: 400;
}

.prose p {
  margin-bottom: 16px;
}

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

.prose h1, .prose h2, .prose h3, .prose h4 {
  font-weight: 500;
  color: var(--text);
  margin-top: 24px;
  margin-bottom: 8px;
  line-height: 1.3;
}

.prose h1 { font-size: 1.25rem; }
.prose h2 { font-size: 1.1rem; }
.prose h3 { font-size: 1rem; }

.prose ul, .prose ol {
  padding-left: 20px;
  margin-bottom: 16px;
}

.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }

.prose li {
  margin-bottom: 4px;
}

.prose blockquote {
  border-left: 2px solid var(--border);
  padding-left: 16px;
  font-style: italic;
  color: var(--text-muted);
  margin: 16px 0;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: #F5F5F5;
  padding: 2px 6px;
  border-radius: 4px;
  color: #333;
}

.prose pre {
  background: #F5F5F5;
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
}

.prose pre code {
  background: none;
  padding: 0;
}

.prose a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.prose strong {
  font-weight: 600;
  color: var(--text);
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* Article tags (inside expanded) — label icon instead of # */
.article-tags {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid #F5F5F5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.article-tags-icon {
  color: var(--text-light);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 0.5;
}

.article-tag-pill {
  font-size: 0.75rem;
  color: var(--text-light);
  background: #F5F5F5;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.01em;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 0;
  color: var(--text-light);
  font-size: 0.9rem;
}

/* Footer */
footer {
  margin-top: 80px;
  padding-top: 24px;
  border-top: 1px solid #F0F0F0;
  text-align: center;
}

footer p {
  font-size: 0.8rem;
  color: var(--text-light);
}

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

footer p a:hover {
  color: var(--text-muted);
  text-decoration: underline;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 10px;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--text-light);
  text-decoration: none;
  transition: color 0.15s;
}

.footer-link:hover {
  color: var(--text-muted);
}

.footer-link svg {
  flex-shrink: 0;
}

/* Expand animation */
.article-content-wrapper {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.article-block.expanded .article-content-wrapper {
  max-height: 9999px;
}

/* Admin-specific styles */
.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-light);
  margin-top: 8px;
}

.admin-badge::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
}

.add-btn {
  margin-left: auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}

.add-btn:hover {
  background: #F5F5F5;
  border-color: var(--border-hover);
  color: var(--text);
}

/* Add/Edit form */
.form-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 12px;
  display: none;
}

.form-card.visible {
  display: block;
}

.form-field {
  width: 100%;
  border: none;
  border-bottom: 1px solid #F0F0F0;
  padding: 10px 0;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  color: var(--text);
  background: transparent;
  outline: none;
  transition: border-color 0.15s;
  resize: none;
}

.form-field:focus {
  border-bottom-color: var(--black);
}

.form-field::placeholder {
  color: var(--text-light);
}

.form-field.title-field {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 4px;
}

.form-field.content-field {
  min-height: 200px;
  line-height: 1.7;
  margin-top: 8px;
}

.form-field.tags-field {
  font-size: 0.875rem;
  margin-top: 4px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
}

.btn {
  padding: 8px 20px;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-family: var(--font-sans);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1;
}

.btn-primary {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
}

.btn-primary:hover {
  background: #333;
}

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-secondary:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.btn-danger {
  background: transparent;
  color: #ef4444;
  border-color: #fecaca;
  font-size: 0.75rem;
}

.btn-danger:hover {
  background: #fef2f2;
}

/* Admin action bar on article */
.article-admin-bar {
  display: flex;
  gap: 8px;
  padding: 12px 24px;
  border-top: 1px solid #F5F5F5;
  background: #FAFAFA;
}

/* Loading */
.loading {
  text-align: center;
  padding: 48px 0;
  color: var(--text-light);
  font-size: 0.9rem;
}

/* Notification toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: var(--white);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.8125rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}
