:root {
  --void: #0a0405;
  --void-2: #14080a;
  --panel: rgba(28, 10, 12, 0.78);
  --line: rgba(232, 90, 90, 0.18);
  --text: #f6e8e8;
  --muted: #b39292;
  --gold: #e85a5a;
  --gold-soft: #c44747;
  --ember: #ff6b4a;
  --crimson: #b91c1c;
  --blood: #7f1d1d;
  --mist: rgba(246, 232, 232, 0.05);
  --danger: #ff7a7a;
  --warn: #e8a05a;
  --radius: 16px;
  --font: "Outfit", system-ui, sans-serif;
  --display: "Cormorant Garamond", Georgia, serif;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 520px at 50% -8%, rgba(185, 28, 28, 0.28), transparent 55%),
    radial-gradient(700px 480px at 90% 100%, rgba(127, 29, 29, 0.35), transparent 50%),
    radial-gradient(500px 400px at 10% 80%, rgba(232, 90, 90, 0.1), transparent 45%),
    linear-gradient(165deg, #120607 0%, #1a0a0c 42%, #080304 100%);
  background-attachment: fixed;
  font-weight: 300;
}

a { color: #ff8a8a; text-decoration: none; }
a:hover { color: #ffb0b0; }
code { background: rgba(255,255,255,0.05); padding: 0.1rem 0.35rem; border-radius: 6px; color: #ff8a8a; }

.btn, button {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: 999px;
  padding: 0.85rem 1.25rem;
  background: rgba(255,255,255,0.05);
  color: var(--text);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.btn:hover, button:hover { transform: translateY(-1px); }

.btn-small {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
  border-radius: 999px;
  border: 1px solid rgba(232, 90, 90, 0.35);
  background: rgba(185, 28, 28, 0.18);
  color: #ff9a9a;
  text-decoration: none;
}
.btn-small:hover { text-decoration: none; background: rgba(185, 28, 28, 0.28); }

.veil-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  padding: 2rem;
}

.veil {
  position: absolute;
  inset: -20%;
  pointer-events: none;
  filter: blur(40px);
  opacity: 0.6;
}
.veil-a {
  background:
    radial-gradient(circle at 30% 40%, rgba(185, 28, 28, 0.35), transparent 42%),
    radial-gradient(circle at 70% 60%, rgba(232, 90, 90, 0.18), transparent 40%);
  animation: drift 18s ease-in-out infinite alternate;
}
.veil-b {
  background:
    radial-gradient(circle at 60% 20%, rgba(246, 232, 232, 0.05), transparent 35%),
    radial-gradient(circle at 20% 80%, rgba(127, 29, 29, 0.25), transparent 40%);
  animation: drift 26s ease-in-out infinite alternate-reverse;
}
@keyframes drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to { transform: translate3d(3%, 2%, 0) scale(1.05); }
}

.sigil-field { position: absolute; inset: 0; pointer-events: none; }
.sigil {
  position: absolute;
  border: 1px solid rgba(232, 90, 90, 0.22);
  border-radius: 50%;
  animation: pulse-ring 8s ease-in-out infinite;
}
.sigil.s1 { width: 280px; height: 280px; left: 8%; top: 18%; }
.sigil.s2 { width: 420px; height: 420px; right: 6%; bottom: 8%; animation-delay: -3s; border-color: rgba(185, 28, 28, 0.28); }
.sigil.s3 { width: 160px; height: 160px; left: 55%; top: 12%; animation-delay: -5s; }
@keyframes pulse-ring {
  0%, 100% { opacity: 0.25; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(1.04); }
}

.gate-panel {
  position: relative;
  z-index: 2;
  width: min(560px, 100%);
  animation: rise 1.1s ease-out both;
}
.gate-panel.compact { width: min(420px, 100%); }
@keyframes rise {
  from { opacity: 0; transform: translateY(22px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.panel-frame {
  position: relative;
  border-radius: 6px;
  padding: 0;
  border: 1px solid rgba(232, 90, 90, 0.45);
  background: #140608;
  box-shadow:
    0 40px 100px rgba(0, 0, 0, 0.75),
    0 0 0 1px rgba(127, 29, 29, 0.5),
    inset 0 0 0 1px rgba(255, 120, 120, 0.08),
    0 0 70px rgba(185, 28, 28, 0.16);
  overflow: hidden;
}

.fbi-panel .panel-frame::before,
.fbi-panel .panel-frame::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 120, 120, 0.55);
  z-index: 4;
  pointer-events: none;
}
.fbi-panel .panel-frame::before {
  top: 10px; left: 10px;
  border-right: 0; border-bottom: 0;
}
.fbi-panel .panel-frame::after {
  bottom: 10px; right: 10px;
  border-left: 0; border-top: 0;
}

.class-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  background: linear-gradient(90deg, #7f1d1d, #b91c1c 45%, #7f1d1d);
  color: #fff5f5;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(255, 180, 180, 0.25);
}
.class-banner .class-code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  letter-spacing: 0.12em;
  opacity: 0.9;
}

.panel-inner {
  position: relative;
  text-align: center;
  padding: clamp(1.5rem, 4vw, 2.2rem) clamp(1.3rem, 4vw, 2.2rem) 1.4rem;
  background:
    linear-gradient(180deg, rgba(28, 8, 10, 0.98), rgba(10, 4, 5, 0.99)),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(255, 80, 80, 0.015) 2px,
      rgba(255, 80, 80, 0.015) 3px
    );
  overflow: hidden;
}
.gate-panel.compact .panel-inner { text-align: left; }

.fbi-topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-align: left;
  margin-bottom: 1.1rem;
}

