/*
 * SubMiner - All-in-one sentence mining overlay
 * Copyright (C) 2024 sudacode
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

@font-face {
  font-family: 'M PLUS 1';
  src: url('./fonts/MPLUS1[wght].ttf') format('truetype');
  font-weight: 100 900;
  font-display: swap;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: transparent;
  font-family:
    'M PLUS 1', 'Noto Sans CJK JP Regular', 'Noto Sans CJK JP', 'Hiragino Sans',
    'Hiragino Kaku Gothic ProN', 'Yu Gothic', 'Arial Unicode MS', Arial, sans-serif;
}

html:focus-visible,
body:focus-visible,
#overlay:focus-visible {
  outline: none;
}

:root {
  --subtitle-sidebar-reserved-width: 0px;

  /* Catppuccin Macchiato */
  --ctp-rosewater: #f4dbd6;
  --ctp-flamingo: #f0c6c6;
  --ctp-pink: #f5bde6;
  --ctp-mauve: #c6a0f6;
  --ctp-red: #ed8796;
  --ctp-maroon: #ee99a0;
  --ctp-peach: #f5a97f;
  --ctp-yellow: #eed49f;
  --ctp-green: #a6da95;
  --ctp-teal: #8bd5ca;
  --ctp-sky: #91d7e3;
  --ctp-sapphire: #7dc4e4;
  --ctp-blue: #8aadf4;
  --ctp-lavender: #b7bdf8;
  --ctp-text: #cad3f5;
  --ctp-subtext1: #b8c0e0;
  --ctp-subtext0: #a5adcb;
  --ctp-overlay2: #939ab7;
  --ctp-overlay1: #8087a2;
  --ctp-overlay0: #6e738d;
  --ctp-surface2: #5b6078;
  --ctp-surface1: #494d64;
  --ctp-surface0: #363a4f;
  --ctp-base: #24273a;
  --ctp-mantle: #1e2030;
  --ctp-crust: #181926;
}

#overlay {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  pointer-events: none;
}

#overlay.interactive {
  pointer-events: auto;
}

.controller-status-toast {
  position: absolute;
  top: 16px;
  left: 16px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(138, 213, 202, 0.45);
  background: linear-gradient(135deg, rgba(10, 44, 40, 0.94), rgba(8, 28, 33, 0.94));
  color: rgba(228, 255, 251, 0.98);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-6px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
  z-index: 1300;
}

.controller-status-toast:not(.hidden) {
  opacity: 1;
  transform: translateY(0);
}

.overlay-error-toast {
  position: absolute;
  top: 16px;
  right: 16px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 148, 148, 0.5);
  background: rgba(48, 12, 12, 0.9);
  color: rgba(255, 238, 238, 0.98);
  font-size: 13px;
  line-height: 1.35;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-6px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
  z-index: 1300;
}

.overlay-error-toast:not(.hidden) {
  opacity: 1;
  transform: translateY(0);
}

/* Follow the configured notification position (default stays top-right). */
.overlay-error-toast.position-top-left {
  left: 16px;
  right: auto;
}

.overlay-error-toast.position-top {
  left: 50%;
  right: auto;
  transform: translate(-50%, -6px);
}

.overlay-error-toast.position-top:not(.hidden) {
  transform: translate(-50%, 0);
}

.overlay-error-toast.position-top-right {
  left: auto;
  right: 16px;
}

.overlay-notification-stack {
  position: absolute;
  top: 16px;
  width: min(420px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
  z-index: 2147483647 !important;
}

.overlay-notification-stack.position-top-left {
  left: 16px;
  right: auto;
  transform: none;
}

.overlay-notification-stack.position-top {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}

.overlay-notification-stack.position-top-right {
  left: auto;
  right: 16px;
  transform: none;
}

.overlay-notification-card {
  /* Accent color is overridden per variant and drives the icon and border tint. */
  --overlay-notification-accent: var(--ctp-blue);

  position: relative;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 22px;
  gap: 12px;
  align-items: start;
  min-height: 72px;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--overlay-notification-accent) 45%, var(--ctp-surface1));
  background: var(--ctp-base);
  box-shadow: 0 12px 28px -12px rgba(24, 25, 38, 0.7);
  color: var(--ctp-text);
  overflow: hidden;
}

/* Direction-aware enter/exit — slide in from the stack's anchored edge, slide back out. */
.overlay-notification-card.entering {
  animation: overlay-notification-enter-right 240ms cubic-bezier(0.21, 1.02, 0.73, 1) both;
}

.overlay-notification-card.leaving {
  pointer-events: none;
  animation: overlay-notification-leave-right 190ms cubic-bezier(0.55, 0.06, 0.68, 0.19) both;
}

.overlay-notification-stack.position-top-left .overlay-notification-card.entering {
  animation-name: overlay-notification-enter-left;
}

.overlay-notification-stack.position-top-left .overlay-notification-card.leaving {
  animation-name: overlay-notification-leave-left;
}

.overlay-notification-stack.position-top .overlay-notification-card.entering {
  animation-name: overlay-notification-enter-top;
}

.overlay-notification-stack.position-top .overlay-notification-card.leaving {
  animation-name: overlay-notification-leave-top;
}

.overlay-notification-card.info {
  --overlay-notification-accent: var(--ctp-blue);
}

.overlay-notification-card.progress {
  --overlay-notification-accent: var(--ctp-sky);
}

.overlay-notification-card.success {
  --overlay-notification-accent: var(--ctp-green);
}

.overlay-notification-card.warning {
  --overlay-notification-accent: var(--ctp-yellow);
}

.overlay-notification-card.error {
  --overlay-notification-accent: var(--ctp-red);
}

.overlay-notification-card.has-image {
  /* Reserve a real track for the thumbnail so it never overlaps the text.
     minmax(0, 100px) lets the column shrink the image on narrow notifications
     instead of letting it spill into the content column. */
  grid-template-columns: minmax(0, 100px) minmax(0, 1fr) 22px;
  min-height: 88px;
}

.overlay-notification-image {
  width: 100%;
  max-width: 100px;
  aspect-ratio: 100 / 56;
  height: auto;
  align-self: center;
  display: block;
  border-radius: 7px;
  border: 1px solid color-mix(in srgb, var(--overlay-notification-accent) 28%, var(--ctp-surface2));
  background: var(--ctp-crust);
  object-fit: cover;
}

.overlay-notification-icon {
  width: 22px;
  height: 22px;
  align-self: center;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: color-mix(in srgb, var(--overlay-notification-accent) 16%, transparent);
  color: var(--overlay-notification-accent);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.overlay-notification-card.info .overlay-notification-icon::before {
  content: 'i';
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
}

.overlay-notification-card.success .overlay-notification-icon::before {
  content: '\2713';
}

.overlay-notification-card.warning .overlay-notification-icon::before {
  content: '!';
}

.overlay-notification-card.error .overlay-notification-icon::before {
  content: '\2715';
  font-size: 11px;
}

.overlay-notification-card.progress .overlay-notification-icon::before {
  content: '';
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--overlay-notification-accent) 28%, transparent);
  border-top-color: var(--overlay-notification-accent);
  animation: overlay-notification-spin 0.75s linear infinite;
}

.overlay-notification-content {
  min-width: 0;
  padding-top: 1px;
}

.overlay-notification-title {
  color: var(--ctp-text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.1px;
}

.overlay-notification-body {
  margin-top: 4px;
  color: var(--ctp-subtext0);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.overlay-notification-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 11px;
}

.overlay-notification-action {
  min-height: 27px;
  padding: 4px 11px;
  border-radius: 7px;
  border: 1px solid color-mix(in srgb, var(--overlay-notification-accent) 35%, var(--ctp-surface2));
  background: color-mix(in srgb, var(--overlay-notification-accent) 12%, var(--ctp-surface0));
  color: var(--ctp-text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 120ms ease,
    border-color 120ms ease;
}

.overlay-notification-action:hover {
  border-color: var(--overlay-notification-accent);
  background: color-mix(in srgb, var(--overlay-notification-accent) 24%, var(--ctp-surface0));
}

.overlay-notification-close {
  width: 22px;
  height: 22px;
  align-self: start;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ctp-overlay1);
  font: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition:
    background 120ms ease,
    color 120ms ease;
}

.overlay-notification-close:hover {
  background: color-mix(in srgb, var(--ctp-red) 18%, transparent);
  color: var(--ctp-red);
}

@keyframes overlay-notification-enter-right {
  from {
    opacity: 0;
    transform: translateX(28px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes overlay-notification-enter-left {
  from {
    opacity: 0;
    transform: translateX(-28px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes overlay-notification-enter-top {
  from {
    opacity: 0;
    transform: translateY(-16px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes overlay-notification-leave-right {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
  }

  to {
    opacity: 0;
    transform: translateX(28px) scale(0.94);
  }
}

@keyframes overlay-notification-leave-left {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
  }

  to {
    opacity: 0;
    transform: translateX(-28px) scale(0.94);
  }
}

@keyframes overlay-notification-leave-top {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  to {
    opacity: 0;
    transform: translateY(-14px) scale(0.94);
  }
}

@media (prefers-reduced-motion: reduce) {
  .overlay-notification-card.entering,
  .overlay-notification-card.leaving {
    animation-duration: 1ms;
  }
}

@keyframes overlay-notification-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Notification history panel — slides in from the same edge the notifications use. */
.notification-history {
  --notification-history-width: min(380px, calc(100vw - 24px));

  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--notification-history-width);
  display: flex;
  flex-direction: column;
  background: color-mix(in srgb, var(--ctp-mantle) 94%, transparent);
  border: 1px solid var(--ctp-surface0);
  box-shadow: 0 18px 48px -18px rgba(24, 25, 38, 0.85);
  color: var(--ctp-text);
  pointer-events: auto;
  z-index: 2147483646;
  opacity: 0;
  visibility: hidden;
  transition:
    transform 240ms cubic-bezier(0.21, 1.02, 0.73, 1),
    opacity 200ms ease,
    visibility 0s linear 240ms;
}

.notification-history.side-left {
  left: 0;
  right: auto;
  border-left: none;
  border-top-right-radius: 14px;
  border-bottom-right-radius: 14px;
  transform: translateX(-104%);
}

.notification-history.side-right {
  left: auto;
  right: 0;
  border-right: none;
  border-top-left-radius: 14px;
  border-bottom-left-radius: 14px;
  transform: translateX(104%);
}

.notification-history.open {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  transition:
    transform 260ms cubic-bezier(0.21, 1.02, 0.73, 1),
    opacity 200ms ease,
    visibility 0s linear 0s;
}

.notification-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--ctp-surface0);
  background: color-mix(in srgb, var(--ctp-crust) 60%, transparent);
}

.notification-history-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: var(--ctp-lavender);
}

.notification-history-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.notification-history-clear {
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--ctp-mauve) 38%, var(--ctp-surface1));
  background: color-mix(in srgb, var(--ctp-mauve) 14%, var(--ctp-surface0));
  color: var(--ctp-text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 120ms ease,
    border-color 120ms ease,
    opacity 120ms ease;
}

.notification-history-clear:hover:not(:disabled) {
  border-color: var(--ctp-mauve);
  background: color-mix(in srgb, var(--ctp-mauve) 26%, var(--ctp-surface0));
}

.notification-history-clear:disabled {
  opacity: 0.4;
  cursor: default;
}

.notification-history-close {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--ctp-overlay1);
  font: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition:
    background 120ms ease,
    color 120ms ease;
}

.notification-history-close:hover {
  background: color-mix(in srgb, var(--ctp-red) 18%, transparent);
  color: var(--ctp-red);
}

.notification-history-body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--ctp-surface2) transparent;
}

