:root {
  color-scheme: dark;
  --sd-bg: #030713;
  --sd-panel: rgba(5, 12, 28, .88);
  --sd-panel-2: rgba(10, 24, 48, .72);
  --sd-text: #eaf8ff;
  --sd-muted: #8fb3c7;
  --sd-cyan: #22e8ff;
  --sd-green: #56ffb5;
  --sd-gold: #ffe66a;
  --sd-pink: #ff4fb8;
  --sd-line: rgba(34, 232, 255, .34);
}

* { box-sizing: border-box; }

body.seedark-world-page {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, Segoe UI, Arial, sans-serif;
  color: var(--sd-text);
  background:
    radial-gradient(circle at 14% 14%, rgba(34, 232, 255, .18), transparent 29%),
    radial-gradient(circle at 84% 10%, rgba(255, 79, 184, .12), transparent 26%),
    radial-gradient(circle at 50% 84%, rgba(86, 255, 181, .08), transparent 34%),
    linear-gradient(180deg, #030713, #071426 56%, #02040f);
}

body.seedark-world-page:before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .16;
  background-image:
    linear-gradient(rgba(34, 232, 255, .18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 232, 255, .08) 1px, transparent 1px);
  background-size: 100% 48px, 54px 100%;
  mask-image: linear-gradient(180deg, black, transparent 84%);
}

.world-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 72px;
}

.world-topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0 22px;
  background: linear-gradient(180deg, rgba(3, 7, 19, .96), rgba(3, 7, 19, .74));
  backdrop-filter: blur(18px);
}

.world-brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-decoration: none;
  color: var(--sd-text);
}

.world-brand strong {
  font-size: 22px;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-shadow: 0 0 18px rgba(34, 232, 255, .75);
}

.world-brand span,
.world-kicker {
  color: var(--sd-muted);
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.world-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  justify-content: flex-end;
}

.world-nav a,
.world-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 39px;
  padding: 10px 13px;
  border: 1px solid var(--sd-line);
  border-radius: 8px;
  color: var(--sd-text);
  background: rgba(34, 232, 255, .07);
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}

.world-nav a:hover,
.world-nav a.active,
.world-button:hover {
  border-color: var(--sd-cyan);
  box-shadow: 0 0 22px rgba(34, 232, 255, .18);
}

.world-button.secondary {
  border-color: rgba(255, 79, 184, .32);
  background: rgba(255, 79, 184, .08);
}

.world-hero {
  display: grid;
  gap: 16px;
  padding: 34px 0 22px;
}

.world-hero h1 {
  margin: 0;
  max-width: 920px;
  font-size: clamp(34px, 6vw, 74px);
  line-height: .95;
  letter-spacing: 0;
  text-shadow: 0 0 28px rgba(34, 232, 255, .55);
}

.world-hero p {
  margin: 0;
  max-width: 760px;
  color: #b6d8e8;
  font-size: 17px;
  line-height: 1.6;
}

.world-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.world-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.world-section-head h2 {
  margin: 4px 0 0;
}

.world-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

.world-card {
  border: 1px solid var(--sd-line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(12, 27, 55, .78), rgba(4, 9, 22, .9)),
    radial-gradient(circle at 15% 0%, rgba(34, 232, 255, .14), transparent 36%);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .34), inset 0 0 28px rgba(34, 232, 255, .04);
  padding: 18px;
}

.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

.feed-list,
.memory-list,
.npc-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.feed-item,
.memory-item {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(34, 232, 255, .22);
  border-radius: 8px;
  background: rgba(2, 8, 20, .58);
}

.feed-time,
.memory-type,
.world-label {
  color: var(--sd-gold);
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.feed-type {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 8px;
  padding: 5px 8px;
  border: 1px solid rgba(86, 255, 181, .36);
  border-radius: 999px;
  color: var(--sd-green);
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.feed-item h2,
.memory-item h2,
.world-card h2 {
  margin: 0 0 8px;
  font-size: 20px;
  letter-spacing: 0;
}

.feed-item p,
.memory-item p,
.world-card p {
  margin: 0;
  color: var(--sd-muted);
  line-height: 1.5;
}

.generated-world-list {
  display: grid;
  gap: 12px;
}

.generated-world-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(34, 232, 255, .22);
  border-radius: 8px;
  background: rgba(2, 8, 20, .58);
}

.generated-world-item h3 {
  margin: 0 0 8px;
  font-size: 19px;
}

.generated-world-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 11px;
  color: var(--sd-gold);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.generated-world-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.generated-world-empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(34, 232, 255, .2);
  border-radius: 8px;
  background: rgba(2, 8, 20, .52);
}

.world-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.world-stat {
  padding: 16px;
  border: 1px solid rgba(34, 232, 255, .26);
  border-radius: 8px;
  background: rgba(2, 8, 20, .58);
}

