:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel-2: #1f2937;
  --soft: #334155;
  --border: #243041;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 16px 40px rgba(0,0,0,.28);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top right, rgba(56,189,248,.14), transparent 28%),
    radial-gradient(circle at top left, rgba(34,197,94,.10), transparent 20%),
    var(--bg);
  color: var(--text);
  line-height: 1.45;
}

a {
  color: inherit;
  text-decoration: none;
}

.shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  padding: 22px 24px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(17,24,39,.8);
  backdrop-filter: blur(10px);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.title-wrap h1 {
  margin: 0 0 8px;
  font-size: clamp(1.8rem, 2.6vw, 3rem);
  line-height: 1.05;
}

.title-wrap h1.muggwomp-title {
  display: inline-block;
  font-family: 'Segoe UI', sans-serif;
  font-weight: 700;
  font-size: 2.2rem;
  line-height: 1.14;
  padding-bottom: 0.08em;
  background: linear-gradient(
    to bottom,
    #f57c00 0%,
    #ff9800 30%,
    #ffb300 60%,
    #ffd54f 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow:
    0 2px 4px rgba(0,0,0,0.5),
    0 0 10px rgba(255,140,0,0.4);
}

.title-wrap p {
  margin: 0;
  color: var(--muted);
  max-width: 880px;
}

.notice {
  position: fixed;
  top: 20px;
  right: max(20px, calc((100vw - 1400px) / 2 + 20px));
  width: min(420px, calc(100vw - 40px));
  margin: 0;
  padding: 13px 16px;
  border: 1px solid rgba(56,189,248,.22);
  background: rgba(15,23,42,.94);
  backdrop-filter: blur(14px);
  color: #d6f3ff;
  border-radius: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  box-shadow: 0 20px 48px rgba(2,6,23,.42);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity .18s ease, transform .18s ease;
  z-index: 40;
}

.notice.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.notice span {
  flex: 1;
  min-width: 0;
}

.notice button {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  color: #d6f3ff;
  font-size: 1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(460px, 1.05fr);
  gap: 18px;
  align-items: start;
}

.main-col,
.side-col {
  display: grid;
  gap: 18px;
}

.card {
  background: rgba(17,24,39,.86);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card h2,
.card h3 {
  margin: 0 0 14px;
  font-size: 1.1rem;
}

.subtle {
  color: var(--muted);
  font-size: .94rem;
}

.url-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
}

.input,
.select,
.number {
  width: 100%;
  background: rgba(255,255,255,.03);
  color: var(--text);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px;
  padding: 14px 15px;
  font: inherit;
  outline: none;
}

.select {
  color: #111827;
  background: #f8fafc;
  border-color: rgba(255,255,255,.1);
}

.select option {
  color: #000;
  background: #fff;
}

.input:focus,
.select:focus,
.number:focus {
  border-color: rgba(56,189,248,.55);
  box-shadow: 0 0 0 4px rgba(56,189,248,.12);
}

.analysis {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 18px;
  align-items: start;
}

.thumb {
  aspect-ratio: 16 / 10;
  border-radius: 18px;
  background:
    linear-gradient(140deg, rgba(56,189,248,.24), rgba(34,197,94,.18)),
    linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.06));
  border: 1px solid rgba(255,255,255,.08);
  display: grid;
  place-items: center;
  color: #dbeafe;
  font-weight: 700;
  letter-spacing: .02em;
  text-align: center;
  padding: 18px;
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 16px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 12px;
}

.info-item {
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 14px;
  padding: 12px 14px;
}

.info-item .label {
  color: var(--muted);
  font-size: .82rem;
  margin-bottom: 6px;
}

.section {
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid rgba(255,255,255,.07);
}

.section:first-of-type {
  padding-top: 0;
  margin-top: 0;
  border-top: none;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.segmented button {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  color: var(--text);
  padding: 11px 14px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
}

.segmented button.active {
  background: rgba(56,189,248,.14);
  border-color: rgba(56,189,248,.45);
  color: #d6f3ff;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  font-size: .92rem;
  color: var(--muted);
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 12px;
}

.toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.07);
  background: rgba(255,255,255,.03);
}

.toggle .meta {
  display: grid;
  gap: 4px;
}

.switch {
  position: relative;
  width: 54px;
  height: 31px;
  background: var(--soft);
  border-radius: 999px;
  transition: .18s ease;
  flex-shrink: 0;
  cursor: pointer;
}

.switch::after {
  content: "";
  position: absolute;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: #fff;
  top: 4px;
  left: 4px;
  transition: .18s ease;
  box-shadow: 0 4px 10px rgba(0,0,0,.2);
}

