*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #21253a;
  --border: #2a2d3e;
  --accent: #6c63ff;
  --accent-light: #8b85ff;
  --accent2: #34d399;
  --text: #e8eaf0;
  --muted: #8b90a8;
  --radius: 12px;
  --mono: 'Fira Code', 'Cascadia Code', Consolas, monospace;
}

[data-theme="light"] {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface2: #eef0f8;
  --border: #dde1ef;
  --accent: #5b52e8;
  --accent-light: #7b74f5;
  --accent2: #059669;
  --text: #1a1d2e;
  --muted: #6b7280;
}

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background .2s, color .2s;
}

/* Nav */
nav {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: .85rem;
  transition: color .15s;
}
nav a:hover { color: var(--text); }
.nav-sep { color: var(--border); }
.page-title { color: var(--text); font-weight: 600; font-size: .9rem; }
.theme-toggle {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  padding: 5px 12px;
  font-size: .82rem;
  transition: all .15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }

/* Wrapper */
.wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

.container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 780px;
}

h1 {
  color: var(--text);
  text-align: center;
  margin-bottom: 28px;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -.3px;
}

.input-section, .output-section {
  margin-bottom: 20px;
}

textarea {
  width: 100%;
  height: 140px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--mono);
  font-size: .88rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color .15s;
}
textarea:focus { border-color: var(--accent); }
textarea::placeholder { color: var(--muted); }

.button-group {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s;
  flex: 1;
}
.btn:hover { transform: translateY(-1px); opacity: .9; }
.btn:active { transform: translateY(0); }

.encode { background: var(--accent); color: #fff; }

.decode {
  background: var(--surface2);
  color: var(--accent-light);
  border: 1px solid var(--border);
}

.copy { background: var(--accent2); color: #fff; width: 100%; }

@media (max-width: 520px) {
  .container { padding: 20px 16px; }
  .button-group { flex-direction: column; }
}