:root {
  --bg: #0a0b0f;
  --bg-subtle: #0f1015;
  --surface: #16181e;
  --surface-hover: #1c1e26;
  --border: #2a2d36;
  --border-focus: #3a3d48;
  --text: #e8eaef;
  --text-soft: #b4b8c2;
  --muted: #6b7280;
  --accent: #67d4f8;
  --accent-soft: rgba(103, 212, 248, 0.15);
  --accent-glow: rgba(103, 212, 248, 0.25);
  --success: #86efac;
  --error: #fca5a5;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --font-sans: "Outfit", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Subtle gradient + noise feel */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, var(--accent-soft), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(103, 212, 248, 0.06), transparent);
  pointer-events: none;
  z-index: 0;
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 2rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ----- Header ----- */
.header {
  text-align: center;
  margin-bottom: 2.25rem;
}

.logo {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 0 0 0.4rem 0;
  color: var(--text);
}

.logo .accent {
  color: var(--accent);
  filter: drop-shadow(0 0 10px var(--accent-glow));
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

/* ----- Tabs ----- */
.tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.tab {
  padding: 0.6rem 1.15rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.tab:hover {
  background: var(--surface-hover);
  border-color: var(--border-focus);
  color: var(--text);
}

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  box-shadow: 0 0 20px var(--accent-glow);
}

/* ----- Panels (card style) ----- */
.panels {
  position: relative;
  flex: 1;
}

.panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.5rem 1.75rem;
  box-shadow: var(--shadow);
}

.panel.active {
  display: block;
  animation: panelIn 0.25s ease-out;
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.options {
  margin-bottom: 1.35rem;
}

.opt {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.opt span {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

.opt input,
.opt textarea {
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  max-width: 16rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.opt-full textarea {
  max-width: none;
  width: 100%;
  min-height: 4rem;
  resize: vertical;
}

.opt input:focus,
.opt textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.io-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
  margin-bottom: 0.4rem;
}

textarea {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
  margin-bottom: 0.85rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea[readonly] {
  opacity: 0.92;
  cursor: default;
  background: var(--surface-hover);
}

.actions {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1.1rem;
}

.btn {
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s, box-shadow 0.2s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-encrypt {
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 0 16px var(--accent-glow);
}

.btn-encrypt:hover {
  opacity: 0.92;
  box-shadow: 0 0 22px var(--accent-glow);
}

.btn-decrypt {
  background: var(--bg-subtle);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-decrypt:hover {
  border-color: var(--border-focus);
  background: var(--surface-hover);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ----- Footer ----- */
.footer {
  margin-top: auto;
  padding-top: 2.25rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 2rem;
  padding-top: 1.75rem;
}

.footer p {
  margin: 0;
}

.footer-note {
  margin-bottom: 0.5rem;
}

.footer-credit {
  color: var(--text-soft);
  font-size: 0.85rem;
}

.footer-credit strong {
  color: var(--accent);
  font-weight: 600;
}

/* ----- Messages ----- */
.message {
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.message.error {
  background: rgba(252, 165, 165, 0.12);
  color: var(--error);
  border: 1px solid rgba(252, 165, 165, 0.25);
}

.message.success {
  background: rgba(134, 239, 172, 0.12);
  color: var(--success);
  border: 1px solid rgba(134, 239, 172, 0.25);
}

/* ----- Hill cipher matrix grid (real-matrix look) ----- */
.hill-matrix-wrap {
  margin-top: 0.85rem;
}

.hill-matrix-grid {
  display: inline-grid;
  gap: 0;
  width: max-content;
  margin-top: 0.4rem;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--border);
}

.hill-matrix-grid input {
  width: 2.5rem;
  min-width: 2.5rem;
  max-width: 2.5rem;
  padding: 0.35rem 0.2rem;
  border: none;
  border-radius: 2px;
  background: var(--bg-subtle);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-align: center;
  transition: background 0.15s, box-shadow 0.15s;
  -moz-appearance: textfield;
}

.hill-matrix-grid input::-webkit-outer-spin-button,
.hill-matrix-grid input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.hill-matrix-grid input:focus {
  outline: none;
  background: var(--surface-hover);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.hill-matrix-grid input::placeholder {
  color: var(--muted);
}
