:root {
  --bg: #0d0f12;
  --surface: #16191f;
  --surface-2: #1d2128;
  --border: #262b33;
  --border-strong: #333a44;
  --text: #e7e9ec;
  --text-dim: #9aa1ac;
  --text-faint: #5f6671;
  --accent: #4f8cff;
  --accent-dim: #2a4d8f;
  --ok: #3ddc97;
  --danger: #ff6b6b;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 30px rgba(0, 0, 0, 0.35);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
}

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

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: radial-gradient(120% 80% at 50% -10%, #181b22 0%, var(--bg) 55%);
}

.wrap {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 56px 24px 32px;
  flex: 1;
}

/* ---------- header ---------- */
.masthead {
  margin-bottom: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.brand .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(79, 140, 255, 0.14);
}

.masthead h1 {
  margin-top: 14px;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.masthead p {
  margin-top: 6px;
  color: var(--text-dim);
  font-size: 14.5px;
}

.masthead .target {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 550;
}

/* ---------- card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ---------- tabs (segmented control) ---------- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 6px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.tab {
  flex: 1;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

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

.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.panel-body {
  padding: 22px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fade 0.25s ease;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- dropzone ---------- */
.drop {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--surface-2);
}

.drop:hover {
  border-color: var(--accent-dim);
}

.drop.dragover {
  border-color: var(--accent);
  background: rgba(79, 140, 255, 0.06);
}

.drop.has-file {
  border-style: solid;
  border-color: var(--accent-dim);
}

.drop .glyph {
  width: 30px;
  height: 30px;
  stroke: var(--text-faint);
  stroke-width: 1.6;
  fill: none;
  margin-bottom: 12px;
  transition: stroke 0.15s;
}

.drop:hover .glyph,
.drop.has-file .glyph {
  stroke: var(--accent);
}

.drop .title {
  font-size: 14.5px;
  font-weight: 550;
  word-break: break-word;
}

.drop .hint {
  font-size: 12.5px;
  color: var(--text-faint);
  margin-top: 4px;
}

/* ---------- form fields ---------- */
.field {
  margin-top: 18px;
}

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-dim);
  margin-bottom: 7px;
}

.field select,
.field input[type="number"] {
  width: 100%;
  appearance: none;
  -moz-appearance: textfield; /* drop Firefox spinner (and its inner border) */
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  transition: border-color 0.15s;
}

/* Drop the WebKit number spinners (they can render an extra inner edge). */
.field input[type="number"]::-webkit-outer-spin-button,
.field input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.field select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%239aa1ac' stroke-width='2'><path d='M3 5l4 4 4-4'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.field select:focus,
.field input:focus {
  outline: none;
  /* single accent border on focus — no extra halo/double border */
  border-color: var(--accent);
}

.custom-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.custom-col {
  flex: 1;
  min-width: 0;
}

.custom-col input {
  width: 100%;
  min-width: 0;
}

.custom-row > span {
  color: var(--text-faint);
  font-size: 13px;
  line-height: 38px; /* vertically align the "×" with the inputs */
}

.link-toggle {
  appearance: none;
  background: none;
  border: 0;
  color: var(--accent);
  font: inherit;
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  padding: 10px 0 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.link-toggle::before {
  content: '+';
  font-size: 14px;
  line-height: 1;
}

.link-toggle[aria-expanded='true']::before {
  content: '−';
}

.link-toggle:hover {
  color: #5d97ff;
}

.hint-sm {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 8px;
}

.warn-sm {
  font-size: 11px;
  color: var(--danger);
  margin-top: 5px;
  line-height: 1.3;
}

/* Non-blocking attention notice (e.g. aspect-ratio mismatch) — amber, not red */
.notice {
  margin-top: 14px;
  padding: 11px 13px;
  font-size: 12.5px;
  line-height: 1.45;
  color: #f0c674;
  background: rgba(240, 198, 116, 0.08);
  border: 1px solid rgba(240, 198, 116, 0.35);
  border-radius: var(--radius-sm);
}

.notice strong {
  color: #f5d99a;
  font-weight: 600;
}

.custom-col input.invalid {
  border-color: var(--danger);
}

/* ---------- button ---------- */
.btn {
  width: 100%;
  margin-top: 20px;
  appearance: none;
  border: 0;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, transform 0.05s, opacity 0.15s;
}

.btn:hover:not(:disabled) {
  background: #5d97ff;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  background: var(--surface-2);
  color: var(--text-faint);
  cursor: not-allowed;
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--accent-dim);
}

/* ---------- progress / status ---------- */
.status {
  padding: 26px 22px;
  border-top: 1px solid var(--border);
  display: none;
}

.status.show {
  display: block;
  animation: fade 0.25s ease;
}

.status-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.spinner {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.status-label {
  font-size: 14.5px;
  font-weight: 550;
}

.status-sub {
  font-size: 12.5px;
  color: var(--text-faint);
  margin-top: 1px;
}

.bar {
  margin-top: 18px;
  height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 999px;
  transition: width 0.35s ease;
}

.pct {
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ---------- result ---------- */
.result {
  padding: 26px 22px;
  border-top: 1px solid var(--border);
  display: none;
}

.result.show {
  display: block;
  animation: fade 0.25s ease;
}

.result-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.result-head .check {
  width: 22px;
  height: 22px;
  stroke: var(--ok);
  stroke-width: 2.2;
  fill: none;
}

.result-head h3 {
  font-size: 15.5px;
  font-weight: 600;
}

.meta {
  display: grid;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 18px;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  padding: 10px 13px;
  font-size: 13px;
}

.meta-row .k {
  color: var(--text-dim);
}

.meta-row .v {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  text-align: right;
  word-break: break-all;
}

.meta-row .v.ok {
  color: var(--ok);
}

a.btn {
  display: block;
  text-align: center;
  text-decoration: none;
}

/* ---------- error toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 16px);
  /* Hidden until an error occurs — an empty div would otherwise show as a small
     bordered box at the bottom of the screen. */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  max-width: 92vw;
  background: var(--surface);
  border: 1px solid var(--danger);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  box-shadow: var(--shadow);
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.3s ease,
    visibility 0.3s;
  z-index: 10;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ---------- footer specs ---------- */
.specs {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-size: 11.5px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

footer {
  text-align: center;
  padding: 20px;
  font-size: 12px;
  color: var(--text-faint);
}

@media (max-width: 480px) {
  .wrap {
    padding: 36px 16px 24px;
  }
  .masthead h1 {
    font-size: 22px;
  }
}
