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

:root {
  --bg: #faf8f5;
  --surface: #fff;
  --border: #e4e0d8;
  --text: #1a1a1a;
  --muted: #888;
  --accent: #1a1a1a;
  --danger: #c0392b;
}

body {
  font-family: Georgia, serif;
  background: var(--bg);
  max-width: 740px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  color: var(--text);
  line-height: 1.65;
  font-size: 1rem;
}

/* ── Nav ── */
nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;

  margin-bottom: 2.5rem;
}

.nav-brand {
  font-size: 1.15rem;
  font-weight: bold;
  letter-spacing: 0.03em;
  text-decoration: none;
  color: var(--text);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}

.nav-links a,
.nav-links button {
  padding: 0.3rem 0.6rem;
  color: var(--muted);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  white-space: nowrap;
  border-radius: 4px;
  transition:
    color 0.15s,
    background 0.15s;
}

.nav-links a:hover,
.nav-links button:hover {
  color: var(--text);
  background: var(--border);
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.tab {
  padding: 0.5rem 0.85rem;
  font-size: 0.9rem;
  font-family: system-ui, sans-serif;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition:
    color 0.15s,
    border-color 0.15s;
}

.tab:hover {
  color: var(--text);
}
.tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
  font-weight: 600;
}

/* ── Spinner ── */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.spinner {
  display: inline-block;
  width: 11px;
  height: 11px;
  border: 2px solid var(--border);
  border-top-color: var(--muted);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

/* ── Links ── */
a {
  color: var(--text);
  text-underline-offset: 2px;
}
a:hover {
  color: #555;
}

/* ── Typography ── */
h1 {
  font-size: 1.75rem;
  margin: 0 0 0.5rem;
  line-height: 1.2;
  font-weight: bold;
}
h2 {
  font-size: 1.25rem;
  margin: 0 0 0.3rem;
  line-height: 1.25;
}
h3 {
  font-size: 1rem;
  margin: 1.5rem 0 0.6rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-size: 0.8rem;
  color: var(--muted);
}
p {
  margin: 0.5rem 0;
}

/* ── Forms ── */
input,
textarea,
select {
  font: inherit;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  margin-bottom: 0.6rem;
  background: var(--surface);
  color: var(--text);
  width: 100%;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #aaa;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

/* ── Buttons ── */
button {
  font: inherit;
  padding: 0.45rem 1rem;
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s;
}

button:hover {
  background: #333;
}

button.danger {
  background: var(--danger);
}
button.danger:hover {
  background: #a93226;
}

/* ── Button component ── */
/* Variants */
.btn {
  font: inherit;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--text);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: #333;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) {
  background: #a93226;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--border);
}

/* Sizes */
.btn-sm {
  padding: 0.25rem 0.65rem;
  font-size: 0.8rem;
}
.btn-md {
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
}
.btn-lg {
  padding: 0.65rem 1.4rem;
  font-size: 1rem;
}

/* ── Articles (feed) ── */
article {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
}

article:last-of-type {
  border-bottom: none;
}
article h2 {
  margin-bottom: 0.2rem;
}
article h2 a {
  text-decoration: none;
}
article h2 a:hover {
  text-decoration: underline;
}

/* ── Cards (groups list) ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  font-family: system-ui, sans-serif;
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 99px;
  border: 1px solid var(--border);
  color: var(--muted);
  vertical-align: middle;
}

/* ── Member list ── */
.member-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.member-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.member-list li:last-child {
  border-bottom: none;
}

/* ── Utility ── */
.muted {
  color: var(--muted);
  font-size: 0.875rem;
}
.text-danger {
  color: var(--danger);
}

/* ── Post title input ── */
.post-title-input {
  border: none;
  border-radius: 0;
  padding-left: 0;
  padding-right: 0;
  box-shadow: none;
  background: transparent;
}

.post-title-input:focus {
  border: none;
  box-shadow: none;
  outline: none;
}

/* ── ProseMirror editor ── */
.pm-wrapper {
  border: none;
  overflow: hidden;
  margin-bottom: 0.5rem;
  background: transparent;
}

.pm-wrapper:focus-within {
  box-shadow: none;
}

.pm-comment {
  border: none;
  background: var(--bg);
  border-radius: 5px;
  margin-bottom: 0;
}

.pm-comment:focus-within {
  box-shadow: none;
}

#editor-toolbar {
  display: flex;
  gap: 0.2rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
}