.notification-history-body::-webkit-scrollbar {
  width: 8px;
}

.notification-history-body::-webkit-scrollbar-thumb {
  background: var(--ctp-surface1);
  border-radius: 8px;
}

.notification-history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.notification-history-item {
  --notification-history-accent: var(--ctp-blue);

  position: relative;
  display: grid;
  grid-template-columns: 4px auto minmax(0, 1fr) 22px;
  gap: 10px;
  align-items: start;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--ctp-surface0);
  background: var(--ctp-base);
}

.notification-history-item::before {
  content: '';
  align-self: stretch;
  border-radius: 4px;
  background: var(--notification-history-accent);
}

.notification-history-item.info {
  --notification-history-accent: var(--ctp-blue);
}
.notification-history-item.progress {
  --notification-history-accent: var(--ctp-sky);
}
.notification-history-item.success {
  --notification-history-accent: var(--ctp-green);
}
.notification-history-item.warning {
  --notification-history-accent: var(--ctp-yellow);
}
.notification-history-item.error {
  --notification-history-accent: var(--ctp-red);
}

.notification-history-thumb {
  width: 56px;
  aspect-ratio: 100 / 56;
  height: auto;
  align-self: center;
  border-radius: 6px;
  border: 1px solid color-mix(in srgb, var(--notification-history-accent) 28%, var(--ctp-surface2));
  background: var(--ctp-crust);
  object-fit: cover;
}

.notification-history-icon {
  width: 10px;
  height: 10px;
  align-self: center;
  border-radius: 50%;
  background: var(--notification-history-accent);
}

.notification-history-content {
  min-width: 0;
}

.notification-history-item-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ctp-text);
}

.notification-history-item-body {
  margin-top: 3px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ctp-subtext0);
  overflow-wrap: anywhere;
}

.notification-history-time {
  display: block;
  margin-top: 5px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--ctp-overlay1);
}

.notification-history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}

.notification-history-action {
  min-height: 24px;
  max-width: 100%;
  padding: 4px 9px;
  border: 1px solid color-mix(in srgb, var(--notification-history-accent) 38%, var(--ctp-surface2));
  border-radius: 6px;
  background: color-mix(in srgb, var(--notification-history-accent) 18%, var(--ctp-surface0));
  color: var(--ctp-text);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition:
    background 120ms ease,
    border-color 120ms ease,
    color 120ms ease;
}

.notification-history-action:hover {
  border-color: color-mix(in srgb, var(--notification-history-accent) 70%, var(--ctp-surface2));
  background: color-mix(in srgb, var(--notification-history-accent) 28%, var(--ctp-surface0));
}

.notification-history-remove {
  width: 22px;
  height: 22px;
  align-self: start;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ctp-overlay1);
  font: inherit;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition:
    background 120ms ease,
    color 120ms ease;
}

.notification-history-remove:hover {
  background: color-mix(in srgb, var(--ctp-red) 18%, transparent);
  color: var(--ctp-red);
}

.notification-history-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 96px;
  padding: 24px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--ctp-overlay0);
}

.notification-history-empty.hidden {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .notification-history {
    transition-duration: 1ms;
  }
}

.modal {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: auto;
  z-index: 1000;
}

#jimakuModal {
  z-index: 1100;
}

#tsukihimeModal {
  z-index: 1100;
}

#tsukihimeModal .jimaku-form {
  grid-template-columns: 1fr 120px auto;
}

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

.tsukihime-tab {
  min-width: 0;
  min-height: 34px;
  padding: 7px 8px;
  border-radius: 7px;
  border: 1px solid rgba(110, 115, 141, 0.22);
  background: rgba(49, 50, 68, 0.76);
  color: var(--ctp-subtext1);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.15;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tsukihime-tab:hover,
.tsukihime-tab:focus-visible {
  border-color: rgba(138, 173, 244, 0.48);
  color: var(--ctp-text);
  outline: none;
}

.tsukihime-tab.active {
  border-color: rgba(238, 212, 159, 0.62);
  background: rgba(238, 212, 159, 0.16);
  color: var(--ctp-yellow);
}

#youtubePickerModal {
  z-index: 1110;
}

.modal.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.modal-content {
  width: min(720px, 92%);
  max-height: 80%;
  background: rgba(36, 39, 58, 0.95);
  border: 1px solid rgba(110, 115, 141, 0.18);
  border-radius: 12px;
  padding: 16px;
  color: var(--ctp-text);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: rgba(73, 77, 100, 0.5);
  color: var(--ctp-subtext0);
  border: 1px solid rgba(110, 115, 141, 0.2);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
}

.modal-close:hover {
  background: rgba(91, 96, 120, 0.6);
  color: var(--ctp-text);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.jimaku-form {
  display: grid;
  grid-template-columns: 1fr 120px 120px auto;
  gap: 10px;
  align-items: end;
}

.jimaku-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--ctp-subtext0);
}

.jimaku-field input {
  background: rgba(24, 25, 38, 0.85);
  border: 1px solid rgba(110, 115, 141, 0.2);
  border-radius: 6px;
  color: var(--ctp-text);
  padding: 6px 8px;
}

.jimaku-button {
  height: 36px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid rgba(110, 115, 141, 0.35);
  background: rgba(54, 58, 79, 0.6);
  color: var(--ctp-text);
  cursor: pointer;
}

.jimaku-button:hover {
  background: rgba(91, 96, 120, 0.7);
}

.jimaku-status {
  min-height: 20px;
  font-size: 13px;
  color: var(--ctp-subtext1);
}

.jimaku-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow: hidden;
}

.jimaku-section.hidden {
  display: none;
}

.jimaku-section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ctp-overlay2);
}

.jimaku-list {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  border: 1px solid rgba(110, 115, 141, 0.14);
  border-radius: 8px;
  max-height: 180px;
}

.jimaku-list li {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(110, 115, 141, 0.1);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.jimaku-list li:last-child {
  border-bottom: none;
}

.jimaku-list li.active {
  background: rgba(138, 173, 244, 0.15);
}

.jimaku-list .jimaku-subtext {
  font-size: 12px;
  color: var(--ctp-overlay2);
}

.jimaku-link {
  align-self: flex-start;
  background: transparent;
  color: var(--ctp-blue);
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
}

.jimaku-link.hidden {
  display: none;
}

.youtube-picker-content {
  width: min(820px, 92%);
  background:
    radial-gradient(circle at top right, rgba(198, 160, 246, 0.1), transparent 34%),
    linear-gradient(180deg, rgba(36, 39, 58, 0.98), rgba(30, 32, 48, 0.98));
  border-color: rgba(138, 173, 244, 0.25);
}

.youtube-picker-body {
  gap: 14px;
}

.youtube-picker-title {
  font-size: 13px;
  color: var(--ctp-subtext1);
}

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

.youtube-picker-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--ctp-subtext0);
}

.youtube-picker-field select {
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(110, 115, 141, 0.28);
  background: rgba(24, 25, 38, 0.92);
  color: var(--ctp-text);
  padding: 6px 10px;
}

.youtube-picker-status {
  min-height: 20px;
  font-size: 13px;
  color: var(--ctp-subtext0);
}

.youtube-picker-tracks {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
  border-radius: 10px;
  border: 1px solid rgba(110, 115, 141, 0.18);
}

.youtube-picker-tracks li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(110, 115, 141, 0.08);
  color: var(--ctp-text);
}

.youtube-picker-tracks li:last-child {
  border-bottom: none;
}

.youtube-picker-track-meta {
  color: var(--ctp-overlay0);
  font-size: 12px;
}

.youtube-picker-footer {
  display: flex;
  justify-content: flex-end;
}

.playlist-browser-content {
  width: min(1480px, calc(100vw - 40px));
  max-width: none;
  min-height: min(760px, calc(100vh - 56px));
  max-height: calc(100vh - 40px);
  padding: 18px 18px 16px;
  background:
    radial-gradient(circle at top left, rgba(138, 173, 244, 0.13), transparent 28%),
    linear-gradient(180deg, rgba(36, 39, 58, 0.985), rgba(30, 32, 48, 0.985));
  border-color: rgba(138, 173, 244, 0.24);
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(18px);
}

.playlist-browser-body {
  flex: 1;
  min-height: 0;
  gap: 16px;
}

.playlist-browser-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ctp-lavender);
  overflow-wrap: anywhere;
}

.playlist-browser-status {
  min-height: 20px;
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ctp-overlay2);
}

.playlist-browser-grid {
  display: grid;
  flex: 1;
  min-height: 0;
  grid-template-columns: minmax(0, 1.15fr) minmax(420px, 0.85fr);
  gap: 18px;
}

.playlist-browser-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(110, 115, 141, 0.16);
  background: linear-gradient(180deg, rgba(54, 58, 79, 0.55), rgba(36, 39, 58, 0.6));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.playlist-browser-pane-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ctp-blue);
}

.playlist-browser-list {
  flex: 1;
  min-height: 0;
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  border-radius: 12px;
  border: 1px solid rgba(110, 115, 141, 0.14);
  background: rgba(30, 32, 48, 0.5);
}

.playlist-browser-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(110, 115, 141, 0.09);
  color: var(--ctp-text);
}

.playlist-browser-row:last-child {
  border-bottom: none;
}

.playlist-browser-row.active {
  background: rgba(138, 173, 244, 0.14);
}

.playlist-browser-row.current {
  background: linear-gradient(
    90deg,
    rgba(138, 173, 244, 0.12),
    rgba(138, 173, 244, 0.03) 28%,
    transparent
  );
  box-shadow: inset 3px 0 0 #8aadf4;
}

.playlist-browser-row-main {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
}

