:root {
  --bg: #090c11;
  --bg-soft: #0d1118;
  --panel: #111722;
  --panel-2: #171e2a;
  --panel-3: #1d2634;
  --line: #293446;
  --text: #f3f5f8;
  --soft: #c6ceda;
  --muted: #8f9aae;
  --accent: #9d8cff;
  --accent-2: #63c8ff;
  --good: #7de4a3;
  --danger: #ff7b88;
  --shadow: 0 28px 80px rgba(0,0,0,.34);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 10% -10%, rgba(157,140,255,.11), transparent 33rem),
    radial-gradient(circle at 95% 3%, rgba(99,200,255,.06), transparent 26rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, textarea, select { font: inherit; }
button { color: inherit; }
a { color: inherit; }
.hidden { display: none !important; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  align-items: center;
  gap: 24px;
  min-height: 72px;
  padding: 10px clamp(14px, 3vw, 34px);
  border-bottom: 1px solid rgba(255,255,255,.07);
  background: rgba(9,12,17,.88);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: max-content;
  text-decoration: none;
}

.brand-glyph {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  color: #06080b;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  font-weight: 950;
  font-size: 1.2rem;
  box-shadow: 0 8px 26px rgba(130,125,255,.23);
}

.brand-copy strong, .brand-copy small { display: block; }
.brand-copy strong { letter-spacing: .055em; font-size: .86rem; }
.brand-copy small { margin-top: 2px; color: var(--muted); font-size: .72rem; }

.top-nav {
  display: flex;
  justify-content: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.top-nav::-webkit-scrollbar { display: none; }

.top-nav button {
  border: 0;
  border-radius: 9px;
  padding: 8px 10px;
  white-space: nowrap;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: .86rem;
}
.top-nav button:hover, .top-nav button.active {
  color: white;
  background: var(--panel-2);
}

.header-actions { display: flex; align-items: center; gap: 8px; }

.icon-button, .lock-button {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  cursor: pointer;
}
.icon-button { width: 39px; height: 39px; font-size: 1.25rem; }
.lock-button { padding: 9px 12px; color: var(--soft); font-weight: 750; }
.lock-button.unlocked { color: var(--good); border-color: rgba(125,228,163,.34); }

.author-bar {
  position: sticky;
  top: 72px;
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px clamp(14px, 3vw, 34px);
  border-bottom: 1px solid rgba(125,228,163,.15);
  background: rgba(15,38,27,.94);
  color: #bceccc;
  backdrop-filter: blur(18px);
  font-size: .86rem;
}
.author-bar > div { display: flex; gap: 7px; }

.button {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 13px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-weight: 750;
}
.button:hover { border-color: #47566f; }
.button.primary {
  border-color: transparent;
  color: white;
  background: linear-gradient(135deg, #8f7cff, #6d91ff);
}
.button.danger {
  color: #ffd8dd;
  border-color: rgba(255,123,136,.34);
  background: rgba(255,123,136,.08);
}
.button.full { width: 100%; }

.app {
  width: min(1280px, calc(100% - 30px));
  margin: 0 auto;
  padding: clamp(28px, 5vw, 64px) 0 90px;
}

.hero {
  position: relative;
  overflow: hidden;
  min-height: 480px;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, .7fr);
  align-items: center;
  gap: 28px;
  padding: clamp(34px, 6vw, 78px);
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(157,140,255,.08), transparent 40%),
    var(--panel);
  box-shadow: var(--shadow);
}

.hero-copy { position: relative; z-index: 2; }

.eyebrow {
  margin: 0 0 10px;
  color: #9ba8bb;
  font-size: .7rem;
  font-weight: 900;
  letter-spacing: .17em;
}

.hero h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(3rem, 7vw, 6.7rem);
  line-height: .91;
  letter-spacing: -.055em;
}
.hero-text {
  max-width: 680px;
  margin: 25px 0 0;
  color: var(--soft);
  font-size: clamp(1rem, 1.5vw, 1.15rem);
  line-height: 1.75;
}

.hero-search {
  display: flex;
  gap: 9px;
  max-width: 620px;
  margin-top: 28px;
}

.hero-art {
  position: relative;
  min-height: 320px;
}
.hero-symbol {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  width: 150px;
  height: 150px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 50%;
  color: white;
  background: rgba(255,255,255,.04);
  box-shadow: 0 0 80px rgba(125,140,255,.2);
  font-size: 4.5rem;
  backdrop-filter: blur(10px);
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(4px);
}
.orb-one {
  width: 240px; height: 240px; top: 10%; left: 3%;
  background: radial-gradient(circle, rgba(157,140,255,.35), transparent 70%);
}
.orb-two {
  width: 220px; height: 220px; right: 0; bottom: 0;
  background: radial-gradient(circle, rgba(99,200,255,.22), transparent 70%);
}

.home-section { margin-top: 58px; }

.section-title-row, .page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}
.section-title-row h2 { margin: 0; font-size: 2rem; }

