:root {
  --fg-blue: #1a0dab;
  --fg-brown: #a52a2a;
  --fg-green: #00915c;
  --bg-light-dark: rgba(0, 0, 0, 0.05);
  --bg-dark: #4d5155;
  --bg-light: #fff;
  --bg-progress: #0074cc;
  --bg-progress-alt: #fff;
  --bg-progress-body: #ffffff0d;
  --disabled: 0.5;
}

body {
  font-size: 13px;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  background-color: var(--bg-light);
  color: #4d5156;
  display: grid;
  grid-template-rows: min-content 1fr min-content min-content;
  margin: 0;
  height: 100vh;
  accent-color: var(--bg-dark);
}
body[data-mode="error"] {
  background-color: #ffdcdc;
}
body::after {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  text-align: center;
  z-index: 2;
  line-height: 1.25;
}

body[data-mode=done] {
  background-color: #f1ffed;
}
body[data-mode=download]::after {
  content: 'Download is in progress. Do not close this window...';
}
body[data-mode=parse]::after {
  content: 'Parsing M3U8 manifest...';
}
body[data-mode=parse]::after,
body[data-mode=download]::after {
  color: #fff;
  font-size: 18px;
  background-color: rgba(0, 0, 0, 0.8);
}

footer {
  border-top: solid 4px var(--bg-light-dark);
  display: grid;
  grid-template-columns: min-content repeat(3, minmax(10px, min-content));
  white-space: nowrap;
  z-index: 2;
  align-items: center;
}
footer > div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: opacity 0.5s;
  opacity: 1;
  padding: 10px;
}
footer > div[id$=-selector]:active {
  opacity: var(--disabled);
  transition: 0s;
}

select,
button,
input[type=submit],
input[type=button] {
  height: 100%;
  color: #444;
  background-image: linear-gradient(rgb(237, 237, 237), rgb(237, 237, 237) 38%, rgb(222, 222, 222));
  box-shadow: rgba(0, 0, 0, 0.08) 0 1px 0, rgba(255, 255, 255, 0.75) 0 1px 2px inset;
  text-shadow: rgb(240, 240, 240) 0 1px 0;
}
button:not(:disabled),
input[type=submit]:not(:disabled),
input[type=button]:not(:disabled) {
  cursor: pointer;
}

select,
button,
textarea,
input {
  border: solid 1px rgba(0, 0, 0, 0.25);
}
button:disabled,
input[type=submit]:disabled,
input[type=button]:disabled {
  opacity: var(--disabled);
}
textarea {
  width: 100%;
  box-sizing: border-box;
  display: block;
}
textarea,
input[type=text],
input[type=number] {
  padding: 5px;
  outline: none;
}
textarea:focus,
input[type=text]:focus,
input[type=number]:focus {
  background-color: #e5f8ff;
}
a,
a:visited {
  color: #07c;
}
.hidden {
  display: none !important;
}
.disabled * {
  opacity: 0.5;
  pointer-events: none;
}

#intro {
  height: 100%;
  display: flex;
  justify-content: center;
  flex-direction: column;
  margin: auto;
  width: fit-content;
  position: absolute;
  inset: 0;
  padding: 2rem;
  box-sizing: border-box;
}
#intro ul {
  margin: 0;
  padding: 10px 25px;
}
body:not([data-mode=empty]) #intro {
  display: none;
}

#prompt {
  padding: 5px;
}
#prompt p {
  margin: 0;
  display: block;
  overflow: auto;
  white-space: pre-line;
  max-height: 50vh;
}
#prompt > form {
  background-color: var(--bg-light-dark);
  padding: 10px;
  max-height: 70%;
  overflow: hidden;
  display: grid;
  grid-template-rows: 1fr min-content min-content;
  grid-gap: 10px;
}
#prompt menu {
  padding: 0;
  direction: rtl;
}
#prompt menu button {
  padding: 5px 10px;
}
#prompt [name=value] {
  width: 100%;
  box-sizing: border-box;
}
#prompt [name=value]:not([required]) {
  display: none;
}
#prompt [value=extra]:empty {
  display: none;
}