.playlist-browser-row-label {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.playlist-browser-row-meta {
  font-size: 12px;
  color: var(--ctp-blue);
  line-height: 1.35;
}

.playlist-browser-row-submeta {
  font-size: 12px;
  color: var(--ctp-subtext0);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.playlist-browser-row-trailing {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 10px;
}

.playlist-browser-chip {
  border: 1px solid rgba(138, 173, 244, 0.24);
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(138, 173, 244, 0.1);
  color: var(--ctp-lavender);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.playlist-browser-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  flex-shrink: 0;
  max-width: 240px;
}

.playlist-browser-action {
  border: 1px solid rgba(138, 173, 244, 0.24);
  background: rgba(49, 54, 83, 0.78);
  color: var(--ctp-text);
  border-radius: 9px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.playlist-browser-action:hover {
  background: rgba(70, 78, 117, 0.88);
  color: var(--ctp-lavender);
}

.playlist-browser-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 2px;
  font-size: 12px;
  color: var(--ctp-overlay0);
}

@media (max-width: 700px) {
  .youtube-picker-grid {
    grid-template-columns: 1fr;
  }

  .playlist-browser-content {
    width: calc(100vw - 20px);
    min-height: calc(100vh - 24px);
    max-height: calc(100vh - 20px);
    padding: 14px;
    border-radius: 14px;
  }

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

  .playlist-browser-row,
  .playlist-browser-row-trailing {
    flex-direction: column;
    align-items: flex-start;
  }

  .playlist-browser-row-actions {
    max-width: none;
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .jimaku-form {
    grid-template-columns: 1fr 1fr;
  }

  .jimaku-button {
    grid-column: span 2;
  }
}

/* Media timing review uses the Catppuccin Macchiato palette without opacity-shifted colors. */
.media-timing-review-modal {
  background: rgba(24, 25, 38, 0.76);
  backdrop-filter: blur(10px);
}

/* Pointer capture keeps events on the track, so the cursor is forced from the modal root. */
.media-timing-review-modal.is-scrubbing,
.media-timing-review-modal.is-scrubbing * {
  cursor: ew-resize;
}

.media-timing-review-modal.is-sliding,
.media-timing-review-modal.is-sliding * {
  cursor: grabbing;
}

.media-timing-review-content {
  width: min(720px, calc(100vw - 32px));
  max-height: min(700px, calc(100vh - 32px));
  overflow: auto;
  gap: 0;
  padding: 0;
  border: 1px solid var(--ctp-surface1);
  border-radius: 16px;
  background: var(--ctp-base);
  color: var(--ctp-text);
  box-shadow:
    0 30px 90px rgba(24, 25, 38, 0.8),
    0 0 0 1px rgba(183, 189, 248, 0.07) inset;
  animation: media-timing-review-enter 180ms cubic-bezier(0.2, 0.9, 0.25, 1);
}

@keyframes media-timing-review-enter {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.media-timing-review-header {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 20px 13px;
  border-bottom: 1px solid var(--ctp-surface0);
  background: var(--ctp-mantle);
}

.media-timing-review-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.media-timing-review-title {
  color: var(--ctp-text);
  font-size: 19px;
  font-weight: 750;
  letter-spacing: -0.025em;
}

.media-timing-review-kind {
  --kind-accent: var(--ctp-teal);

  padding: 3px 9px;
  border: 1px solid color-mix(in srgb, var(--kind-accent) 42%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--kind-accent) 13%, transparent);
  color: var(--kind-accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.media-timing-review-kind[data-kind='word'] {
  --kind-accent: var(--ctp-mauve);
}

.media-timing-review-kind[data-kind='audio'] {
  --kind-accent: var(--ctp-sky);
}

.media-timing-review-editor {
  padding: 14px 20px 18px;
}

.media-timing-review-sentence-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.media-timing-review-sentence-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.media-timing-review-sentence-label {
  color: var(--ctp-overlay1);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.media-timing-review-line-count {
  padding: 2px 8px;
  border: 1px solid var(--ctp-surface1);
  border-radius: 999px;
  background: var(--ctp-mantle);
  color: var(--ctp-subtext0);
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.media-timing-review-line-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.media-timing-review-line-stepper {
  display: flex;
  align-items: center;
  gap: 4px;
}

.media-timing-review-line-stepper span {
  margin-right: 2px;
  color: var(--ctp-overlay1);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.media-timing-review-line-stepper button {
  width: 24px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--ctp-surface2);
  border-radius: 6px;
  background: var(--ctp-surface0);
  color: var(--ctp-text);
  font-size: 13px;
  font-weight: 750;
  line-height: 1;
  cursor: pointer;
}

.media-timing-review-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 108px;
  overflow: auto;
  margin: 0 0 12px;
  padding: 8px 14px;
  border-left: 3px solid var(--ctp-mauve);
  border-radius: 0 10px 10px 0;
  background: var(--ctp-mantle);
  color: var(--ctp-subtext1);
  font-size: 15px;
  font-weight: 560;
  line-height: 1.45;
  white-space: pre-wrap;
}

.media-timing-review-line {
  color: var(--ctp-overlay1);
}

.media-timing-review-line.is-current {
  color: var(--ctp-text);
}

/* Only dim context lines when some are actually added. */
.media-timing-review-text .media-timing-review-line:only-child {
  color: var(--ctp-subtext1);
}

.media-timing-review-readout {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px solid var(--ctp-surface1);
  border-radius: 12px;
  background: var(--ctp-mantle);
}

.media-timing-review-readout > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
  padding: 8px 12px;
}

.media-timing-review-readout > div + div {
  border-left: 1px solid var(--ctp-surface0);
}

.media-timing-review-readout span {
  color: var(--ctp-overlay1);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.media-timing-review-readout strong {
  color: var(--ctp-lavender);
  font-variant-numeric: tabular-nums;
  font-size: 16px;
  font-weight: 720;
}

.media-timing-review-readout .media-timing-review-duration {
  align-items: center;
  min-width: 128px;
  background: var(--ctp-surface0);
  text-align: center;
}

.media-timing-review-readout > div:last-child {
  align-items: flex-end;
  text-align: right;
}

.media-timing-review-readout .media-timing-review-duration strong {
  color: var(--ctp-teal);
}

.media-timing-review-timeline-shell {
  padding: 10px 12px 8px;
  border: 1px solid var(--ctp-surface1);
  border-radius: 14px;
  background: var(--ctp-mantle);
}

.media-timing-review-timeline-labels,
.media-timing-review-expand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ctp-overlay1);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.05em;
}

.media-timing-review-timeline-labels span:first-child,
.media-timing-review-timeline-labels span:last-child {
  color: var(--ctp-subtext0);
  font-variant-numeric: tabular-nums;
}

.media-timing-review-track {
  --selection-start: 20%;
  --selection-end: 80%;
  --original-start: 25%;
  --original-end: 75%;
  --playhead-duration: 1s;

  position: relative;
  height: 52px;
  margin: 8px 0 9px;
  overflow: hidden;
  border: 1px solid var(--ctp-surface2);
  border-radius: 10px;
  background:
    linear-gradient(var(--ctp-surface1), var(--ctp-surface1)) center / 100% 1px no-repeat,
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent calc(10% - 1px),
      color-mix(in srgb, var(--ctp-surface1) 65%, transparent) calc(10% - 1px),
      color-mix(in srgb, var(--ctp-surface1) 65%, transparent) 10%
    ),
    linear-gradient(180deg, var(--ctp-crust), var(--ctp-mantle));
  cursor: ew-resize;
  touch-action: none;
  user-select: none;
}

.media-timing-review-waveform {
  position: absolute;
  z-index: 1;
  inset: 4px 0;
  width: 100%;
  height: calc(100% - 8px);
  pointer-events: none;
  transition: opacity 160ms ease;
}

#mediaTimingReviewWaveformPath {
  fill: url('#mediaTimingReviewWaveformFill');
}

.media-timing-review-waveform-edge-stop {
  stop-color: var(--ctp-sky);
}

.media-timing-review-waveform-core-stop {
  stop-color: var(--ctp-blue);
}

/* Sits above the selection scrim so adjacent dialogue reads as outside the mined subtitle. */
.media-timing-review-original-range {
  position: absolute;
  z-index: 4;
  top: 0;
  bottom: 0;
  left: var(--original-start);
  right: calc(100% - var(--original-end));
  min-width: 1px;
  background: color-mix(in srgb, var(--ctp-peach) 11%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ctp-peach) 28%, transparent);
  pointer-events: none;
}

.media-timing-review-original-boundary {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--ctp-peach);
  box-shadow: 0 0 8px color-mix(in srgb, var(--ctp-peach) 45%, transparent);
}

.media-timing-review-original-boundary.is-start {
  left: 0;
}

.media-timing-review-original-boundary.is-end {
  right: 0;
}

.media-timing-review-original-label {
  position: absolute;
  z-index: 7;
  padding: 3px 5px;
  border: 1px solid color-mix(in srgb, var(--ctp-crust) 35%, transparent);
  border-radius: 4px;
  background: var(--ctp-peach);
  box-shadow: 0 2px 6px color-mix(in srgb, var(--ctp-crust) 55%, transparent);
  color: var(--ctp-crust);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1;
  pointer-events: none;
  white-space: nowrap;
  text-transform: uppercase;
}

.media-timing-review-original-label.is-start {
  top: 5px;
  left: calc(var(--original-start) + 7px);
}

.media-timing-review-original-label.is-end {
  right: calc(100% - var(--original-end) + 7px);
  bottom: 5px;
}

.media-timing-review-track.is-loading::after {
  position: absolute;
  z-index: 2;
  inset: 0;
  content: '';
  background: linear-gradient(
    105deg,
    transparent 20%,
    rgba(138, 173, 244, 0.16) 44%,
    rgba(183, 189, 248, 0.22) 50%,
    transparent 76%
  );
  transform: translateX(-100%);
  animation: media-timing-waveform-loading 1.1s ease-in-out infinite;
  pointer-events: none;
}

.media-timing-review-track.is-waveform-unavailable .media-timing-review-waveform {
  opacity: 0;
}

@keyframes media-timing-waveform-loading {
  to {
    transform: translateX(100%);
  }
}

/* The oversized shadow spread dims everything outside the clip; the track clips it. */
.media-timing-review-selected-range {
  position: absolute;
  z-index: 3;
  inset: 0 calc(100% - var(--selection-end)) 0 var(--selection-start);
  border-inline: 1px solid color-mix(in srgb, var(--ctp-teal) 65%, transparent);
  background: color-mix(in srgb, var(--ctp-teal) 9%, transparent);
  box-shadow: 0 0 0 2000px color-mix(in srgb, var(--ctp-crust) 62%, transparent);
  cursor: grab;
}

.media-timing-review-playhead {
  position: absolute;
  z-index: 5;
  top: 0;
  bottom: 0;
  left: var(--selection-start);
  width: 2px;
  background: var(--ctp-yellow);
  box-shadow: 0 0 12px color-mix(in srgb, var(--ctp-yellow) 75%, transparent);
  opacity: 0;
  pointer-events: none;
}

.media-timing-review-track.is-previewing .media-timing-review-playhead {
  opacity: 1;
  animation: media-timing-review-playhead var(--playhead-duration) linear forwards;
}

@keyframes media-timing-review-playhead {
  from {
    left: var(--selection-start);
  }
  to {
    left: var(--selection-end);
  }
}

.media-timing-review-handle {
  position: absolute;
  z-index: 6;
  top: 0;
  bottom: 0;
  width: 14px;
  border: 1px solid var(--ctp-teal);
  background: linear-gradient(
    180deg,
    var(--ctp-teal),
    color-mix(in srgb, var(--ctp-teal) 74%, var(--ctp-crust))
  );
  cursor: ew-resize;
  touch-action: none;
  transition: box-shadow 130ms ease;
}

/* Widens the grab area past the visible bracket without moving the clip edge. */
.media-timing-review-handle::before {
  position: absolute;
  inset: 0 -7px;
  content: '';
}

.media-timing-review-handle::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 18px;
  content: '';
  border-inline: 1px solid color-mix(in srgb, var(--ctp-crust) 55%, transparent);
  transform: translate(-50%, -50%);
}

.media-timing-review-handle-start {
  left: var(--selection-start);
  border-radius: 5px 0 0 5px;
}

.media-timing-review-handle-end {
  left: var(--selection-end);
  border-radius: 0 5px 5px 0;
  transform: translateX(-100%);
}

.media-timing-review-handle:hover {
  box-shadow: 0 0 16px color-mix(in srgb, var(--ctp-teal) 60%, transparent);
}

.media-timing-review-handle:focus-visible {
  outline: 2px solid transparent;
  box-shadow:
    inset 0 0 0 2px var(--ctp-yellow),
    0 0 16px color-mix(in srgb, var(--ctp-yellow) 55%, transparent);
}

.media-timing-review-expand-row span {
  text-align: center;
}

.media-timing-review-expand-button,
.media-timing-review-quiet-button,
.media-timing-review-original-button,
.media-timing-review-skip-button,
.media-timing-review-discard-button,
.media-timing-review-play-button,
.media-timing-review-confirm-button,
.media-timing-review-fine-control button {
  border: 1px solid var(--ctp-surface2);
  border-radius: 9px;
  background: var(--ctp-surface0);
  color: var(--ctp-text);
  font: inherit;
  font-size: 12px;
  font-weight: 720;
  cursor: pointer;
  transition:
    background 130ms ease,
    border-color 130ms ease,
    transform 130ms ease;
}

