:root {
  color-scheme: light dark;
  --foreground: #282828;
  --background: #fefefe;
  --buttonface: color-mix(in srgb, var(--background) 96%, var(--foreground));
  --linktext: #085fcc;
  --titlebar-height: 34px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --foreground: #eee;
    --background: #282828;
    --linktext: #99c8ff;
  }
}

html {
  height: 100%;
  color: var(--foreground);
  background-color: var(--background);
  user-select: none;
  overflow: hidden;
}
body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  margin: 0 !important;
  overflow: hidden;
}

.ProfilePicker {
  display: flex;
  margin: auto 0;
  flex-direction: column;
  padding: 0 0 80px;
  overflow: auto;
  position: relative;
}
.ProfilePicker-Avatar {
  margin: 0 auto;
  width: 120px;
  height: 120px;
  pointer-events: none;
  border-radius: 50%;
}

.ProfilePicker-List {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  padding: 0 60px 30px;
}
.ProfilePicker-Profile {
  position: relative;
  padding: 21px 12px 18px;
  display: grid;
  height: auto;
  gap: 18px;
  background-color: var(--buttonface);
  border: 0;
  border-radius: 12px;
  transition: background 64ms linear, outline-offset 200ms linear;
  outline-offset: 1px;
}
.ProfilePicker-Profile:has(.ProfilePicker-Drop.open),
.ProfilePicker-Profile:has(.ProfilePicker-Menu:hover) {
  pointer-events: none;
}
.ProfilePicker-Profile > * {
  pointer-events: auto;
}

.ProfilePicker-Name {
  user-select: all;
  text-align: center;
  border: none;
  background-color: transparent;
  border-radius: 0;
  border: solid transparent;
  border-width: 0 0 2px 0;
  padding: 3px;
  transition: border-color 200ms linear;
  font-size: 14px;
  text-overflow: ellipsis;
  width: -webkit-fill-available;
  &:hover {
    border-color: color-mix(in srgb, var(--background) 80%, var(--foreground));
  }
  &:focus {
    border-color: var(--linktext);
    outline: none;
  }
}

.ProfilePicker-Controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 15px 20px;
  background-color: var(--background);
  border-top: 1px solid color-mix(in srgb, var(--background) 85%, var(--foreground));
  z-index: 10;
}
.ProfilePicker-Controls button {
  -webkit-appearance: none;
  padding: 6px 12px 6px 6px;
  border-radius: 24px;
  border: 1px solid var(--linktext);
  font-size: inherit;
  display: flex;
  align-items: center;
  gap: 9px;
  background-color: transparent;
  color: var(--linktext);
  margin-left: 0;
}
.ProfilePicker-Controls label {
  display: flex;
  gap: 6px;
  font-size: inherit;
  margin-right: 0;
}
.ProfilePicker-Controls label input {
  scale: 1.2;
}

h1 {
  font-size: 24px;
  margin: 24px 0;
  grid-column: 1 / span all;
  text-align: center;
  font-weight: 400;
}
p {
  max-width: 50ch;
  text-align: center;
  margin: 0 auto 36px;
}
.logo {
  pointer-events: none;
  margin: var(--titlebar-height) auto 0;
}

.ProfilePicker-Menu {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  rotate: 90deg;
  padding-bottom: 9px;
  &:not(:hover) {
    background-color: transparent;
  }
}
.ProfilePicker-Menu:focus menu,
.ProfilePicker-Menu:active menu {
  display: flex;
}
button:hover {
  transition-duration: 64ms;
  background-color: color-mix(in srgb, var(--background) 92%, var(--foreground));
}
button:active:not(:has(input:focus-within)) {
  transition-duration: 64ms;
  background-color: color-mix(in srgb, var(--background) 90%, var(--foreground));
}
button:focus-visible {
  outline-offset: 3px;
}

.ProfilePicker-Drop.open {
  display: flex;
}
.ProfilePicker-Drop {
  position: absolute;
  top: 28px;
  left: 40px;
  display: none;
  flex-direction: column;
  min-width: 140px;
  background-color: color-mix(in srgb, var(--background) 92%, var(--foreground));
  padding: 6px 0;
  margin: 0;
  box-shadow: 0 0 10px #0006;
  border-radius: 10px;
  overflow: hidden;
  z-index: 1;
}
.ProfilePicker-Drop li {
  padding: 6px 12px;
  list-style: none;
  text-align: left;
  &.disabled {
    pointer-events: none;
    opacity: 0.5;
  }
}
.ProfilePicker-Drop li:focus {
  outline: unset;
}

