:root {
  color-scheme: dark;
  --bg: #0d1113;
  --surface: #151b1e;
  --surface-soft: #101619;
  --ink: #eef4f1;
  --muted: #9ca9a7;
  --line: #293236;
  --teal: #36c6b6;
  --teal-dark: #1a9f93;
  --blue: #8db8ff;
  --green: #76d99b;
  --gold: #f2c36d;
  --shadow: 0 18px 44px rgba(0, 0, 0, .34);
  --shadow-soft: 0 10px 26px rgba(0, 0, 0, .24);
}

* { box-sizing: border-box; }

html,
body {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, Arial, Helvetica, sans-serif;
  background:
    linear-gradient(180deg, rgba(30, 92, 87, .22) 0, rgba(13, 17, 19, 0) 360px),
    var(--bg);
  color: var(--ink);
}

a { color: inherit; }

.shell {
  width: min(1220px, calc(100% - 32px));
  max-width: calc(100vw - 32px);
  margin: 0 auto;
  padding: 24px 0 52px;
}

.topbar {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.brand {
  display: grid;
  gap: 3px;
}

.brand strong { font-size: 17px; }

.brand span,
.meta {
  color: var(--muted);
  font-size: 14px;
}

.navlink,
.primary-action,
.ghost-action {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font: inherit;
  font-weight: 850;
  cursor: pointer;
}

.primary-action {
  border-color: transparent;
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  color: #041211;
}

.ghost-action { background: transparent; }

.navlink:hover,
.ghost-action:hover,
.caption-reset:hover {
  border-color: rgba(54, 198, 182, .42);
  background: #1a2326;
}

.primary-action:hover {
  filter: brightness(1.06);
}

.action-link.is-done,
.primary-action.is-done,
.ghost-action.is-done {
  border-color: rgba(118, 217, 155, .34);
  background: rgba(49, 119, 78, .22);
  color: var(--green);
}

.page-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 22px;
  align-items: end;
  margin-bottom: 24px;
}

.page-head > *,
.topbar > *,
.pills > * {
  min-width: 0;
}

.hero-panel {
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .035) 0%, rgba(54, 198, 182, .08) 100%),
    var(--surface);
  box-shadow: var(--shadow);
}

h1, h2, h3, p { margin: 0; }