.fbi-seal {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
.seal-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 120, 120, 0.55);
}
.seal-ring.inner {
  inset: 8px;
  border-width: 1px;
  border-style: dashed;
  border-color: rgba(255, 150, 150, 0.4);
}
.seal-star {
  color: #ff6b6b;
  font-size: 1.1rem;
  line-height: 1;
  z-index: 1;
  text-shadow: 0 0 12px rgba(185, 28, 28, 0.6);
}
.seal-text {
  position: absolute;
  bottom: 10px;
  font-size: 0.42rem;
  letter-spacing: 0.08em;
  color: #ff9a9a;
  font-weight: 600;
  z-index: 1;
}

.fbi-meta { min-width: 0; }
.agency-line {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #ff8f8f;
}
.case-line {
  margin: 0.35rem 0 0;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.panel-divider {
  width: 100%;
  height: 1px;
  margin: 0 auto 1.25rem;
  background: linear-gradient(90deg, transparent, rgba(255, 120, 120, 0.55), transparent);
}
.panel-divider.hard {
  height: 2px;
  background:
    linear-gradient(90deg, transparent 0%, #7f1d1d 12%, #e85a5a 50%, #7f1d1d 88%, transparent 100%);
  box-shadow: 0 0 12px rgba(185, 28, 28, 0.35);
}
.gate-panel.compact .panel-divider { margin-left: 0; }

.fbi-stripes {
  height: 8px;
  margin: 0 auto 1.4rem;
  max-width: 220px;
  background: repeating-linear-gradient(
    -45deg,
    #7f1d1d,
    #7f1d1d 6px,
    #e85a5a 6px,
    #e85a5a 12px
  );
  opacity: 0.85;
  border: 1px solid rgba(255, 140, 140, 0.25);
}

.fbi-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.65rem 1.1rem;
  margin-top: 1.5rem;
  padding-top: 0.95rem;
  border-top: 1px solid rgba(232, 90, 90, 0.22);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(179, 146, 146, 0.9);
}

.gate-whisper {
  margin: 0 0 0.75rem;
  font-size: 0.68rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: #d96a6a;
  font-weight: 500;
}
.gate-brand {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(2.5rem, 7vw, 3.5rem);
  letter-spacing: 0.1em;
  line-height: 0.95;
  color: var(--text);
  text-shadow: 0 0 42px rgba(185, 28, 28, 0.35);
}
.gate-brand em {
  font-style: italic;
  font-weight: 400;
  color: #ff6b6b;
  display: inline-block;
}
.gate-brand.small {
  font-size: clamp(2rem, 6vw, 2.8rem);
  letter-spacing: 0.04em;
}
.gate-tagline {
  margin: 0.95rem 0 0.35rem;
  font-family: var(--font);
  font-size: clamp(0.95rem, 2.4vw, 1.1rem);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ff8f8f;
  text-shadow: 0 0 24px rgba(185, 28, 28, 0.35);
}
.gate-line {
  margin: 0.75rem auto 1.2rem;
  max-width: 32ch;
  color: var(--muted);
  font-family: var(--display);
  font-size: 1.05rem;
  font-style: italic;
  line-height: 1.45;
}
.gate-panel.compact .gate-line { margin-left: 0; }

.btn-enter {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-width: 220px;
  width: min(100%, 300px);
  padding: 1rem 1.8rem;
  border: 1px solid rgba(255, 120, 120, 0.5);
  border-radius: 2px;
  background: linear-gradient(180deg, #c62828, #7f1d1d);
  color: #fff5f5;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.74rem;
  text-decoration: none;
  box-shadow: 0 10px 28px rgba(127, 29, 29, 0.5);
}
.btn-enter:hover {
  text-decoration: none;
  border-color: rgba(255, 180, 180, 0.8);
  box-shadow: 0 0 36px rgba(185, 28, 28, 0.45);
  color: #fff;
}
.btn-glow {
  position: absolute;
  inset: -40%;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.16), transparent 70%);
  animation: sheen 4.5s ease-in-out infinite;
}
@keyframes sheen {
  0% { transform: translateX(-40%) rotate(12deg); }
  100% { transform: translateX(40%) rotate(12deg); }
}

