:root {
  color-scheme: dark;
  --bg: #0e0f11;
  --surface: #17191d;
  --surface-soft: #202329;
  --ink: #f4f6f8;
  --muted: #a5adb7;
  --line: #343840;
  --line-strong: #5d646f;
  --accent: #62d18b;
  --accent-strong: #238b52;
  --accent-soft: #173425;
  --blue: #7aa2ff;
  --danger: #c94753;
  --danger-soft: #2c171a;
  --player: #090b0d;
  --player-panel: #171a1f;
  --player-line: #343a43;
  --safe-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  --safe-right: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
  --safe-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  --safe-left: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

body {
  min-width: 0;
  font-size: 15px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select {
  font: inherit;
}

button,
label.file-btn,
select {
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
label.file-btn:focus-within {
  outline: 3px solid rgba(46, 109, 230, 0.25);
  outline-offset: 2px;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.app-shell {
  min-height: 100dvh;
}

.app-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: 60px;
  padding: max(8px, var(--safe-top)) max(14px, var(--safe-right)) 8px max(14px, var(--safe-left));
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
  align-items: center;
  gap: 14px;
  background: rgba(17, 19, 22, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand,
.brand-copy,
.bar-actions,
.mode-switch,
.page-heading,
.section-heading,
.cover-layout,
.cover-actions,
.video-import-row,
.reset-section,
.player-topbar,
.player-controls,
.episode-panel-head,
.episode-range-bar,
.dialog-head {
  display: flex;
  align-items: center;
}

.brand {
  min-width: 0;
  gap: 10px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #111318;
  background: var(--accent);
  border-radius: 6px;
}

.brand-mark svg {
  width: 22px;
  height: 22px;
}

.brand-copy {
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}

.brand-copy strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-copy small,
.section-heading p,
.reset-section p,
.project-summary,
.storage-usage {
  color: var(--muted);
}

.brand-copy small {
  margin-top: 3px;
  font-size: 12px;
}

.mode-switch {
  min-width: 224px;
  padding: 3px;
  gap: 3px;
  background: #24272d;
  border: 1px solid #3b4048;
  border-radius: 7px;
}

.mode-btn {
  min-width: 104px;
  height: 38px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.mode-btn.active {
  color: #ffffff;
  background: #514d65;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.mode-btn svg {
  width: 17px;
  height: 17px;
}

.bar-actions {
  justify-content: flex-end;
  gap: 8px;
}

.save-state {
  font-size: 13px;
  color: var(--accent-strong);
}

.save-state.saving {
  color: var(--muted);
}

.icon-btn,
.player-icon-btn,
.range-nav-btn {
  display: inline-grid;
  place-items: center;
  border: 0;
  cursor: pointer;
}

.episode-jump .range-nav-btn {
  width: 58px;
  flex-basis: 58px;
  font-size: 13px;
  font-weight: 700;
}

.icon-btn {
  width: 38px;
  height: 38px;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.workspace {
  width: 100%;
}

.editor-view {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 54px;
}

.page-heading {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 26px;
  line-height: 1.25;
}

h2 {
  margin-bottom: 0;
  font-size: 17px;
  line-height: 1.3;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}

.form-section {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
}

.basics-section,
.theme-section,
.videos-section,
.backup-section,
.reset-section {
  grid-column: 1;
}

.cover-section {
  grid-column: 2;
  grid-row: 1 / span 3;
}

.section-heading {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-heading p,
.backup-section p,
.reset-section p {
  margin: 4px 0 0;
  font-size: 13px;
}

.backup-section,
.reset-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.backup-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 10px;
}

.project-toolbar {
  min-height: 62px;
  margin-bottom: 16px;
  padding: 10px 12px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.project-picker {
  min-width: 220px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.project-picker > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.project-picker select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
}

.project-delete {
  color: #ff929b;
}

.theme-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.theme-option {
  position: relative;
  min-width: 0;
  padding: 12px;
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  background: #111316;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.theme-option.is-selected {
  background: #13261b;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(98, 209, 139, 0.28);
}

.theme-option:focus-visible {
  outline: 3px solid rgba(98, 209, 139, 0.32);
  outline-offset: 2px;
}

.theme-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-option-preview {
  width: 116px;
  height: 66px;
  padding: 5px;
  display: grid;
  gap: 3px;
  background: #171a1f;
  border: 1px solid #353b44;
  border-radius: 5px;
  overflow: hidden;
}

.theme-option-preview i {
  min-width: 0;
  display: grid;
  place-items: center;
  color: #cdd2d8;
  background: #292d33;
  border-radius: 2px;
  font-size: 8px;
  font-style: normal;
}

.theme-preview-grid {
  grid-template-columns: repeat(5, 1fr);
}

.theme-preview-list {
  grid-template-columns: 1fr;
}

.theme-option-preview i.active {
  color: #ffffff;
  background: var(--accent-strong);
}

.theme-option-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.theme-option-copy strong {
  font-size: 14px;
}

.theme-option-copy small {
  color: var(--muted);
  font-size: 12px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

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

.field > span:first-child {
  color: #3e4650;
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field textarea,
.episode-jump input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  color: var(--ink);
  background: #111316;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
}

.field textarea {
  min-height: 94px;
  padding: 10px 12px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.episode-jump input:focus {
  border-color: var(--blue);
}

.input-suffix {
  position: relative;
}

.input-suffix input {
  padding-right: 44px;
}

.input-suffix > span {
  position: absolute;
  top: 50%;
  right: 13px;
  transform: translateY(-50%);
  color: var(--muted);
}

.primary-btn,
.secondary-btn,
.danger-btn,
.text-btn {
  min-height: 42px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 5px;
  font-weight: 700;
  cursor: pointer;
}

.primary-btn {
  color: #ffffff;
  background: var(--accent-strong);
  border: 1px solid var(--accent-strong);
}

.primary-btn:hover {
  background: #05673b;
}

.secondary-btn {
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--line-strong);
}

.text-btn {
  min-height: 36px;
  padding: 0 8px;
  color: var(--blue);
  background: transparent;
  border: 0;
}

.text-btn:disabled,
.secondary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.danger-outline {
  color: var(--danger);
  border-color: #e3a7ad;
}

.danger-btn {
  color: #ffffff;
  background: var(--danger);
  border: 1px solid var(--danger);
}

.primary-btn svg,
.secondary-btn svg,
.danger-btn svg {
  width: 18px;
  height: 18px;
}

.cover-layout {
  flex-direction: column;
  gap: 16px;
}

.cover-frame {
  width: min(100%, 220px);
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: var(--player-panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.cover-frame img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.cover-actions {
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.video-import-row {
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.compact-field {
  width: 170px;
}

.storage-usage {
  padding: 5px 8px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
}

.import-note {
  margin: -10px 0 16px;
  color: var(--muted);
  font-size: 12px;
}

.assignment-head,
.assignment-row {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr) 92px;
  align-items: center;
  gap: 12px;
}

.assignment-head {
  padding: 0 12px 8px;
  color: var(--muted);
  font-size: 12px;
}

.assignment-list {
  min-height: 82px;
  max-height: 330px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.assignment-empty {
  min-height: 80px;
  padding: 20px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.assignment-row {
  min-height: 52px;
  padding: 8px 12px;
  width: 100%;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  cursor: pointer;
}

.assignment-row:last-child {
  border-bottom: 0;
}

.assignment-episode {
  font-weight: 700;
}

.assignment-file {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assignment-size {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.reset-section {
  justify-content: space-between;
  gap: 20px;
  box-shadow: none;
  background: var(--danger-soft);
  border-color: #efc7cb;
}

.preview-view {
  width: var(--app-viewport-width, 100vw);
  height: var(--app-viewport-height, 100dvh);
  min-height: 0;
  background: var(--player);
  overflow: hidden;
}

body.preview-mode {
  width: var(--app-viewport-width, 100vw);
  height: var(--app-viewport-height, 100dvh);
  overflow: hidden;
}

body.preview-mode .app-shell,
body.preview-mode .workspace {
  width: var(--app-viewport-width, 100vw);
  height: var(--app-viewport-height, 100dvh);
  min-height: 0;
  overflow: hidden;
}

body.preview-mode .preview-view {
  position: fixed;
  inset: 0;
  width: var(--app-viewport-width, 100vw);
  height: var(--app-viewport-height, 100dvh);
}

body.preview-mode .app-bar {
  display: none;
}

.player-shell {
  --controls-height: 78px;
  position: relative;
  width: 100%;
  height: 100%;
  display: block;
  background: var(--player);
  overflow: hidden;
}

.player-shell.episodes-collapsed {
  display: block;
}

.video-pane {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #000000;
}

.video-pane video,
.video-fallback {
  width: 100%;
  height: 100%;
}

.video-pane video {
  display: block;
  object-fit: cover;
  background: #000000;
}

.video-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.video-fallback::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.52);
}

.video-fallback img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(14px);
  transform: scale(1.08);
  opacity: 0.72;
}

.fallback-copy {
  position: relative;
  z-index: 1;
  max-width: min(460px, 80%);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  color: #ffffff;
  text-align: center;
}

.fallback-copy strong {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 24px;
}

.fallback-copy span {
  color: #c6ccd4;
}

.player-topbar {
  position: absolute;
  z-index: 5;
  top: 0;
  left: 0;
  right: 0;
  min-height: 68px;
  padding: max(12px, var(--safe-top)) max(18px, var(--safe-right)) 12px max(18px, var(--safe-left));
  gap: 12px;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.72);
}

.player-title-block {
  min-width: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
}

.player-title-block strong,
.player-title-block span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-title-block strong {
  font-size: 16px;
}

.player-title-block span {
  margin-top: 2px;
  color: #c6ccd4;
  font-size: 12px;
}

.local-badge {
  flex: 0 0 auto;
  padding: 4px 7px;
  color: #a6f0c9;
  background: #0f4c32;
  border: 1px solid #237b56;
  border-radius: 4px;
  font-size: 11px;
}

.player-controls {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: var(--controls-height);
  padding: 12px max(18px, var(--safe-right)) max(12px, var(--safe-bottom)) max(18px, var(--safe-left));
  gap: 10px;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.76);
  contain: layout paint;
}

.player-text-control,
.danmaku-control {
  height: 42px;
  flex: 0 0 auto;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}

.player-text-control {
  min-width: 64px;
  padding: 0 14px;
  font-weight: 700;
}

.player-text-control[aria-expanded="true"] {
  color: #ffffff;
  border-color: #35d77e;
  box-shadow: inset 0 0 0 1px rgba(53, 215, 126, 0.24);
}

.danmaku-control {
  min-width: 96px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
}

.danmaku-control i {
  position: relative;
  width: 34px;
  height: 20px;
  flex: 0 0 34px;
  background: #5a5f66;
  border-radius: 10px;
  transition: background 150ms ease;
}

.danmaku-control i::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 150ms ease;
}

.danmaku-control.active i {
  background: var(--accent-strong);
}

.danmaku-control.active i::after {
  transform: translateX(14px);
}

.player-icon-btn {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  font-size: 24px;
}

.player-icon-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.player-icon-btn svg {
  width: 19px;
  height: 19px;
}

.mobile-back {
  font-size: 22px;
}

.time-code {
  width: 44px;
  flex: 0 0 auto;
  color: #d9dee4;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  text-align: center;
}

.seek-slider {
  min-width: 80px;
  height: 28px;
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
}

.episode-panel {
  position: absolute;
  z-index: 10;
  top: 0;
  right: 0;
  bottom: var(--controls-height);
  width: clamp(300px, 31vw, 520px);
  min-width: 0;
  height: auto;
  display: flex;
  flex-direction: column;
  color: #ffffff;
  background: var(--player-panel);
  border-left: 1px solid var(--player-line);
  overflow: hidden;
  box-shadow: -16px 0 34px rgba(0, 0, 0, 0.2);
  transform: translateX(0);
  transition: transform 180ms ease, opacity 160ms ease;
}

.episode-panel::after {
  content: "";
  position: absolute;
  z-index: 3;
  right: 0;
  bottom: 0;
  left: 0;
  height: 44px;
  background: linear-gradient(to bottom, rgba(23, 26, 31, 0), var(--player-panel));
  pointer-events: none;
}

.episodes-collapsed .episode-panel {
  opacity: 0;
  transform: translateX(100%);
  pointer-events: none;
}

.episode-panel-head {
  min-height: 68px;
  padding: max(12px, var(--safe-top)) max(14px, var(--safe-right)) 12px max(16px, var(--safe-left));
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--player-line);
}

.episode-panel-head > div {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.episode-panel-head span {
  max-width: 100%;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 17px;
  font-weight: 700;
}

.episode-panel-head small {
  margin-top: 2px;
  color: #99a3ae;
  font-size: 11px;
}

.panel-close {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
  font-size: 22px;
}

.episode-range-bar {
  min-height: 54px;
  padding: 8px 12px;
  gap: 8px;
  border-bottom: 1px solid var(--player-line);
}

.episode-jump {
  min-width: 0;
  display: flex;
  flex: 1;
  gap: 6px;
}

.episode-jump input {
  width: 100%;
  min-width: 88px;
  height: 36px;
  padding: 0 8px;
  color: #ffffff;
  background: #22262d;
  border: 1px solid #444b55;
  border-radius: 5px;
}

.range-indicator {
  color: #aab2bc;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.range-nav-btn {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  color: #ffffff;
  background: #292e36;
  border: 1px solid #444b55;
  border-radius: 5px;
  font-size: 24px;
}

.range-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.episode-grid {
  position: relative;
  min-height: 0;
  padding: 8px 12px 48px;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #5a626d #20242a;
  contain: layout paint style;
}

.episode-canvas {
  position: relative;
  width: 100%;
  min-height: 100%;
}

.episode-row {
  position: absolute;
  left: 0;
  right: 0;
  height: 72px;
  display: grid;
  grid-template-columns: repeat(5, minmax(44px, 1fr));
  align-items: center;
  gap: 8px;
}

.episode-btn {
  position: relative;
  min-width: 0;
  height: 62px;
  color: #d9dee4;
  background: #22262d;
  border: 1px solid #3b424c;
  border-radius: 5px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

.player-shell[data-episode-theme="list"] .episode-row {
  grid-template-columns: minmax(0, 1fr);
}

.player-shell[data-episode-theme="list"] .episode-btn {
  height: 56px;
  padding: 0 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.danmaku-layer {
  position: absolute;
  z-index: 4;
  inset: 68px 0 76px;
  overflow: hidden;
  pointer-events: none;
  contain: layout paint;
}

.danmaku-item {
  position: absolute;
  right: 0;
  max-width: 72%;
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
  transform: translate3d(110%, 0, 0);
  will-change: transform;
  animation: danmaku-move linear forwards;
}

.danmaku-item.green {
  color: #7be0a0;
}

.danmaku-item.orange {
  color: #ffb450;
}

@keyframes danmaku-move {
  from { transform: translate3d(110%, 0, 0); }
  to { transform: translate3d(calc(-100vw - 110%), 0, 0); }
}

.native-android .app-bar {
  backdrop-filter: none;
}

.native-android .danmaku-item,
.reduced-effects .danmaku-item {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}

.reduced-effects .episode-panel,
.reduced-effects .danmaku-control i,
.reduced-effects .danmaku-control i::after {
  transition: none;
}

.episode-btn:hover {
  border-color: #7b8794;
}

.episode-btn.has-video::after {
  content: "";
  position: absolute;
  top: 5px;
  right: 5px;
  width: 6px;
  height: 6px;
  background: #2bd478;
  border-radius: 50%;
}

.episode-btn.active {
  color: #ffffff;
  background: var(--accent-strong);
  border-color: #41d690;
  font-weight: 700;
}

.player-shell.pseudo-fullscreen {
  position: fixed;
  z-index: 1000;
  inset: 0;
  width: var(--app-viewport-width, 100vw);
  height: var(--app-viewport-height, 100dvh);
}

.app-dialog {
  width: min(420px, calc(100% - 28px));
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: 0 24px 70px rgba(12, 18, 26, 0.24);
}

.app-dialog::backdrop {
  background: rgba(12, 16, 22, 0.55);
}

.app-dialog form {
  padding: 20px;
}

.dialog-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.dialog-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.dialog-head strong {
  font-size: 18px;
}

.install-steps {
  margin-bottom: 18px;
  color: #424a54;
}

.install-steps p {
  margin-bottom: 10px;
}

.full-btn {
  width: 100%;
}

.toast {
  position: fixed;
  z-index: 2000;
  left: 50%;
  bottom: max(24px, var(--safe-bottom));
  max-width: min(520px, calc(100% - 28px));
  padding: 11px 15px;
  color: #ffffff;
  background: #20242a;
  border: 1px solid #454c55;
  border-radius: 5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (max-width: 900px) {
  .app-bar {
    grid-template-columns: 1fr auto;
  }

  .brand-copy small,
  .save-state {
    display: none;
  }

  .mode-switch {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    min-width: 0;
  }

  .mode-btn {
    min-width: 0;
    flex: 1;
  }

  .bar-actions {
    grid-column: 2;
    grid-row: 1;
  }

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

  .basics-section,
  .theme-section,
  .cover-section,
  .videos-section,
  .backup-section,
  .reset-section {
    grid-column: 1;
    grid-row: auto;
  }

  .cover-layout {
    flex-direction: row;
    align-items: flex-end;
  }

  .cover-frame {
    width: 160px;
  }

  .cover-actions {
    width: auto;
    flex-direction: column;
    align-items: stretch;
  }

}

@media (max-width: 680px) and (orientation: portrait) {
  .player-shell {
    --controls-height: 112px;
  }

  .editor-view {
    width: calc(100% - 20px);
    padding-top: 18px;
  }

  .page-heading {
    align-items: flex-end;
  }

  h1 {
    font-size: 22px;
  }

  .page-heading .primary-btn {
    min-width: 46px;
    padding: 0 12px;
    font-size: 0;
  }

  .form-section {
    padding: 16px;
  }

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

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

  .cover-layout {
    align-items: center;
  }

  .cover-frame {
    width: 128px;
  }

  .video-import-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .compact-field {
    width: auto;
    grid-column: 1 / -1;
  }

  .danger-outline {
    grid-column: 1 / -1;
  }

  .assignment-head,
  .assignment-row {
    grid-template-columns: 72px minmax(0, 1fr) 66px;
    gap: 8px;
  }

  .reset-section {
    align-items: flex-start;
    flex-direction: column;
  }

  .video-pane {
    width: 100%;
    height: 100%;
  }

  .episode-panel {
    top: auto;
    right: 0;
    bottom: var(--controls-height);
    left: 0;
    width: 100%;
    height: min(62%, 530px);
    border-left: 0;
    border-top: 1px solid var(--player-line);
    transform: translateY(0);
    transition: transform 180ms ease, opacity 180ms ease;
  }

  .episodes-collapsed .episode-panel {
    transform: translateY(100%);
  }

  .episode-grid {
    padding-left: 10px;
    padding-right: 10px;
  }

  .episode-row {
    grid-template-columns: repeat(5, minmax(48px, 1fr));
    gap: 6px;
  }

  .player-controls {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    grid-template-rows: 40px 40px;
    gap: 4px 6px;
    padding-top: 8px;
    padding-bottom: max(8px, var(--safe-bottom));
  }

  #playPauseBtn { grid-column: 1; grid-row: 1; }
  #currentTime { grid-column: 2; grid-row: 1; }
  #seekSlider { grid-column: 3 / 8; grid-row: 1; }
  #durationTime { grid-column: 8; grid-row: 1; }
  #episodePanelBtn { grid-column: 1 / 3; grid-row: 2; }
  #danmakuToggleBtn { grid-column: 3 / 6; grid-row: 2; }
  #muteBtn { grid-column: 6; grid-row: 2; }
  #orientationBtn { grid-column: 7; grid-row: 2; }
  #fullscreenBtn { grid-column: 8; grid-row: 2; }

  .player-icon-btn {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .time-code {
    width: auto;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .app-bar {
    display: none;
  }

  .preview-view {
    height: var(--app-viewport-height, 100dvh);
  }

  .player-shell {
    --controls-height: 62px;
  }

  .player-topbar,
  .episode-panel-head {
    min-height: 54px;
    padding-top: max(7px, var(--safe-top));
    padding-bottom: 7px;
  }

  .player-controls {
    min-height: 58px;
    padding-top: 7px;
    padding-bottom: max(7px, var(--safe-bottom));
  }

  .episode-range-bar {
    min-height: 46px;
    padding-top: 5px;
    padding-bottom: 5px;
  }

  .episode-grid {
    padding-top: 4px;
  }

  .episode-btn {
    height: 38px;
  }

  .episode-row {
    height: 52px;
  }

  .episode-panel {
    width: clamp(280px, 38vw, 420px);
  }

  .player-shell[data-episode-theme="list"] .episode-btn {
    height: 44px;
  }
}

@media (max-width: 750px) and (orientation: landscape) {
  .player-controls {
    padding-left: max(10px, var(--safe-left));
    padding-right: max(10px, var(--safe-right));
    gap: 5px;
  }

  .player-controls .player-icon-btn {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .seek-slider {
    min-width: 48px;
  }

  .time-code {
    width: 38px;
    font-size: 11px;
  }

  .player-text-control {
    min-width: 54px;
    padding: 0 10px;
  }

  .danmaku-control {
    min-width: 86px;
    padding: 0 8px;
    gap: 6px;
  }
}

@media (max-width: 640px) and (orientation: landscape) {
  .player-controls .time-code {
    display: none;
  }
}

@media (max-width: 540px) {
  .project-toolbar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .project-picker {
    width: 100%;
    flex-basis: 100%;
  }

  .backup-section,
  .reset-section {
    align-items: stretch;
    flex-direction: column;
  }

  .backup-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .theme-options {
    grid-template-columns: 1fr;
  }

  .theme-option {
    grid-template-columns: 104px minmax(0, 1fr);
  }

  .theme-option-preview {
    width: 104px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