.media-timing-review-expand-button {
  min-width: 82px;
  padding: 5px 9px;
  color: var(--ctp-sky);
  font-variant-numeric: tabular-nums;
}

.media-timing-review-expand-button:disabled,
.media-timing-review-content button:disabled {
  cursor: default;
  opacity: 0.42;
}

.media-timing-review-content button:not(:disabled):hover {
  border-color: var(--ctp-lavender);
  background: var(--ctp-surface1);
}

.media-timing-review-content button:not(:disabled):active {
  transform: translateY(1px);
}

.media-timing-review-content button:focus-visible {
  outline: 2px solid var(--ctp-yellow);
  outline-offset: 2px;
}

.media-timing-review-fine-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.media-timing-review-fine-control {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--ctp-surface0);
  border-radius: 10px;
  background: var(--ctp-mantle);
  color: var(--ctp-subtext1);
}

.media-timing-review-fine-control span {
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.media-timing-review-fine-control button {
  min-width: 58px;
  padding: 5px 8px;
  font-variant-numeric: tabular-nums;
}

.media-timing-review-status {
  min-height: 21px;
  padding-top: 8px;
  color: var(--ctp-teal);
  font-size: 11px;
  font-weight: 620;
}

.media-timing-review-status.is-error {
  color: var(--ctp-red);
}

.media-timing-review-footer,
.media-timing-review-preview-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.media-timing-review-footer {
  justify-content: space-between;
  padding-top: 4px;
}

.media-timing-review-play-button,
.media-timing-review-confirm-button,
.media-timing-review-quiet-button,
.media-timing-review-original-button,
.media-timing-review-skip-button,
.media-timing-review-discard-button {
  padding: 9px 15px;
}

.media-timing-review-play-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border-color: var(--ctp-teal);
  background: var(--ctp-teal);
  color: var(--ctp-crust);
}

.media-timing-review-play-glyph {
  width: 0;
  height: 0;
  border-block: 5px solid transparent;
  border-left: 9px solid currentcolor;
}

.media-timing-review-play-button.is-playing {
  border-color: var(--ctp-yellow);
  background: var(--ctp-yellow);
}

.media-timing-review-play-button.is-playing .media-timing-review-play-glyph {
  width: 9px;
  height: 10px;
  border: 0;
  border-radius: 2px;
  background: currentcolor;
}

.media-timing-review-confirm-button {
  border-color: var(--ctp-blue);
  background: var(--ctp-blue);
  color: var(--ctp-crust);
}

.media-timing-review-original-button {
  border-color: var(--ctp-yellow);
  color: var(--ctp-yellow);
}

.media-timing-review-skip-button {
  border-color: var(--ctp-sky);
  color: var(--ctp-sky);
}

.media-timing-review-discard-button {
  border-color: var(--ctp-red);
  background: var(--ctp-red);
  color: var(--ctp-crust);
}

.media-timing-review-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding-top: 14px;
  color: var(--ctp-overlay1);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.media-timing-review-hints kbd {
  display: inline-block;
  min-width: 15px;
  margin-right: 3px;
  padding: 1px 5px;
  border: 1px solid var(--ctp-surface1);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--ctp-mantle);
  color: var(--ctp-subtext0);
  font-family: inherit;
  font-size: 9px;
  font-weight: 750;
  text-align: center;
}

.media-timing-review-cancel-step {
  min-height: 300px;
  padding: 44px 38px 34px;
  text-align: center;
}

.media-timing-review-cancel-mark {
  display: grid;
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
  place-items: center;
  border: 2px solid var(--ctp-yellow);
  border-radius: 50%;
  background: color-mix(in srgb, var(--ctp-yellow) 12%, transparent);
  color: var(--ctp-yellow);
  font-size: 26px;
  font-weight: 760;
}

.media-timing-review-cancel-step h2 {
  color: var(--ctp-text);
  font-size: 21px;
  font-weight: 760;
}

.media-timing-review-cancel-step p {
  max-width: 520px;
  margin: 8px auto 24px;
  color: var(--ctp-subtext0);
  font-size: 13px;
  line-height: 1.5;
}

.media-timing-review-cancel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

@media (prefers-reduced-motion: reduce) {
  .media-timing-review-content {
    animation: none;
  }

  .media-timing-review-track.is-loading::after,
  .media-timing-review-track.is-previewing .media-timing-review-playhead {
    animation: none;
  }
}

@media (max-width: 640px) {
  .media-timing-review-content {
    width: calc(100vw - 18px);
    max-height: calc(100vh - 18px);
  }

  .media-timing-review-header,
  .media-timing-review-editor {
    padding-right: 15px;
    padding-left: 15px;
  }

  .media-timing-review-readout {
    grid-template-columns: 1fr;
  }

  .media-timing-review-readout > div + div {
    border-top: 1px solid var(--ctp-surface0);
    border-left: 0;
  }

  .media-timing-review-fine-grid {
    grid-template-columns: 1fr;
  }

  .media-timing-review-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .media-timing-review-preview-actions > *,
  .media-timing-review-confirm-button {
    flex: 1;
  }
}

body.subtitle-sidebar-embedded-open #subtitleContainer {
  max-width: min(80%, calc(100vw - var(--subtitle-sidebar-reserved-width) - 24px));
  transform: translateX(calc(var(--subtitle-sidebar-reserved-width) * -0.5));
}

#subtitleContainer {
  max-width: min(80%, calc(100vw - var(--subtitle-sidebar-reserved-width) - 24px));
  margin-bottom: 60px;
  padding: 12px 20px;
  background: rgb(30, 32, 48, 0.88);
  border-radius: 8px;
  pointer-events: auto;
  transform: translateX(0);
}

#subtitleRoot {
  text-align: center;
  font-size: 35px;
  line-height: var(--visible-sub-line-height, 1.32);
  overflow-wrap: anywhere;
  word-break: keep-all;
  color: #cad3f5;
  --subtitle-known-word-color: #a6da95;
  --subtitle-n-plus-one-color: #c6a0f6;
  --subtitle-name-match-color: #f5bde6;
  --subtitle-jlpt-n1-color: #ed8796;
  --subtitle-jlpt-n2-color: #f5a97f;
  --subtitle-jlpt-n3-color: #f9e2af;
  --subtitle-jlpt-n4-color: #a6e3a1;
  --subtitle-jlpt-n5-color: #8aadf4;
  --subtitle-hover-token-color: #f4dbd6;
  --subtitle-hover-token-background-color: transparent;
  --subtitle-frequency-single-color: #f5a97f;
  --subtitle-frequency-band-1-color: #ed8796;
  --subtitle-frequency-band-2-color: #f5a97f;
  --subtitle-frequency-band-3-color: #f9e2af;
  --subtitle-frequency-band-4-color: #8bd5ca;
  --subtitle-frequency-band-5-color: #8aadf4;

  text-shadow:
    -1px -1px 2px rgba(0, 0, 0, 0.95),
    1px -1px 2px rgba(0, 0, 0, 0.95),
    -1px 1px 2px rgba(0, 0, 0, 0.95),
    1px 1px 2px rgba(0, 0, 0, 0.95),
    0 0 8px rgba(0, 0, 0, 0.5);
  /* Enable text selection for Yomitan */
  user-select: text;
  cursor: text;
  -webkit-text-fill-color: currentColor;
}

#subtitleRoot:empty {
  display: none;
}

#subtitleContainer:has(#subtitleRoot:empty) {
  display: none;
}

#subtitleContainer.primary-sub-hover {
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: auto;
}

#subtitleContainer.primary-sub-hover:hover {
  opacity: 1;
}

body.primary-sub-visible-on-yomitan-popup #subtitleContainer.primary-sub-hover {
  opacity: 1;
}

#subtitleContainer.primary-sub-hidden {
  display: none;
  pointer-events: none;
}

body.settings-modal-open #subtitleContainer {
  display: none !important;
  pointer-events: none !important;
}

body.settings-modal-open iframe.yomitan-popup,
body.settings-modal-open iframe[id^='yomitan-popup'],
body.settings-modal-open [data-subminer-yomitan-popup-host='true'] {
  display: none !important;
  pointer-events: none !important;
}

#subtitleRoot .c {
  display: inline;
  position: relative;
  color: inherit;
  -webkit-text-fill-color: currentColor !important;
}

#subtitleRoot .c:hover {
  background: var(--subtitle-hover-token-background-color, transparent);
  color: var(--subtitle-hover-token-color, #f4dbd6) !important;
  -webkit-text-fill-color: var(--subtitle-hover-token-color, #f4dbd6) !important;
  border-radius: 2px;
}

#subtitleRoot .word {
  display: inline;
  position: relative;
  -webkit-text-fill-color: currentColor !important;
}

#subtitleRoot .word.keyboard-selected {
  outline: 2px solid rgba(135, 201, 255, 0.92);
  outline-offset: 2px;
  border-radius: 4px;
  box-shadow:
    0 0 0 2px rgba(12, 18, 28, 0.68),
    0 0 18px rgba(120, 188, 255, 0.45);
}

#subtitleRoot .word[data-frequency-rank]::before {
  content: attr(data-frequency-rank);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%) translateY(2px);
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(15, 17, 26, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #f5f5f5;
  font-size: 0.48em;
  line-height: 1.2;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 120ms ease,
    transform 120ms ease;
  z-index: 1;
}

#subtitleRoot .word[data-frequency-rank]:hover::before,
#subtitleRoot .word.keyboard-selected[data-frequency-rank]::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#subtitleRoot .word[data-jlpt-level]::after {
  content: attr(data-jlpt-level);
  position: absolute;
  left: 50%;
  bottom: -0.42em;
  transform: translateX(-50%) translateY(2px);
  font-size: 0.42em;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0.03em;
  white-space: nowrap;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.85),
    0 0 3px rgba(0, 0, 0, 0.65);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 120ms ease,
    transform 120ms ease;
  z-index: 1;
}

#subtitleRoot .word[data-jlpt-level]:hover::after,
#subtitleRoot .word.keyboard-selected[data-jlpt-level]::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#subtitleRoot .word.word-known {
  color: var(--subtitle-known-word-color, #a6da95);
}

/* Anki maturity tiers ride on word-known and only override its color, so
   hover/selection rules keyed on word-known keep applying. */
#subtitleRoot .word.word-known.word-maturity-new {
  color: var(--subtitle-maturity-new-color, #ee99a0);
}

#subtitleRoot .word.word-known.word-maturity-learning {
  color: var(--subtitle-maturity-learning-color, #b7bdf8);
}

#subtitleRoot .word.word-known.word-maturity-young {
  color: var(--subtitle-maturity-young-color, #91d7e3);
}

#subtitleRoot .word.word-known.word-maturity-mature {
  color: var(--subtitle-maturity-mature-color, #a6da95);
}

#subtitleRoot .word.word-n-plus-one {
  color: var(--subtitle-n-plus-one-color, #c6a0f6);
}

#subtitleRoot .word.word-name-match {
  color: var(--subtitle-name-match-color, #f5bde6);
}

#subtitleRoot .word.word-character-image-token {
  display: inline-block;
  position: relative;
  padding-left: 1.08em;
  margin-left: 0.18em;
  vertical-align: baseline;
}

