:root {
  color-scheme: light;
  --ink: #18211d;
  --muted: #5d675f;
  --paper: #f8f4ea;
  --panel: #fffaf0;
  --line: #ddd3be;
  --leaf: #2f7a4f;
  --fern: #9bb65a;
  --clay: #bd5d3c;
  --river: #267c87;
  --gold: #d8a12e;
  --shadow: 0 18px 45px rgba(57, 45, 27, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(216, 161, 46, 0.16), transparent 34rem),
    linear-gradient(180deg, #fbf7ed 0%, var(--paper) 48%, #eee7d7 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

.site-header {
  min-height: 92vh;
  background:
    linear-gradient(90deg, rgba(24, 33, 29, 0.86) 0%, rgba(24, 33, 29, 0.58) 45%, rgba(24, 33, 29, 0.12) 100%),
    url("https://upload.wikimedia.org/wikipedia/commons/thumb/b/b4/T-Rex.jpg/1280px-T-Rex.jpg") center / cover;
  color: #fffdf6;
  display: flex;
  flex-direction: column;
}

.topbar {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand,
.nav-links {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  text-decoration: none;
  font-weight: 800;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.76);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
}

.nav-links a {
  color: rgba(255, 253, 246, 0.86);
  font-size: 0.94rem;
  font-weight: 700;
  text-decoration: none;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  color: #fff;
}

.hero {
  width: min(1180px, calc(100% - 32px));
  margin: auto;
  padding: 56px 0 72px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 360px);
  align-items: end;
  gap: 34px;
}

.hero-copy {
  max-width: 720px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 18px;
  font-size: clamp(3rem, 8vw, 6.8rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.hero-copy p:last-child {
  max-width: 620px;
  margin-bottom: 0;
  color: rgba(255, 253, 246, 0.88);
  font-size: 1.14rem;
}

.hero-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.2);
  box-shadow: var(--shadow);
}

.hero-panel div {
  min-width: 0;
  padding: 18px 14px;
  background: rgba(24, 33, 29, 0.62);
}

.metric-value,
.metric-label {
  display: block;
}

.metric-value {
  font-size: 1.65rem;
  font-weight: 900;
}

.metric-label {
  color: rgba(255, 253, 246, 0.78);
  font-size: 0.8rem;
  font-weight: 800;
}

main {
  padding-bottom: 56px;
}

.controls-band {
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 244, 234, 0.92);
  backdrop-filter: blur(16px);
}

