:root {
  --night: #0e1318;
  --slate: #161d25;
  --stone: #24303b;
  --river: #3e6d78;
  --river-deep: #1c3a44;
  --lamp: #e6b56a;
  --lamp-soft: rgba(230, 181, 106, 0.18);
  --ember: #c45d38;
  --paper: #eadcc6;
  --paper-dim: #cbbda6;
  --mist: #8ea0ad;
  --line: rgba(234, 220, 198, 0.14);
  --ok: #8fbf9a;
  --shut: #8a5a52;
  font-family: Figtree, "Segoe UI", sans-serif;
  color: var(--paper);
  background: var(--night);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  background: var(--night);
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, textarea, input {
  font: inherit;
  color: inherit;
}

.sky {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(1200px 500px at 50% -10%, #243140, transparent 55%),
    radial-gradient(800px 400px at 80% 10%, rgba(230, 181, 106, 0.12), transparent 50%),
    linear-gradient(#121820, #0e1318 40%, #152028 70%, #1c3a44);
}
.sky:after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(#eadcc6 0.7px, transparent 0.8px);
  background-size: 140px 90px;
  opacity: 0.18;
}
.mist {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 28vh;
  z-index: -1;
  background: linear-gradient(transparent, rgba(28, 58, 68, 0.55));
  pointer-events: none;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 22px 28px 10px;
  max-width: 1180px;
  margin: 0 auto;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}
.brand strong {
  display: block;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.7rem;
  letter-spacing: 0.04em;
  line-height: 1;
}
.brand em {
  display: block;
  font-style: italic;
  color: var(--paper-dim);
  font-size: 0.92rem;
}
.mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 40% 40%, var(--lamp), #a36b2a 55%, #24303b 56%);
  box-shadow: 0 0 18px var(--lamp-soft);
}
nav { display: flex; gap: 18px; }
nav a {
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--mist);
  border-bottom: 1px solid transparent;
  padding-bottom: 4px;
}
nav a:hover, nav a.on { color: var(--lamp); border-color: var(--lamp); }

.view {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 28px 80px;
}

.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 28px;
  align-items: end;
  padding: 18px 0 28px;
}
.hero h1 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  font-size: clamp(2.4rem, 5vw, 4.2rem);
  line-height: 0.95;
  margin: 0 0 12px;
}
.hero p.lede {
  font-size: 1.12rem;
  color: var(--paper-dim);
  max-width: 38rem;
  line-height: 1.5;
}
.hero-img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: 18px 18px 4px 4px;
  border: 1px solid var(--line);
  display: block;
}

.banner {
  border: 1px solid rgba(196, 93, 56, 0.45);
  background: rgba(196, 93, 56, 0.12);
  color: var(--paper);
  padding: 12px 16px;
  border-radius: 10px;
  margin: 8px 0 22px;
}
.banner code { color: var(--lamp); }

.areas, .doors {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.card, .door {
  background: linear-gradient(180deg, rgba(36, 48, 59, 0.9), rgba(22, 29, 37, 0.92));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  transition: transform 0.18s ease, border-color 0.18s ease;
}
.card:hover, .door:hover {
  transform: translateY(-3px);
  border-color: rgba(230, 181, 106, 0.4);
}
.card-img {
  width: calc(100% + 36px);
  height: 150px;
  object-fit: cover;
  border-radius: 15px 15px 0 0;
  margin: -18px -18px 10px;
  display: block;
}
.area-img {
  width: 100%;
  height: 260px;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid var(--line);
  display: block;
  margin-bottom: 18px;
}
.card h2, .door h3 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.7rem;
  margin: 0;
}
.kicker {
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.68rem;
  color: var(--lamp);
}
.muted { color: var(--mist); line-height: 1.45; font-size: 0.95rem; }
.thesis {
  margin: 36px 0 10px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-size: 1.45rem;
  color: var(--paper);
  max-width: 40rem;
}