.world-stat b {
  display: block;
  color: var(--sd-gold);
  font-size: 30px;
  line-height: 1;
}

.world-stat span {
  display: block;
  margin-top: 9px;
  color: var(--sd-muted);
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.world-form {
  display: grid;
  gap: 12px;
}

.world-input,
.world-textarea {
  width: 100%;
  padding: 14px 15px;
  color: var(--sd-text);
  background: rgba(3, 7, 19, .82);
  border: 1px solid rgba(34, 232, 255, .55);
  border-radius: 8px;
  outline: none;
  font: inherit;
}

.world-textarea {
  min-height: 108px;
  resize: vertical;
}

.world-textarea.compact {
  min-height: 82px;
}

.world-import-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(34, 232, 255, .2);
  border-radius: 8px;
  background: rgba(2, 8, 20, .5);
}

.world-import-panel[hidden] {
  display: none;
}

.world-share-status {
  min-height: 20px;
  color: var(--sd-gold);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.json-preview {
  margin: 0;
  min-height: 420px;
  overflow: auto;
  padding: 16px;
  border: 1px solid rgba(86, 255, 181, .28);
  border-radius: 8px;
  color: #bdfdde;
  background: rgba(1, 7, 14, .78);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.companion-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  min-width: 58px;
  min-height: 58px;
  border: 1px solid rgba(34, 232, 255, .72);
  border-radius: 999px;
  color: var(--sd-text);
  background: radial-gradient(circle at 28% 22%, rgba(255, 255, 255, .2), transparent 24%), rgba(4, 13, 30, .96);
  box-shadow: 0 0 28px rgba(34, 232, 255, .32);
  cursor: pointer;
  font: 700 12px/1 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: .1em;
}

.companion-fab-inline {
  box-shadow: 0 0 28px rgba(34, 232, 255, .32), 0 0 0 6px rgba(3, 7, 19, .72);
}

.companion-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 21;
  width: min(390px, 100vw);
  height: 100vh;
  padding: 22px;
  border-left: 1px solid rgba(34, 232, 255, .48);
  background: rgba(3, 7, 19, .96);
  box-shadow: -24px 0 70px rgba(0, 0, 0, .55);
  transform: translateX(104%);
  transition: transform .2s ease;
}

.companion-panel.open { transform: translateX(0); }

.companion-inline-dock {
  margin-top: 16px;
}

.companion-inline-dock .companion-panel {
  position: static;
  width: 100%;
  height: auto;
  max-height: none;
  padding: 18px;
  border: 1px solid rgba(34, 232, 255, .32);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(12, 27, 55, .78), rgba(4, 9, 22, .92)),
    radial-gradient(circle at 90% 0%, rgba(255, 79, 184, .12), transparent 38%);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .28), inset 0 0 28px rgba(34, 232, 255, .04);
  transform: none;
  display: none;
}

.companion-inline-dock .companion-panel.open {
  display: block;
  transform: none;
}

.companion-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.companion-head h2 { margin: 0; }

.companion-close {
  border: 1px solid rgba(34, 232, 255, .38);
  border-radius: 8px;
  color: var(--sd-text);
  background: rgba(34, 232, 255, .07);
  min-width: 38px;
  min-height: 38px;
  cursor: pointer;
}

.companion-message {
  margin: 0 0 12px;
  padding: 14px;
  border: 1px solid rgba(34, 232, 255, .24);
  border-radius: 8px;
  color: #cceef8;
  background: rgba(7, 18, 38, .82);
}

.companion-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 14px;
}

.home-world-strip {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 16px 24px 0;
}

.home-world-strip a {
  text-decoration: none;
  color: var(--sd-text);
  border: 1px solid var(--sd-line);
  border-radius: 8px;
  background: rgba(3, 7, 19, .74);
  padding: 14px;
}

.home-world-strip b {
  display: block;
  margin-bottom: 6px;
  color: var(--sd-gold);
}

.home-world-strip span {
  color: var(--sd-muted);
  font-size: 12px;
}

@media (max-width: 860px) {
  .world-topbar { position: static; align-items: flex-start; flex-direction: column; }
  .world-nav { justify-content: flex-start; }
  .world-grid { grid-template-columns: 1fr; }
  .span-4,
  .span-5,
  .span-7,
  .span-8,
  .span-12 { grid-column: auto; }
  .world-stat-grid,
  .home-world-strip { grid-template-columns: 1fr; }
  .feed-item,
  .memory-item,
  .generated-world-item { grid-template-columns: 1fr; }
  .world-section-head,
  .generated-world-empty { align-items: flex-start; flex-direction: column; }
  .generated-world-actions { justify-content: flex-start; }
}