.controls {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.search-box {
  min-width: min(420px, 100%);
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.search-box input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  color: var(--ink);
  font: inherit;
  font-weight: 650;
  padding: 0 14px;
  outline: none;
}

.search-box input:focus {
  border-color: var(--river);
  box-shadow: 0 0 0 3px rgba(38, 124, 135, 0.16);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

button {
  font: inherit;
}

.filter-btn {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  color: var(--muted);
  cursor: pointer;
  font-weight: 850;
  padding: 0 14px;
}

.filter-btn.active {
  border-color: #1f5d40;
  background: var(--leaf);
  color: #fff;
}

.intro-strip,
.dino-grid,
.compare-section,
.sources {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.intro-strip {
  padding: 34px 0 18px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.intro-strip article {
  border-left: 4px solid var(--clay);
  padding: 4px 0 4px 16px;
}

.intro-strip strong,
.intro-strip span {
  display: block;
}

.intro-strip strong {
  font-size: 0.88rem;
}

.intro-strip span {
  color: var(--muted);
}

.dino-grid {
  padding: 20px 0 64px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.dino-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.dino-image {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #d8d0bf;
  cursor: zoom-in;
}

.dino-image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  filter: saturate(0.96) contrast(1.04);
  transition: transform 240ms ease;
}

.dino-card:hover .dino-image img {
  transform: scale(1.04);
}

.dino-image:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: -3px;
}

.diet-pill {
  position: absolute;
  left: 12px;
  bottom: 12px;
  border-radius: 999px;
  background: rgba(24, 33, 29, 0.82);
  color: #fffdf6;
  font-size: 0.76rem;
  font-weight: 900;
  padding: 6px 10px;
  text-transform: uppercase;
}

.dino-body {
  padding: 18px;
}

.dino-body h3 {
  margin-bottom: 2px;
  font-size: 1.36rem;
  line-height: 1.08;
}

.name-meaning {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
}

.stat-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}

.stat {
  min-height: 66px;
  border: 1px solid rgba(221, 211, 190, 0.9);
  border-radius: 8px;
  background: #fffdf7;
  padding: 10px;
}

.stat:nth-child(n + 3) {
  grid-column: 1 / -1;
  min-height: 0;
}

.stat span {
  display: block;
}

.stat dt,
.stat dd {
  margin: 0;
}

.stat-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.stat-value {
  margin-top: 2px;
  font-size: 0.92rem;
  font-weight: 900;
  line-height: 1.22;
}

.quick-fact {
  margin: 0;
  color: #38423b;
  font-size: 0.95rem;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.tag {
  border: 1px solid rgba(47, 122, 79, 0.28);
  border-radius: 999px;
  background: rgba(155, 182, 90, 0.16);
  color: #235538;
  font-size: 0.76rem;
  font-weight: 850;
  padding: 5px 9px;
}

.compare-section {
  padding: 18px 0 54px;
}

.section-heading {
  max-width: 720px;
  margin-bottom: 22px;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1;
}

.chart-wrap {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.chart {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  padding: 18px;
  box-shadow: var(--shadow);
}

.chart h3 {
  margin-bottom: 16px;
  font-size: 1.05rem;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(126px, 0.7fr) minmax(0, 1.4fr) 76px;
  align-items: center;
  gap: 12px;
  min-height: 36px;
  margin: 12px 0;
}

.bar-label {
  min-width: 0;
  font-size: 0.9rem;
  font-weight: 850;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #ebe2cf;
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--river), var(--fern), var(--gold));
}

.bar-value {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 900;
  text-align: right;
}

.sources {
  border-top: 1px solid var(--line);
  padding-top: 34px;
}

.sources p {
  max-width: 820px;
  color: var(--muted);
}

.sources ul {
  columns: 2;
  gap: 36px;
  padding-left: 20px;
}

.sources li {
  break-inside: avoid;
  margin: 8px 0;
}

.empty-state {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.72);
  padding: 36px;
  text-align: center;
  color: var(--muted);
  font-weight: 800;
}

.admin-page {
  background: #f8f4ea;
}

.admin-header {
  min-height: 360px;
  background:
    linear-gradient(90deg, rgba(24, 33, 29, 0.9), rgba(24, 33, 29, 0.62)),
    url("https://upload.wikimedia.org/wikipedia/commons/thumb/b/b4/T-Rex.jpg/1280px-T-Rex.jpg") center / cover;
  color: #fffdf6;
}

.admin-hero,
.admin-main,
.admin-dashboard,
.admin-auth {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.admin-hero {
  padding: 72px 0 84px;
}

.admin-hero h1 {
  max-width: 780px;
  margin-bottom: 14px;
  font-size: clamp(2.7rem, 7vw, 5.8rem);
  line-height: 0.96;
}

.admin-hero p:last-child {
  max-width: 660px;
  color: rgba(255, 253, 246, 0.86);
  font-size: 1.08rem;
}

.admin-main {
  padding: 34px 0 72px;
}

.admin-auth,
.admin-form,
.admin-list-panel,
.import-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  box-shadow: var(--shadow);
}

.admin-auth {
  padding: 24px;
}

.admin-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 244, 234, 0.94);
  padding: 14px 0;
  backdrop-filter: blur(16px);
}

.admin-split {
  display: grid;
  grid-template-columns: minmax(320px, 0.78fr) minmax(0, 1fr);
  gap: 18px;
  padding: 24px 0;
}

