* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

:root {
  color-scheme: dark;
  --bg: #07080a;
  --panel: rgba(14, 17, 22, 0.96);
  --panel-2: #171a20;
  --line: rgba(255, 255, 255, 0.15);
  --text: #f6f7f9;
  --muted: #aeb6c2;
  --yellow: #f5c62f;
  --yellow-dark: #d5a915;
  --blue: #66a6ff;
  --danger: #ff7070;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  height: 46px;
  display: grid;
  grid-template-columns: auto minmax(280px, 620px) 1fr;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  background: #030303;
  border-bottom: 1px solid #1f2329;
}

.brand {
  font-size: 23px;
  font-weight: 800;
  color: #ff9aab;
  white-space: nowrap;
}

.brand span {
  color: #d3bdf7;
}

.searchbar {
  display: grid;
  grid-template-columns: 130px 1fr 84px;
  gap: 8px;
  min-width: 0;
}

.searchbar select,
.searchbar input,
.bottom-search input {
  height: 34px;
  border: 1px solid #2b3139;
  border-radius: 6px;
  background: #171a20;
  color: var(--text);
  padding: 0 10px;
  min-width: 0;
}

.searchbar button,
.actions button,
.ai-form button {
  border: 1px solid #525862;
  border-radius: 6px;
  background: #2a2e35;
  color: var(--text);
  font-weight: 700;
}

.searchbar button {
  height: 34px;
}

.searchbar button:hover,
.actions button:hover,
.ai-form button:hover {
  border-color: #7a8390;
  background: #343942;
}

.status {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}

.layout {
  height: calc(100dvh - 46px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 382px;
  min-height: 0;
}

.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: radial-gradient(circle at 50% 35%, #25272b 0, #17191d 40%, #0a0b0d 100%);
  overflow: hidden;
}

.player {
  position: absolute;
  inset: 0 0 132px;
  width: 100%;
  height: calc(100% - 132px);
  object-fit: contain;
  background: #262626;
}

.stage::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 132px;
  height: 180px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.5));
  pointer-events: none;
}

.center-controls {
  position: absolute;
  left: 50%;
  top: calc(50% - 58px);
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 26px;
  z-index: 5;
  pointer-events: none;
}

.round-btn,
.play-btn {
  pointer-events: auto;
  display: grid;
  place-items: center;
  border: 4px solid rgba(255, 255, 255, 0.72);
  background: rgba(0, 0, 0, 0.16);
  color: rgba(255, 255, 255, 0.86);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.28);
}

.round-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  font-size: 52px;
  line-height: 1;
  padding-bottom: 8px;
}

.play-btn {
  width: 94px;
  height: 94px;
  border-radius: 50%;
  font-size: 42px;
  padding-left: 6px;
}

.subtitle-overlay {
  position: absolute;
  left: 50%;
  bottom: 164px;
  transform: translateX(-50%);
  z-index: 6;
  width: min(980px, calc(100% - 80px));
  text-align: center;
  pointer-events: none;
}

.subtitle-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
  pointer-events: auto;
}

.subtitle-primary,
.subtitle-zh {
  display: inline;
  padding: 7px 14px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.78);
  text-shadow: 0 2px 2px rgba(0, 0, 0, 0.7);
  line-height: 1.22;
  word-break: normal;
  overflow-wrap: anywhere;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.subtitle-primary {
  font-size: clamp(24px, 2.2vw, 34px);
  font-weight: 650;
}

.subtitle-zh {
  display: table;
  margin: 10px auto 0;
  font-size: clamp(20px, 1.8vw, 28px);
  color: #f4f5f7;
}

.ai-pill {
  flex: 0 0 auto;
  width: 38px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: var(--yellow);
  color: #111;
  font-weight: 900;
  pointer-events: auto;
}

.word-token {
  border-radius: 4px;
  padding: 0 2px;
}

.word-token:hover,
.word-token.active {
  background: rgba(245, 198, 47, 0.78);
  color: #101010;
}

.thumb-strip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 46px;
  height: 86px;
  z-index: 7;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  background: rgba(0, 0, 0, 0.78);
  border-top: 1px solid rgba(255, 255, 255, 0.24);
  scrollbar-color: #b8bcc4 #25272b;
}

.thumb {
  position: relative;
  flex: 0 0 142px;
  height: 86px;
  border: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 0;
  padding: 0;
  color: #fff;
  background: #101214;
  text-align: left;
  overflow: hidden;
}

.thumb.active {
  outline: 2px solid var(--yellow);
  outline-offset: -2px;
}

.thumb video,
.side-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #050505;
  display: block;
}

.thumb::after,
.side-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 25%, rgba(0, 0, 0, 0.82));
  pointer-events: none;
}

.thumb-number {
  position: absolute;
  top: 6px;
  left: 7px;
  z-index: 2;
  min-width: 22px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: var(--yellow);
  color: #111;
  font-size: 12px;
  font-weight: 900;
}

.thumb-caption {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 6px;
  z-index: 2;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.bottom-search {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 46px;
  z-index: 8;
  display: grid;
  grid-template-columns: 54px 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: #15171a;
  border-top: 1px solid #2c3036;
}

.lang-badge {
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid #4b515b;
  border-radius: 8px;
  color: #cfd4dc;
  font-weight: 800;
}

.side-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  background: var(--panel);
  border-left: 1px solid #222831;
  box-shadow: -20px 0 40px rgba(0, 0, 0, 0.24);
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--line);
}