#subtitleRoot .word-character-image {
  position: absolute;
  left: 0;
  top: 50%;
  width: 0.9em;
  height: 0.9em;
  border-radius: 50%;
  object-fit: cover;
  transform: translateY(calc(-50% + 0.05em));
  pointer-events: none;
  box-shadow:
    0 0 0 0.06em rgba(255, 255, 255, 0.32),
    0 0.08em 0.2em rgba(0, 0, 0, 0.45);
}

#subtitleRoot .word.word-jlpt-n1 {
  text-decoration-line: none;
  border-bottom: 3px solid var(--subtitle-jlpt-n1-color, #ed8796);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5));
}

#subtitleRoot .word.word-jlpt-n1[data-jlpt-level]::after {
  color: var(--subtitle-jlpt-n1-color, #ed8796);
}

#subtitleRoot .word.word-jlpt-n2 {
  text-decoration-line: none;
  border-bottom: 3px solid var(--subtitle-jlpt-n2-color, #f5a97f);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5));
}

#subtitleRoot .word.word-jlpt-n2[data-jlpt-level]::after {
  color: var(--subtitle-jlpt-n2-color, #f5a97f);
}

#subtitleRoot .word.word-jlpt-n3 {
  text-decoration-line: none;
  border-bottom: 3px solid var(--subtitle-jlpt-n3-color, #f9e2af);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5));
}

#subtitleRoot .word.word-jlpt-n3[data-jlpt-level]::after {
  color: var(--subtitle-jlpt-n3-color, #f9e2af);
}

#subtitleRoot .word.word-jlpt-n4 {
  text-decoration-line: none;
  border-bottom: 3px solid var(--subtitle-jlpt-n4-color, #a6e3a1);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5));
}

#subtitleRoot .word.word-jlpt-n4[data-jlpt-level]::after {
  color: var(--subtitle-jlpt-n4-color, #a6e3a1);
}

#subtitleRoot .word.word-jlpt-n5 {
  text-decoration-line: none;
  border-bottom: 3px solid var(--subtitle-jlpt-n5-color, #8aadf4);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5));
}

#subtitleRoot .word.word-jlpt-n5[data-jlpt-level]::after {
  color: var(--subtitle-jlpt-n5-color, #8aadf4);
}

#subtitleRoot .word.word-frequency-single {
  color: var(--subtitle-frequency-single-color, #f5a97f);
}

#subtitleRoot .word.word-frequency-band-1 {
  color: var(--subtitle-frequency-band-1-color, #ed8796);
}

#subtitleRoot .word.word-frequency-band-2 {
  color: var(--subtitle-frequency-band-2-color, #f5a97f);
}

#subtitleRoot .word.word-frequency-band-3 {
  color: var(--subtitle-frequency-band-3-color, #f9e2af);
}

#subtitleRoot .word.word-frequency-band-4 {
  color: var(--subtitle-frequency-band-4-color, #8bd5ca);
}

#subtitleRoot .word.word-frequency-band-5 {
  color: var(--subtitle-frequency-band-5-color, #8aadf4);
}

#subtitleRoot
  .word:not(.word-known):not(.word-n-plus-one):not(.word-name-match):not(
    .word-frequency-single
  ):not(.word-frequency-band-1):not(.word-frequency-band-2):not(.word-frequency-band-3):not(
    .word-frequency-band-4
  ):not(.word-frequency-band-5):hover {
  background: var(--subtitle-hover-token-background-color, transparent);
  border-radius: 3px;
  color: var(--subtitle-hover-token-color, #f4dbd6) !important;
  -webkit-text-fill-color: var(--subtitle-hover-token-color, #f4dbd6) !important;
}

#subtitleRoot .word.word-known:hover,
#subtitleRoot .word.word-n-plus-one:hover,
#subtitleRoot .word.word-name-match:hover,
#subtitleRoot .word.word-frequency-single:hover,
#subtitleRoot .word.word-frequency-band-1:hover,
#subtitleRoot .word.word-frequency-band-2:hover,
#subtitleRoot .word.word-frequency-band-3:hover,
#subtitleRoot .word.word-frequency-band-4:hover,
#subtitleRoot .word.word-frequency-band-5:hover {
  background: var(--subtitle-hover-token-background-color, transparent);
  border-radius: 3px;
  filter: brightness(1.18) saturate(1.08);
}

#subtitleRoot .word.word-known .c:hover,
#subtitleRoot .word.word-n-plus-one .c:hover,
#subtitleRoot .word.word-name-match .c:hover,
#subtitleRoot .word.word-frequency-single .c:hover,
#subtitleRoot .word.word-frequency-band-1 .c:hover,
#subtitleRoot .word.word-frequency-band-2 .c:hover,
#subtitleRoot .word.word-frequency-band-3 .c:hover,
#subtitleRoot .word.word-frequency-band-4 .c:hover,
#subtitleRoot .word.word-frequency-band-5 .c:hover {
  background: transparent;
  color: inherit !important;
  -webkit-text-fill-color: currentColor !important;
}