.category-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 13px;
}

.category-card {
  min-height: 170px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--panel);
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease;
}
.category-card:hover { transform: translateY(-3px); border-color: #46556c; }
.category-symbol { color: var(--accent-2); font-size: 1.7rem; }
.category-card h3 { margin: 18px 0 4px; font-size: 1.25rem; }
.category-card p { margin: 0; color: var(--muted); line-height: 1.5; font-size: .86rem; }
.category-card footer {
  display: flex; justify-content: space-between; margin-top: 14px; color: var(--muted); font-size: .76rem;
}

.entry-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 16px;
}

.entry-card {
  overflow: hidden;
  min-height: 310px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease;
}
.entry-card:hover { transform: translateY(-3px); border-color: #46556c; }

.entry-card-image,
.entry-card-placeholder {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0a0e14;
}
.entry-card-image { display: block; object-fit: cover; }
.entry-card-placeholder {
  display: grid; place-items: center;
  color: #617087;
  background:
    radial-gradient(circle at 30% 20%, rgba(157,140,255,.13), transparent 45%),
    #111722;
  font-size: 2.5rem;
}
.entry-card-content { padding: 16px 17px 18px; }
.entry-card-kicker { color: var(--accent-2); font-size: .68rem; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.entry-card h3 { margin: 6px 0 4px; font-size: 1.3rem; }
.entry-card-subtitle { margin: 0; color: var(--soft); font-size: .9rem; }
.entry-card-summary {
  display: -webkit-box;
  overflow: hidden;
  margin: 11px 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: .9rem;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255,255,255,.02);
  font-size: .71rem;
}

.page-heading {
  align-items: center;
  padding-bottom: 25px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.page-heading h1 {
  margin: 0;
  font-size: clamp(2.7rem, 6vw, 5.6rem);
  line-height: .95;
  letter-spacing: -.05em;
}
.page-description { max-width: 650px; margin: 13px 0 0; color: var(--muted); line-height: 1.6; }

.inline-search { width: min(360px, 100%); }
.inline-search span, .field > span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 800;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  outline: none;
  border-radius: 10px;
  padding: 10px 11px;
  color: var(--text);
  background: #0b0f15;
}
textarea { resize: vertical; line-height: 1.55; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }

.result-meta { margin: 0 0 18px; color: var(--muted); }

.empty-state {
  grid-column: 1 / -1;
  padding: 58px 22px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
}

.back-button {
  margin-bottom: 18px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.back-button:hover { color: white; }

.wiki-article { min-width: 0; }

.article-hero {
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0,1fr) 390px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.article-title-block { padding: clamp(30px, 5vw, 60px); }
.article-title-block h1 {
  margin: 5px 0 10px;
  font-size: clamp(3rem, 7vw, 6.6rem);
  line-height: .9;
  letter-spacing: -.055em;
}
.article-subtitle { color: var(--soft); font-size: 1.08rem; }
.article-summary { max-width: 780px; margin-top: 28px; color: var(--soft); line-height: 1.75; }

.article-cover {
  min-height: 420px;
  background: #090d12;
}
.article-cover img {
  width: 100%; height: 100%; min-height: 420px; max-height: 620px; object-fit: cover; display: block;
}
.article-cover-placeholder {
  width: 100%; height: 100%; min-height: 420px; display: grid; place-items: center;
  color: #536177; font-size: 4rem;
  background:
    radial-gradient(circle at 30% 30%, rgba(157,140,255,.15), transparent 45%),
    #0f151e;
}

.article-toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 23px;
}

.article-layout {
  display: grid;
  grid-template-columns: minmax(0,1fr) 330px;
  gap: 22px;
  margin-top: 22px;
}

.article-main, .article-side {
  min-width: 0;
}

.article-section {
  position: relative;
  margin-bottom: 18px;
  padding: clamp(22px, 4vw, 38px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}
.article-section h2 {
  margin: 0 0 15px;
  padding-bottom: 11px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  font-size: 1.75rem;
}
.article-section-body {
  white-space: pre-wrap;
  color: #d9dfe8;
  line-height: 1.82;
}
.section-edit-button {
  position: absolute; top: 18px; right: 18px;
}

.infobox, .side-card {
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}
.infobox-title {
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(157,140,255,.18), rgba(99,200,255,.08));
  font-weight: 900;
}
.infobox-row {
  display: grid;
  grid-template-columns: 42% 58%;
  gap: 10px;
  padding: 11px 14px;
  border-top: 1px solid rgba(255,255,255,.06);
  font-size: .88rem;
}
.infobox-row span:first-child { color: var(--muted); font-weight: 800; }
.infobox-row span:last-child { color: var(--soft); word-break: break-word; }

.side-card h3 {
  margin: 0;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  font-size: 1rem;
}
.side-card-content { padding: 14px; }

.relationship-list { display: grid; gap: 9px; }
.relationship-item {
  display: grid;
  grid-template-columns: 46px minmax(0,1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 11px;
  background: var(--bg-soft);
}
.relationship-thumb {
  width: 46px; height: 46px; overflow: hidden; display: grid; place-items: center;
  border-radius: 9px; background: var(--panel-3); color: var(--muted);
}
.relationship-thumb img { width: 100%; height: 100%; object-fit: cover; }
.relationship-name { font-weight: 800; font-size: .9rem; cursor: pointer; }
.relationship-label { color: var(--accent-2); font-size: .75rem; }
.relationship-note { margin-top: 3px; color: var(--muted); font-size: .75rem; line-height: 1.35; }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 8px;
}
.gallery-item {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  border-radius: 10px;
  background: var(--bg-soft);
  cursor: pointer;
}
.gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-caption {
  position: absolute; inset: auto 0 0 0; padding: 25px 8px 7px;
  background: linear-gradient(transparent, rgba(0,0,0,.76));
  font-size: .7rem;
}
.gallery-delete {
  position: absolute; top: 6px; right: 6px;
  width: 28px; height: 28px; border: 1px solid rgba(255,255,255,.2);
  border-radius: 8px; background: rgba(0,0,0,.62); cursor: pointer;
}

.modal {
  width: min(760px, calc(100vw - 24px));
  max-height: 90vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 19px;
  padding: 0;
  color: var(--text);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(3px); }
.modal form { padding: 25px; }
.compact-modal { width: min(440px, calc(100vw - 24px)); }
.editor-modal { width: min(880px, calc(100vw - 24px)); }
.modal-close {
  float: right;
  width: 36px; height: 36px;
  border: 0; border-radius: 9px;
  background: var(--panel-2); color: white;
  cursor: pointer; font-size: 1.3rem;
}
.modal h2 { margin: 4px 0 8px; font-size: 1.8rem; }
.muted { color: var(--muted); line-height: 1.55; }
.field { display: block; margin: 15px 0; }
.field small { display: block; margin-top: 6px; color: var(--muted); }
.form-grid { display: grid; gap: 12px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); margin: 18px 0; }
.form-grid .field { margin: 0; }
.check-field { display: flex; gap: 9px; align-items: center; margin: 16px 0; color: var(--soft); }
.check-field input { width: auto; }
.modal-actions { display: flex; gap: 9px; align-items: center; margin-top: 22px; }
.spacer { flex: 1; }
.error {
  padding: 10px 12px;
  border: 1px solid rgba(255,123,136,.3);
  border-radius: 10px;
  color: #ffc1c8;
  background: rgba(255,123,136,.08);
}

