:root {
  --void: #000000;
  --abyss: #01090b;
  --mist: #021719;
  --mote: #1b5057;
  --cyan: #40c8d0;
  --cyan-dim: #2a8f96;
  --cyan-faint: rgba(64, 200, 208, 0.14);
  --line: rgba(64, 200, 208, 0.16);
  --text: #cfe9eb;
  --muted: #6f9296;
  --danger: #e07a7a;
  --radius: 14px;
  --font-title: "Cinzel", "Trajan Pro", Georgia, serif;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--void);
  color: var(--text);
  font: 15px/1.5 var(--font-ui);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------ backdrop */

.glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 48% 34% at 32% 58%, rgba(3, 30, 34, 0.9), transparent 70%),
    radial-gradient(ellipse 30% 24% at 82% 50%, rgba(2, 22, 26, 0.7), transparent 70%),
    radial-gradient(ellipse 70% 45% at 50% 62%, var(--mist), transparent 75%);
}

#motes {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

/* ------------------------------------------------------------ layout */

.shell {
  position: relative;
  z-index: 2;
  min-height: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: 14vh 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.masthead { text-align: center; }

.masthead h1 {
  margin: 0;
  font: 400 clamp(34px, 7vw, 56px)/1 var(--font-title);
  letter-spacing: 0.32em;
  text-indent: 0.32em; /* balance trailing letter-spacing */
  text-transform: uppercase;
  color: #e6f6f7;
  text-shadow: 0 0 24px rgba(64, 200, 208, 0.25), 0 0 2px rgba(64, 200, 208, 0.4);
}

.tagline {
  margin: 14px 0 0;
  color: var(--muted);
  letter-spacing: 0.24em;
  font-size: 12px;
  text-transform: uppercase;
}

.panel {
  background: linear-gradient(180deg, rgba(4, 18, 20, 0.72), rgba(1, 8, 10, 0.78));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(64, 200, 208, 0.06);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ------------------------------------------------------------ mode tabs */

.modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
}

.mode {
  font: 500 13px var(--font-ui);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 7px;
  padding: 9px 0;
  cursor: pointer;
  transition: color .2s, background .2s;
}
.mode:hover { color: var(--text); }
.mode.is-active {
  color: var(--cyan);
  background: var(--cyan-faint);
}

/* ------------------------------------------------------------ drop zone */

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 36px 16px;
  border: 1px dashed rgba(64, 200, 208, 0.28);
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  transition: border-color .2s, background .2s;
}
.drop:hover, .drop.is-over {
  border-color: var(--cyan);
  background: rgba(64, 200, 208, 0.05);
}
.drop.has-file { border-style: solid; }
.drop-icon { color: var(--cyan-dim); margin-bottom: 4px; }
.drop-title { font-weight: 500; overflow-wrap: anywhere; }
.drop-sub { color: var(--muted); font-size: 13px; }

/* ------------------------------------------------------------ url */