#subtitleRoot
  .word:is(.word-jlpt-n1, .word-jlpt-n2, .word-jlpt-n3, .word-jlpt-n4, .word-jlpt-n5):not(
    .word-known
  ):not(.word-n-plus-one):not(.word-name-match):not(.word-frequency-single):not(
    .word-frequency-band-1
  ):not(.word-frequency-band-2):not(.word-frequency-band-3):not(.word-frequency-band-4):not(
    .word-frequency-band-5
  ):hover {
  color: var(--subtitle-hover-token-color, #f4dbd6) !important;
  -webkit-text-fill-color: var(--subtitle-hover-token-color, #f4dbd6) !important;
}

#subtitleRoot::selection,
#subtitleRoot .word::selection,
#subtitleRoot .c::selection {
  background: var(--subtitle-hover-token-background-color, transparent);
  color: var(--subtitle-hover-token-color, #f4dbd6) !important;
  -webkit-text-fill-color: var(--subtitle-hover-token-color, #f4dbd6) !important;
}

#subtitleRoot *::selection {
  background: var(--subtitle-hover-token-background-color, transparent) !important;
  color: var(--subtitle-hover-token-color, #f4dbd6) !important;
  -webkit-text-fill-color: var(--subtitle-hover-token-color, #f4dbd6) !important;
}

#subtitleRoot .word.word-known::selection,
#subtitleRoot .word.word-known .c::selection {
  color: var(--subtitle-known-word-color, #a6da95) !important;
  -webkit-text-fill-color: var(--subtitle-known-word-color, #a6da95) !important;
}

#subtitleRoot .word.word-known.word-maturity-new::selection,
#subtitleRoot .word.word-known.word-maturity-new .c::selection {
  color: var(--subtitle-maturity-new-color, #ee99a0) !important;
  -webkit-text-fill-color: var(--subtitle-maturity-new-color, #ee99a0) !important;
}

#subtitleRoot .word.word-known.word-maturity-learning::selection,
#subtitleRoot .word.word-known.word-maturity-learning .c::selection {
  color: var(--subtitle-maturity-learning-color, #b7bdf8) !important;
  -webkit-text-fill-color: var(--subtitle-maturity-learning-color, #b7bdf8) !important;
}

#subtitleRoot .word.word-known.word-maturity-young::selection,
#subtitleRoot .word.word-known.word-maturity-young .c::selection {
  color: var(--subtitle-maturity-young-color, #91d7e3) !important;
  -webkit-text-fill-color: var(--subtitle-maturity-young-color, #91d7e3) !important;
}

#subtitleRoot .word.word-known.word-maturity-mature::selection,
#subtitleRoot .word.word-known.word-maturity-mature .c::selection {
  color: var(--subtitle-maturity-mature-color, #a6da95) !important;
  -webkit-text-fill-color: var(--subtitle-maturity-mature-color, #a6da95) !important;
}

#subtitleRoot .word.word-n-plus-one::selection,
#subtitleRoot .word.word-n-plus-one .c::selection {
  color: var(--subtitle-n-plus-one-color, #c6a0f6) !important;
  -webkit-text-fill-color: var(--subtitle-n-plus-one-color, #c6a0f6) !important;
}

#subtitleRoot .word.word-name-match::selection,
#subtitleRoot .word.word-name-match .c::selection {
  color: var(--subtitle-name-match-color, #f5bde6) !important;
  -webkit-text-fill-color: var(--subtitle-name-match-color, #f5bde6) !important;
}

#subtitleRoot .word.word-frequency-single::selection,
#subtitleRoot .word.word-frequency-single .c::selection {
  color: var(--subtitle-frequency-single-color, #f5a97f) !important;
  -webkit-text-fill-color: var(--subtitle-frequency-single-color, #f5a97f) !important;
}

#subtitleRoot .word.word-frequency-band-1::selection,
#subtitleRoot .word.word-frequency-band-1 .c::selection {
  color: var(--subtitle-frequency-band-1-color, #ed8796) !important;
  -webkit-text-fill-color: var(--subtitle-frequency-band-1-color, #ed8796) !important;
}

#subtitleRoot .word.word-frequency-band-2::selection,
#subtitleRoot .word.word-frequency-band-2 .c::selection {
  color: var(--subtitle-frequency-band-2-color, #f5a97f) !important;
  -webkit-text-fill-color: var(--subtitle-frequency-band-2-color, #f5a97f) !important;
}

#subtitleRoot .word.word-frequency-band-3::selection,
#subtitleRoot .word.word-frequency-band-3 .c::selection {
  color: var(--subtitle-frequency-band-3-color, #f9e2af) !important;
  -webkit-text-fill-color: var(--subtitle-frequency-band-3-color, #f9e2af) !important;
}

#subtitleRoot .word.word-frequency-band-4::selection,
#subtitleRoot .word.word-frequency-band-4 .c::selection {
  color: var(--subtitle-frequency-band-4-color, #8bd5ca) !important;
  -webkit-text-fill-color: var(--subtitle-frequency-band-4-color, #8bd5ca) !important;
}

#subtitleRoot .word.word-frequency-band-5::selection,
#subtitleRoot .word.word-frequency-band-5 .c::selection {
  color: var(--subtitle-frequency-band-5-color, #8aadf4) !important;
  -webkit-text-fill-color: var(--subtitle-frequency-band-5-color, #8aadf4) !important;
}

#subtitleRoot .word.word-jlpt-n1.word-known,
#subtitleRoot .word.word-jlpt-n1.word-n-plus-one,
#subtitleRoot .word.word-jlpt-n1.word-name-match,
#subtitleRoot .word.word-jlpt-n1.word-frequency-single,
#subtitleRoot .word.word-jlpt-n1.word-frequency-band-1,
#subtitleRoot .word.word-jlpt-n1.word-frequency-band-2,
#subtitleRoot .word.word-jlpt-n1.word-frequency-band-3,
#subtitleRoot .word.word-jlpt-n1.word-frequency-band-4,
#subtitleRoot .word.word-jlpt-n1.word-frequency-band-5,
#subtitleRoot .word.word-jlpt-n1:hover,
#subtitleRoot .word.word-jlpt-n1 .c:hover,
#subtitleRoot .word.word-jlpt-n1::selection,
#subtitleRoot .word.word-jlpt-n1 .c::selection {
  text-decoration-color: var(--subtitle-jlpt-n1-color, #ed8796) !important;
  -webkit-text-decoration-color: var(--subtitle-jlpt-n1-color, #ed8796) !important;
}

#subtitleRoot .word.word-jlpt-n2.word-known,
#subtitleRoot .word.word-jlpt-n2.word-n-plus-one,
#subtitleRoot .word.word-jlpt-n2.word-name-match,
#subtitleRoot .word.word-jlpt-n2.word-frequency-single,
#subtitleRoot .word.word-jlpt-n2.word-frequency-band-1,
#subtitleRoot .word.word-jlpt-n2.word-frequency-band-2,
#subtitleRoot .word.word-jlpt-n2.word-frequency-band-3,
#subtitleRoot .word.word-jlpt-n2.word-frequency-band-4,
#subtitleRoot .word.word-jlpt-n2.word-frequency-band-5,
#subtitleRoot .word.word-jlpt-n2:hover,
#subtitleRoot .word.word-jlpt-n2 .c:hover,
#subtitleRoot .word.word-jlpt-n2::selection,
#subtitleRoot .word.word-jlpt-n2 .c::selection {
  text-decoration-color: var(--subtitle-jlpt-n2-color, #f5a97f) !important;
  -webkit-text-decoration-color: var(--subtitle-jlpt-n2-color, #f5a97f) !important;
}

#subtitleRoot .word.word-jlpt-n3.word-known,
#subtitleRoot .word.word-jlpt-n3.word-n-plus-one,
#subtitleRoot .word.word-jlpt-n3.word-name-match,
#subtitleRoot .word.word-jlpt-n3.word-frequency-single,
#subtitleRoot .word.word-jlpt-n3.word-frequency-band-1,
#subtitleRoot .word.word-jlpt-n3.word-frequency-band-2,
#subtitleRoot .word.word-jlpt-n3.word-frequency-band-3,
#subtitleRoot .word.word-jlpt-n3.word-frequency-band-4,
#subtitleRoot .word.word-jlpt-n3.word-frequency-band-5,
#subtitleRoot .word.word-jlpt-n3:hover,
#subtitleRoot .word.word-jlpt-n3 .c:hover,
#subtitleRoot .word.word-jlpt-n3::selection,
#subtitleRoot .word.word-jlpt-n3 .c::selection {
  text-decoration-color: var(--subtitle-jlpt-n3-color, #f9e2af) !important;
  -webkit-text-decoration-color: var(--subtitle-jlpt-n3-color, #f9e2af) !important;
}

#subtitleRoot .word.word-jlpt-n4.word-known,
#subtitleRoot .word.word-jlpt-n4.word-n-plus-one,
#subtitleRoot .word.word-jlpt-n4.word-name-match,
#subtitleRoot .word.word-jlpt-n4.word-frequency-single,
#subtitleRoot .word.word-jlpt-n4.word-frequency-band-1,
#subtitleRoot .word.word-jlpt-n4.word-frequency-band-2,
#subtitleRoot .word.word-jlpt-n4.word-frequency-band-3,
#subtitleRoot .word.word-jlpt-n4.word-frequency-band-4,
#subtitleRoot .word.word-jlpt-n4.word-frequency-band-5,
#subtitleRoot .word.word-jlpt-n4:hover,
#subtitleRoot .word.word-jlpt-n4 .c:hover,
#subtitleRoot .word.word-jlpt-n4::selection,
#subtitleRoot .word.word-jlpt-n4 .c::selection {
  text-decoration-color: var(--subtitle-jlpt-n4-color, #a6e3a1) !important;
  -webkit-text-decoration-color: var(--subtitle-jlpt-n4-color, #a6e3a1) !important;
}

#subtitleRoot .word.word-jlpt-n5.word-known,
#subtitleRoot .word.word-jlpt-n5.word-n-plus-one,
#subtitleRoot .word.word-jlpt-n5.word-name-match,
#subtitleRoot .word.word-jlpt-n5.word-frequency-single,
#subtitleRoot .word.word-jlpt-n5.word-frequency-band-1,
#subtitleRoot .word.word-jlpt-n5.word-frequency-band-2,
#subtitleRoot .word.word-jlpt-n5.word-frequency-band-3,
#subtitleRoot .word.word-jlpt-n5.word-frequency-band-4,
#subtitleRoot .word.word-jlpt-n5.word-frequency-band-5,
#subtitleRoot .word.word-jlpt-n5:hover,
#subtitleRoot .word.word-jlpt-n5 .c:hover,
#subtitleRoot .word.word-jlpt-n5::selection,
#subtitleRoot .word.word-jlpt-n5 .c::selection {
  text-decoration-color: var(--subtitle-jlpt-n5-color, #8aadf4) !important;
  -webkit-text-decoration-color: var(--subtitle-jlpt-n5-color, #8aadf4) !important;
}

#subtitleRoot
  .word:is(.word-jlpt-n1, .word-jlpt-n2, .word-jlpt-n3, .word-jlpt-n4, .word-jlpt-n5):not(
    .word-known
  ):not(.word-n-plus-one):not(.word-name-match):not(.word-frequency-single):not(
    .word-frequency-band-1
  ):not(.word-frequency-band-2):not(.word-frequency-band-3):not(.word-frequency-band-4):not(
    .word-frequency-band-5
  )::selection,
#subtitleRoot
  .word:is(.word-jlpt-n1, .word-jlpt-n2, .word-jlpt-n3, .word-jlpt-n4, .word-jlpt-n5):not(
    .word-known
  ):not(.word-n-plus-one):not(.word-name-match):not(.word-frequency-single):not(
    .word-frequency-band-1
  ):not(.word-frequency-band-2):not(.word-frequency-band-3):not(.word-frequency-band-4):not(
    .word-frequency-band-5
  )
  .c::selection {
  color: var(--subtitle-hover-token-color, #f4dbd6) !important;
  -webkit-text-fill-color: var(--subtitle-hover-token-color, #f4dbd6) !important;
}

#subtitleRoot br {
  display: block;
  content: '';
  margin-bottom: var(--visible-sub-line-gap, 0.08em);
}

body.platform-macos.layer-visible #subtitleRoot {
  --visible-sub-line-height: 1.64;
  --visible-sub-line-gap: 0.54em;
}

#subtitleRoot.has-selection .word:hover,
#subtitleRoot.has-selection .c:hover {
  background: transparent;
}

body.subtitle-sidebar-embedded-open #secondarySubContainer {
  max-width: min(80%, calc(100vw - var(--subtitle-sidebar-reserved-width) - 24px));
  transform: translateX(calc(-50% - (var(--subtitle-sidebar-reserved-width) * 0.5)));
}

#secondarySubContainer {
  --secondary-sub-background-color: transparent;
  --secondary-sub-backdrop-filter: none;

  position: absolute;
  top: 40px;
  left: 50%;
  max-width: min(80%, calc(100vw - var(--subtitle-sidebar-reserved-width) - 24px));
  padding: 10px 18px;
  background: var(--secondary-sub-background-color, transparent);
  backdrop-filter: var(--secondary-sub-backdrop-filter, none);
  -webkit-backdrop-filter: var(--secondary-sub-backdrop-filter, none);
  border-radius: 8px;
  pointer-events: auto;
  transform: translateX(-50%);
}

body.layer-modal #subtitleContainer,
body.layer-modal #secondarySubContainer {
  display: none !important;
  pointer-events: none !important;
}

body.layer-modal #overlay {
  justify-content: center;
}

#secondarySubRoot {
  text-align: center;
  font-size: 24px;
  line-height: 1.5;
  color: #ffffff;
  -webkit-text-stroke: 0.45px rgba(0, 0, 0, 0.7);
  paint-order: stroke fill;
  text-shadow:
    -1px -1px 2px rgba(0, 0, 0, 0.95),
    1px -1px 2px rgba(0, 0, 0, 0.95),
    -1px 1px 2px rgba(0, 0, 0, 0.95),
    1px 1px 2px rgba(0, 0, 0, 0.95),
    0 0 8px rgba(0, 0, 0, 0.5);
  user-select: text;
  cursor: text;
}

#secondarySubRoot:empty {
  display: none;
}

#secondarySubContainer:has(#secondarySubRoot:empty) {
  display: none;
}

body.settings-modal-open #secondarySubContainer {
  display: none !important;
  pointer-events: none !important;
}

body.settings-modal-open .subtitle-sidebar-modal {
  display: none !important;
  pointer-events: none !important;
}

.secondary-sub-hidden {
  display: none !important;
}

body.subtitle-sidebar-embedded-open #secondarySubContainer.secondary-sub-hover {
  left: 0;
  right: var(--subtitle-sidebar-reserved-width);
  max-width: none;
  padding-right: 0;
  transform: none;
}

#secondarySubContainer.secondary-sub-hover {
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: auto;
  top: 0;
  left: 0;
  right: 0;
  transform: none;
  max-width: 100%;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  padding: 40px 0 0 0;
  border-radius: 0;
  display: flex;
  justify-content: center;
}

body.platform-windows #secondarySubContainer.secondary-sub-hover {
  top: 40px;
  padding-top: 0;
}

#secondarySubContainer.secondary-sub-hover #secondarySubRoot {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-radius: 8px;
  padding: 10px 18px;
}

#secondarySubContainer.secondary-sub-hover:hover,
#secondarySubContainer.secondary-sub-hover.secondary-sub-hover-active {
  opacity: 1;
}

#secondarySubContainer.secondary-sub-hover:hover #secondarySubRoot,
#secondarySubContainer.secondary-sub-hover.secondary-sub-hover-active #secondarySubRoot {
  background: var(--secondary-sub-background-color, transparent);
  backdrop-filter: var(--secondary-sub-backdrop-filter, none);
  -webkit-backdrop-filter: var(--secondary-sub-backdrop-filter, none);
}

iframe.yomitan-popup,
iframe[id^='yomitan-popup'],
[data-subminer-yomitan-popup-host='true'] {
  pointer-events: auto !important;
  z-index: 2147483645;
}

.kiku-info-text {
  font-size: 14px;
  color: var(--ctp-subtext1);
  line-height: 1.5;
}

.kiku-cards-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.kiku-card {
  background: rgba(54, 58, 79, 0.85);
  border: 2px solid rgba(110, 115, 141, 0.2);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.15s;
  outline: none;
}

.kiku-card:hover {
  border-color: rgba(110, 115, 141, 0.45);
}

.kiku-card.active {
  border-color: rgba(138, 173, 244, 0.85);
  background: rgba(138, 173, 244, 0.12);
}

.kiku-card-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ctp-overlay1);
  font-weight: 600;
}

.kiku-card.active .kiku-card-label {
  color: var(--ctp-blue);
}

.kiku-card-expression {
  font-size: 22px;
  font-weight: 600;
  color: var(--ctp-text);
}

.kiku-card-sentence {
  font-size: 14px;
  color: var(--ctp-subtext0);
  max-height: 52px;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.kiku-card-meta {
  font-size: 12px;
  color: var(--ctp-overlay1);
  display: flex;
  gap: 10px;
}

.kiku-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(110, 115, 141, 0.14);
}

.kiku-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.kiku-preview-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ctp-text);
}

.kiku-preview-toggle {
  display: inline-flex;
  gap: 6px;
}

.kiku-preview-toggle button {
  padding: 5px 10px;
  border-radius: 5px;
  border: 1px solid rgba(110, 115, 141, 0.2);
  background: rgba(54, 58, 79, 0.4);
  color: var(--ctp-subtext0);
  cursor: pointer;
  font-size: 12px;
}

.kiku-preview-toggle button.active {
  border-color: rgba(138, 173, 244, 0.45);
  background: rgba(138, 173, 244, 0.16);
  color: var(--ctp-blue);
}

.kiku-preview-json {
  margin: 0;
  min-height: 220px;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid rgba(110, 115, 141, 0.2);
  border-radius: 8px;
  background: rgba(24, 25, 38, 0.8);
  padding: 10px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--ctp-text);
}

.kiku-preview-error {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--ctp-red);
}

.kiku-delete-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ctp-subtext1);
  user-select: none;
}