.switch.on {
  background: rgba(34,197,94,.7);
}

.switch.on::after {
  left: 27px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.btn {
  border: 1px solid rgba(255,255,255,.09);
  background: var(--panel);
  color: var(--text);
  border-radius: 14px;
  padding: 11px 14px;
  cursor: pointer;
  transition: .18s ease;
  font: inherit;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(56,189,248,.35);
}

.btn.primary {
  background: linear-gradient(135deg, rgba(56,189,248,.95), rgba(14,165,233,.85));
  color: #07131e;
  border: none;
  font-weight: 700;
}

#analyzeBtn,
#summaryStartBtn,
#summaryDownloadLink,
#downloadLink {
  background: linear-gradient(
    to bottom,
    #f57c00 0%,
    #ff9800 30%,
    #ffb300 60%,
    #ffd54f 100%
  );
  color: #2d1400;
  box-shadow:
    0 10px 22px rgba(245,124,0,.2),
    0 0 10px rgba(255,140,0,.2);
}

.btn.secondary {
  background: rgba(255,255,255,.03);
  color: var(--text);
}

.btn.warn {
  background: rgba(245,158,11,.14);
  color: #fde7b3;
  border-color: rgba(245,158,11,.25);
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.btn:disabled:hover {
  transform: none;
  border-color: rgba(255,255,255,.09);
}

.summary-list,
.activity-list,
.failure-list {
  display: grid;
  gap: 10px;
}

.summary-item,
.activity-item,
.failure-item {
  border: 1px solid rgba(255,255,255,.06);
  background: rgba(255,255,255,.03);
  border-radius: 14px;
  padding: 12px 14px;
}

.summary-item {
  display: grid;
  gap: 6px;
  align-items: start;
}

.summary-item span {
  display: block;
  font-size: .88rem;
  color: var(--muted);
  line-height: 1.2;
}

.summary-item strong {
  display: block;
  text-align: left;
  max-width: none;
  overflow-wrap: anywhere;
  line-height: 1.3;
  font-size: 1rem;
}

.summary-item-wide {
  grid-column: 1 / -1;
}

.playlist-reference-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.playlist-reference-header h2 {
  margin-bottom: 6px;
}

.playlist-reference-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  margin-top: 16px;
}

.playlist-selection-panel {
  margin: 0;
  border: 1px solid rgba(255,255,255,.06);
  background: rgba(255,255,255,.025);
  border-radius: 16px;
  padding: 16px;
}

.playlist-selection-panel h3 {
  margin-bottom: 12px;
}

.playlist-selection-panel .toggle {
  margin-top: 0;
}

.playlist-selection-panel .field {
  margin-top: 14px;
}

.playlist-reference-main {
  min-width: 0;
}

.playlist-reference-toolbar,
.playlist-reference-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.playlist-reference-toolbar {
  margin-top: 0;
  flex-wrap: wrap;
}

.playlist-reference-toolbar .input {
  flex: 1;
  min-width: 220px;
}

.playlist-reference-range,
.playlist-reference-page {
  color: var(--muted);
  font-size: .92rem;
  white-space: nowrap;
}

.playlist-reference-list {
  margin-top: 16px;
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}

.playlist-reference-item,
.playlist-reference-empty {
  border: 1px solid rgba(255,255,255,.06);
  background: rgba(255,255,255,.03);
  border-radius: 14px;
  padding: 12px 14px;
}

.playlist-reference-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.playlist-reference-item-number {
  min-width: 44px;
  border-radius: 999px;
  border: 1px solid rgba(56,189,248,.22);
  background: rgba(56,189,248,.1);
  color: #d6f3ff;
  padding: 7px 10px;
  text-align: center;
  font-weight: 700;
  cursor: pointer;
}

.playlist-reference-item-number:hover {
  border-color: rgba(56,189,248,.42);
  background: rgba(56,189,248,.18);
}

.playlist-reference-item-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playlist-reference-empty {
  color: var(--muted);
}

.progress-block {
  display: grid;
  gap: 14px;
}

.progress-bar {
  height: 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.06);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(56,189,248,.95), rgba(34,197,94,.9));
  border-radius: inherit;
  transition: width .35s ease;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: .95rem;
}

.cooldown-card {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(245,158,11,.25);
  background: linear-gradient(180deg, rgba(245,158,11,.12), rgba(245,158,11,.06));
  border-radius: 16px;
  padding: 14px 16px;
}

