:root {
  --ink: #0f141b;
  --panel: #161d26;
  --panel-2: #1c242f;
  --line: #27313e;
  --text: #e2e8f0;
  --muted: #8a99ac;
  --raw: #f0b429;      /* base64, before */
  --resolved: #4fd1a5; /* hosted URL, after */
  --danger: #ff7a6b;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "IBM Plex Mono", Menlo, Consolas, monospace;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(900px 420px at 82% -12%, rgba(79, 209, 165, .09), transparent 65%),
    var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--resolved); }

.wrap { max-width: 940px; margin: 0 auto; padding: 40px 22px 72px; }

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
  margin-bottom: 26px;
}

.masthead h1 {
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -.02em;
  margin: 0;
}

.masthead p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.masthead a { color: var(--muted); font-size: 13px; text-decoration: none; }
.masthead a:hover { color: var(--text); }

/* signature: the before/after transform strip */
.transform {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 2px solid var(--raw);
  border-radius: 4px;
  padding: 14px 16px;
  margin-bottom: 28px;
  overflow: hidden;
}
.transform div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.transform .before { color: var(--raw); opacity: .85; }
.transform .arrow { color: var(--muted); padding: 3px 0; letter-spacing: .3em; font-size: 10px; }
.transform .after { color: var(--resolved); }
.transform .tag { color: var(--muted); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 24px;
}

label {
  display: block;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 7px;
}

.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }

input[type=text], input[type=password], input[type=file] {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13.5px;
  padding: 11px 13px;
}

input[type=file] { padding: 9px 13px; }
input:focus-visible { outline: 2px solid var(--resolved); outline-offset: 1px; }

.field { margin-bottom: 20px; }
.row { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }

button {
  background: var(--resolved);
  color: #06231a;
  border: 0;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .02em;
  padding: 12px 22px;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

.alert {
  border: 1px solid rgba(255, 122, 107, .4);
  background: rgba(255, 122, 107, .08);
  color: var(--danger);
  border-radius: 4px;
  padding: 11px 14px;
  font-size: 13.5px;
  margin-bottom: 20px;
}

/* results */
.result { margin-top: 30px; }
.result h2 {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  margin: 0 0 14px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--panel);
}
.stat { padding: 16px 18px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat b { display: block; font-family: var(--mono); font-size: 22px; font-weight: 600; }
.stat span { color: var(--muted); font-size: 12px; }
.stat.warn b { color: var(--danger); }

.downloads { display: flex; flex-wrap: wrap; gap: 12px; margin: 20px 0 10px; }
.dl {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 260px;
  text-decoration: none;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 13px;
}
.dl:hover { border-color: var(--resolved); }
.dl small { color: var(--muted); font-family: var(--sans); font-size: 12px; }

.meta { font-family: var(--mono); font-size: 12.5px; color: var(--muted); margin: 14px 0 0; }
.meta code { color: var(--resolved); }

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.thumbs a {
  display: block;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px;
  text-align: center;
}
.thumbs img { width: 100%; height: 62px; object-fit: contain; background: #fff; border-radius: 2px; }
.thumbs span { display: block; font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* login */
.gate { max-width: 380px; margin: 14vh auto 0; padding: 0 22px; }
.gate .card { padding: 28px; }
.gate h1 { font-family: var(--mono); font-size: 17px; margin: 0 0 6px; }
.gate p.sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }

@media (max-width: 700px) {
  .row, .stats { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(2n) { border-right: 0; }
  .stat { border-bottom: 1px solid var(--line); }
}

/* conversion controls */
select {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 11px 13px;
}
select:focus-visible { outline: 2px solid var(--resolved); outline-offset: 1px; }

input[type=number] {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13.5px;
  padding: 11px 13px;
}
input[type=number]:focus-visible { outline: 2px solid var(--resolved); outline-offset: 1px; }

.row.three { grid-template-columns: 2fr 1fr 1fr; }
.warn-text { color: var(--raw); }

.noprev {
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(240, 180, 41, .12);
  border: 1px dashed var(--raw);
  border-radius: 2px;
  color: var(--raw);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .06em;
}

@media (max-width: 700px) { .row.three { grid-template-columns: 1fr; } }

/* url preview */
.urlpreview {
  margin-top: 9px;
  background: var(--ink);
  border: 1px solid var(--line);
  border-left: 2px solid var(--resolved);
  border-radius: 4px;
  padding: 9px 12px;
  overflow: hidden;
}
.urlpreview .lbl {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 3px;
}
.urlpreview code {
  display: block;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--resolved);
  white-space: nowrap;
  overflow-x: auto;
}
.hint code { color: var(--resolved); font-family: var(--mono); font-size: 12px; }

/* in-memory CSV save button */
.dlbtn {
  text-align: left;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 400;
  letter-spacing: 0;
  padding: 14px 16px;
  width: 100%;
}
.dlbtn:hover { border-color: var(--resolved); filter: none; }
.dlbtn small { color: var(--muted); font-family: var(--sans); font-size: 12px; }
