* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: #111;
  font-family: Tahoma, Verdana, Arial, sans-serif;
  background:
    linear-gradient(180deg, #7fc7ff 0%, #d7f0ff 54%, #48a64d 55%, #1d7b36 100%);
  overflow-x: hidden;
}

body.mika-sky {
  animation: mika-sky-rotate 14s linear infinite;
}

@keyframes mika-sky-rotate {
  0% {
    background:
      linear-gradient(180deg, #7fc7ff 0%, #d7f0ff 54%, #48a64d 55%, #1d7b36 100%);
  }

  20% {
    background:
      linear-gradient(180deg, #b993ff 0%, #f2d7ff 54%, #48a64d 55%, #1d7b36 100%);
  }

  40% {
    background:
      linear-gradient(180deg, #ff93cf 0%, #ffe0ef 54%, #48a64d 55%, #1d7b36 100%);
  }

  60% {
    background:
      linear-gradient(180deg, #ffb66f 0%, #fff0c8 54%, #48a64d 55%, #1d7b36 100%);
  }

  80% {
    background:
      linear-gradient(180deg, #77e6d5 0%, #d7fff7 54%, #48a64d 55%, #1d7b36 100%);
  }

  100% {
    background:
      linear-gradient(180deg, #7fc7ff 0%, #d7f0ff 54%, #48a64d 55%, #1d7b36 100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  body.mika-sky {
    animation: none;
    background:
      linear-gradient(180deg, #b993ff 0%, #f2d7ff 54%, #48a64d 55%, #1d7b36 100%);
  }
}

button,
input,
textarea {
  font: inherit;
}

.desktop {
  min-height: 100vh;
  padding: 18px 18px 92px;
}

body.youtube-active .desktop {
  padding-bottom: 118px;
}

.xp-window {
  width: min(1220px, 100%);
  height: calc(100vh - 116px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 2px solid #0a246a;
  border-radius: 6px 6px 0 0;
  background: #ece9d8;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}

.titlebar {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  color: #fff;
  background: linear-gradient(90deg, #0054e3 0%, #2683ff 48%, #0054e3 100%);
  border-bottom: 1px solid #06307f;
}

.titlebar-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  white-space: nowrap;
}

.tiny-icon {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #fff;
  border-radius: 3px;
  color: #06307f;
  background: #fff;
  font-size: 10px;
  font-weight: 700;
}

.window-buttons {
  display: flex;
  gap: 4px;
}

.window-buttons span {
  width: 20px;
  height: 20px;
  border: 1px solid #fff;
  border-radius: 3px;
  background: linear-gradient(#ffffff, #77a8ff);
  box-shadow: inset 0 -1px 0 #174caf;
}

.window-buttons span:last-child {
  background: linear-gradient(#ffb299, #d94a2e);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-top: 1px solid #fff;
  border-bottom: 1px solid #aca899;
  background: #ece9d8;
}

.xp-button,
.row-play,
.media-button,
.tab,
.choice {
  cursor: pointer;
}

.xp-button {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid #7f9db9;
  border-radius: 3px;
  color: #111;
  text-decoration: none;
  background: linear-gradient(#fff, #dbe9ff);
  box-shadow: inset 1px 1px 0 #fff;
}

.xp-button:hover {
  border-color: #316ac5;
}

.xp-button.compact {
  min-width: 78px;
}

.zip-button {
  min-width: 54px;
  font-size: 12px;
}

.zip-button.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.search-box {
  min-width: 180px;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid #7f9db9;
  background: #fff;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
}

.window-body {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-right: 1px solid #aca899;
  background: #d6d3c6;
  overflow: auto;
}

.photo-panel {
  position: relative;
}

.photo-panel img {
  width: 100%;
  aspect-ratio: 1 / 1.1;
  display: block;
  object-fit: cover;
  object-position: 70% center;
  border: 2px solid #fff;
  outline: 1px solid #7f7f7f;
  background: #fff;
}

.speech {
  position: relative;
  margin: 9px 0 0;
  padding: 8px 9px;
  border: 1px solid #111;
  border-radius: 7px;
  background: #fffef5;
  font-size: 12px;
  line-height: 1.35;
}

.speech::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 32px;
  width: 14px;
  height: 14px;
  border-left: 1px solid #111;
  border-top: 1px solid #111;
  background: #fffef5;
  transform: rotate(45deg);
}

.tabs {
  display: grid;
  gap: 6px;
}

.tab {
  min-height: 33px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border: 1px solid #8f8f8f;
  border-radius: 4px;
  color: #111;
  background: linear-gradient(#fff, #e6e2d6);
  text-align: left;
}

.tab span {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #316ac5;
  border-radius: 3px;
  color: #fff;
  background: #316ac5;
  font-size: 13px;
  font-weight: 700;
}

.tab.active {
  border-color: #316ac5;
  background: linear-gradient(#dbe9ff, #fff);
  font-weight: 700;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-top: auto;
}

.stats div {
  min-height: 42px;
  display: grid;
  align-content: center;
  padding: 6px;
  border: 1px solid #aca899;
  background: #f8f7ef;
}

.stats b,
.stats span {
  display: block;
}

.stats b {
  color: #0a246a;
  font-size: 18px;
}

.stats span {
  font-size: 11px;
}

.content {
  min-width: 0;
  overflow: auto;
  padding: 14px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.92)),
    #f6f5ed;
}

.view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
}

p {
  margin: 4px 0 0;
  color: #4d4d4d;
}

.browser-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
  gap: 12px;
}

.chooser {
  max-height: calc(100vh - 270px);
  display: grid;
  align-content: start;
  gap: 6px;
  overflow: auto;
}

.choice {
  min-height: 42px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid #aca899;
  border-radius: 5px;
  background: #fff;
  text-align: left;
}

.choice span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.choice b {
  min-width: 28px;
  padding: 2px 4px;
  border-radius: 3px;
  color: #fff;
  background: #2e7d32;
  font-size: 11px;
  text-align: center;
}

.choice.active {
  border-color: #316ac5;
  background: #dbe9ff;
}

.detail-pane,
.track-list,
.setup-panel,
.loading,
.empty {
  min-width: 0;
}

.track-list {
  display: grid;
  gap: 6px;
}

.track-row {
  min-height: 54px;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 70px 38px;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border: 1px solid #c9c4b5;
  border-radius: 5px;
  background: #fff;
}

.track-row.current {
  border-color: #316ac5;
  background: #eaf2ff;
}

.track-row.missing {
  opacity: 0.68;
}

.row-play {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid #316ac5;
  border-radius: 4px;
  color: #fff;
  background: #316ac5;
}

.row-play.off {
  border-color: #8f8f8f;
  background: #8f8f8f;
}

.track-copy {
  min-width: 0;
}

.track-title,
.track-sub,
.track-path {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-title {
  font-weight: 700;
}

.track-sub,
.track-path,
.track-num {
  color: #5a5a5a;
  font-size: 12px;
}

.track-path,
.track-num {
  text-align: right;
}

.playlist-title {
  margin-bottom: 8px;
  font-weight: 700;
}

.playlist-title span {
  display: inline-block;
  margin-left: 8px;
  color: #5a5a5a;
  font-size: 12px;
  font-weight: 400;
}

.setup-panel,
.loading,
.empty {
  padding: 18px;
  border: 1px solid #aca899;
  border-radius: 6px;
  background: #fff;
}

.setup-panel code,
.path-line {
  overflow-wrap: anywhere;
}

.path-line {
  padding: 8px;
  border: 1px inset #aca899;
  background: #f6f6f6;
  font-size: 12px;
}

.player {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  min-height: 76px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(240px, 430px) auto;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  color: #fff;
  background: linear-gradient(#245edb, #0b3ca8);
  border-top: 1px solid #6ea8ff;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.28);
}

.player-now {
  min-width: 0;
}

.now-title,
.now-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.now-title {
  font-weight: 700;
}

.now-meta {
  margin-top: 3px;
  color: #d9e8ff;
  font-size: 12px;
}

.transport {
  display: flex;
  align-items: center;
  gap: 8px;
}

.media-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid #06307f;
  border-radius: 5px;
  color: #06307f;
  background: linear-gradient(#fff, #c7dcff);
  box-shadow: inset 1px 1px 0 #fff;
  font-size: 16px;
}

.play-toggle {
  width: 46px;
  height: 46px;
  font-size: 18px;
}

.progress-wrap {
  min-width: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.progress-wrap input {
  width: 100%;
  accent-color: #7bd553;
}

.youtube-fallback {
  width: 150px;
  aspect-ratio: 16 / 9;
  border: 1px solid #6ea8ff;
  border-radius: 4px;
  overflow: hidden;
  background: #000;
}

.youtube-fallback[hidden] {
  display: none;
}

.youtube-fallback iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
}

.admin-desktop {
  padding-bottom: 18px;
}

.admin-window {
  height: calc(100vh - 36px);
}

.admin-body-grid {
  grid-template-columns: 260px minmax(0, 1fr);
}

.admin-sidebar {
  gap: 12px;
}

.admin-content {
  display: grid;
  align-content: start;
}

.admin-form {
  min-width: 0;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.field span {
  color: #333;
  font-size: 12px;
  font-weight: 700;
}

.field input,
.field textarea {
  width: 100%;
  min-width: 0;
  border: 1px inset #aca899;
  background: #fff;
  color: #111;
}

.field input {
  min-height: 30px;
  padding: 4px 6px;
}

.field textarea {
  min-height: 84px;
  padding: 6px;
  resize: vertical;
  line-height: 1.35;
}

.field-wide {
  grid-column: 1 / -1;
}

.admin-login {
  display: grid;
  gap: 12px;
}

.admin-facts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.admin-facts div {
  min-height: 42px;
  display: grid;
  align-content: center;
  padding: 6px;
  border: 1px solid #aca899;
  background: #f8f7ef;
}

.admin-facts b,
.admin-facts span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-facts b {
  color: #0a246a;
  font-size: 13px;
  white-space: nowrap;
}

.admin-facts span {
  font-size: 11px;
}

.admin-fact-wide {
  grid-column: 1 / -1;
}

.speech[data-kind="ok"] {
  background: #f2fff0;
}

.speech[data-kind="warn"] {
  background: #fff8d8;
}

.speech[data-kind="error"] {
  background: #ffe7df;
}

@media (max-width: 760px) {
  .desktop {
    padding: 8px 8px 154px;
  }

  body.youtube-active .desktop {
    padding-bottom: 246px;
  }

  .xp-window {
    height: calc(100dvh - 170px);
    border-radius: 5px 5px 0 0;
  }

  body.youtube-active .xp-window {
    height: calc(100dvh - 262px);
  }

  .titlebar-title {
    font-size: 13px;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .search-box {
    order: 3;
    flex-basis: 100%;
  }

  .window-body {
    display: flex;
    flex-direction: column;
  }

  .sidebar {
    flex: none;
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
    border-right: 0;
    border-bottom: 1px solid #aca899;
    overflow: visible;
  }

  .photo-panel {
    display: contents;
  }

  .photo-panel img {
    width: 92px;
    height: 104px;
  }

  .speech {
    margin: 0;
    align-self: start;
    min-height: 58px;
  }

  .speech::before {
    top: 18px;
    left: -8px;
  }

  .tabs {
    grid-column: 1 / -1;
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .tab {
    flex: 0 0 auto;
    min-width: 112px;
  }

  .stats {
    display: none;
  }

  .content {
    padding: 10px;
  }

  .view-head {
    align-items: flex-start;
  }

  h1 {
    font-size: 20px;
  }

  .browser-grid {
    grid-template-columns: 1fr;
  }

  .chooser {
    max-height: none;
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .choice {
    flex: 0 0 190px;
  }

  .track-row {
    grid-template-columns: 34px minmax(0, 1fr) 46px;
    gap: 7px;
    min-height: 52px;
  }

  .track-num {
    display: none;
  }

  .track-path {
    font-size: 11px;
  }

  .player {
    min-height: 138px;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
  }

  .player-now {
    grid-column: 1;
  }

  .transport {
    grid-column: 1;
    grid-row: 2;
    justify-content: center;
  }

  .media-button {
    width: 36px;
    height: 36px;
  }

  .play-toggle {
    width: 42px;
    height: 42px;
  }

  .progress-wrap {
    grid-column: 1;
    grid-row: 3;
  }

  .youtube-fallback.active {
    grid-column: 1;
    grid-row: 4;
    justify-self: center;
    width: min(160px, 100%);
  }

  .admin-desktop {
    padding-bottom: 8px;
  }

  .admin-window {
    height: calc(100dvh - 16px);
  }

  .admin-body-grid {
    display: flex;
    flex-direction: column;
  }

  .admin-sidebar {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .admin-facts {
    grid-column: 1 / -1;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {
  .track-row {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .track-path {
    display: none;
  }

  .transport {
    gap: 5px;
  }

  .media-button {
    width: 34px;
    height: 34px;
  }
}