.panel-head h1 {
  margin: 0 0 5px;
  font-size: 16px;
}

.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.counter {
  flex: 0 0 64px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 1px solid #3b414a;
  border-radius: 8px;
  background: #20242b;
}

.counter strong {
  font-size: 22px;
  line-height: 1;
}

.counter span {
  font-size: 11px;
  color: var(--muted);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  padding: 10px 14px 8px;
}

.metrics span {
  min-width: 0;
  padding: 6px 8px;
  border-radius: 6px;
  background: #20242b;
  color: #d7dbe2;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px 14px 14px;
  border-bottom: 1px solid var(--line);
}

.actions button {
  height: 34px;
}

.actions .primary-action {
  grid-column: 1 / -1;
  background: var(--yellow);
  color: #121212;
  border: 0;
}

.actions .primary-action:hover {
  background: #ffd850;
}

.list-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  color: #d9dde4;
  font-size: 13px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.subtitle-list {
  min-height: 0;
  overflow: auto;
  scrollbar-color: #b8bcc4 #25272b;
}

.line-item {
  position: relative;
  display: grid;
  grid-template-columns: 28px 86px minmax(0, 1fr) 40px;
  gap: 8px;
  align-items: center;
  min-height: 86px;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
  color: var(--text);
  text-align: left;
  width: 100%;
}

.line-item:hover,
.line-item.active {
  background: rgba(245, 198, 47, 0.14);
}

.line-no {
  color: #9aa3ae;
  font-weight: 800;
  text-align: right;
}

.side-thumb {
  position: relative;
  width: 86px;
  height: 56px;
  border-radius: 4px;
  overflow: hidden;
  background: #050505;
}

.side-play {
  position: absolute;
  left: 6px;
  top: 6px;
  z-index: 2;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.55);
  font-size: 13px;
}

.line-text {
  min-width: 0;
}

.line-original {
  font-size: 13px;
  line-height: 1.25;
  font-weight: 850;
}

.line-translation {
  margin-top: 4px;
  color: #c8ced8;
  font-size: 13px;
  line-height: 1.32;
}

.line-ai {
  width: 34px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: var(--yellow);
  color: #111;
  font-weight: 900;
}

.word-popup {
  position: fixed;
  z-index: 50;
  width: min(390px, calc(100vw - 20px));
  border: 1px solid #3a414d;
  border-radius: 8px;
  background: #11151b;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.46);
  overflow: hidden;
}

.popup-head,
.ai-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.popup-head strong {
  display: block;
  font-size: 22px;
}

.word-meta {
  margin-top: 5px;
  color: #d8dde6;
  font-size: 13px;
}

.popup-head button,
.ai-head button {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 1px solid #555d69;
  border-radius: 6px;
  background: #2b3038;
  color: #fff;
}

.popup-body {
  padding: 12px 14px 14px;
  color: #eef1f6;
  line-height: 1.55;
  white-space: pre-wrap;
}

.ai-dialog {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.62);
}

.ai-card {
  width: min(720px, 100%);
  max-height: min(760px, calc(100dvh - 36px));
  display: grid;
  grid-template-rows: auto minmax(180px, 1fr) auto;
  border: 1px solid #3a414d;
  border-radius: 8px;
  background: #10141a;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.ai-head h2 {
  margin: 0 0 5px;
  font-size: 18px;
}

.ai-head p {
  margin: 0;
  color: #cbd2dc;
  font-size: 13px;
  line-height: 1.35;
}

.ai-messages {
  overflow: auto;
  padding: 14px;
}

.ai-message {
  margin-bottom: 12px;
  padding: 11px 12px;
  border-radius: 8px;
  background: #242832;
  line-height: 1.55;
  white-space: pre-wrap;
}

.ai-message.user {
  background: var(--yellow);
  color: #101010;
}

.ai-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 10px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
}

.ai-form textarea {
  min-width: 0;
  resize: vertical;
  border: 1px solid #3b414a;
  border-radius: 6px;
  background: #20242a;
  color: #fff;
  padding: 10px;
}

.ai-form button {
  background: var(--yellow);
  color: #111;
  border: 0;
}

.empty {
  padding: 22px 16px;
  color: var(--muted);
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .topbar {
    height: auto;
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
  }

  .brand {
    font-size: 20px;
  }

  .searchbar {
    grid-template-columns: 106px minmax(0, 1fr) 66px;
  }

  .status {
    text-align: left;
  }

  .layout {
    height: auto;
    min-height: calc(100dvh - 112px);
    display: block;
  }

  .stage {
    height: 58dvh;
    min-height: 420px;
  }

  .player {
    inset: 0 0 122px;
    height: calc(100% - 122px);
  }

  .stage::after {
    bottom: 122px;
  }

  .subtitle-overlay {
    bottom: 148px;
    width: calc(100% - 20px);
  }

  .subtitle-primary {
    font-size: 22px;
  }

  .subtitle-zh {
    font-size: 18px;
  }

  .play-btn {
    width: 78px;
    height: 78px;
    font-size: 34px;
  }

  .round-btn {
    width: 52px;
    height: 52px;
    font-size: 42px;
  }

  .thumb-strip {
    height: 76px;
  }

  .thumb {
    flex-basis: 118px;
    height: 76px;
  }

  .bottom-search {
    height: 46px;
  }

  .side-panel {
    min-height: 46dvh;
    border-left: 0;
    border-top: 1px solid #222831;
  }

  .line-item {
    grid-template-columns: 26px 94px minmax(0, 1fr) 38px;
  }
}
