:root {
  --bg: #e8ece7;
  --bg-soft: #f4f6f3;
  --surface: #ffffff;
  --ink: #1c2420;
  --ink-muted: #5a6b61;
  --line: #c9d2cb;
  --accent: #2f6b4f;
  --accent-hover: #245540;
  --accent-soft: #e3efe8;
  --danger: #9b2c2c;
  --shadow: 0 1px 2px rgba(28, 36, 32, 0.06), 0 8px 24px rgba(28, 36, 32, 0.08);
  --radius: 12px;
  --font-display: "Fraunces", "Palatino Linotype", Palatino, serif;
  --font-body: "Manrope", "Segoe UI", sans-serif;
  --max: 1080px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #d7e7dc 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #d5e2ea 0%, transparent 50%),
    var(--bg);
  line-height: 1.55;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--accent-hover);
}

/* —— Header / nav —— */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(244, 246, 243, 0.88);
  border-bottom: 1px solid var(--line);
}

.site-header__inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  color: inherit;
  text-decoration: none;
}

.brand__mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.brand__tag {
  font-size: 0.78rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.nav a {
  text-decoration: none;
  color: var(--ink-muted);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
}

.nav a:hover,
.nav a.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

/* —— Layout —— */
.page {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3.5rem;
}

.page-intro {
  margin-bottom: 1.5rem;
}

.page-intro h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  letter-spacing: -0.02em;
  margin: 0 0 0.4rem;
  line-height: 1.15;
}

.page-intro p {
  margin: 0;
  color: var(--ink-muted);
  max-width: 42rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.search {
  flex: 1 1 220px;
  max-width: 360px;
  position: relative;
}

.search input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 0.7rem 0.9rem 0.7rem 2.4rem;
  font: inherit;
  color: var(--ink);
}

.search::before {
  content: "";
  position: absolute;
  left: 0.85rem;
  top: 50%;
  width: 0.85rem;
  height: 0.85rem;
  border: 2px solid var(--ink-muted);
  border-radius: 50%;
  transform: translateY(-55%);
  opacity: 0.7;
  pointer-events: none;
}

.search::after {
  content: "";
  position: absolute;
  left: 1.55rem;
  top: 58%;
  width: 0.45rem;
  height: 2px;
  background: var(--ink-muted);
  transform: rotate(45deg);
  opacity: 0.7;
  pointer-events: none;
}

/* —— Buttons —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  border-radius: 10px;
  padding: 0.7rem 1.1rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: var(--accent-hover);
  color: #fff;
}

.btn--ghost {
  background: var(--bg-soft);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn--ghost:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.btn--danger {
  background: #f4e4e4;
  color: var(--danger);
  border: 1px solid #e2bcbc;
}

.btn--danger:hover {
  background: #ead0d0;
  color: #7a1f1f;
}

.btn--small {
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  border-radius: 8px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.nav-user {
  font-weight: 700;
  color: var(--ink);
  padding: 0.45rem 0.55rem;
  font-size: 0.9rem;
}

.nav-logout {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
}

.nav-logout:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.profile__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.admin-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem 1.35rem;
  margin-bottom: 1.25rem;
}

.admin-panel h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin: 0 0 0.85rem;
}

.table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.admin-table th {
  color: var(--ink-muted);
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.role-pill {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.role-pill--admin {
  background: #efe4d4;
  color: #7a4e16;
}

.role-pill--user {
  background: var(--accent-soft);
  color: var(--accent);
}

/* —— Article list —— */
.article-list {
  display: grid;
  gap: 0.75rem;
}

.article-card {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 1rem;
  align-items: center;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.article-card:hover {
  border-color: #9bb5a5;
  transform: translateY(-1px);
  color: inherit;
}

.article-card__avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px var(--line);
  background: var(--accent-soft);
}

.article-card__title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin: 0 0 0.15rem;
  letter-spacing: -0.01em;
}

.article-card__latin {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.95rem;
}

.article-card__meta {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.empty-state {
  padding: 2rem 1.25rem;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--ink-muted);
}

[hidden] {
  display: none !important;
}