@media (max-width: 560px) {
  .class-banner { flex-direction: column; gap: 0.25rem; text-align: center; }
  .fbi-topbar { flex-direction: column; text-align: center; }
  .fbi-meta { text-align: center; }
  .fbi-footer { flex-direction: column; gap: 0.35rem; }
}


.alert {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  margin: 0 auto 1.2rem;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.28);
  max-width: 100%;
  text-align: left;
}
.gate-panel.compact .alert { margin-left: 0; }
.alert-error { border-color: rgba(255, 122, 122, 0.4); color: #ffb4b4; }
.alert-warn { border-color: rgba(232, 160, 90, 0.4); color: #f0c49a; }

.stack-form { display: grid; gap: 1rem; margin-top: 0.5rem; }
.stack-form .btn-enter { width: 100%; }
.stack-form label { display: grid; gap: 0.4rem; color: var(--muted); font-size: 0.85rem; letter-spacing: 0.04em; }
.stack-form input, .search-form input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.35);
  color: var(--text);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  font: inherit;
}
.stack-form input:focus, .search-form input:focus {
  outline: 1px solid rgba(232, 90, 90, 0.5);
  border-color: transparent;
}

body.is-ready .gate-panel { animation-play-state: running; }

.mail-app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px 1fr;
}
.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(12, 5, 6, 0.92);
  backdrop-filter: blur(16px);
  padding: 1.35rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.sidebar-brand { display: flex; align-items: center; gap: 0.75rem; }
.brand-word {
  font-family: var(--display);
  font-weight: 500;
  letter-spacing: 0.06em;
  font-size: 1.05rem;
}
.brand-word em { font-style: italic; color: #ff6b6b; font-weight: 400; }

.brand-mark {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  border: 1px solid rgba(232, 90, 90, 0.4);
  background: linear-gradient(145deg, rgba(185, 28, 28, 0.45), rgba(127, 29, 29, 0.35));
  color: #ff9a9a;
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  box-shadow: 0 0 24px rgba(185, 28, 28, 0.25);
}
.brand-mark.sm { width: 36px; height: 36px; font-size: 0.78rem; margin: 0; }

.user-chip {
  display: flex; gap: 0.7rem; align-items: center;
  padding: 0.75rem;
  border-radius: 12px;
  background: var(--mist);
  border: 1px solid var(--line);
}
.user-chip.inline { padding: 0; border: 0; background: transparent; }
.user-chip img { border-radius: 50%; object-fit: cover; }
.user-name { font-weight: 500; font-size: 0.9rem; }
.user-email { color: var(--muted); font-size: 0.75rem; word-break: break-all; }

.folder-nav { display: grid; gap: 0.2rem; }
.folder-nav a {
  color: var(--muted);
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.folder-nav a:hover { background: rgba(255,255,255,0.03); color: var(--text); }
.folder-nav a.active {
  background: rgba(185, 28, 28, 0.22);
  color: #ff8f8f;
  font-weight: 500;
}

.sidebar-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--line); }
.sidebar-foot a, .back-link { color: var(--muted); font-size: 0.9rem; }
.back-link { display: inline-block; }

