:root {
  --bg: #050506;
  --panel: rgba(19, 20, 23, 0.82);
  --panel-strong: rgba(31, 33, 38, 0.94);
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.2);
  --text: #eeeeef;
  --muted: #9da0aa;
  --dim: #686b75;
  --red: #d44141;
  --red-soft: rgba(212, 65, 65, 0.18);
  --red-line: rgba(212, 65, 65, 0.42);
  --gold: #d6b271;
  --green: #8bd18b;
  --error: #ff7676;
  --shadow: 0 20px 80px rgba(0, 0, 0, 0.48);
  --radius: 22px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 8%, rgba(153, 22, 22, 0.26), transparent 34%),
    radial-gradient(circle at 78% 12%, rgba(128, 46, 46, 0.17), transparent 32%),
    linear-gradient(135deg, #060607 0%, #090a0d 45%, #0c0909 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--red-line) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.045) 1px, transparent 1px);
  background-size: 100% 160px, 160px 100%;
  mask-image: radial-gradient(circle at top, rgba(0,0,0,0.8), transparent 70%);
  opacity: 0.32;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  mix-blend-mode: screen;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 220 220' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.35'/%3E%3C/svg%3E");
}

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 34px 0 44px;
  position: relative;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 28px;
  padding: 38px;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 8px);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02)),
    radial-gradient(circle at 85% 30%, rgba(212, 65, 65, 0.22), transparent 32%);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

.hero::after {
  content: "";
  position: absolute;
  left: -6%;
  right: -6%;
  top: 63%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--red), transparent);
  transform: rotate(-2deg);
  opacity: 0.55;
}


.topline {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0,0,0,0.28);
}

.lang-button {
  border: 0;
  border-radius: 999px;
  padding: 6px 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.lang-button.active {
  color: var(--text);
  background: var(--red-soft);
  box-shadow: inset 0 0 0 1px var(--red-line);
}

.eyebrow, .section-kicker {
  color: var(--red);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 0.76rem;
  font-weight: 800;
  margin: 0 0 10px;
}

h1, h2 { margin: 0; letter-spacing: -0.04em; }

h1 {
  font-size: clamp(3.1rem, 8vw, 6.8rem);
  line-height: 0.92;
  text-shadow: 0 0 38px rgba(212, 65, 65, 0.22);
}

h2 { font-size: clamp(1.55rem, 3vw, 2.4rem); }

.subtitle {
  max-width: 650px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
  margin: 20px 0 0;
}

.seal {
  width: clamp(96px, 18vw, 160px);
  aspect-ratio: 1;
  border: 1px solid var(--red-line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background:
    radial-gradient(circle, rgba(212, 65, 65, 0.22), transparent 60%),
    rgba(0,0,0,0.28);
  box-shadow: inset 0 0 35px rgba(212, 65, 65, 0.18), 0 0 55px rgba(212, 65, 65, 0.13);
}

.seal span {
  font-family: Georgia, serif;
  font-size: clamp(3.2rem, 9vw, 6.4rem);
  color: rgba(255,255,255,0.88);
}

.panel {
  margin-top: 18px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.grid.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.field {
  display: grid;
  gap: 9px;
}

.field span, .mini-field, .check, .radio {
  color: var(--text);
  font-weight: 750;
  font-size: 0.92rem;
}

.field small, .note, .muted {
  color: var(--muted);
}

textarea, input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.42);
  color: var(--text);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea {
  min-height: 118px;
  padding: 16px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  line-height: 1.55;
  font-size: 0.95rem;
}

.tall textarea { min-height: 190px; }

.output-field textarea {
  min-height: 160px;
  background: rgba(0, 0, 0, 0.58);
}

input {
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
}

textarea:focus, input:focus {
  border-color: rgba(212, 65, 65, 0.78);
  box-shadow: 0 0 0 4px rgba(212, 65, 65, 0.16);
  background: rgba(0, 0, 0, 0.55);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 18px;
}

.stat {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,0.035);
  min-width: 0;
}

.stat b {
  display: block;
  color: var(--dim);
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  margin-bottom: 7px;
}

.stat span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, monospace;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 18px 0 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0,0,0,0.35);
  width: max-content;
  max-width: 100%;
}

.tab, button {
  cursor: pointer;
  font: inherit;
}

.tab {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.tab.active {
  color: var(--text);
  background: var(--red-soft);
  box-shadow: inset 0 0 0 1px var(--red-line);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.options-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin: 16px 0;
}

.check, .radio, .mini-field {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,0.035);
}

.check input, .radio input {
  width: auto;
  min-height: auto;
  accent-color: var(--red);
}

.mini-field input {
  width: 86px;
  min-height: 30px;
  border-radius: 10px;
  padding: 6px 8px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 18px 0;
}

.primary-button, .ghost-button {
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 900;
  border: 1px solid transparent;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, #a92525, #e04f4f);
  box-shadow: 0 12px 34px rgba(212, 65, 65, 0.2);
}

.ghost-button {
  color: var(--text);
  background: rgba(255,255,255,0.05);
  border-color: var(--line-strong);
}

.primary-button:hover, .ghost-button:hover, .tab:hover {
  filter: brightness(1.08);
}

.note {
  margin: 12px 0 0;
  line-height: 1.55;
  min-height: 1.4em;
}

.note.ok { color: var(--green); }
.note.error { color: var(--error); }
.note.warn { color: var(--gold); }

.table-wrap {
  margin-top: 18px;
  overflow: auto;
  max-height: 620px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(0,0,0,0.34);
}

.cipher-table {
  border-collapse: collapse;
  min-width: 100%;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.88rem;
}

.cipher-table th, .cipher-table td {
  border: 1px solid rgba(255,255,255,0.08);
  padding: 9px 10px;
  text-align: center;
  min-width: 44px;
}

.cipher-table th {
  position: sticky;
  top: 0;
  background: #15161a;
  color: var(--muted);
  z-index: 1;
}

.cipher-table th:first-child {
  left: 0;
  z-index: 2;
}

.cipher-table td:first-child, .cipher-table .row-head {
  position: sticky;
  left: 0;
  background: #111216;
  color: var(--muted);
  font-weight: 800;
}

.rules-copy {
  color: var(--muted);
  line-height: 1.75;
  max-width: 850px;
}

.rules-copy code {
  color: var(--gold);
  background: rgba(255,255,255,0.07);
  padding: 2px 7px;
  border-radius: 7px;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--dim);
  margin-top: 18px;
  font-size: 0.85rem;
}

@media (max-width: 780px) {
  .hero { padding: 26px; align-items: flex-start; }
  .seal { display: none; }
  .grid.two, .status-grid { grid-template-columns: 1fr; }
  .tabs { width: 100%; border-radius: 20px; }
  .tab { flex: 1 1 auto; }
  .panel { padding: 20px; }
}

/* Keeps the title decoration from stealing clicks from the language switcher. */
.hero::after { pointer-events: none; }
.topline, .lang-switch { position: relative; z-index: 4; }
.hero h1 { position: relative; z-index: 1; pointer-events: none; }
