:root {
  --bg: #0f0f13;
  --surface: #1a1a24;
  --border: #2e2e40;
  --primary: #6366f1;
  --primary-end: #a855f7;
  --text: #e2e2f0;
  --muted: #6b6b8a;
  --error: #f87171;
  --success: #34d399;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  padding: 20px 32px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(26, 26, 36, 0.8);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

header img { width: 40px; height: 40px; }

header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--primary-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

main {
  flex: 1;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

.subtitle {
  color: var(--muted);
  font-size: 0.9rem;
}

.panels {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: start;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

textarea {
  width: 100%;
  height: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: "Fira Code", "Cascadia Code", "Consolas", monospace;
  font-size: 0.88rem;
  padding: 14px;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  line-height: 1.65;
}

textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

textarea.error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.15);
}

textarea::placeholder { color: var(--muted); opacity: 0.7; }

.panel-actions {
  display: flex;
  gap: 8px;
}

.btn {
  padding: 7px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  user-select: none;
}

.btn:hover { background: var(--border); border-color: var(--muted); }
.btn.copied { border-color: var(--success); color: var(--success); }

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding-top: 26px;
  min-width: 56px;
}

.arrow-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: transform 0.15s, box-shadow 0.15s;
  user-select: none;
}

.arrow-btn:hover { transform: scale(1.12); }
.arrow-btn:active { transform: scale(0.96); }

.btn-encode {
  background: linear-gradient(135deg, var(--primary), var(--primary-end));
  color: white;
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.4);
}

.btn-encode:hover {
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.6);
}

.btn-decode {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-decode:hover { border-color: var(--primary); }

.error-msg {
  font-size: 0.82rem;
  color: var(--error);
  min-height: 1.4em;
  padding: 0 2px;
}

footer {
  text-align: center;
  padding: 20px;
  font-size: 0.78rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

@media (max-width: 720px) {
  main { padding: 20px 16px; }

  .panels {
    grid-template-columns: 1fr;
  }

  .controls {
    flex-direction: row;
    padding-top: 0;
    justify-content: center;
  }
}
