:root {
  --bg: #f8fafc;
  --bg-2: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-focus: #6366f1;
  --text: #0f172a;
  --text-2: #334155;
  --text-muted: #64748b;
  --text-placeholder: #94a3b8;
  --accent: #4f46e5;
  --accent-light: #eef2ff;
  --accent-hover: #4338ca;
  --accent-2: #0ea5e9;
  --accent-2-light: #e0f2fe;
  --green: #059669;
  --green-light: #d1fae5;
  --red: #dc2626;
  --red-light: #fee2e2;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg: 0 4px 6px rgba(0,0,0,.04), 0 12px 40px rgba(0,0,0,.1);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --nav-h: 58px;
  --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img, svg { display: block; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
textarea, input { font-family: inherit; }
code { font-family: var(--font-mono); font-size: 0.85em; background: var(--bg-2); padding: 0.1em 0.4em; border-radius: 4px; }

/* ── NAV ── */
#nav {
  position: sticky;
  top: 0;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.nav-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.logo-icon {
  background: var(--accent);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-xs);
  letter-spacing: 0.02em;
}

.logo-text {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
  color: var(--text);
}

.nav-tabs {
  display: flex;
  gap: 0.375rem;
  margin-left: auto;
  background: var(--bg-2);
  padding: 0.3rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
}

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

.nav-tab.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.nav-tab svg { flex-shrink: 0; }

/* ── HERO ── */
.hero {
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  padding: 4rem 1.5rem 3rem;
  text-align: center;
}

.hero-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--green-light);
  color: var(--green);
  border: 1px solid #a7f3d0;
  border-radius: 50px;
  padding: 0.35rem 1rem;
  font-size: 0.8rem;
  font-weight: 500;
}

.badge-lock { font-size: 0.9rem; }

.hero-title {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.hero-title .grad {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 520px;
  line-height: 1.75;
}

.hero-features {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.feature-pill {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid #c7d2fe;
  border-radius: 50px;
  padding: 0.3rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 500;
}

/* ── TOOL CONTAINER ── */
.tool-container {
  max-width: 900px;
  margin: 2.5rem auto;
  padding: 0 1.5rem;
  flex: 1;
}

/* ── PANEL ── */
.panel { display: none; }
.panel.active { display: block; }

.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.panel-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.encode-icon { background: var(--accent-light); color: var(--accent); }
.decode-icon { background: var(--accent-2-light); color: var(--accent-2); }

/* ── DROP ZONE ── */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg);
  position: relative;
  outline: none;
}

.dropzone:hover, .dropzone:focus-visible {
  border-color: var(--accent);
  background: var(--accent-light);
}

.dropzone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
  transform: scale(1.01);
}

.dz-icon {
  margin: 0 auto 1rem;
  color: var(--text-muted);
  transition: transform var(--transition), color var(--transition);
}

.dropzone:hover .dz-icon { transform: translateY(-4px); color: var(--accent); }

.dz-icon-drop { font-size: 2.5rem; }

.dz-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 0.25rem;
}

.dz-sub { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.dz-browse { color: var(--accent); font-weight: 600; }
.dz-hint { font-size: 0.78rem; color: var(--text-placeholder); }

.file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

/* ── FILE INFO ── */
.file-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  animation: slideIn 0.25s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.fi-icon { font-size: 1.8rem; flex-shrink: 0; }
.fi-details { flex: 1; min-width: 0; }

.fi-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fi-meta { font-size: 0.78rem; color: var(--text-muted); }

.fi-clear {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}

.fi-clear:hover { background: var(--red-light); color: var(--red); }

/* ── PROGRESS ── */
.progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.progress-bar {
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s ease;
}

/* ── OUTPUT ── */
.output-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  animation: slideIn 0.3s ease;
}

.output-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.output-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-2);
}

.output-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.output-size {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-xs);
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  transition: all var(--transition);
}

.action-btn:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}

