:root {
  --bg-deep: #0a0a0a;
  --bg-surface: #141414;
  --glass: rgba(20, 20, 20, 0.85);
  --glass-border: rgba(255, 255, 255, 0.06);
  --text: #e8e8e8;
  --text-dim: #777;
  --accent: #22c55e;
  --radius: 10px;
  --font: 'Poppins', system-ui, -apple-system, Segoe UI, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-deep);
  display: flex;
}

a { color: inherit; text-decoration: none; }

/* ======== SIDEBAR ======== */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: 220px;
  height: 100vh;
  z-index: 100;
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--glass-border);
}

.sb-avatar {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.9rem;
  color: var(--bg-deep);
  background: linear-gradient(135deg, var(--accent), var(--accent));
}

.sb-info { min-width: 0; }
.sb-name {
  font-size: 0.82rem; font-weight: 600;
  background: linear-gradient(90deg, var(--accent), var(--accent));
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sb-npm {
  font-size: 0.6rem; color: var(--text-dim);
  font-family: var(--mono);
}

.sb-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.sb-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  color: var(--text-dim);
  transition: all 0.14s ease;
  border: 1px solid transparent;
}

.sb-nav a:hover {
  color: var(--text);
  background: rgba(0, 240, 255, 0.04);
  border-color: rgba(0, 240, 255, 0.08);
}

.sb-nav a.active {
  color: var(--accent);
  background: rgba(0, 240, 255, 0.06);
  border-color: rgba(0, 240, 255, 0.15);
}

.sb-nav a .sb-badge {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--accent);
  background: rgba(0, 240, 255, 0.06);
}

.sb-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--glass-border);
  font-size: 0.62rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.5;
}

/* ======== MAIN ======== */
.main {
  margin-left: 220px;
  flex: 1;
  min-height: 100vh;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 32px 80px;
}

/* ======== PAGE HEAD ======== */
.page-head {
  margin-bottom: 28px;
  position: relative;
}

.page-head::before {
  content: '';
  position: absolute;
  top: -12px; left: 0;
  width: 60px; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent));
  border-radius: 2px;
}

.page-head .eyebrow {
  display: inline-block;
  font-size: 0.62rem; letter-spacing: 2px; text-transform: uppercase;
  color: var(--accent); margin-bottom: 10px;
  font-family: var(--mono);
}

.page-head h1 {
  margin: 0 0 8px;
  font-size: 2rem;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.page-head h1 span {
  background: linear-gradient(135deg, var(--accent), var(--accent), var(--accent));
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}

.page-head p {
  margin: 0;
  color: var(--text-dim);
  max-width: 56ch;
  font-size: 0.88rem;
  line-height: 1.6;
}

/* ======== CARD GLASS ======== */
.glass {
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 24px;
}

.glass-strong {
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 24px;
}

/* ======== LANDING GRID ======== */
.landing-hero {
  text-align: center;
  padding: 24px 0 8px;
}

.landing-hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  margin: 0 0 12px;
  letter-spacing: -0.5px;
}

.landing-hero h1 span {
  background: linear-gradient(135deg, var(--accent), var(--accent), var(--accent));
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}

.landing-hero .subtitle {
  color: var(--text-dim);
  font-size: 0.88rem;
  max-width: 48ch;
  margin: 0 auto 4px;
  line-height: 1.6;
}

.landing-hero .npm-badge {
  display: inline-block;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--accent);
  padding: 4px 14px;
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: 999px;
  background: rgba(0, 240, 255, 0.04);
}

.cipher-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 28px;
}

.cipher-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border-radius: 12px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.cipher-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.02), transparent 60%);
  opacity: 0;
  transition: opacity 0.2s;
}

.cipher-card:hover {
  border-color: rgba(0, 240, 255, 0.25);
  transform: translateY(-2px);
}

.cipher-card:hover::before {
  opacity: 1;
}

.cc-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cc-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 0.9rem;
  color: var(--bg-deep);
  background: linear-gradient(135deg, var(--accent), var(--accent));
  flex-shrink: 0;
}

.cc-body h3 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
}

.cc-body p {
  margin: 0;
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.cc-tag {
  align-self: flex-start;
  font-size: 0.6rem;
  font-family: var(--mono);
  color: var(--accent);
  padding: 2px 8px;
  border: 1px solid rgba(0, 240, 255, 0.15);
  border-radius: 4px;
}

/* ======== FORM ELEMENTS ======== */
.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 5px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }

