:root {
  --bg: #09090f;
  --surface: #111118;
  --surface2: #16161f;
  --surface3: #1c1c28;
  --border: #23232f;
  --border-bright: #2e2e3e;
  --accent: #7c3aed;
  --accent-bright: #8b5cf6;
  --accent-glow: rgba(124,58,237,0.18);
  --cyan: #06b6d4;
  --cyan-dim: rgba(6,182,212,0.12);
  --green: #10b981;
  --text: #e2e2f0;
  --text-muted: #6b6b8a;
  --text-dim: #4a4a6a;
  --danger: #ef4444;
  --danger-bg: rgba(239,68,68,0.08);
  --radius: 10px;
  --radius-sm: 6px;
}

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

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

/* Subtle grid background */
.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(124,58,237,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124,58,237,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

header {
  position: relative;
  z-index: 10;
  background: rgba(9,9,15,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  flex-shrink: 0;
}
.logo-svg { width: 28px; height: 28px; flex-shrink: 0; }
.logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.4px;
}
.accent { color: var(--accent-bright); }

.nav-pills {
  display: flex;
  gap: 2px;
  background: var(--surface2);
  padding: 3px;
  border-radius: 9px;
  border: 1px solid var(--border);
}

.nav-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 13px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.15s;
  white-space: nowrap;
}
.nav-pill svg { flex-shrink: 0; }
.nav-pill:hover { color: var(--text); background: var(--surface3); }
.nav-pill.active {
  background: linear-gradient(135deg, var(--accent), #5b21b6);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 12px rgba(124,58,237,0.35);
}

.header-badge {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 99px;
}
.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.4; }
}

main {
  flex: 1;
  padding: 18px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lang-selector-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.lang-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: opacity 0.2s;
}

.lang-group label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

select {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  min-width: 155px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6b8a' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
select:focus {
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
select option { background: var(--surface2); }

.swap-btn {
  background: var(--surface2);
  border: 1px solid var(--border-bright);
  color: var(--text-muted);
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.swap-btn:hover { color: var(--accent-bright); border-color: var(--accent); background: var(--accent-glow); }
.swap-btn.spin svg { animation: spin180 0.3s ease; }
@keyframes spin180 { from { transform: rotate(0deg); } to { transform: rotate(180deg); } }

.shortcut-hint {
  font-size: 0.72rem;
  color: var(--text-dim);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  font-family: "JetBrains Mono", monospace;
}

.editor-area {
  display: grid;
  grid-template-columns: 1fr 72px 1fr;
  height: 510px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.03);
}

.panel {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 14px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

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

.icon-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  height: 26px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.15s;
  white-space: nowrap;
}
.icon-btn:hover {
  background: var(--surface3);
  color: var(--text);
  border-color: var(--border-bright);
}

textarea#input-code {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: none;
  padding: 14px 16px;
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.65;
  resize: none;
  outline: none;
  tab-size: 4;
  caret-color: var(--accent-bright);
}
textarea#input-code::placeholder {
  color: var(--text-dim);
  line-height: 1.9;
}
textarea#input-code:focus { background: #0b0b13; }

.panel-footer {
  padding: 5px 14px;
  font-size: 0.7rem;
  color: var(--text-dim);
  background: var(--surface2);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  min-height: 26px;
  align-items: center;
}
.stat { font-family: "JetBrains Mono", monospace; }

/* Center column */
.center-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  gap: 12px;
  position: relative;
}

.arrow-track {
  width: 2px;
  height: 80px;
  background: var(--border);
  border-radius: 1px;
  overflow: hidden;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 0;
}
.arrow-flow {
  width: 100%;
  height: 40%;
  background: linear-gradient(180deg, transparent, var(--accent), transparent);
  animation: flow 1.8s ease-in-out infinite;
}
@keyframes flow {
  0% { transform: translateY(-100%); opacity: 0; }
  30% { opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translateY(250%); opacity: 0; }
}

.convert-btn {
  position: relative;
  z-index: 1;
  background: linear-gradient(145deg, var(--accent), #5b21b6);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 10px 0;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 48px;
  letter-spacing: 0.3px;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(124,58,237,0.4);
  text-transform: uppercase;
}
.convert-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 20px rgba(124,58,237,0.55);
}
.convert-btn:disabled { opacity: 0.5; transform: none; cursor: wait; }

.btn-icon-wrap svg { display: block; }

.convert-btn.loading .btn-icon-wrap svg {
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Output panel */
#output-area {
  flex: 1;
  overflow: auto;
  background: var(--bg);
  position: relative;
}

#output-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 0.8rem;
}

#output-code {
  margin: 0;
  min-height: 100%;
}
#output-code.hidden { display: none; }

#output-code code {
  display: block;
  padding: 14px 16px;
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.65;
  background: transparent !important;
  white-space: pre-wrap;
  word-break: break-word;
}
.hljs { background: transparent !important; }

/* Error */
.error-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--danger-bg);
  border: 1px solid rgba(239,68,68,0.25);
  color: var(--danger);
  padding: 9px 14px;
  border-radius: var(--radius);
  font-size: 0.83rem;
}
.hidden { display: none !important; }

/* Feature cards */
.feature-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: border-color 0.2s;
}
.feature-card:hover { border-color: var(--border-bright); }

.feature-icon {
  width: 32px; height: 32px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.convert-icon { background: var(--accent-glow); color: var(--accent-bright); }
.analyze-icon { background: var(--cyan-dim); color: var(--cyan); }
.deob-icon { background: rgba(16,185,129,0.1); color: var(--green); }

.feature-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}
.feature-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
}

footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 12px 24px;
  font-size: 0.72rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.footer-sep { color: var(--border-bright); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

@media (max-width: 900px) {
  .editor-area {
    grid-template-columns: 1fr;
    grid-template-rows: auto 60px auto;
    height: auto;
  }
  .center-col {
    flex-direction: row;
    height: 60px;
    border-left: none;
    border-right: none;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
  }
  .arrow-track { display: none; }
  .convert-btn { flex-direction: row; width: auto; padding: 10px 20px; }
  textarea#input-code { min-height: 240px; }
  #output-area { min-height: 240px; }
  .feature-cards { grid-template-columns: 1fr; }
  .shortcut-hint { display: none; }
}

@media (max-width: 600px) {
  header { padding: 0 14px; gap: 12px; }
  main { padding: 12px 14px; }
  .nav-pill span:not(svg) { display: none; }
  .feature-cards { display: none; }
}
