  :root {
    --bg:#111;
    --panel:#0b1216;
    --muted:#9aa3ad;
    --accent:#00c7a7;
    --good:#00ff99;
    --bad:#ff6b6b;
    --glass: rgba(255,255,255,0.03);
  }

  body {
    background: var(--bg);
    color: #e6eef3;
    font-family: Consolas, 'Courier New', monospace;
    margin: 0;
    padding: clamp(12px, 4vw, 28px);
    -webkit-font-smoothing: antialiased;
  }

  /* Center header block */
  .header {
    text-align: center;
    margin-bottom: 28px;
    padding: 0 1rem;
  }

  /* Fluid, centered heading */
  .header h1 {
    display: block;
    margin: 0 auto 12px auto;
    font-size: clamp(1.2rem, 4vw, 1.8rem);
    font-weight: 600;
    background: #1a1a1a;
    padding: 0.75em 1.5em;
    border-radius: 8px;
    letter-spacing: 0.5px;
    color: #e6eef3;
    text-wrap: balance;
    width: min(90%, 700px);
  }

  /* Fluid lead paragraph */
  .header .lead {
    display: block;
    margin: 0 auto;
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    width: min(90%, 700px);
    line-height: 1.6;
    color: #aaa;
    background: rgba(255,255,255,0.05);
    padding: 0.6em 1.2em;
    border-radius: 6px;
  }

  /* Layout grid */
  .wrap {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    gap: 18px;
    grid-template-columns: 1fr 520px;
    align-items: start;
  }

  .panel {
    background: var(--panel);
    padding: 16px;
    border-radius: 10px;
    box-shadow: 0 8px 22px rgba(0,0,0,0.6);
  }

  .controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    align-items: center;
  }

  .csvInputDiv{
    margin-top:12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    align-items: center;
  }

  label.small {
    font-size: 13px;
    color: var(--muted);
    margin-right: 6px;
  }

  select,
  input[type="text"],
  input[type="file"],
  input[type="number"] {
    background: #0b0d0f;
    color: #e9f3f2;
    border: 1px solid rgba(255,255,255,0.03);
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
  }

  input[type="checkbox"] {
    transform: scale(1.05);
    margin-right: 6px;
  }


  textarea#csvInput {
    width: 100%;
    height: 220px;
    resize: vertical;
    background: #090b0c;
    color: #e6eef3;
    border-radius: 8px;
    padding: 12px;
    border: 1px solid var(--glass);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
    font-size: 13px;
  }

  .small-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
  }

  .btn {
    background: var(--accent);
    color: #022;
    padding: 8px 12px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s ease;
  }
  .btn:hover { background: #00e0c0; }

  .btn.ghost {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.04);
    color: var(--muted);
  }

  /* Highlight the active Pretty/Minify toggle */
  /* Pretty / Minify active highlight (distinct from Download) */
  #prettyBtn.active,
  #minBtn.active {
    background: var(--good);
    color: #021;
    border: 1px solid var(--good);
    box-shadow: 0 0 10px rgba(0, 255, 153, 0.25);
  }

  #prettyBtn:not(.active),
  #minBtn:not(.active) {
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
    border: 1px solid rgba(255, 255, 255, 0.05);
    opacity: 0.85;
  }

