:root {
  color-scheme: dark;
  --background: #0c1220;
  --surface: #151e30;
  --border: #2b3850;
  --text: #eef3ff;
  --muted: #a9b7cf;
  --accent: #8cb4ff;
  --accent-hover: #aac8ff;
  --error: #ffb4b4;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  line-height: 1.5;
}

.container {
  width: min(100% - 32px, 760px);
  margin: 0 auto;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 0;
}

.brand {
  color: var(--text);
  text-decoration: none;
  font-size: 1.15rem;
  font-weight: 750;
}

.intro {
  padding: 36px 0 24px;
}

h1 {
  margin: 14px 0 10px;
  font-size: clamp(1.8rem, 5vw, 2.7rem);
  line-height: 1.15;
  letter-spacing: -0.04em;
}

.subtitle {
  margin: 0 0 24px;
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 650;
}

.card {
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
}

label,
legend {
  font-weight: 650;
}

input[type="url"],
input[type="password"] {
  display: block;
  width: 100%;
  min-height: 50px;
  margin: 8px 0 24px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--background);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}

input::placeholder {
  color: #8998b2;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 10px;
}

.format-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.format-option {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 88px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
}

.format-option:has(input:checked) {
  border-color: var(--accent);
  background: #1b2d4a;
}

input[type="radio"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.format-option strong,
.format-option small {
  display: block;
}

.format-option small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.primary {
  background: var(--accent);
  color: #101a2b;
}

.primary:hover {
  background: var(--accent-hover);
}

.secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.secondary:hover {
  background: #21304a;
}

.button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.full-width {
  width: 100%;
}

.hint,
.footer-note {
  color: var(--muted);
  font-size: 0.85rem;
}

.hint {
  margin: 18px 0;
}

.footer-note {
  margin: 20px 0 36px;
  text-align: center;
}

.status-panel {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

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

#status-text {
  margin: 0 0 16px;
  overflow-wrap: anywhere;
}

.status-panel.error,
.notice.error {
  color: var(--error);
}

.spinner {
  width: 20px;
  height: 20px;
  margin-bottom: 16px;
  flex-shrink: 0;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login-card {
  width: min(100%, 440px);
}

.notice {
  padding: 12px;
  border: 1px solid currentColor;
  border-radius: 10px;
}

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

@media (max-width: 480px) {
  .card {
    padding: 20px;
  }

  .header {
    padding: 18px 0;
  }

  .header .button {
    padding: 9px 12px;
    font-size: 0.85rem;
  }

  .format-options {
    grid-template-columns: 1fr;
  }

  .intro {
    padding-top: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }
}

.debug-details {
  margin-top: 20px;
  color: var(--text);
}

.debug-details summary {
  cursor: pointer;
  font-weight: 650;
}

#debug-output {
  max-height: 360px;
  overflow: auto;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--background);
  color: var(--muted);
  font-family: monospace;
  font-size: 0.8rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.progress-container {
  margin-top: 22px;
}

.progress-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 0.9rem;
}

#progress-percent {
  flex-shrink: 0;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

#download-progress {
  display: block;
  width: 100%;
  height: 14px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  appearance: none;
  background: var(--background);
  accent-color: var(--accent);
}

#download-progress::-webkit-progress-bar {
  background: var(--background);
  border-radius: 999px;
}

#download-progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 999px;
}

#download-progress::-moz-progress-bar {
  background: var(--accent);
  border-radius: 999px;
}

#download-progress:indeterminate {
  background: linear-gradient(
    90deg,
    var(--background) 25%,
    var(--accent) 50%,
    var(--background) 75%
  );
  background-size: 200% 100%;
  animation: progress-loading 1.5s linear infinite;
}

#download-progress:indeterminate::-webkit-progress-bar {
  background: transparent;
}

#download-progress:indeterminate::-moz-progress-bar {
  background: transparent;
}

#progress-info {
  min-height: 1.3em;
  margin: 8px 0 0;
}

@keyframes progress-loading {
  from {
    background-position: 200% 0;
  }

  to {
    background-position: 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  #download-progress:indeterminate {
    animation: none;
  }
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#player-panel {
  margin-bottom: 16px;
}

#player-panel audio,
#player-panel video {
  display: block;
  width: 100%;
  margin-top: 12px;
  border-radius: 12px;
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.file-item:first-child {
  border-top: 0;
}

.file-info {
  min-width: 0;
}

.file-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.file-actions .button {
  padding: 8px 12px;
  font-size: 0.85rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#player-panel {
  margin-bottom: 16px;
}

#player-panel audio,
#player-panel video {
  display: block;
  width: 100%;
  margin-top: 12px;
  border-radius: 12px;
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.file-item:first-child {
  border-top: 0;
}

.file-info {
  min-width: 0;
}

.file-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.file-actions .button {
  padding: 8px 12px;
  font-size: 0.85rem;
}