.kiku-delete-toggle input {
  accent-color: var(--ctp-blue);
}

.kiku-confirm-button {
  padding: 8px 20px;
  border-radius: 6px;
  border: 1px solid rgba(138, 173, 244, 0.4);
  background: rgba(138, 173, 244, 0.15);
  color: var(--ctp-blue);
  font-weight: 600;
  cursor: pointer;
}

.kiku-confirm-button:hover {
  background: rgba(138, 173, 244, 0.25);
}

.subsync-modal-content {
  width: min(560px, 92%);
}

.subsync-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.subsync-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--ctp-subtext1);
}

.subsync-radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 14px;
  font-size: 13px;
  color: var(--ctp-subtext1);
}

.subsync-field select {
  background: rgba(24, 25, 38, 0.9);
  border: 1px solid rgba(110, 115, 141, 0.2);
  border-radius: 6px;
  color: var(--ctp-text);
  padding: 8px 10px;
}

.subsync-footer {
  display: flex;
  justify-content: flex-end;
}

.kiku-cancel-button {
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid rgba(110, 115, 141, 0.25);
  background: transparent;
  color: var(--ctp-overlay2);
  cursor: pointer;
}

.kiku-cancel-button:hover {
  background: rgba(54, 58, 79, 0.5);
  color: var(--ctp-text);
}

.kiku-hint {
  text-align: center;
  font-size: 11px;
  color: var(--ctp-overlay0);
}

.runtime-modal-content {
  width: min(560px, 92%);
}

.runtime-options-hint {
  font-size: 12px;
  color: var(--ctp-subtext0);
}

.runtime-options-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(110, 115, 141, 0.2);
  border-radius: 8px;
  max-height: 320px;
  overflow-y: auto;
}

.runtime-options-list-entry {
  list-style: none;
}

.runtime-options-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(110, 115, 141, 0.1);
  cursor: pointer;
}

.runtime-options-item-button {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  color: inherit;
}

.runtime-options-list-entry:last-child .runtime-options-item {
  border-bottom: none;
}

.runtime-options-item.active {
  background: rgba(138, 173, 244, 0.15);
}

.runtime-options-item-button:focus-visible {
  outline: 2px solid rgba(138, 173, 244, 0.85);
  outline-offset: -2px;
}

.runtime-options-label {
  font-size: 14px;
  color: var(--ctp-text);
}

.runtime-options-value {
  font-size: 13px;
  color: var(--ctp-blue);
}

.runtime-options-allowed {
  font-size: 11px;
  color: var(--ctp-overlay1);
}

.runtime-options-status {
  min-height: 18px;
  font-size: 12px;
  color: var(--ctp-subtext0);
}

.runtime-options-status.error {
  color: var(--ctp-red);
}

.character-dictionary-content {
  width: min(680px, 92%);
}

.character-dictionary-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.character-dictionary-tab {
  border: 1px solid rgba(110, 115, 141, 0.28);
  border-radius: 6px;
  background: rgba(24, 25, 38, 0.78);
  color: var(--ctp-subtext0);
  padding: 6px 10px;
  cursor: pointer;
}

.character-dictionary-tab.active {
  border-color: rgba(138, 173, 244, 0.62);
  background: rgba(138, 173, 244, 0.18);
  color: var(--ctp-text);
}

.character-dictionary-current {
  font-size: 12px;
  color: var(--ctp-subtext1);
}

.character-dictionary-search {
  display: flex;
  gap: 8px;
  margin: 10px 0;
}

.character-dictionary-search-input {
  min-width: 0;
  flex: 1 1 auto;
  border: 1px solid rgba(110, 115, 141, 0.28);
  border-radius: 6px;
  background: rgba(24, 25, 38, 0.88);
  color: var(--ctp-text);
  padding: 7px 9px;
}

.character-dictionary-search-input:focus {
  border-color: rgba(138, 173, 244, 0.75);
  outline: none;
}

.character-dictionary-candidates {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(110, 115, 141, 0.2);
  border-radius: 8px;
  max-height: 340px;
  overflow-y: auto;
}

.character-dictionary-candidate,
.character-dictionary-empty {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(110, 115, 141, 0.1);
}

.character-dictionary-candidate {
  cursor: pointer;
}

.character-dictionary-candidate:last-child,
.character-dictionary-empty:last-child {
  border-bottom: none;
}

.character-dictionary-candidate.active {
  background: rgba(138, 173, 244, 0.15);
}

.character-dictionary-candidate-body {
  min-width: 0;
}

.character-dictionary-manager-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.character-dictionary-managed-entry {
  align-items: flex-start;
}

.character-dictionary-use {
  flex: 0 0 auto;
  border: 1px solid rgba(138, 173, 244, 0.38);
  border-radius: 6px;
  background: rgba(54, 58, 79, 0.8);
  color: var(--ctp-text);
  padding: 6px 10px;
  cursor: pointer;
}

.character-dictionary-use:hover {
  background: rgba(91, 96, 120, 0.9);
}

.character-dictionary-use:disabled {
  cursor: default;
  opacity: 0.72;
}

.character-dictionary-empty {
  color: var(--ctp-overlay1);
  font-size: 13px;
}

.controller-select-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--ctp-text);
}

.controller-select-field select {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid rgba(110, 115, 141, 0.2);
  border-radius: 8px;
  background: rgba(24, 25, 38, 0.9);
  color: var(--ctp-text);
}

.controller-select-summary {
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--ctp-subtext0);
}

.controller-config-list {
  display: flex;
  flex-direction: column;
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(110, 115, 141, 0.25) transparent;
}

.controller-config-group {
  margin-top: 14px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(110, 115, 141, 0.12);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ctp-blue);
}

.controller-config-group:first-child {
  margin-top: 0;
}

.controller-config-row {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(110, 115, 141, 0.1);
  background: transparent;
  cursor: pointer;
  transition: background 120ms ease;
}

.controller-config-row:last-child {
  border-bottom: none;
}

.controller-config-row:hover {
  background: rgba(54, 58, 79, 0.4);
}

.controller-config-row.expanded {
  background: rgba(138, 173, 244, 0.08);
  border-color: rgba(138, 173, 244, 0.2);
}

.controller-config-label {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--ctp-text);
}

.controller-config-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.controller-config-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border: 0;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(138, 173, 244, 0.12);
  color: var(--ctp-blue);
  cursor: pointer;
  white-space: nowrap;
}

.controller-config-badge.disabled {
  background: rgba(110, 115, 141, 0.1);
  color: var(--ctp-overlay0);
}

.controller-config-reset-icon,
.controller-config-edit-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 14px;
  color: var(--ctp-overlay0);
  cursor: pointer;
  transition: color 120ms ease;
}

.controller-config-row:hover .controller-config-reset-icon,
.controller-config-row:hover .controller-config-edit-icon {
  color: var(--ctp-overlay2);
}

.controller-config-edit-panel {
  overflow: hidden;
  animation: configEditSlideIn 180ms ease-out;
  border-bottom: 1px solid rgba(138, 173, 244, 0.15);
  background: rgba(138, 173, 244, 0.04);
}

@keyframes configEditSlideIn {
  from {
    max-height: 0;
    opacity: 0;
  }
  to {
    max-height: 120px;
    opacity: 1;
  }
}

.controller-config-edit-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
}

.controller-config-edit-hint {
  font-size: 12px;
  color: var(--ctp-overlay2);
}

.controller-config-edit-hint.learning {
  color: var(--ctp-blue);
  animation: configLearnPulse 1.2s ease-in-out infinite;
}

@keyframes configLearnPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

.controller-config-edit-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.btn-learn {
  padding: 5px 14px;
  border-radius: 5px;
  border: 1px solid rgba(138, 173, 244, 0.4);
  background: rgba(138, 173, 244, 0.15);
  color: var(--ctp-blue);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease;
}

.btn-learn:hover {
  background: rgba(138, 173, 244, 0.25);
}

.btn-learn.active {
  border-color: rgba(138, 173, 244, 0.7);
  background: rgba(138, 173, 244, 0.25);
}

.btn-secondary {
  padding: 5px 12px;
  border-radius: 5px;
  border: 1px solid rgba(110, 115, 141, 0.2);
  background: transparent;
  color: var(--ctp-overlay0);
  font-size: 12px;
  cursor: pointer;
  transition:
    background 120ms ease,
    color 120ms ease;
}

.btn-secondary:hover {
  background: rgba(73, 77, 100, 0.4);
  color: var(--ctp-subtext0);
}

.controller-debug-content {
  position: relative;
  width: min(760px, 94%);
}

.controller-debug-toast {
  position: absolute;
  top: 18px;
  right: 56px;
  z-index: 2;
  max-width: min(320px, calc(100% - 88px));
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(120, 214, 168, 0.34);
  background: rgba(20, 38, 30, 0.96);
  color: rgba(220, 255, 232, 0.98);
  font-size: 12px;
  line-height: 1.3;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

.controller-debug-toast.error {
  border-color: rgba(255, 143, 143, 0.34);
  background: rgba(52, 22, 24, 0.96);
  color: rgba(255, 225, 225, 0.98);
}

.controller-debug-summary {
  min-height: 18px;
  font-size: 13px;
  color: var(--ctp-text);
  line-height: 1.45;
}

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

.controller-debug-span {
  grid-column: 1 / -1;
}

.controller-debug-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.controller-debug-pre {
  min-height: 220px;
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(110, 115, 141, 0.2);
  background: rgba(24, 25, 38, 0.85);
  color: var(--ctp-text);
  font-size: 12px;
  line-height: 1.5;
  overflow: auto;
  white-space: pre-wrap;
}

.subtitle-sidebar-modal {
  inset: 0;
  justify-content: flex-end;
  align-items: flex-start;
  padding: 14px;
  background: transparent;
  pointer-events: none;
}

body.subtitle-sidebar-embedded-open .subtitle-sidebar-modal {
  padding: 0;
  align-items: stretch;
}

.subtitle-sidebar-content {
  width: min(var(--subtitle-sidebar-max-width, 420px), 92vw);
  max-height: calc(100vh - 28px);
  height: auto;
  margin-left: auto;
  font-family: var(
    --subtitle-sidebar-font-family,
    'Hiragino Sans',
    'M PLUS 1',
    'Source Han Sans JP',
    'Noto Sans CJK JP',
    sans-serif
  );
  font-size: var(--subtitle-sidebar-font-size, 16px);
  background: var(--subtitle-sidebar-background-color, rgba(73, 77, 100, 0.9));
  color: var(--subtitle-sidebar-text-color, var(--ctp-text));
  border: 1px solid rgba(110, 115, 141, 0.18);
  border-radius: 10px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 2px 8px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(183, 189, 248, 0.06);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  opacity: var(--subtitle-sidebar-opacity, 0.95);
  pointer-events: auto;
}

.subtitle-sidebar-content .modal-header {
  padding: 10px 14px 8px;
  border-bottom: 1px solid rgba(110, 115, 141, 0.14);
  gap: 8px;
}

.subtitle-sidebar-content .modal-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ctp-subtext1);
  text-transform: uppercase;
}

.subtitle-sidebar-content .modal-close {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(73, 77, 100, 0.5);
  border: 1px solid rgba(110, 115, 141, 0.2);
  color: var(--ctp-subtext0);
  transition: all 140ms ease;
}

.subtitle-sidebar-content .modal-close:hover {
  background: rgba(91, 96, 120, 0.6);
  color: var(--ctp-text);
  border-color: rgba(110, 115, 141, 0.35);
}

