:root {
  color-scheme: dark;
  --bg: #080a12;
  --panel: #10131d;
  --text: #f3f4f7;
  --muted: #858b9b;
  --line: #272c38;
  --soft: #090b12;
  --accent: #baff49;
  --secondary: #9a7cff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button, textarea, input { font: inherit; }
button, label { -webkit-tap-highlight-color: transparent; }
.shell { width: min(1100px, calc(100% - 32px)); margin-inline: auto; }

.nav {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand { color: var(--text); font-weight: 650; text-decoration: none; }
.hero { padding: 44px 0 24px; }
.hero h1 { margin: 0; font-size: clamp(24px, 4vw, 34px); letter-spacing: -.035em; }

.workspace {
  overflow: hidden;
  background: #0d1018;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.workspace-top {
  min-height: 58px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mode-switch {
  position: relative;
  display: flex;
  padding: 3px;
  border-radius: 7px;
  background: var(--soft);
}

.mode {
  position: relative;
  z-index: 1;
  width: 88px;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}

.mode.active { color: #10120d; font-weight: 600; }
.mode-slider {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 88px;
  height: 32px;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 5px;
  transition: transform .2s ease;
}
.mode-switch.decode .mode-slider { transform: translateX(88px); background: var(--secondary); border-color: var(--secondary); }

.text-button, .icon-button, .copy-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}

.copy-button { display: flex; align-items: center; gap: 6px; }
.icon-button svg, .copy-button svg {
  width: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.panels { display: grid; grid-template-columns: 1fr 1fr; min-height: 480px; }
.panel { min-width: 0; display: flex; flex-direction: column; }
.input-panel { border-right: 1px solid var(--line); }
.panel-head, .panel-foot { display: flex; align-items: center; justify-content: space-between; }
.panel-head { height: 52px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.panel-head > div, .output-actions { display: flex; align-items: center; gap: 8px; }
.panel-head strong { font-size: 13px; font-weight: 600; }
.panel-index { display: none; }

.drop-zone, .result-wrap { position: relative; flex: 1; min-height: 380px; }
.drop-zone.drag { background: #baff4908; outline: 1px dashed var(--accent); outline-offset: -10px; }
.drop-zone.has-value .drop-prompt { display: none; }
textarea {
  width: 100%;
  height: 100%;
  padding: 18px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
}
.drop-zone textarea, .result-wrap textarea { position: absolute; inset: 0; }
.result-wrap textarea { display: none; }
.result-wrap.has-result textarea { display: block; }

.drop-prompt, .empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  pointer-events: none;
}
.drop-prompt p, .empty-state p { margin: 0 0 8px; font-size: 13px; }
.file-button { color: var(--accent); cursor: pointer; pointer-events: auto; font-size: 13px; }
.file-button input { display: none; }
.result-wrap.has-result .empty-state { display: none; }

.icon-button, .copy-button { height: 30px; border: 1px solid var(--line); border-radius: 5px; }
.icon-button { width: 31px; display: grid; place-items: center; }
.copy-button { padding: 0 9px; }
.icon-button:disabled, .copy-button:disabled { opacity: .35; cursor: default; }

.panel-foot {
  height: 36px;
  padding: 0 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.preview { position: absolute; inset: 0; overflow: auto; padding: 18px; background: #0d1018; }
.preview img { display: block; max-width: 100%; max-height: 320px; margin: auto; }
.preview pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 13px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; }
.preview-meta { margin-top: 12px; text-align: center; color: var(--muted); font-size: 11px; }
#typeBadge { color: var(--secondary); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  padding: 9px 13px;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition: .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 720px) {
  .hero { padding-top: 32px; }
  .panels { grid-template-columns: 1fr; }
  .input-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .drop-zone, .result-wrap { min-height: 300px; }
}

@media (max-width: 420px) {
  .shell { width: min(100% - 20px, 1100px); }
}