input, textarea, select {
  width: 100%;
  font-family: var(--font);
  font-size: 0.85rem;
  color: var(--text);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 10px 14px;
  outline: none;
  transition: border 0.12s;
}

textarea {
  resize: vertical;
  min-height: 80px;
  font-family: var(--mono);
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.06);
}

select {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2322c55e'/%3E%3C/svg%3E");
  background-position: calc(100% - 12px) center;
  background-size: 10px 6px;
  background-repeat: no-repeat;
}

.matrix-grid { display: grid; gap: 8px; max-width: 260px; }
.matrix-grid input { text-align: center; font-family: var(--mono); }

/* ======== TOGGLE ======== */
.toggle {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  margin-bottom: 16px;
}

.toggle button {
  border: 0; cursor: pointer;
  padding: 6px 18px;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  background: transparent;
  transition: all 0.12s ease;
}

.toggle button.active {
  color: var(--bg-deep);
  background: var(--accent);
}

/* ======== BUTTON ======== */
.btn {
  border: 0; cursor: pointer;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--bg-deep);
  padding: 10px 24px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent));
  transition: all 0.15s ease;
  position: relative;
  overflow: hidden;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(0, 240, 255, 0.2);
}

.btn:active { transform: translateY(0); }

/* ======== OUTPUT ======== */
.output-terminal {
  background: rgba(0, 0, 0, 0.5);
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  overflow: hidden;
}

.term-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid var(--glass-border);
}

.term-dots {
  display: flex;
  gap: 5px;
}

.term-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
}

.term-dot.r { background: #ec6a5e; }
.term-dot.y { background: #f5bd4b; }
.term-dot.g { background: #5ac35a; }

.term-title {
  font-size: 0.65rem;
  font-family: var(--mono);
  color: var(--text-dim);
}

.term-actions {
  display: flex;
  gap: 6px;
}

.btn-term {
  border: 1px solid var(--glass-border);
  cursor: pointer;
  background: rgba(0, 240, 255, 0.06);
  color: var(--accent);
  font-family: var(--font);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 4px;
  transition: all 0.12s;
}

.btn-term:hover { background: rgba(0, 240, 255, 0.14); }

.term-body {
  padding: 16px;
  min-height: 60px;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
  color: var(--text);
}

.term-body.placeholder {
  color: var(--text-dim);
  font-family: var(--font);
  font-style: italic;
}

.term-body.error {
  color: #ec6a5e;
  font-family: var(--font);
  font-style: normal;
}

/* ======== STEPS ======== */
.steps {
  display: none;
  flex-direction: column;
  margin-top: 16px;
  background: rgba(0, 0, 0, 0.2);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
}

.step {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 7px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.step:first-child { border-top: none; }

.step .num {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.68rem;
}

.step .formula { color: var(--text); word-break: break-word; }

.step .char {
  color: var(--accent);
  font-weight: 800;
  justify-self: end;
  font-size: 0.8rem;
  text-transform: lowercase;
}

.result-big {
  color: var(--accent);
  font-weight: 700;
  font-size: 1.4rem;
  margin-top: 8px;
}

.result-big.placeholder {
  color: rgba(255, 255, 255, 0.15);
  font-weight: 400;
  font-size: 1rem;
}

.meta {
  margin-top: 8px;
  font-size: 0.68rem;
  color: var(--text-dim);
  font-family: var(--mono);
}

.meta b { color: var(--accent); }

/* ======== RESPONSIVE ======== */
@media (max-width: 768px) {
  .sidebar {
    width: 56px;
    padding: 16px 8px;
  }

  .sidebar-brand {
    justify-content: center;
    padding-bottom: 12px;
    margin-bottom: 20px;
  }

  .sb-info, .sb-nav a span:not(.sb-badge), .sb-foot { display: none; }

  .sb-nav a { justify-content: center; padding: 10px; }

  .main { margin-left: 56px; }
  .container { padding: 24px 16px 60px; }

  .cipher-grid { grid-template-columns: 1fr; }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 1.4rem; }
  .landing-hero h1 { font-size: 1.5rem; }
}