.admin-form,
.admin-list-panel,
.import-panel {
  padding: 22px;
}

.admin-form {
  align-self: start;
}

.admin-form label {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.admin-form input,
.admin-form textarea,
#importJson {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
  color: var(--ink);
  font: inherit;
  font-weight: 650;
  padding: 11px 12px;
  outline: none;
}

.admin-form textarea,
#importJson {
  min-height: 140px;
  resize: vertical;
}

.admin-form input:focus,
.admin-form textarea:focus,
#importJson:focus {
  border-color: var(--river);
  box-shadow: 0 0 0 3px rgba(38, 124, 135, 0.16);
}

.compact-form {
  max-width: 520px;
  box-shadow: none;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-note {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.primary-action,
.secondary-action,
.danger-action {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
  padding: 0 14px;
}

.primary-action {
  background: var(--leaf);
  color: #fff;
}

.secondary-action {
  border-color: var(--line);
  background: #fffdf7;
  color: var(--muted);
}

.danger-action {
  border-color: rgba(189, 93, 60, 0.36);
  background: rgba(189, 93, 60, 0.1);
  color: #8d3d28;
}

.status-line {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--river);
  font-weight: 850;
}

.image-preview {
  min-height: 124px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #eee7d7;
  color: var(--muted);
  font-weight: 850;
  text-align: center;
}

.image-preview img {
  width: 100%;
  max-height: 260px;
  display: block;
  object-fit: cover;
}

.admin-list {
  display: grid;
  gap: 10px;
}

.admin-entry {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid rgba(221, 211, 190, 0.88);
  border-radius: 8px;
  background: #fffaf0;
  padding: 10px;
}

.admin-entry img,
.admin-entry-thumb {
  width: 82px;
  height: 68px;
  border-radius: 6px;
  object-fit: cover;
  background: #d8d0bf;
}

.admin-entry-thumb {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-align: center;
}

.admin-entry h3 {
  margin-bottom: 4px;
  font-size: 1.06rem;
}

.admin-entry p {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.admin-entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-entry-actions button {
  min-height: 34px;
}

.import-panel {
  margin-top: 10px;
}

.json-format {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #18211d;
  color: #fffdf6;
  padding: 14px;
  font-size: 0.86rem;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 24px;
}

.image-modal.open {
  display: grid;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(24, 33, 29, 0.78);
  cursor: zoom-out;
}

.modal-content {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  border: 1px solid rgba(255, 253, 246, 0.3);
  border-radius: 8px;
  background: #fffdf7;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
  overflow: hidden;
}

.modal-content img {
  width: 100%;
  display: block;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #d8d0bf;
}

.modal-content h2 {
  margin: 0;
  padding: 16px 18px 18px;
  font-size: clamp(1.4rem, 3vw, 2.4rem);
  line-height: 1;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  background: rgba(24, 33, 29, 0.72);
  color: #fffdf6;
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 900;
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 980px) {
  .site-header {
    min-height: 760px;
  }

  .hero {
    grid-template-columns: 1fr;
    align-content: end;
  }

  .dino-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-wrap,
  .intro-strip,
  .admin-split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .topbar,
  .controls {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-links {
    width: 100%;
    justify-content: space-between;
  }

  .filter-group {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .filter-btn {
    white-space: nowrap;
  }

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

  .hero-panel {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 6px;
    margin: 18px 0;
  }

  .bar-value {
    text-align: left;
  }

  .sources ul {
    columns: 1;
  }

  .image-modal {
    padding: 14px;
  }

  .admin-toolbar,
  .form-grid {
    grid-template-columns: 1fr;
    align-items: stretch;
    flex-direction: column;
  }

  .admin-entry {
    grid-template-columns: 68px minmax(0, 1fr);
  }

  .admin-entry img,
  .admin-entry-thumb {
    width: 68px;
    height: 58px;
  }
}