.mail-main { min-width: 0; display: flex; flex-direction: column; }
.mail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 3, 4, 0.5);
}
.mail-toolbar h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.65rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.search-form { display: flex; gap: 0.5rem; min-width: min(420px, 100%); }
.search-form button {
  background: rgba(185, 28, 28, 0.22);
  color: #ff9a9a;
  border-radius: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.mail-list { display: flex; flex-direction: column; }
.mail-row {
  display: grid;
  grid-template-columns: 220px 1fr 130px;
  gap: 1rem;
  padding: 0.95rem 1.5rem;
  border-bottom: 1px solid rgba(232, 90, 90, 0.1);
  color: inherit;
  text-decoration: none;
  transition: background 0.15s ease;
}
.mail-row:hover { background: rgba(185, 28, 28, 0.08); text-decoration: none; }
.mail-row.unread .mail-from,
.mail-row.unread .mail-subject { font-weight: 500; color: #fff5f5; }
.mail-from { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-subject { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-subject .snippet { color: var(--muted); font-weight: 300; }
.mail-date { text-align: right; color: var(--muted); font-size: 0.82rem; }
.star { color: #ff6b6b; margin-right: 0.25rem; }
.empty-state {
  padding: 3.5rem 1.4rem;
  color: var(--muted);
  text-align: center;
  font-family: var(--display);
  font-style: italic;
  font-size: 1.2rem;
}
.pager { padding: 1rem 1.5rem; }

.message-header { padding: 1.5rem; border-bottom: 1px solid var(--line); }
.message-header h1 {
  margin: 0 0 1rem;
  font-family: var(--display);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 500;
}
.meta { display: grid; gap: 0.35rem; color: var(--muted); font-size: 0.9rem; }
.message-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.1rem; }
.message-actions button {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  color: var(--muted);
}
.message-actions button:hover { color: var(--text); border-color: rgba(232, 90, 90, 0.4); }
.message-body { padding: 1rem 1.5rem 2rem; flex: 1; }
.mail-frame {
  width: 100%;
  min-height: 60vh;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.mail-text {
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.2rem;
  color: var(--text);
  font-family: var(--font);
}

.admin-shell { min-height: 100vh; }
.admin-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 5, 6, 0.9);
}
.admin-user { display: flex; gap: 1rem; align-items: center; color: var(--muted); }
.admin-main { padding: 1.75rem clamp(1rem, 3vw, 2rem); max-width: 1100px; }
.admin-main h1 {
  margin: 0 0 0.5rem;
  font-family: var(--display);
  font-weight: 500;
  font-size: 2.2rem;
}
.lede { color: var(--muted); max-width: 58ch; margin-bottom: 1.5rem; font-family: var(--display); font-style: italic; font-size: 1.1rem; }
.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  background: rgba(18, 8, 9, 0.75);
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  text-align: left;
  padding: 0.95rem 1rem;
  border-bottom: 1px solid rgba(232, 90, 90, 0.1);
  vertical-align: middle;
}
.data-table th {
  color: #d96a6a;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 500;
}
.data-table tr:last-child td { border-bottom: 0; }
.stats-strip {
  padding: 0.7rem 1.5rem;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}
.admin-badge {
  display: inline-block;
  margin: 0 0 0.75rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(185, 28, 28, 0.2);
  color: #ff9a9a;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}
.admin-mail .folder-nav a.active {
  background: rgba(185, 28, 28, 0.22);
  color: #ff8f8f;
}

@media (max-width: 900px) {
  .sigil { display: none; }
  .mail-app { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .mail-row { grid-template-columns: 1fr; gap: 0.25rem; }
  .mail-date { text-align: left; }
  .mail-toolbar { flex-direction: column; align-items: stretch; }
  .search-form { min-width: 0; }
  .gate-brand { letter-spacing: 0.04em; }
}
