body {
  margin: 0;
  padding: 0;
  background-color: #fff;
  color: #000;
}

/* @media (prefers-color-scheme: dark) { */
body {
  background-color: #000;
  color: #fff;
}
/* } */

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 10px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

fieldset {
  margin-bottom: 10px;
  border: 1px solid #4a5568;
  border-radius: 4px;
  padding: 12px 12px 6px 12px;
  transition: all 0.3s ease;

  &.collapsed {
    padding: 0 12px;

    & > *:not(legend) {
      display: none;
    }

    & legend {
      opacity: 0.7;
    }
  }

  & legend {
    padding: 0 8px;
    color: #718096;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    transition: opacity 0.3s ease;

    &:hover {
      opacity: 0.7;
    }
  }

  & button {
    margin: 0 5px 10px 0;
  }
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.loading-spinner {
  color: white;
  padding: 20px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.8);
}

button {
  background-color: transparent;
  border: 1px solid #4a5568;
  color: #000;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;

  &[data-checked="true"] {
    color: #fff;
    background-color: #4a5568;
    border-color: #4a5568;
  }

  @media (hover: hover) {
    &:hover {
      background-color: #2d3748;
      border-color: #2d3748;
    }
  }

  &:disabled {
    border-color: #cbd5e0;
    color: #a0aec0;
    cursor: not-allowed;
    opacity: 0.7;
  }

  &:disabled:hover {
    background-color: #e2e8f0;
    border-color: #cbd5e0;
  }
}

/* @media (prefers-color-scheme: dark) { */
button:not(dialog button) {
  color: #fff;
}

dialog {
  button:hover {
    color: #fff;
  }
}
/* } */

.icon-button {
  position: fixed;
  bottom: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;

  & svg {
    width: 24px;
    height: 24px;
    fill: white;
  }
}

.export-button {
  left: 90px;
}

.import-button {
  left: 20px;
}

ruby {
  ruby-align: center;
}

/* Fix background color overlapping text */
ruby,
span {
  border: 1px solid transparent;
}

rt {
  font-size: 0.6em;
  color: rgba(255, 255, 255, 0.7);
}

span.ruby-like {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: bottom;
}

span.ruby-like rt {
  order: -1;
  font-size: 0.6em;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: -0.85em;
}

.noun {
  background-color: rgba(255, 99, 71, 0.5);
}

.verb {
  background-color: rgba(65, 105, 225, 0.5);
}

.adjective {
  background-color: rgba(50, 205, 50, 0.5);
}

.adverb {
  background-color: rgba(255, 165, 0, 0.5);
}

.pronoun {
  background-color: rgba(238, 130, 238, 0.5);
}

.media-player {
  background-color: #000;
  min-height: 200px;
  margin-bottom: 10px;
  position: relative;

  & video,
  & audio {
    width: 100%;
    height: auto;
  }
}

.media-control,
.edge-control {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;

  @media (hover: hover) {
    &:hover .control-icon {
      opacity: 0.8;
    }
  }
}

.media-controls-container {
  --left-width: 40%;
  --right-width: 40%;
  --side-margin: 10%;

  position: absolute;
  width: 100%;
  height: 100%;
  display: flex;
}

.media-control {
  position: absolute;
  height: 100%;
  display: flex;
  align-items: center;
  pointer-events: auto;

  &.left {
    width: var(--left-width);
    left: var(--side-margin);
    justify-content: center;
  }

  &.right {
    width: var(--right-width);
    left: calc(100% - var(--right-width) - var(--side-margin));
    justify-content: center;
  }

  &:only-child {
    width: 100%;
    left: 0;
  }
}

.edge-control {
  width: 10%;

  &.left {
    left: 0;
  }
  &.right {
    right: 0;
  }
}

.control-icon {
  color: rgba(255, 255, 255, 0.5);
  opacity: 0.3;
  pointer-events: none;

  &.media {
    width: 48px;
    height: 48px;
  }
}

.ios-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  background-color: black;
  overflow: hidden;
}