.toast {
  position: fixed;
  right: 20px; bottom: 20px;
  z-index: 80;
  max-width: min(390px, calc(100vw - 40px));
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #1b2431;
  box-shadow: var(--shadow);
}

@media (max-width: 1050px) {
  .site-header { grid-template-columns: auto 1fr auto; }
  .brand-copy small { display: none; }
  .category-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .entry-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .article-layout { grid-template-columns: minmax(0,1fr) 300px; }
}

@media (max-width: 820px) {
  .site-header { grid-template-columns: auto auto; }
  .top-nav {
    grid-column: 1 / -1;
    order: 3;
    justify-content: start;
    margin: -4px -4px 0;
    padding-bottom: 2px;
  }
  .header-actions { justify-self: end; }
  .author-bar { top: 110px; }
  .hero { grid-template-columns: 1fr; min-height: auto; }
  .hero-art { min-height: 220px; }
  .category-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .article-hero { grid-template-columns: 1fr; }
  .article-cover { order: -1; min-height: 300px; }
  .article-cover img, .article-cover-placeholder { min-height: 300px; max-height: 520px; }
  .article-layout { grid-template-columns: 1fr; }
  .article-side { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
  .infobox { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .brand-copy { display: none; }
  .lock-button { font-size: 0; }
  .lock-button::after { content: "🔒"; font-size: 1rem; }
  .lock-button.unlocked::after { content: "🔓"; }
  .app { width: min(100% - 20px, 1280px); padding-top: 22px; }
  .hero { padding: 27px 20px; border-radius: 20px; }
  .hero h1 { font-size: clamp(2.8rem, 16vw, 4.7rem); }
  .hero-search { flex-direction: column; }
  .category-grid, .entry-grid { grid-template-columns: 1fr; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .inline-search { width: 100%; }
  .article-title-block { padding: 26px 20px; }
  .article-title-block h1 { font-size: clamp(2.8rem, 15vw, 4.8rem); }
  .article-side { grid-template-columns: 1fr; }
  .form-grid.two { grid-template-columns: 1fr; }
  .author-bar { align-items: stretch; flex-direction: column; top: 110px; }
}