.cooldown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cooldown-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15,23,42,.35);
  border: 1px solid rgba(255,255,255,.08);
  color: #fde7b3;
  font-size: .82rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.cooldown-card strong {
  font-size: 1.3rem;
  color: #fff2cd;
  letter-spacing: .03em;
}

.cooldown-card p {
  margin: 0;
  color: #fde7b3;
  line-height: 1.45;
}

.cooldown-note {
  font-size: .88rem;
  color: rgba(255, 242, 205, .78);
}

.cooldown-actions {
  display: flex;
  justify-content: flex-start;
}

.summary-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(230px, 270px);
  gap: 20px;
  align-items: start;
}

.summary-left,
.summary-right {
  display: grid;
  gap: 14px;
}

#summaryCard .summary-layout {
  grid-template-areas:
    "list media"
    "list action";
  row-gap: 14px;
}

#summaryCard .summary-layout.media-hidden {
  grid-template-columns: 1fr;
  grid-template-areas: "list";
}

#summaryCard .summary-left {
  display: contents;
}

#summaryCard .summary-left > .summary-list {
  grid-area: list;
}

#summaryCard .summary-right {
  grid-area: media;
}

#summaryActionRow {
  grid-area: action;
  margin-top: -116px;
  justify-self: start;
  align-self: start;
}

#summaryStartBtn,
#summaryDownloadLink {
  width: 112px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.summary-media-thumb {
  aspect-ratio: 16 / 10;
  border-radius: 18px;
  background:
    linear-gradient(140deg, rgba(56,189,248,.24), rgba(34,197,94,.18)),
    linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.06));
  border: 1px solid rgba(255,255,255,.08);
  display: grid;
  place-items: center;
  color: #dbeafe;
  font-weight: 700;
  letter-spacing: .02em;
  text-align: center;
  padding: 18px;
  overflow: hidden;
  max-width: 270px;
  justify-self: end;
}

.summary-media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
}

.summary-media-meta {
  display: grid;
  gap: 4px;
}

.summary-media-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.28;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.summary-media-line {
  color: var(--muted);
  font-size: .94rem;
}

.muted-box {
  padding: 14px;
  border-radius: 16px;
  border: 1px dashed rgba(255,255,255,.12);
  background: rgba(255,255,255,.02);
  color: var(--muted);
}

.playlist-selection-feedback {
  margin-top: 14px;
}

.playlist-selection-feedback.is-active {
  border-style: solid;
  border-color: rgba(56,189,248,.28);
  background: rgba(56,189,248,.06);
  color: #d6f3ff;
}

.playlist-selection-feedback.is-invalid {
  border-style: solid;
  border-color: rgba(239,68,68,.26);
  background: rgba(239,68,68,.08);
  color: #fecaca;
}

.hidden {
  display: none !important;
}

.locked {
  opacity: .62;
  pointer-events: none;
  filter: saturate(.75);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2,6,23,.68);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}

.modal {
  width: min(560px,100%);
  background: rgba(17,24,39,.98);
  border: 1px solid rgba(239,68,68,.28);
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 22px 60px rgba(0,0,0,.45);
}

.modal h2 {
  margin: 0 0 12px;
  color: #fee2e2;
}

.modal p {
  margin: 0 0 10px;
  color: var(--text);
}

.modal .subtle {
  display: block;
  margin-top: 6px;
}

@media (max-width: 1080px) {
  .summary-layout {
    grid-template-columns: 1fr;
  }

  .playlist-reference-layout {
    grid-template-columns: 1fr;
  }

  #summaryCard .summary-layout {
    grid-template-areas:
      "list"
      "media"
      "action";
  }

  #summaryActionRow {
    margin-top: 0;
  }

  .summary-media-thumb {
    max-width: none;
    justify-self: stretch;
  }
}

@media (max-width:1080px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .main-col,
  .side-col {
    display: contents;
  }

  #urlCard { order: 1; }
  #summaryCard { order: 2; }
  #analysisCard { order: 3; }
  #optionsCard { order: 4; }
  #progressCard { order: 5; }
  #resultCard { order: 6; }
  #maintenanceCard { order: 7; }
}

@media (max-width:760px) {
  .shell {
    padding: 14px;
  }

  .notice {
    top: 14px;
    left: 14px;
    right: 14px;
    width: auto;
  }

  .header {
    padding: 18px;
    flex-direction: column;
  }

  .url-row,
  .analysis,
  .field-grid,
  .toggle-grid,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .url-row {
    grid-template-columns: 1fr;
  }

  .brand {
    gap: 14px;
  }

  .brand-logo {
    width: 58px;
    height: 58px;
  }
}