/* —— Profile (VK-style) —— */
.profile {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.profile__cover {
  position: relative;
  aspect-ratio: 3 / 1;
  background: #c5d4c8;
  overflow: hidden;
}

.profile__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile__body {
  position: relative;
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 1rem 1.25rem;
  padding: 0 1.25rem 1.25rem;
  min-height: 5.5rem;
}

.profile__avatar-wrap {
  position: relative;
  margin-top: -72px;
  width: 160px;
  height: 160px;
  z-index: 2;
}

.profile__avatar {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  object-fit: cover;
  border: 5px solid #fff;
  box-shadow: 0 2px 10px rgba(28, 36, 32, 0.18);
  background: var(--accent-soft);
}

.profile__info {
  padding-top: 0.85rem;
  min-width: 0;
}

.profile__heading {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.profile__name {
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 2.6vw, 2rem);
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.profile__latin {
  margin: 0.35rem 0 0.7rem;
  color: var(--ink-muted);
  font-size: 1.05rem;
}

.profile__taxons {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1.25rem;
}

.profile__taxons li {
  display: flex;
  gap: 0.4rem;
  font-size: 0.92rem;
  color: var(--ink-muted);
}

.taxon-label {
  font-weight: 700;
  color: var(--ink);
}

.taxon-value {
  font-style: italic;
}

/* —— Wiki content —— */
.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 1.25rem;
  align-items: start;
}

.article-layout > .profile {
  grid-column: 1 / -1;
}

.wiki-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem 1.5rem;
  box-shadow: var(--shadow);
}

.wiki-section h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0 0 0.75rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--line);
}

.wiki-prose {
  font-size: 1.02rem;
  color: var(--ink);
}

.wiki-meta {
  margin: 1.25rem 0 0;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.taxobox {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
  position: sticky;
  top: 4.5rem;
}

.taxobox__title {
  margin: 0 0 0.65rem;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.05rem;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.45rem;
  border-radius: 8px;
}

.taxobox__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.taxobox__table th,
.taxobox__table td {
  padding: 0.4rem 0.25rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
}

.taxobox__table th {
  width: 42%;
  color: var(--ink-muted);
  font-weight: 600;
}

.taxobox__media {
  margin-top: 0.85rem;
  text-align: center;
}

.taxobox__media img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.taxobox__media p {
  margin: 0.4rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

/* —— Forms —— */
.form-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.4rem 1.6rem;
  max-width: 720px;
}

.form-grid {
  display: grid;
  gap: 1rem;
}

.form-row {
  display: grid;
  gap: 0.35rem;
}

.form-row label {
  font-weight: 700;
  font-size: 0.92rem;
}

.form-row .hint {
  font-size: 0.82rem;
  color: var(--ink-muted);
  margin: 0;
}

.form-row input[type="text"],
.form-row input[type="search"],
.form-row textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

.form-row textarea {
  min-height: 160px;
  resize: vertical;
}

.form-row input:focus,
.form-row textarea:focus,
.search input:focus {
  outline: 2px solid #9ec5b0;
  outline-offset: 1px;
  border-color: var(--accent);
}

.form-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.file-field {
  border: 1px dashed #a8bdb0;
  border-radius: 10px;
  padding: 0.9rem;
  background: var(--bg-soft);
}

.file-field input[type="file"] {
  width: 100%;
  font: inherit;
  font-size: 0.9rem;
}

.preview {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.preview img {
  border: 1px solid var(--line);
  background: #fff;
}

.preview--round img {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
}

.preview--cover img {
  width: 100%;
  max-width: 320px;
  aspect-ratio: 3 / 1;
  object-fit: cover;
  border-radius: 8px;
}

.field-error,
.form-error {
  color: var(--danger);
  font-size: 0.88rem;
  margin: 0.35rem 0 0;
  min-height: 1.2em;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.notice {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.notice--error h1 {
  margin-top: 0;
  font-family: var(--font-display);
}

.draft-status {
  margin: 0.25rem 0 0;
  min-height: 1.3em;
  font-size: 0.88rem;
  color: var(--accent);
}

.site-footer {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
  color: var(--ink-muted);
  font-size: 0.85rem;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 820px) {
  .article-layout {
    grid-template-columns: 1fr;
  }

  .taxobox {
    position: static;
    order: 3;
  }

  .wiki-section {
    order: 2;
  }
}

@media (max-width: 640px) {
  .site-header__inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .brand__tag {
    display: none;
  }

  .profile__body {
    grid-template-columns: 1fr;
    padding-top: 0;
  }

  .profile__avatar-wrap {
    width: 112px;
    height: 112px;
    margin-top: -56px;
    margin-left: 0.15rem;
  }

  .profile__avatar {
    width: 112px;
    height: 112px;
    border-width: 4px;
  }

  .profile__info {
    padding-top: 0;
  }

  .form-pair {
    grid-template-columns: 1fr;
  }

  .article-card {
    grid-template-columns: 56px 1fr;
  }

  .article-card__avatar {
    width: 56px;
    height: 56px;
  }
}
