body {
  --text: #ddd;
  --text-dim: #ccc;
  --base: #1a1a1a;
  --up: color-mix(in oklab, var(--base) 50%, #3a3a3a 50%);
  --top: color-mix(in oklab, var(--base) 50%, #585858 50%);
  display: flex;
  flex-direction: column;
  width: 100dvw;
  height: 100dvh;
  color: var(--text);
  font-family: Lexend, Arial, sans-serif;
  margin: 0px;
  background-color: var(--up);
  overflow: hidden;
}
* {
  transition-property: right, color, background-color, border-color;
  transition-duration: 500ms;
}
h1, h2 {
  margin: 0px;
}
a {
  color: #8af;
}
input, select {
  color: currentColor;
  border: none;
  border-radius: 1rem;
  background-color: var(--base);
}
button {
  cursor: pointer;
  color: currentColor;
  padding: 5px;
  border: none;
  background: none;
}
button:has(svg) {
  display: flex;
  align-items: center;
  justify-content: center;
}
svg {
  fill: currentColor;
  stroke: currentColor;
}

dialog {
  color: var(--text);
  font-family: Lexend, Arial, sans-serif;
  padding: 5px;
  border: 2px var(--base) solid;
  border-radius: 0.5rem;
  background: var(--up);
  overflow: visible;
}

.rmenu {
  position: absolute;
  flex-direction: column;
  margin: 0px;
  z-index: 999;
}
.rmenu[open] {
  display: flex;
}
.rmenu button {
  margin: 0px;
  padding: 4px 2px;
}

#tabs {
  display: flex;
  height: 30px;
  background-color: var(--base);
}
#tabs div {
  display: flex;
  width: fit-content;
  height: 30px;
}
#tabs button {
  flex: 1;
  display: flex;
  gap: 5px;
  align-items: center;
  max-width: 175px;
  min-width: 0px;
  text-align: left;
  margin: 2px;
  border-radius: 0.5rem;
  overflow: hidden;
  container-type: inline-size;
}
@container (max-width: 45px) {
  #tabs button .title {
    display: none;
  }
}
@container (max-width: 35px) {
  #tabs button[active] img {
    display: none;
  }
}
@container (max-width: 30px) {
  #tabs button:not([active]) .close {
    display: none;
  }
}
#tabs button:hover {
  background-color: var(--top);
}
#tabs button.add {
  flex: 0;
  min-width: 26px;
  border-radius: 1rem;
}
#tabs button[active] {
  margin-bottom: 0px;
  border-radius: 0.75rem 0.75rem 0px 0px;
  background-color: var(--up);
}
#tabs button img {
  width: 16px;
  height: 16px;
  object-fit: contain;
}
#tabs button .title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
}
#tabs button .close {
  padding: 0px 5px;
  border-radius: 1rem;
}
#tabs button .close:hover {
  background-color: var(--top);
}

/* Vertical tabs */
#box #tabs {
  flex-direction: column;
  height: 100%;
  border-right: 2px var(--top) solid;
  background: none;
}
#box #tabs div {
  flex-direction: column;
  width: 180px !important;
  height: unset;
}
#box #tabs button[active] {
  margin: 2px;
  border-radius: 0.5rem;
  background-color: var(--base);
}
#box #tabs button.add {
  width: fit-content;
  min-height: 26px;
  margin-inline: auto;
}

.nav {
  display: flex;
  gap: 5px;
  padding: 5px;
  border-bottom: 2px var(--top) solid;
}
.nav input {
  flex: 1;
  min-width: 0px;
  padding: 8px;
}
.nav button {
  border-radius: 1rem;
}
.nav button:hover {
  background-color: var(--top);
}
#url {
  outline: none;
}

main, #box {
  flex: 1;
  position: relative;
  display: flex;
  overflow: hidden;
}
iframe {
  flex: 1;
  margin: 0px;
  padding: 0px;
  border: none;
  box-sizing: border-box;
}

#settings, #history {
  position: absolute;
  top: 0px;
  right: -30dvw;
  bottom: 0px;
  width: 30dvw;
  padding: 10px;
  border-left: 2px var(--top) solid;
  background: var(--up);
  box-sizing: border-box;
  transition-property: right, color, background-color, border-color;
}
#settings b {
  display: block;
  font-size: 125%;
}
#settings label {
  display: block;
  width: fit-content;
  padding: 2px 0px;
}
#settings input, #settings select {
  color: var(--text-dim);
  padding: 2px;
}
#settings button, #history button {
  color: var(--text-dim);
  border-radius: 0.5rem;
  background-color: var(--base);
}
#settings .notice {
  color: var(--text-dim);
  font-size: 75%;
}

.title {
  display: flex;
  gap: 5px;
  align-items: center;
}
.title img {
  height: 30px;
}

.themes {
  display: flex;
  gap: 5px;
  justify-content: space-between;
  align-items: center;
}
#settings .themes button {
  flex: 1;
  color: #ddd;
  background-color: var(--color);
  aspect-ratio: 16 / 9;
}

input[type="color"] {
  height: 25px;
  padding: 0px !important;
  border-radius: 5px;
}

#history .inner {
  display: flex;
  gap: 2px;
  flex-direction: column;
}
#history .inner > span {
  cursor: pointer;
  display: flex;
  gap: 5px;
  align-items: center;
}
#history .inner > span span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#history .inner .title {
  flex-shrink: 0;
  font-weight: 500;
}
#history .inner .url {
  font-size: 70%;
  font-weight: 400;
  color: var(--text-dim);
}
#history img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

/* Mobile */
@media (max-width: 700px) {
  #settings, #history {
    right: -100dvw;
    width: 100dvw;
    border: none;
  }
}