.entry {
  display: contents;
}
.entry.done span {
  color: #007e00;
  font-weight: bold;
}
.entry.error span {
  color: #db0000;
  font-weight: bold;
}
#hrefs-container {
  overflow: auto;
  padding: 10px;
}
#hrefs {
  display: grid;
  grid-template-columns: min-content min-content min-content repeat(2, min-content) 1fr repeat(3, min-content);
  grid-gap: 2px 10px;
  align-items: center;
  overflow: hidden;
}
#hrefs * {
  overflow: hidden;
  white-space: nowrap;
  align-items: center;
  text-overflow: ellipsis;
}

#hrefs .entry:nth-child(2n) [data-id="href"] {
  background-color: var(--bg-light-dark);
}
#hrefs span[data-id=extracted-name] {
  font-style: italic;
}
#hrefs span[data-id=extracted-name],
#hrefs span[data-id=name] {
  max-width: 20ch;
}
#hrefs span[data-id=size] {
  color: var(--fg-blue);
  justify-self: center;
}
#hrefs span[data-id=href] {
  padding: 10px;
  color: var(--fg-brown);
}
#hrefs span[data-id=ext] {
  color: var(--fg-green);
  justify-self: center;
}
#hrefs input[type=button]:not(:last-child) {
  margin-right: -8px;
}
.entry[data-blocked="true"] span[data-id=name] {
  text-decoration: line-through;
}

#progress {
  z-index: 10;
  display: grid;
}
#progress progress {
  height: 5px;
  border: none;
  width: 100%;
}
#progress progress,
#progress progress::-webkit-progress-bar {
  background-color: var(--bg-progress-body);
}
#current-progress::-webkit-progress-value {
  background: var(--bg-progress);
}
#current-progress::-moz-progress-bar {
  background: var(--bg-progress);
}
#global-progress::-webkit-progress-value {
  background: var(--bg-progress-alt);
}
#global-progress::-moz-progress-bar {
  background: var(--bg-progress-alt);
}

body[data-mode=download] {
  grid-template-rows: min-content min-content 1fr min-content min-content;
}
body:not([data-mode=download]) #progress {
  display: none;
}
#progress progress[value="0"] {
  display: none;
}

#tools {
  padding: 10px;
  text-align: end;
  height: 32px;
}
body[data-mode=empty] #tools {
  visibility: hidden;
}

#options {
  width: 18px;
  height: 18px;
  background: url('images/options.svg') center center no-repeat;
  background-size: 18px;
  position: relative;
  overflow: visible;
  user-select: none;
  border-right: solid 5px var(--bg-light-dark);
}

#options > div {
  position: absolute;
  bottom: 0;
  left: 0;
  z-index: 2;
  padding: 25px 25px 44px 5px;
  cursor: default;
  visibility: hidden;
}
#options > div > div {
  box-shadow: 0 0 2px var(--bg-dark);
  background-color: var(--bg-light);
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr min-content;
  align-items: center;
  grid-gap: 10px;
}
#options:hover > div {
  visibility: visible;
}
#options input,
#options label {
  cursor: pointer;
}
#options input {
  background-color: var(--bg-light-dark);
  border: none;
  cursor: text;
  justify-self: end;
}
#options input[type="text"],
#options input[type="number"] {
  width: 20ch;
}
#options .sep,
#options a {
  grid-column: 1/3;
}
#options .sep {
  background-color: var(--bg-light-dark);
  height: 4px;
}
#options a {
  text-decoration: none;
  color: var(--bg-progress);
}
#options select {
  padding: 3px;
}
#power-container {
  display: contents;
}
#forbidden-container {
  background-color: #fff6d6;
  color: #1b2d5b;
  text-align: center;
  height: 0;
  visibility: collapse;
}
body.forbidden #forbidden-container {
  height: unset;
  visibility: unset;
  padding: 10px;
}

body[data-mode="prepare"] #download-all,
body[data-mode="download"] #download-all,
body[data-mode="prepare"] #hrefs input[type="submit"],
body[data-mode="download"] #hrefs input[type="submit"] {
  opacity: var(--disabled);
  pointer-events: none;
}

.contents {
  display: contents;
}
