#toast {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  bottom: auto;
  left: 50%;
  z-index: 20;
  max-width: calc(100% - 32px);
  padding: 8px 13px;
  border-radius: 12px;
  box-shadow: 0 8px 24px #0007;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-60px);
  transition: opacity .2s, transform .2s;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

@media (max-width: 599px) {
  main,
  #app,
  #mainView,
  #adminView {
    width: 100%;
    max-width: 100vw;
    min-width: 0;
  }

  .card,
  .item,
  .file,
  .video-shell,
  .plyr {
    max-width: 100%;
    min-width: 0;
  }
}

.item {
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.item.is-complete {
  border-color: #2f684f;
  background: linear-gradient(180deg, #122019e8, #101820e8);
  box-shadow: inset 3px 0 0 #45d69a66;
}

.item.is-complete .bar i {
  background: linear-gradient(90deg, #31bd82, #67e0ad);
}

.item .title {
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.item .files,
.item .file {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.item .files {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  align-items: stretch;
  gap: 7px;
  min-width: 0;
}

.item .file {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 9px;
  overflow: hidden;
  margin-top: 0;
  white-space: normal;
}

.item .file span {
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
}

.conversion-state {
  display: block;
  flex: 0 0 100%;
  margin-top: 3px;
  color: #ffbe7d;
  font-size: 11px;
}

.fi {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  line-height: 1;
}

button .fi,
.upload .fi {
  margin-right: 7px;
}

button.icon .fi,
button.paste-button .fi {
  margin-right: 0;
}

.speed-counter {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid #353d50;
  border-radius: 12px;
  background: #141927;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.speed-counter strong { color: var(--text); font-variant-numeric: tabular-nums; }
.player-heading { display: flex; align-items: center; gap: 8px; padding: 2px 2px 0 8px; }
.player-heading .player-title { flex: 1; min-width: 0; margin-left: 0; }
.close-player { flex: 0 0 42px; color: #dfe4ed; font-size: 20px; }
.item .file.is-playing { border: 1px solid #8f78ff; background: #302855; box-shadow: inset 3px 0 0 #a995ff, 0 0 0 1px #6e57dc33; color: #fff; }
.item .file.is-playing .fi { color: #c7bbff; }
.file-row.is-file-complete .file {
  border: 1px solid #2c604a;
  background: #16251f;
}
.file-row.is-file-complete .file .fi { color: #66dfac; }
.watch-toggle {
  display: inline-grid;
  place-items: center;
  width: 42px;
  min-width: 42px;
  padding: 0;
  border: 1px solid #353d50;
  border-radius: 12px;
  background: #171d2a;
  color: #8d96a8;
  font-size: 17px;
}
.watch-toggle .fi { margin-right: 0; }
.watch-toggle[aria-pressed="true"] {
  border-color: #3e745d;
  background: #14291f;
  color: var(--ok);
}
.file-row.is-watched .file span { color: #b6bfcb; }

.icon,
.paste-button {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  min-height: 42px;
}

.paste-button {
  flex: 0 0 46px;
  padding: 0;
  background: #242b3b;
  border: 1px solid #353d50;
  color: #dfe4ed;
  font-size: 18px;
}

.inputrow > #add,
.vpn-test,
#saveSettings,
.control-one,
.delete-one,
.danger-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sectionhead h2,
.admin-title h2,
h3 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.storage-summary span .fi,
.stat > .fi {
  margin-right: 4px;
}

.attribution {
  padding: 10px 0 2px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.attribution a {
  color: #a995ff;
  text-decoration: none;
}

.wireguard-upload { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wireguard-upload span { overflow: hidden; text-overflow: ellipsis; }
button:disabled { cursor: not-allowed; opacity: .55; }
.torrent-upload-button { display: inline-flex; align-items: center; justify-content: center; width: 100%; min-height: 48px; }
.torrent-drop-hint { margin: 8px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.torrent-drop-hint .fi { margin-right: 5px; }
.torrent-drop-overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; background: #090b10d9; backdrop-filter: blur(8px); pointer-events: none; }
.torrent-drop-overlay > div { display: grid; place-items: center; gap: 9px; width: min(100%,420px); min-height: 220px; padding: 28px; border: 2px dashed #9b86ff; border-radius: 24px; background: #17152a; text-align: center; box-shadow: 0 20px 70px #0008; }
.torrent-drop-overlay .fi { color: #b6a7ff; font-size: 38px; }
.torrent-drop-overlay strong { font-size: 20px; }
.torrent-drop-overlay span { color: var(--muted); font-size: 13px; }
.seek-feedback.speed { left: 50%; background: #07091059; border: 1px solid #ffffff2e; color: #ffffffe8; transform: translate(-50%,-50%) scale(.8); backdrop-filter: blur(1.5px); }
.seek-feedback.speed.show { transform: translate(-50%,-50%) scale(1); animation: speed-pulse .7s ease-in-out infinite alternate; box-shadow: 0 0 0 0 #a995ff38; }
.plyr__control--overlaid {
  width: 66px;
  height: 66px;
  padding: 0;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
}
.plyr__control--overlaid svg {
  left: 0;
  width: 24px;
  height: 24px;
}
.tstream-nav-control {
  display: inline-grid !important;
  place-items: center;
}
.tstream-nav-control .fi {
  margin-right: 0;
  font-size: 18px;
}
.center-toggle {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 9;
  display: inline-grid;
  place-items: center;
  width: 74px;
  height: 74px;
  padding: 0;
  border: 1px solid #ffffff2e;
  border-radius: 50%;
  background: #07091096;
  color: #fff;
  font-size: 25px;
  transform: translate(-50%, -50%);
  backdrop-filter: blur(3px);
  box-shadow: 0 14px 40px #0008;
}
.center-toggle .fi { margin-right: 0; }
.center-toggle:active { transform: translate(-50%, -50%) scale(.94); }
@media (max-width: 420px) {
  .plyr__control--overlaid {
    width: 58px;
    height: 58px;
  }
  .center-toggle {
    width: 62px;
    height: 62px;
  }
  .tstream-nav-control {
    padding-left: 7px !important;
    padding-right: 7px !important;
  }
}
@keyframes speed-pulse {
  from { transform: translate(-50%,-50%) scale(.94); box-shadow: 0 0 0 0 #a995ff42; }
  to { transform: translate(-50%,-50%) scale(1.08); box-shadow: 0 0 0 13px #a995ff00; }
}
.vpn-progress { display: grid; gap: 7px; margin-top: 13px; color: var(--muted); font-size: 12px; }
.vpn-progress-track { height: 6px; overflow: hidden; border-radius: 10px; background: #292f3c; }
.vpn-progress-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--accent),#a38eff); transition: width .3s linear; }
.vpn-progress.rollback .vpn-progress-track i { background: linear-gradient(90deg,#ff9d52,#ff6d78); }
.vpn-progress.done .vpn-progress-track i { background: var(--ok); }
.sort-downloads { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 0 12px; border: 1px solid #39364b; border-radius: 11px; background: #201e2c; color: #d9d5e8; }
.sort-downloads:hover { border-color: #74699e; background: #29253a; }
.sort-downloads .fi { color: #aa98ff; }

@media (max-width: 420px) {
  header { gap: 8px; }
  .header-actions { gap: 2px; }
  .speed-counter { gap: 5px; padding: 0 8px; }
  .sort-downloads { padding: 0 10px; }
  .sort-downloads span { display: none; }
  .inputrow > #add {
    padding: 0 13px;
  }

  .inputrow > #add span {
    display: none;
  }

  .inputrow > #add .fi {
    margin-right: 0;
  }
}