.url-row input, .opt input, .opt select {
  width: 100%;
  font: 14px var(--font-ui);
  color: var(--text);
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.url-row input:focus, .opt input:focus, .opt select:focus {
  border-color: var(--cyan-dim);
  box-shadow: 0 0 0 3px rgba(64, 200, 208, 0.12);
}
.url-row input::placeholder { color: #3e5d60; }

.url-info {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
  font-size: 13px;
}
.url-info img {
  width: 96px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  flex: none;
}
.url-info img[src=""] { display: none; }
.url-title { font-weight: 500; overflow-wrap: anywhere; }
.url-meta { color: var(--muted); }

/* ------------------------------------------------------------ targets */

.targets { display: flex; flex-direction: column; gap: 12px; }
.group-label {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 7px;
}
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  font: 500 13px var(--font-ui);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s, box-shadow .15s;
}
.chip:hover { border-color: var(--cyan-dim); }
.chip.is-selected {
  color: #001114;
  background: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 18px rgba(64, 200, 208, 0.35);
}

/* ------------------------------------------------------------ options */

.options summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
  list-style: none;
  user-select: none;
}
.options summary::-webkit-details-marker { display: none; }
.options summary::before { content: "+ "; color: var(--cyan-dim); }
.options[open] summary::before { content: "− "; }
.opt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
.opt { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.opt input, .opt select { padding: 9px 11px; }
.opt[hidden] { display: none; }

/* ------------------------------------------------------------ actions */

.go, .download {
  display: block;
  width: 100%;
  font: 600 14px var(--font-ui);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-align: center;
  text-decoration: none;
  color: #001114;
  background: var(--cyan);
  border: 0;
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  box-shadow: 0 0 28px rgba(64, 200, 208, 0.28);
  transition: box-shadow .2s, transform .1s, opacity .2s;
}
.go:hover:not(:disabled), .download:hover { box-shadow: 0 0 40px rgba(64, 200, 208, 0.45); }
.go:active:not(:disabled), .download:active { transform: translateY(1px); }
.go:disabled {
  cursor: not-allowed;
  color: var(--muted);
  background: rgba(64, 200, 208, 0.08);
  box-shadow: none;
}

.again {
  width: 100%;
  margin-top: 10px;
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 10px;
  padding: 11px;
  font: 500 13px var(--font-ui);
  letter-spacing: 0.1em;
  cursor: pointer;
}
.again:hover { color: var(--text); border-color: var(--cyan-dim); }

.status {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
}
.status-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.status-text {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text);
}
.status.is-indeterminate .status-text::after {
  content: "";
  animation: ellipsis 1.2s steps(4, end) infinite;
}
@keyframes ellipsis {
  0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; }
}
.status-pct {
  font: 500 26px/1 var(--font-title);
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 18px rgba(64, 200, 208, 0.45);
  min-width: 3.2ch;
  text-align: right;
}
.status-detail {
  font-size: 12px;
  color: var(--muted);
  min-height: 1.5em;
  overflow-wrap: anywhere;
}
.status-detail:empty { display: none; }

.bar {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: rgba(64, 200, 208, 0.08);
  box-shadow: inset 0 0 0 1px rgba(64, 200, 208, 0.12);
  overflow: hidden;
}
.bar span {
  position: relative;
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #1b6f76, var(--cyan));
  box-shadow: 0 0 14px rgba(64, 200, 208, 0.6);
  transition: width .5s cubic-bezier(.25, .8, .35, 1);
  overflow: hidden;
}
/* a slow sheen travelling along the filled part */
.bar span::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  transform: translateX(-100%);
  animation: sheen 2.2s ease-in-out infinite;
}
@keyframes sheen { to { transform: translateX(100%); } }

.status.is-indeterminate .bar span {
  width: 28%;
  transition: none;
  animation: sweep 1.5s ease-in-out infinite;
}
@keyframes sweep {
  from { transform: translateX(-100%); }
  to { transform: translateX(360%); }
}
.status.is-error { border-color: rgba(224, 122, 122, 0.3); }
.status.is-error .status-text {
  color: var(--danger);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  line-height: 1.5;
}
.status.is-error .bar,
.status.is-error .status-pct { display: none; }

.advanced { margin-top: 12px; }
.advanced summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  color: var(--muted);
  user-select: none;
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::before { content: "+"; color: var(--cyan-dim); }
.advanced[open] summary::before { content: "−"; }

.foot {
  margin-top: auto;
  text-align: center;
  font-size: 12px;
  color: #3e5d60;
}

[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

@media (max-width: 480px) {
  .shell { padding-top: 9vh; }
  .panel { padding: 16px; }
}

/* ------------------------------------------------------------ static (Pages) additions */

.server-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}
.server-row input {
  flex: 1;
  min-width: 0;
  font: 12px var(--font-ui);
  color: var(--text);
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 10px;
  outline: none;
}
.server-row input:focus { border-color: var(--cyan-dim); }
.dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: #3e5d60;
}
.dot.is-ok { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.dot.is-bad { background: var(--danger); }
.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.hint code { color: var(--text); font-size: 11.5px; }
.cancel {
  align-self: center;
  background: none; border: 0; color: var(--muted);
  font: 500 12px var(--font-ui); letter-spacing: 0.1em; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}
.cancel:hover { color: var(--text); }
.hint a { color: var(--cyan); }