.pm-btn {
  background: none;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 0.15rem 0.45rem;
  font-size: 0.78rem;
  font-family: system-ui, sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.1s;
  min-width: 1.8rem;
  line-height: 1.4;
}

.pm-btn:hover {
  background: var(--border);
  color: var(--text);
}
.pm-btn.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

.pm-comment .ProseMirror {
  min-height: 60px;
  padding: 0.6rem 0.75rem;
}

.ProseMirror {
  padding: 0.85rem 1rem;
  min-height: 220px;
  outline: none;
  font-family: Georgia, serif;
  line-height: 1.65;
  font-size: 1rem;
}

.ProseMirror > * + * {
  margin-top: 0.65rem;
}
.ProseMirror p {
  margin: 0;
}
.ProseMirror h1 {
  font-size: 1.5rem;
  font-weight: bold;
  margin: 0;
}
.ProseMirror h2 {
  font-size: 1.2rem;
  font-weight: bold;
  margin: 0;
}
.ProseMirror h3 {
  font-size: 1rem;
  font-weight: bold;
  margin: 0;
}

/* ── Dropdown component ── */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  font: inherit;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
  white-space: nowrap;
  width: 100%;
  justify-content: space-between;
}

.dropdown-trigger:hover {
  border-color: #aaa;
}

.dropdown-trigger:focus-visible {
  outline: none;
  border-color: #aaa;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

.dropdown-chevron {
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 0.15s;
}

.dropdown-chevron--open {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  list-style: none;
  margin: 0;
  padding: 0.3rem;
  z-index: 50;
  overflow: hidden;
  transition:
    opacity 0.12s ease,
    transform 0.12s ease;
}

.dropdown-item {
  padding: 0.4rem 0.65rem;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.1s;
  color: var(--text);
}

.dropdown-item:hover {
  background: var(--border);
}

.dropdown-item--active {
  font-weight: 600;
}

[x-cloak] {
  display: none !important;
}

/* ── Entry detail ── */
.entry-article {
  padding: 0;
  border: none;
  margin-bottom: 4rem;
}

.entry-title {
  font-size: 2.75rem;
  line-height: 1.1;
  margin: 0 0 1.25rem;
  font-weight: bold;
  letter-spacing: -0.02em;
}

.entry-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 2.75rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.entry-meta a {
  color: var(--text);
  text-decoration: none;
}
.entry-meta a:hover {
  text-decoration: underline;
}

/* ── Entry body (rendered HTML) ── */
.entry-body {
  font-size: 1.15rem;
  line-height: 1.85;
}
.entry-body > * + * {
  margin-top: 1.6rem;
}
.entry-body p {
  margin: 0;
}
.entry-body p + p {
  margin-top: 1.4rem;
}
.entry-body h1 {
  font-size: 1.7rem;
  font-weight: bold;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin-top: 2.5rem;
}
.entry-body h2 {
  font-size: 1.4rem;
  font-weight: bold;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin-top: 2.25rem;
}
.entry-body h3 {
  font-size: 1.15rem;
  font-weight: bold;
  line-height: 1.3;
  margin-top: 2rem;
  text-transform: none;
  color: var(--text);
}
.entry-body strong {
  font-weight: bold;
}
.entry-body em {
  font-style: italic;
}
.entry-body blockquote {
  border-left: 3px solid var(--text);
  padding: 0.25rem 0 0.25rem 1.5rem;
  color: var(--text);
  margin: 0;
  font-style: italic;
  font-size: 1.2rem;
  line-height: 1.7;
}
.entry-body code {
  font-family: monospace;
  background: var(--border);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  font-size: 0.88em;
}
.entry-body pre {
  background: var(--border);
  padding: 1rem 1.25rem;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.9rem;
}
.entry-body a {
  text-decoration: underline;
}
.entry-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}
.entry-img,
.entry-body img {
  display: block;
  max-width: 100%;
  max-height: 520px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
  margin: 0.5rem auto;
}

/* ── Comments ── */
#comments {
  border-top: 1px solid var(--border);
  padding-top: 2.5rem;
}

#comments h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 1.75rem;
}

.comment-item {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
}

.comment-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.comment-body {
  font-size: 1rem;
  line-height: 1.7;
}