.door-plate {
  height: 92px;
  border-radius: 10px;
  background:
    linear-gradient(90deg, transparent 49.2%, rgba(12, 8, 6, 0.55) 50%, transparent 50.8%),
    linear-gradient(180deg, rgba(230, 181, 106, 0.12), transparent 45%),
    linear-gradient(90deg, #2a1d16 0%, #4a3326 18%, #3b281e 50%, #553926 82%, #2a1d16 100%);
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.4), inset 0 -10px 16px rgba(0,0,0,0.2);
}
.door-portrait {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid rgba(230, 181, 106, 0.25);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.resident-portrait {
  width: 96px;
  height: 96px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--line);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  margin-bottom: 12px;
}
.audit-head {
  display: flex;
  flex-direction: column;
}
.door-plate .handle {
  position: absolute;
  right: 14px;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--lamp);
  transform: translateY(-50%);
  box-shadow: 0 0 10px var(--lamp);
}
.door[data-door="shut"] .door-plate { filter: grayscale(0.4) brightness(0.7); }
.door[data-door="rebel"] .door-plate { background: linear-gradient(90deg, #4a241c, #2a1612); }
.door[data-door="open"] .door-plate:after {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 28%;
  background: linear-gradient(90deg, rgba(230,181,106,0.25), transparent);
}
.chip {
  align-self: flex-start;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--paper-dim);
}

.talk {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  min-height: 68vh;
}
.thread {
  background: rgba(22, 29, 37, 0.72);
  border: 1px solid var(--line);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  min-height: 68vh;
}
.thread-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.thread-head h1 {
  font-family: "Cormorant Garamond", Georgia, serif;
  margin: 0;
  font-size: 2rem;
}
.messages {
  flex: 1;
  overflow: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bubble {
  max-width: 80%;
  padding: 10px 12px;
  border-radius: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.bubble.user {
  align-self: flex-end;
  background: rgba(62, 109, 120, 0.35);
}
.bubble.resident {
  align-self: flex-start;
  background: rgba(36, 48, 59, 0.9);
  border: 1px solid var(--line);
}
.composer {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1;
  min-height: 52px;
  resize: vertical;
  background: #121820;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
button.primary, button.ghost {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
}
button.primary {
  background: var(--lamp);
  color: #1a140c;
  font-weight: 700;
}
button.primary:disabled { opacity: 0.45; cursor: not-allowed; }
button.ghost, a.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--paper);
  text-decoration: none;
}
button.danger {
  background: transparent;
  border: 1px solid rgba(196, 93, 56, 0.5);
  color: #e8b4a4;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}

.side {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel {
  background: rgba(22, 29, 37, 0.72);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}
.panel h2 {
  font-family: "Cormorant Garamond", Georgia, serif;
  margin: 0 0 8px;
  font-size: 1.35rem;
}
.gate {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}
.gate:last-child { border-bottom: 0; }
.gate .flag { color: var(--mist); }
.gate.ok .flag { color: var(--ok); }
.gate.bad .flag { color: #d08a7a; }
.note { font-size: 0.85rem; color: var(--mist); margin: 10px 0 0; }

.character-sheet .sheet-meta p {
  margin: 4px 0;
  font-size: 0.92rem;
}
.character-sheet .sheet-section {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.character-sheet .sheet-section h3 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.1rem;
  margin: 0 0 6px;
  color: var(--lamp);
}
.character-sheet .sheet-list {
  margin: 0;
  padding-left: 18px;
  font-size: 0.88rem;
  color: var(--paper-dim);
}
.character-sheet .sheet-list li {
  margin-bottom: 4px;
}
.character-sheet a {
  color: var(--lamp);
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color 0.15s ease;
}
.character-sheet a:hover {
  text-decoration-color: var(--lamp);
}

.report {
  background: #f3ead8;
  color: #2a2118;
  border-radius: 12px;
  padding: 28px;
  white-space: pre-wrap;
  font-family: Figtree, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  box-shadow: 0 20px 50px rgba(0,0,0,0.28);
}
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.empty {
  color: var(--mist);
  font-style: italic;
  padding: 12px 0;
}

.section-title {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 2rem;
  margin: 8px 0 16px;
}

.admin-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.admin-card {
  background: rgba(22, 29, 37, 0.72);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}
.admin-card h4 {
  margin: 0 0 4px;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--lamp);
}
.admin-card .stat-val {
  font-size: 1.8rem;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 700;
  color: var(--paper);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 0.9rem;
}
.admin-table th, .admin-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.admin-table th {
  color: var(--lamp);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.05rem;
  border-bottom: 1px solid rgba(230, 181, 106, 0.3);
}

.admin-login-box {
  max-width: 400px;
  margin: 40px auto;
  background: rgba(22, 29, 37, 0.85);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
}
.admin-login-box h2 {
  font-family: "Cormorant Garamond", Georgia, serif;
  margin-top: 0;
  font-size: 1.8rem;
}
.admin-login-box input[type="password"] {
  width: 100%;
  padding: 10px 14px;
  margin: 14px 0 18px;
  background: #121820;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--paper);
}

.foot {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 28px 40px;
  color: var(--mist);
  font-size: 0.88rem;
}

@media (max-width: 880px) {
  .hero, .areas, .doors, .talk { grid-template-columns: 1fr; }
  .top { padding: 16px; }
  .view { padding: 8px 16px 64px; }
  .hero-img { height: 160px; }
  .area-img { height: 180px; }
}