h1 {
  max-width: 980px;
  font-size: clamp(34px, 5vw, 62px);
  line-height: 1;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

h2 {
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.12;
  letter-spacing: 0;
}

.lead {
  max-width: 760px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.48;
  overflow-wrap: anywhere;
}

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

.card,
.toolbar,
.list-item,
.stat,
.progress-card,
.caption-config {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.card {
  min-height: 230px;
  display: grid;
  align-content: space-between;
  gap: 20px;
  padding: 22px;
  text-decoration: none;
}

.card.primary-card {
  background:
    linear-gradient(145deg, rgba(54, 198, 182, .11), rgba(255, 255, 255, .025)),
    var(--surface);
  border-color: rgba(54, 198, 182, .28);
}

.card p {
  color: var(--muted);
  line-height: 1.48;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 8px;
  background: rgba(54, 198, 182, .13);
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.pill.blue { background: rgba(141, 184, 255, .13); color: var(--blue); }
.pill.green { background: rgba(118, 217, 155, .13); color: var(--green); }
.pill.gold { background: rgba(242, 195, 109, .13); color: var(--gold); }

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
  margin: 18px 0 14px;
}

.stat { padding: 16px; }

.stat b {
  display: block;
  margin-bottom: 5px;
  color: var(--teal);
  font-size: 30px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.progress-card {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #242d30;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--green));
  transition: width .25s ease;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  margin-bottom: 14px;
  position: sticky;
  top: 0;
  z-index: 2;
  backdrop-filter: blur(12px);
  background: rgba(21, 27, 30, .88);
}

input[type="search"] {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  color: var(--ink);
  font: inherit;
  background: #0f1518;
}

input[type="search"]::placeholder { color: #75817f; }

.list {
  display: grid;
  gap: 12px;
}

.list-item {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 16px;
  padding: 12px;
}

.list-item.completed-video {
  border-color: rgba(118, 217, 155, .35);
  background:
    linear-gradient(180deg, rgba(118, 217, 155, .09), rgba(255, 255, 255, .02)),
    var(--surface);
}

.thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  background: #101417;
}

.item-body {
  min-width: 0;
  display: grid;
  align-content: space-between;
  gap: 10px;
}

.title-main {
  font-size: 18px;
  font-weight: 900;
  line-height: 1.28;
}

.title-main .original-title {
  color: var(--muted);
  font-weight: 700;
}

.title-sub {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

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

.date {
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.empty {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.youtube-shell {
  margin-bottom: 18px;
  max-width: 100%;
  border: 1px solid #0d1114;
  border-radius: 8px;
  overflow: hidden;
  background: #050607;
  box-shadow: 0 24px 60px rgba(10, 14, 18, .24);
}

.youtube-wrap {
  position: relative;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
  --caption-size: 28px;
  --caption-text: #ffffff;
  --caption-bg-rgb: 0, 0, 0;
  --caption-bg-opacity: .82;
}

#youtubePlayer,
#youtubePlayer iframe {
  width: 100%;
  height: 100%;
  display: block;
  position: relative;
  z-index: 1;
}

.youtube-wrap:fullscreen {
  width: 100vw;
  height: 100vh;
  background: #000;
}

.youtube-wrap:fullscreen #youtubePlayer,
.youtube-wrap:fullscreen #youtubePlayer iframe {
  width: 100%;
  height: 100%;
}

.youtube-wrap .caption-overlay {
  position: absolute;
  z-index: 5;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 24px clamp(18px, 4vw, 46px);
  pointer-events: none;
  text-align: center;
}

.youtube-wrap .caption-pt {
  display: inline-block;
  max-width: min(92%, 980px);
  color: var(--caption-text);
  font-size: var(--caption-size);
  font-weight: 900;
  line-height: 1.28;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .95);
}

.youtube-wrap .caption-overlay.style-box-white .caption-pt {
  padding: 7px 16px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 8px;
  background: rgba(var(--caption-bg-rgb), var(--caption-bg-opacity));
  backdrop-filter: blur(4px);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.player-controls {
  position: absolute;
  z-index: 8;
  top: 14px;
  right: 14px;
  max-width: calc(100% - 28px);
  min-width: 0;
  display: flex;
  gap: 8px;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  background: rgba(6, 10, 12, .72);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .26);
  backdrop-filter: blur(14px);
}

.player-controls button {
  min-width: 0;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 7px;
  background: rgba(16, 22, 25, .9);
  color: #eef4f1;
  font: inherit;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
}

.player-controls button:hover {
  transform: translateY(-1px);
  background: rgba(31, 42, 46, .96);
}

.player-progress {
  position: absolute;
  z-index: 8;
  left: 14px;
  right: 14px;
  bottom: 14px;
  min-height: 46px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  background: rgba(6, 10, 12, .78);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .3);
  backdrop-filter: blur(14px);
  transition: opacity .18s ease, transform .18s ease;
}

.youtube-wrap:fullscreen .player-progress {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

.youtube-wrap:fullscreen.show-progress .player-progress,
.youtube-wrap:fullscreen .player-progress:focus-within,
.youtube-wrap:fullscreen:hover .player-progress {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.player-time {
  min-width: 48px;
  color: #eef4f1;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.player-progress input[type="range"] {
  width: 100%;
  min-width: 0;
  accent-color: var(--teal);
  cursor: pointer;
}

.caption-config {
  margin-bottom: 18px;
}

.caption-config summary {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  font-weight: 900;
}

.caption-config summary::-webkit-details-marker { display: none; }

.caption-config summary::after {
  content: "+";
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--teal);
  font-size: 20px;
  line-height: 1;
}

.caption-config[open] summary::after { content: "-"; }

.caption-config summary small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.caption-settings {
  display: grid;
  grid-template-columns: 1.2fr .7fr .7fr 1fr 1fr auto;
  gap: 12px;
  align-items: end;
  padding: 0 14px 14px;
}

.caption-settings label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.caption-settings span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.caption-settings output {
  color: var(--teal);
  font-variant-numeric: tabular-nums;
}

.caption-settings input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
}

.caption-settings input[type="color"] {
  width: 100%;
  min-height: 38px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f1518;
  cursor: pointer;
}

.caption-reset {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 11px;
  background: var(--surface-soft);
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.player-head { margin-bottom: 18px; }

.player-head h1 {
  max-width: 980px;
  font-size: clamp(28px, 3.4vw, 44px);
  line-height: 1.05;
}

.player-head h1 .original-title {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: clamp(16px, 1.45vw, 22px);
  font-weight: 750;
  line-height: 1.28;
}

@media (max-width: 760px) {
  .shell {
    width: min(100%, calc(100vw - 48px));
    max-width: calc(100vw - 48px);
    margin: 0 auto;
  }

  .page-head,
  .grid,
  .stats,
  .caption-settings,
  .toolbar,
  .list-item {
    grid-template-columns: 1fr;
  }

  .topbar,
  .row {
    align-items: stretch;
    flex-direction: column;
  }

  .player-controls {
    left: 10px;
    right: 10px;
    top: 10px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .player-controls button {
    width: 100%;
    padding: 0 8px;
    font-size: 13px;
  }

  .player-progress {
    left: 10px;
    right: 10px;
    bottom: 10px;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    gap: 6px;
    padding: 8px;
  }

  .player-time {
    min-width: 44px;
    font-size: 12px;
  }
}