#prettyBtn:not(.active):hover,
#minBtn:not(.active):hover {
  background: rgba(0, 255, 153, 0.1);
  opacity: 1;
}
  #prettyBtn:not(.active),
  #minBtn:not(.active) {
    opacity: 0.7;
  }
  #prettyBtn:not(.active):hover,
  #minBtn:not(.active):hover {
    opacity: 1;
  }
  .muted { color: var(--muted); font-size: 13px; }

  .stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
  }

  .stat {
    background: rgba(255,255,255,0.02);
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--muted);
  }

  .preview {
    max-height: 340px;
    overflow: auto;
    border-radius: 8px;
    border: 1px solid var(--glass);
    margin-top: 10px;
  }

  table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 500px;
  }

  th, td {
    padding: 6px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    text-align: left;
    vertical-align: top;
  }

  th {
    position: sticky;
    top: 0;
    background: rgba(0,0,0,0.12);
    backdrop-filter: blur(6px);
  }

  pre#jsonOutput {
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 560px;
    overflow: auto;
    background: #060708;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--glass);
    color: #cfeee3;
    font-size: 13px;
  }

  .error { color: var(--bad); font-weight: 600; }
  .ok { color: var(--good); font-weight: 600; }

  .right-column .panel { margin-bottom: 12px; }

  .toolbar {
    display: flex;
    gap: 8px;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
  }

  .small { font-size: 13px; color: var(--muted); }

  .mapping {
    margin-top: 12px;
    display: block;
    border-radius: 8px;
    padding: 10px;
    background: rgba(255,255,255,0.02);
  }

  .map-row {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 6px 6px;
    border-radius: 6px;
    margin-bottom: 6px;
    background: transparent;
    flex-wrap: wrap;
  }

  .map-row .col-index { width: 28px; text-align: center; color: var(--muted); }

  .map-row input.rename {
    flex: 1;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.03);
    background: #0b0d0f;
    color: #e6eef3;
    min-width: 140px;
  }

  .map-row .incl { width: 26px; display: flex; justify-content: center; }
  .map-row .move { display: flex; gap: 6px; flex-wrap: nowrap; }
  .map-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

  .hint { color: var(--muted); font-size: 13px; margin-top: 8px; }

  .details {
    margin-left: 36px;
    margin-top: 6px;
    margin-bottom: 8px;
    padding: 10px;
    background: rgba(255,255,255,0.01);
    border-radius: 6px;
    display: none;
  }

  .details label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 6px;
  }

  .details input[type="text"], .details select { width: 220px; }

  .gear-btn {
    margin-left: 6px;
    padding: 6px 8px;
    border-radius: 8px;
    border: none;
    background: #122428;
    color: var(--muted);
    cursor: pointer;
  }

  .gear-btn.active { background: #163634; color: #cfeee3; }

  .type-pill {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(255,255,255,0.02);
    color: var(--muted);
    border: 1px solid rgba(255,255,255,0.02);
  }

  /* ---------- Responsive Design ---------- */

/* Tablet and small laptops */
@media (max-width: 1024px) {
  .wrap {
    grid-template-columns: 1fr;
    max-width: 100%;
  }

  .right-column {
    order: 2;
  }

  .panel {
    width: 100%;
    box-sizing: border-box;
  }
}

/* Mobile layout */
@media (max-width: 768px) {
  body {
    padding: 16px;
  }

  /* Make .wrap a vertical stack */
  .wrap {
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: 100%;
    box-sizing: border-box;
  }

  /* Panels span full width */
  .wrap .panel {
    width: 100%;
    margin: 0;
    padding: 16px;
    border-radius: 10px;
    box-sizing: border-box;
  }

  /* Reset all inline widths inside panels */
  .wrap input[style*="width"],
  .wrap select[style*="width"] {
    width: 100% !important;
  }

  /* General input and control spacing */
  .controls,
  .small-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  label.small {
    margin-bottom: 4px;
  }

  select,
  input[type="text"],
  input[type="number"],
  input[type="file"],
  textarea#csvInput {
    width: 100%;
    font-size: 0.95rem;
    padding: 10px 12px;
    box-sizing: border-box;
  }

  .csvInputDiv{
    margin-top:12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    align-items: center;
  }
  textarea#csvInput {
    min-height: 180px;
  }

  /* Buttons full width and better tap targets */
  .btn,
  .btn.ghost {
    width: 100%;
    font-size: 1rem;
    padding: 10px 14px;
    margin-top: 6px;
  }

  /* Reset auto-margin elements */
  #clearBtn {
    margin-left: 0 !important;
  }

  /* Stats center and wrap cleanly */
  .stats {
    justify-content: center;
    gap: 10px;
  }

  /* Mapping UI adjustments */
  .mapping {
    padding: 12px;
  }

  .map-row,
  .map-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .map-row input.rename {
    width: 100%;
  }

  /* Toolbar buttons stack nicely */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .toolbar > div:first-child {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
  }

  /* Fix preview and JSON output overflow */
  table {
    min-width: unset;
    width: 100%;
    display: block;
    overflow-x: auto;
  }

  .preview,
  pre#jsonOutput {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  pre#jsonOutput {
    max-height: 400px;
    font-size: 0.9rem;
    padding: 10px;
  }

  /* Extra breathing room between panels */
  .panel:not(:last-child) {
    margin-bottom: 16px;
  }
}

/* Small mobile */
@media (max-width: 480px) {
  .header h1 {
    font-size: clamp(1rem, 5vw, 1.2rem);
    padding: 0.6em 1em;
  }

  .header .lead {
    font-size: clamp(0.8rem, 3.5vw, 0.9rem);
    padding: 0.5em 1em;
  }

  .btn {
    font-size: 0.9rem;
    padding: 8px;
  }

  .stat {
    font-size: 12px;
  }
}