.ProfilePicker-Drop li:focus-visible,
.ProfilePicker-Drop:not(:has(li:focus-visible)) li:hover {
  color: var(--background);
  background-color: var(--linktext);
  outline: unset;
}

dialog.ProfilePicker-Dialog {
  --iconSize: 48px;
  width: 600px;
  background-color: var(--background);
  padding: 18px;
  box-shadow: 0 0 0 1px #0003, 0 0 6px #0006;
  border: unset;
  border-radius: 12px;
  max-width: 80vw;
  transform: translateY(30px);
  transition: all 0.3s allow-discrete;
  transform-origin: center top;
  opacity: 0;
  display: none;
  &:open {
    opacity: 1;
    transform: translateY(0);
    display: block;
  }
  &::backdrop {
    background-color: #0110;
    transition: all 0.3s allow-discrete;
  }
  &:open::backdrop {
    background-color: #0116;
  }
  form {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .ProfilePicker-Name {
    font-size: 18px;
    margin: 0;
  }
  .ProfilePicker-Buttons {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 6px;
    input {
      border-radius: 6px;
      padding: 3px 12px;
      border-width: 1px;
      border-style: solid;
    }
  }
  input[type='submit'] {
    color: #fff;
    background-color: #085fcc;
    border: 0;
  }
  &.confirm {
    width: 260px;
    input[type='submit'] {
      color: #fff;
      background-color: #900;
    }
  }
}
@starting-style {
  dialog.ProfilePicker-Dialog:open {
    opacity: 0;
    transform: translateY(-30px);
  }
  dialog.ProfilePicker-Dialog:open::backdrop {
    background-color: #0110;
  }
}

.avatarlist {
  display: grid;
  grid-gap: 12px;
  grid-template-columns: repeat(auto-fill, var(--iconSize));
  justify-content: center;
}

.avatarbox {
  border: unset;
  padding: unset;
  background: var(--background);
  width: var(--iconSize);
  height: var(--iconSize);
  display: grid;
  border-radius: 50%;
  transition: scale 200ms ease-out;
}

.avatarbox.selected {
  outline: 3px solid var(--linktext);
}

.avatarbox:hover {
  scale: 1.2;
}

.avatarbox.avatarbox-custom {
  color: #fff;
  max-width: var(--iconSize);
  line-height: var(--iconSize);
  max-height: var(--iconSize);
  font-size: var(--iconSize);
  font-weight: 100;
  background: color-mix(in srgb, var(--background) 45%, var(--foreground));
}

.avatarbox-image {
  border-radius: 50%;
  background-size: 100%;
  background-repeat: no-repeat;
}

@media (prefers-color-scheme: dark) {
  :root {
    --foreground: #eee;
    --background: #282828;
    --linktext: #99c8ff;
  }

  .ProfilePicker-Controls button {
    background-image:
      linear-gradient(color-mix(in srgb, var(--background) 90%, var(--foreground)),
      color-mix(in srgb, var(--background) 100%, var(--foreground)));
    &:hover {
      background: var(--background);
    }
  }
}

/* ====== WINDOW TITLE BAR ====== */
.window-bar {
  -webkit-app-region: drag;
  pointer-events: none;
  user-select: none;
  display: none;
  position: fixed;
  inset: 0;
  padding: 0 12px 0 20px;
  justify-content: space-between;
  align-items: center;
  background-color: color-mix(in srgb, var(--foreground), transparent 95%);
  border-bottom: 1px solid color-mix(in srgb, var(--background) 85%, var(--foreground));
  color: var(--foreground);
  height: var(--titlebar-height);
  z-index: 1;
}

/* When window-bar is shown, content container should account for its height */
.window-bar.visible {
  display: flex;
}
.window-bar.visible ~ .ProfilePicker {
  top: var(--titlebar-height);
}

.title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ====== WINDOW BUTTONS ====== */
.window-close {
  -webkit-app-region: no-drag;
  width: 25px;
  height: 20px;
  border: 0;
  border-radius: 6px;
  pointer-events: all;
  background-color: color-mix(in srgb, var(--foreground), transparent 90%);
  transition: background 0.3s, fill 0.3s;
}

.window-close:hover{
  background-color: color-mix(in srgb, var(--foreground), transparent 85%);
  transition-duration: 0s;
}

.window-close:active{
  filter: brightness(0.93);
}

.window-close svg {
  width: 10px;
  height: 10px;
  fill: currentColor;
}
