:root {
  --ink: #02060a;
  --moss: #071018;
  --leaf: #0d3a42;
  --mint: #6ee7f5;
  --foam: #e8f6ef;
  --sun: #f0b429;
  --sun-deep: #d4920a;
  --muted: rgba(232, 246, 239, 0.62);
  --line: rgba(110, 231, 245, 0.16);
  --danger: #ff6b6b;
  --radius: 14px;
  --font-display: "Noto Serif SC", "Songti SC", serif;
  --font-body: "DM Sans", "Noto Sans SC", sans-serif;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--foam);
  background: #000;
  line-height: 1.6;
  position: relative;
  overflow-x: hidden;
}

.dragon-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: #000;
}

.page-veil {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.12) 0%, rgba(0, 8, 14, 0.22) 45%, rgba(0, 0, 0, 0.55) 100%);
}

.hero,
.section,
.site-footer {
  position: relative;
  z-index: 2;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem clamp(1.2rem, 4vw, 3rem);
  background: linear-gradient(180deg, rgba(7, 26, 20, 0.72), rgba(7, 26, 20, 0));
  backdrop-filter: blur(2px);
}

.brand {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.brand span {
  color: var(--sun);
}

.nav-links {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.nav-links a:hover {
  color: var(--foam);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 0;
  border-radius: 999px;
  padding: 0.85rem 1.4rem;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--sun);
  color: #1a1200;
  font-weight: 700;
}

.btn-primary:hover {
  background: #ffc44d;
}

.btn-ghost {
  background: transparent;
  color: var(--foam);
  border: 1px solid var(--line);
}

.btn-ghost:hover {
  border-color: var(--mint);
  color: var(--mint);
}

.btn-danger {
  background: rgba(255, 107, 107, 0.15);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, 0.35);
}

.hero {
  min-height: auto;
  overflow: hidden;
  padding: 5.2rem clamp(1.2rem, 4vw, 3rem) 1.6rem;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(240px, 0.95fr) minmax(260px, 1.1fr);
  gap: clamp(1.2rem, 3vw, 2.5rem);
  align-items: start;
  width: min(1100px, 100%);
}

.hero-main {
  animation: rise 0.9s ease both;
}

.hero-brand {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 3.6vw, 2.4rem);
  line-height: 1.15;
  margin: 0 0 0.5rem;
  letter-spacing: 0.04em;
}

.hero-brand em {
  font-style: normal;
  color: var(--sun);
}

.hero-lead {
  margin: 0 0 1.1rem;
  max-width: 28ch;
  font-size: clamp(0.95rem, 1.6vw, 1.08rem);
  color: var(--muted);
}

.hero-about {
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(0, 12, 18, 0.62);
  backdrop-filter: blur(8px);
  animation: rise 0.9s ease 0.12s both;
}

.hero-about h2 {
  margin: 0 0 0.55rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--sun);
}

.hero-about p {
  margin: 0 0 0.7rem;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.75;
}

.hero-about p:last-child {
  margin-bottom: 0;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

@media (max-width: 820px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }
}

.section {
  padding: clamp(1.8rem, 4vh, 3rem) clamp(1.2rem, 4vw, 3rem);
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 1.8rem;
}

.section-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 700;
}

.section-head p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  max-width: 40ch;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.search-box,
.select-box,
.field input,
.field textarea,
.field select {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--foam);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  outline: none;
}

.search-box {
  flex: 1 1 240px;
  max-width: 360px;
}

.select-box {
  flex: 0 1 160px;
}

.search-box:focus,
.select-box:focus,
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--mint);
}

.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.1rem;
}

.resource-item {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 280px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 12, 18, 0.68);
  backdrop-filter: blur(6px);
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.25s ease, background 0.2s ease;
  animation: rise 0.6s ease both;
}

.resource-item:hover {
  transform: translateY(-4px);
  border-color: rgba(110, 231, 245, 0.45);
  background: rgba(0, 20, 28, 0.82);
}

.resource-cover {
  height: 140px;
  background:
    linear-gradient(180deg, transparent 20%, rgba(7, 26, 20, 0.85)),
    var(--cover, linear-gradient(135deg, #1f5c45, #0b2a20));
  background-size: cover;
  background-position: center;
}

.resource-body {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 1rem 1.1rem 1.15rem;
  flex: 1;
}

.resource-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.resource-item h3 {
  margin: 0;
  font-size: 1.15rem;
  font-family: var(--font-display);
  line-height: 1.35;
}

.resource-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.resource-foot {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--mint);
}

.empty-state {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  padding: 1rem;
  background: rgba(2, 10, 8, 0.72);
  backdrop-filter: blur(6px);
}

.modal.open {
  display: grid;
}

.modal-panel {
  width: min(560px, 100%);
  max-height: min(85vh, 720px);
  overflow: auto;
  background: linear-gradient(180deg, #123528, #0b231b);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1.4rem;
  animation: rise 0.35s ease both;
}

.modal-panel h3 {
  margin: 0 0 0.6rem;
  font-family: var(--font-display);
  font-size: 1.6rem;
}

.modal-panel .desc {
  color: var(--muted);
  white-space: pre-wrap;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.3rem;
}

.site-footer {
  padding: 2rem clamp(1.2rem, 4vw, 3rem) 3rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

/* Admin */
.admin-body {
  min-height: 100vh;
}

.admin-shell {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.admin-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.admin-top h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3vw, 2.4rem);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(8, 28, 22, 0.55);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.panel h2 {
  margin: 0 0 1rem;
  font-size: 1.2rem;
  font-family: var(--font-display);
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(8, 28, 22, 0.7);
  padding: 2rem 1.5rem;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2.2rem;
}

.login-card p {
  margin: 0.4rem 0 1.4rem;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 0.95rem;
}

.field label {
  font-size: 0.9rem;
  color: var(--muted);
}

.field textarea {
  min-height: 110px;
  resize: vertical;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 1rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 0.8rem 0.55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 0.92rem;
}

th {
  color: var(--muted);
  font-weight: 600;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 60;
  background: #123528;
  border: 1px solid rgba(143, 214, 181, 0.4);
  color: var(--foam);
  padding: 0.8rem 1rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.share-link-box {
  margin-top: 1.1rem;
}

.share-link-box label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.share-link-row {
  display: flex;
  gap: 0.5rem;
}

.share-link-row input {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--foam);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  outline: none;
}

.share-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 5rem 1.2rem 2rem;
}

.share-card {
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(8, 28, 22, 0.7);
  box-shadow: var(--shadow);
  padding: 1.8rem 1.4rem;
  animation: rise 0.45s ease both;
}

.share-card h1 {
  margin: 0 0 0.55rem;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.4rem);
}

.share-kicker {
  margin: 0 0 0.6rem;
  color: var(--sun);
  letter-spacing: 0.08em;
  font-size: 0.85rem;
}

.share-meta {
  margin: 0 0 0.9rem;
  color: var(--muted);
  font-size: 0.92rem;
}

code {
  color: var(--mint);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.upload-progress {
  margin: 1rem 0 0.4rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.upload-progress-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--leaf), var(--sun));
  transition: width 0.2s ease;
}

.upload-progress-text {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.hidden {
  display: none !important;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 720px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .nav-links a:not(.btn) {
    display: none;
  }
}