body.subtitle-sidebar-embedded-open #subtitleSidebarContent {
  width: min(var(--subtitle-sidebar-max-width, 420px), 44vw);
  max-height: 100vh;
  height: 100vh;
  border-radius: 0;
  border-top: none;
  border-right: none;
  border-bottom: none;
  box-shadow:
    -12px 0 32px rgba(0, 0, 0, 0.3),
    -1px 0 0 rgba(110, 115, 141, 0.12);
}

.subtitle-sidebar-body {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
}

.subtitle-sidebar-content .runtime-options-status {
  font-size: 11px;
  padding: 4px 14px;
  color: var(--ctp-overlay0);
  letter-spacing: 0.02em;
}

.subtitle-sidebar-list {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  min-height: 0;
  border-radius: 0;
  background: transparent;
}

.subtitle-sidebar-list::-webkit-scrollbar {
  width: 6px;
}

.subtitle-sidebar-list::-webkit-scrollbar-track {
  background: transparent;
}

.subtitle-sidebar-list::-webkit-scrollbar-thumb {
  background: rgba(110, 115, 141, 0.25);
  border-radius: 3px;
}

.subtitle-sidebar-list::-webkit-scrollbar-thumb:hover {
  background: rgba(110, 115, 141, 0.4);
}

.subtitle-sidebar-item {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid rgba(110, 115, 141, 0.08);
  cursor: pointer;
  transition:
    background-color 120ms ease,
    color 120ms ease;
  position: relative;
}

.subtitle-sidebar-item:last-child {
  border-bottom: none;
}

.subtitle-sidebar-item:hover {
  background: var(--subtitle-sidebar-hover-background-color, rgba(54, 58, 79, 0.65));
}

.subtitle-sidebar-item:focus-visible {
  outline: 2px solid var(--subtitle-sidebar-active-line-color, #f5bde6);
  outline-offset: -2px;
  background: var(--subtitle-sidebar-hover-background-color, rgba(54, 58, 79, 0.65));
}

.subtitle-sidebar-item.active {
  background: var(--subtitle-sidebar-active-background-color, rgba(138, 173, 244, 0.12));
}

.subtitle-sidebar-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--subtitle-sidebar-active-line-color, #f5bde6);
  opacity: 0.85;
}

.subtitle-sidebar-timestamp {
  font-size: 0.72em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  color: var(--subtitle-sidebar-timestamp-color, var(--ctp-overlay0));
  padding-top: 2px;
}

.subtitle-sidebar-item:hover .subtitle-sidebar-timestamp {
  color: var(--subtitle-sidebar-timestamp-color, var(--ctp-subtext0));
}

.subtitle-sidebar-item.active .subtitle-sidebar-timestamp {
  color: var(--subtitle-sidebar-active-line-color, var(--ctp-pink));
  opacity: 0.75;
}

.subtitle-sidebar-item.active .subtitle-sidebar-text {
  color: var(--subtitle-sidebar-active-line-color, var(--ctp-pink));
}

.subtitle-sidebar-text {
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 1em;
  color: var(--subtitle-sidebar-text-color, var(--ctp-text));
}

.session-help-content {
  width: min(760px, 92%);
  max-height: 84%;
  color: var(--ctp-text);
}

@media (max-width: 720px) {
  .controller-debug-grid {
    grid-template-columns: 1fr;
  }
}

.session-help-shortcut,
.session-help-warning,
.session-help-status {
  min-height: 18px;
  font-size: 13px;
  color: var(--ctp-subtext1);
  line-height: 1.45;
}

.session-help-shortcut {
  font-weight: 600;
  color: var(--ctp-text);
}

.session-help-warning {
  color: var(--ctp-yellow);
}

.session-help-content-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(84vh - 220px);
  overflow-y: auto;
  padding-right: 4px;
}

.session-help-tabs {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  padding: 4px 0 6px;
  background: linear-gradient(180deg, rgba(30, 32, 48, 0.98), rgba(30, 32, 48, 0.82));
  backdrop-filter: blur(10px);
}

.session-help-tab {
  min-width: 0;
  min-height: 34px;
  padding: 7px 8px;
  border-radius: 7px;
  border: 1px solid rgba(110, 115, 141, 0.22);
  background: rgba(49, 50, 68, 0.76);
  color: var(--ctp-subtext1);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.15;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-help-tab:hover,
.session-help-tab:focus-visible {
  border-color: rgba(138, 173, 244, 0.48);
  color: var(--ctp-text);
  outline: none;
}

.session-help-tab.active {
  border-color: rgba(238, 212, 159, 0.62);
  background: rgba(238, 212, 159, 0.16);
  color: var(--ctp-yellow);
}

.session-help-filter {
  width: 100%;
  min-height: 32px;
  border: 1px solid rgba(110, 115, 141, 0.3);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(24, 25, 38, 0.9);
  color: var(--ctp-text);
  font-size: 13px;
  line-height: 1.2;
}

.session-help-filter::placeholder {
  color: var(--ctp-overlay0);
}

.session-help-filter:focus {
  outline: none;
  border-color: rgba(138, 173, 244, 0.6);
  box-shadow: 0 0 0 2px rgba(138, 173, 244, 0.2);
}

.session-help-content-no-results {
  color: var(--ctp-subtext0);
  padding: 12px;
  font-size: 13px;
}

.session-help-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(110, 115, 141, 0.15);
  border-radius: 10px;
  background: rgba(54, 58, 79, 0.15);
  backdrop-filter: blur(1px);
}

.session-help-section-title {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--ctp-overlay1);
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0 4px;
}

.session-help-item-list {
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(110, 115, 141, 0.15);
  border-radius: 8px;
  overflow: hidden;
}

.session-help-item {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  border: none;
  border-bottom: 1px solid rgba(110, 115, 141, 0.1);
  background: transparent;
  color: var(--ctp-text);
  cursor: pointer;
}

.session-help-item:last-child {
  border-bottom: none;
}

.session-help-item:hover,
.session-help-item:focus-visible,
.session-help-item.active {
  background: rgba(138, 173, 244, 0.2);
  outline: none;
}

.session-help-item.active {
  box-shadow: inset 3px 0 0 0 var(--ctp-blue);
}

.session-help-item-left {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.session-help-item-right {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.session-help-key {
  font-size: 12px;
  font-weight: 700;
  color: var(--ctp-text);
  white-space: nowrap;
  padding: 4px 9px;
  font-family:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',
    monospace;
  border-radius: 999px;
  background: rgba(138, 173, 244, 0.16);
  border: 1px solid rgba(138, 173, 244, 0.35);
  letter-spacing: 0.01em;
}

.session-help-action {
  font-size: 13px;
  color: var(--ctp-subtext1);
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}

.session-help-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(110, 115, 141, 0.4);
  flex: 0 0 auto;
}

@media (max-width: 640px) {
  .kiku-cards-container {
    grid-template-columns: 1fr;
  }

  .session-help-content-list {
    max-height: calc(84vh - 190px);
  }

  .session-help-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .session-help-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }

  .session-help-item-right {
    justify-content: flex-start;
    width: 100%;
  }

  .session-help-key {
    width: 100%;
    justify-content: center;
    text-align: center;
  }
}

/* Changelog modal */
.changelog-content {
  width: min(820px, 94%);
  max-height: 86%;
  color: var(--ctp-text);
}

.changelog-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.changelog-refresh {
  min-height: 28px;
  padding: 5px 12px;
  border-radius: 7px;
  border: 1px solid rgba(110, 115, 141, 0.3);
  background: rgba(49, 50, 68, 0.76);
  color: var(--ctp-subtext1);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.changelog-refresh:hover,
.changelog-refresh:focus-visible {
  border-color: rgba(138, 173, 244, 0.5);
  color: var(--ctp-text);
  outline: none;
}

.changelog-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.changelog-installed {
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(166, 218, 149, 0.45);
  background: rgba(166, 218, 149, 0.14);
  color: var(--ctp-green);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.changelog-source {
  color: var(--ctp-subtext0);
}

.changelog-warning {
  min-height: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ctp-yellow);
}

.changelog-warning:empty {
  display: none;
}

.changelog-status {
  min-height: 18px;
  font-size: 12px;
  color: var(--ctp-subtext1);
}

.changelog-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(86vh - 190px);
  overflow-y: auto;
  padding-right: 4px;
}

.changelog-list-empty {
  color: var(--ctp-subtext0);
  padding: 12px;
  font-size: 13px;
}

.changelog-entry {
  /* Flex children shrink by default, which crushes expanded entries inside the
     scrolling list; pin them to their content height instead. */
  flex: 0 0 auto;
  border: 1px solid rgba(110, 115, 141, 0.18);
  border-radius: 10px;
  background: rgba(54, 58, 79, 0.16);
  overflow: hidden;
}

.changelog-entry[open] {
  border-color: rgba(138, 173, 244, 0.28);
  background: rgba(54, 58, 79, 0.26);
}

.changelog-entry-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.changelog-entry-summary::-webkit-details-marker {
  display: none;
}

.changelog-entry-summary::before {
  content: '▸';
  color: var(--ctp-overlay1);
  font-size: 11px;
  transition: transform 120ms ease;
}

.changelog-entry[open] > .changelog-entry-summary::before {
  transform: rotate(90deg);
}

.changelog-entry-summary:hover,
.changelog-entry-summary:focus-visible,
.changelog-entry-summary.active {
  background: rgba(138, 173, 244, 0.12);
  outline: none;
}

.changelog-entry-summary.active {
  box-shadow: inset 3px 0 0 var(--ctp-yellow);
}

.changelog-entry-version {
  font-size: 14px;
  font-weight: 800;
  color: var(--ctp-text);
}

.changelog-entry-date {
  font-size: 12px;
  color: var(--ctp-subtext0);
}

.changelog-entry-badge {
  margin-left: auto;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.changelog-entry-badge-installed {
  border: 1px solid rgba(166, 218, 149, 0.5);
  background: rgba(166, 218, 149, 0.16);
  color: var(--ctp-green);
}

.changelog-entry-badge-newer {
  border: 1px solid rgba(238, 212, 159, 0.55);
  background: rgba(238, 212, 159, 0.16);
  color: var(--ctp-yellow);
}

.changelog-entry-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 14px 14px;
}

.changelog-section-title {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--ctp-blue);
}

.changelog-items {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 0;
  padding-left: 18px;
  list-style: disc;
}

.changelog-items-nested {
  gap: 5px;
  margin-top: 6px;
  padding-left: 16px;
  list-style: circle;
}

.changelog-item {
  font-size: 13px;
  line-height: 1.55;
  color: var(--ctp-subtext1);
}

.changelog-item::marker {
  color: var(--ctp-overlay1);
}

.changelog-items-nested > .changelog-item {
  font-size: 12.5px;
  color: var(--ctp-subtext0);
}

.changelog-item strong {
  color: var(--ctp-text);
}

.changelog-code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(24, 25, 38, 0.85);
  color: var(--ctp-peach);
  font-family: monospace;
  font-size: 12px;
}

.changelog-link {
  color: var(--ctp-blue);
  text-decoration: underline dotted;
}

.changelog-internal {
  border-top: 1px dashed rgba(110, 115, 141, 0.25);
  padding-top: 10px;
}

.changelog-internal-summary {
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ctp-overlay1);
}

.changelog-empty-entry {
  font-size: 12px;
  color: var(--ctp-subtext0);
}

@media (max-width: 640px) {
  .changelog-list {
    max-height: calc(86vh - 200px);
  }

  .changelog-entry-badge {
    margin-left: 0;
  }
}