.fill-screen-video {
  object-fit: cover;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.fill-screen-video.fill-left {
  object-position: left center;
}

.fill-screen-video.fill-center {
  object-position: center center;
}

.fill-screen-video.fill-right {
  object-position: right center;
}

.ios-fullscreen.fill-mode {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.ios-fullscreen.fill-mode video {
  object-fit: cover;
  min-width: 100%;
  min-height: 100%;
}

.stats {
  position: absolute;
  font-size: 0.9em;
  top: 10px;
  right: 10px;
  color: #999;
  background: rgba(0, 0, 0, 0.5);
  padding: 5px 10px;
  border-radius: 4px;
  z-index: 10000;
}

.ios-fullscreen .stats {
  position: fixed;
}

.ios-fullscreen .fullscreen-toggle-bottom-right {
  position: fixed;
}

.fullscreen-toggle {
  left: 10px;
  right: auto;
  cursor: pointer;
  background: none;
  padding: 0;
}

.fullscreen-toggle svg {
  width: 20px;
  height: 20px;
}

.fullscreen-toggle-bottom-right {
  position: absolute;
  top: auto !important;
  bottom: 10px;
  right: 18px;
  left: auto;
  cursor: pointer;
  background: none;
  padding: 0;
}

.fullscreen-toggle-bottom-right svg {
  width: 20px;
  height: 20px;
}

.fillscreen-toggle {
  right: 10px;
  margin-top: -3.5px;
  cursor: pointer;
  background: none;
}

.history {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2.5px;

  & div {
    cursor: pointer;
    overflow-wrap: break-word;
    word-break: break-word;
  }

  & > div:last-child {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }

  & span svg path {
    fill: #666;
    cursor: pointer;
  }

  & button {
    margin-left: 5px;
  }
}

.filename {
  position: relative;
  z-index: 1;

  &::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background-color: #999;
    z-index: -1;
    transition: width 0.3s ease;
    width: var(--progress, 0%);
  }
}

.active-subtitle {
  min-height: 50px;
  padding: 5px 0;
  display: flex;
  flex-direction: column;

  & .primary {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
  }

  & .primary p,
  & .secondary p {
    margin: 0;
    min-height: inherit;
    color: #fff;
  }

  & .primary p {
    font-size: 1.5em;
    min-height: auto;
    display: inline-block;
  }

  & .secondary p {
    font-size: 1.25em;
  }
}

.embedded-subtitles {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2;
  background: rgba(0, 0, 0, 0.5);
  padding: 20px;
  pointer-events: auto;
}

.blur-text {
  filter: blur(5px);
  transition: filter 0.3s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;

  &:hover,
  &:focus,
  &[data-unblurred="true"] {
    filter: blur(0);
  }
}

.loading-text::after {
  content: "...";
  display: inline-block;
  animation: ellipsis 1.5s infinite;
  margin-left: 4px;
}

@keyframes ellipsis {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.keyboard-shortcuts {
  font-size: 0.9em;
  color: #666;
  margin: 10px 0;
  text-align: center;
}

.most-recent {
  text-align: center;
  color: #666;
  word-wrap: break-word;
  overflow-wrap: break-word;
  cursor: pointer;

  & p {
    margin: 0;
  }
}

.due-count {
  color: inherit;

  &[data-due-count="1"] {
    color: red;
  }
}

.bottom-area {
  flex: 1;
  min-height: calc(100vh - 100%);
  margin: -10px;
  margin-top: 0;
}

.weak {
  color: #666;
}

.error-messages {
  margin-bottom: 5px;
}

.error-message {
  background-color: #f8d7da;
  color: #721c24;
  padding: 10px;
  border: 1px solid #f5c6cb;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.word-popover {
  padding: 16px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  font-size: 14px;
  border: none;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);

  & .word-info {
    text-align: center;
    margin-bottom: 12px;
    font-size: 16px;
  }

  & .actions {
    margin-top: 12px;
    display: flex;
    justify-content: center;
    gap: 12px;
  }

  & button {
    font-size: 12px;
    padding: 4px 8px;
  }
}