.action-btn-dl {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.action-btn-dl:hover {
  background: var(--accent-hover);
  color: #fff;
  border-color: var(--accent-hover);
}

.output-textarea {
  width: 100%;
  height: 180px;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.6;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  resize: vertical;
  outline: none;
  transition: border-color var(--transition);
  word-break: break-all;
}

.output-textarea:focus { border-color: var(--border-focus); }

.include-prefix-row {
  display: flex;
  align-items: center;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.toggle-label input { display: none; }

.toggle-switch {
  width: 36px; height: 20px;
  background: var(--border);
  border-radius: 20px;
  position: relative;
  flex-shrink: 0;
  transition: background var(--transition);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition);
}

.toggle-label input:checked + .toggle-switch { background: var(--accent); }
.toggle-label input:checked + .toggle-switch::after { transform: translateX(16px); }

/* ── DECODE PANEL ── */
.input-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.input-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-2);
}

.decode-textarea {
  width: 100%;
  height: 220px;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.6;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  resize: vertical;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  word-break: break-all;
}

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

.decode-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.78rem;
  font-family: var(--font-mono);
}

#decodeMetaType {
  background: var(--accent-light);
  color: var(--accent);
  padding: 0.15rem 0.6rem;
  border-radius: 4px;
  font-weight: 500;
}

#decodeMetaSize { color: var(--text-muted); padding: 0.15rem 0; }

.decode-filename-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.fl-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-2);
}

.fl-input {
  padding: 0.65rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: var(--font-mono);
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
  max-width: 320px;
}

.fl-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.btn-decode {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.8rem 2rem;
  background: var(--accent-2);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  transition: all var(--transition);
  box-shadow: 0 2px 12px rgba(14,165,233,0.3);
  width: fit-content;
}

.btn-decode:hover {
  background: #0284c7;
  transform: translateY(-1px);
  box-shadow: 0 4px 18px rgba(14,165,233,0.4);
}

.btn-decode:active { transform: translateY(0); }

.decode-error, .decode-success {
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.decode-error {
  background: var(--red-light);
  color: var(--red);
  border: 1px solid #fca5a5;
}

.decode-success {
  background: var(--green-light);
  color: var(--green);
  border: 1px solid #6ee7b7;
}

/* ── INFO SECTION ── */
.info-section, .faq-section {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 4rem 1.5rem;
}

.faq-section { background: var(--bg); }

.info-container {
  max-width: 900px;
  margin: 0 auto;
}

.info-section h2, .faq-section h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 2rem;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.info-card {
  padding: 1.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform var(--transition), box-shadow var(--transition);
}

.info-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.ic-num {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.info-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.info-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.7;
}

/* ── FAQ ── */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color var(--transition);
}

.faq-item:hover { border-color: var(--accent); }
.faq-item[open] { border-color: var(--accent); }

.faq-item summary {
  padding: 1rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.faq-item summary::-webkit-details-marker { display: none; }

.faq-item summary::after {
  content: '+';
  font-size: 1.2rem;
  font-weight: 300;
  color: var(--accent);
  transition: transform var(--transition);
  flex-shrink: 0;
}

.faq-item[open] summary::after { transform: rotate(45deg); }

.faq-item p {
  padding: 0 1.25rem 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.75;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

/* ── FOOTER ── */
footer {
  background: var(--text);
  color: rgba(255,255,255,0.55);
  padding: 1.5rem;
  font-size: 0.83rem;
}

.footer-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.footer-inner strong { color: rgba(255,255,255,0.85); }

footer nav { display: flex; gap: 1rem; }
footer nav a { color: rgba(255,255,255,0.55); transition: color var(--transition); }
footer nav a:hover { color: rgba(255,255,255,0.9); }

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #1e293b;
  color: #fff;
  padding: 0.65rem 1.2rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 200;
  box-shadow: var(--shadow-lg);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ── RESPONSIVE ── */
@media (max-width: 720px) {
  .nav-tabs { display: none; }
  .hero { padding: 3rem 1.25rem 2rem; }
  .panel-card { padding: 1.5rem; }
  .info-grid { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; text-align: center; }
  .output-actions { flex-wrap: wrap; }
  .hero-features { gap: 0.375rem; }
  .feature-pill { font-size: 0.75rem; padding: 0.25rem 0.7rem; }
}

/* Mobile tab switcher */
@media (max-width: 720px) {
  .tool-container::before {
    content: '';
    display: block;
  }
}
