/* The clip search app at /. Its colours are the tokens of /static/site/tokens.css (linked before this file), so it
   follows the system's light or dark setting like the /custom pages; it does not load site.css. The header's first
   row copies the /custom header's rules. */

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
a { color: var(--accent); }
.muted { color: var(--muted); font-size: 13px; }

/* ---- buttons: the look of the site's .btn; the primary and pressed ones gold ---- */
button {
  padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line2); background: var(--card2); color: var(--text);
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, opacity .15s;
}
button:hover:not(:disabled) { border-color: var(--line3); background: var(--card3); }
button:disabled { opacity: .4; cursor: default; }
button.primary, button[aria-pressed="true"], #search button { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); font-weight: 600; }
button.primary:hover:not(:disabled), button[aria-pressed="true"]:hover:not(:disabled), #search button:hover:not(:disabled) { background: #ffe07a; border-color: var(--gold); }
button.link, button.link:hover:not(:disabled) { background: none; border: none; padding: 0; color: var(--accent); }
button.link:hover:not(:disabled) { text-decoration: underline; }
.rec.on, .rec.on:hover:not(:disabled) { background: var(--rose); border-color: var(--rose); color: #fff; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 8px; border: 1px solid var(--line2);
  background: var(--card2); color: var(--text); font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, opacity .15s;
}
.btn:hover { border-color: var(--line3); background: var(--card3); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn.gold:hover { background: #ffe07a; }

/* ---- header: one sticky block; row 1 is the /custom header, row 2 the search and the views ---- */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); }
.top a { text-decoration: none; }
.wrap { max-width: 1680px; margin: 0 auto; padding: 0 40px; }
.nav { border-bottom: 1px solid color-mix(in srgb, var(--text) 7%, transparent); }
.nav .wrap { display: flex; align-items: center; gap: 40px; height: 64px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: .2px; flex: none; color: var(--text); }
.logo i {
  width: 30px; height: 30px; border-radius: 8px; background: var(--gold); display: grid; place-items: center;
  box-shadow: 0 6px 18px -6px var(--gold);
}
.logo i svg { width: 15px; height: 15px; fill: var(--gold-ink); margin-left: 2px; }
.logo small { font-weight: 500; color: var(--muted); font-size: 12px; margin-left: 4px; }
.nav .links { display: flex; align-items: stretch; height: 100%; gap: 4px; }
.nav .links > a {
  display: flex; align-items: center; padding: 0 14px; height: 100%; color: var(--soft); font-size: 15px; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.nav .links > a:hover { color: var(--text); }
.nav .links a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.nav .right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.nav .menu { display: none; background: none; border: 1px solid var(--line2); border-radius: 8px; padding: 6px 9px; }
.top .bar { display: flex; gap: 16px; align-items: center; padding-top: 8px; padding-bottom: 8px; }
#search { display: flex; gap: 8px; flex: 1; min-width: 240px; max-width: 640px; }
#q {
  flex: 1; min-width: 0; padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--line2); background: var(--card); outline: none;
}
#q::placeholder { color: var(--muted); }
#q:focus { border-color: var(--line3); }

.tabs { display: flex; gap: 4px; margin-left: auto; }
.tabs button { background: none; border-color: transparent; color: var(--muted); }
.tabs button:hover:not(:disabled) { background: none; border-color: var(--line); color: var(--text); }
.tabs button[aria-current="page"], .tabs button[aria-current="page"]:hover:not(:disabled) { color: var(--text); border-color: var(--line2); background: var(--card); }
.badge {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 2px; border-radius: 999px;
  background: var(--rose); color: #fff; font-size: 12px; line-height: 18px; text-align: center;
}
.count { font-weight: 400; font-size: 12px; color: var(--muted); }

/* ---- player ---- */
.layout {
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr);
  gap: 20px; padding: 20px 40px; max-width: 1680px; margin: 0 auto;   /* the header's .wrap: same edges */
}
/* below the two header rows (about 124px) */
.stage { position: sticky; top: 144px; align-self: start; min-width: 0; }
.screen { aspect-ratio: 16 / 9; background: #000; border-radius: var(--r); overflow: hidden; }
video { width: 100%; height: 100%; display: block; }

.subs { padding: 14px 4px 6px; min-height: 96px; }
.subs p { margin: 0; cursor: pointer; transition: filter .15s; }
.en { font-size: 22px; line-height: 1.35; font-weight: 600; }
.zh { font-size: 16px; color: var(--muted); margin-top: 6px !important; }
.subs p.veiled { filter: blur(7px); user-select: none; }
mark { background: none; color: var(--accent); }

.controls { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.row label { cursor: pointer; }
.row input { accent-color: var(--gold); }
.src { margin-left: auto; }
.controls.learn { margin-top: 0; }
#save, #explain { flex: 1; max-width: 180px; }

.note {
  margin-top: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--card); font-size: 14px;
}
.note p { margin: 6px 0; }
.note p > b { color: var(--accent); margin-right: 8px; font-weight: 600; }
.note-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.note-head button { padding: 4px 10px; font-size: 13px; }
.usage { margin: 8px 0 0; padding-left: 18px; }
.usage li { margin: 4px 0; }
.ex { color: var(--muted); margin: 2px 0 4px; }
.ex span { font-size: 13px; }

/* ---- review ---- */
.card { padding: 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); }
.prompt { margin: 0 0 12px; }
.phrase { font-size: 22px; font-weight: 700; color: var(--accent); margin: 0 0 4px; }
.card .meta { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.gist { font-size: 14px; margin-bottom: 12px; }
.gist p { margin: 0 0 4px; }
#rvShow { width: 100%; padding: 12px; }
.rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rate button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; }
.rate span { font-size: 12px; color: var(--muted); }
.rate button[data-r="1"] b { color: var(--rose); }
.rate button[data-r="3"] b { color: var(--good); }

/* ---- recap ---- */
.seg { display: flex; gap: 6px; margin-bottom: 10px; }
.seg button { font-size: 13px; padding: 5px 12px; border-radius: 999px; }
.rc-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 4px 0 8px; }
.rc-head h3, .rc-head h4 { margin: 0; margin-right: auto; }
#rcBody h4 { margin: 16px 0 6px; color: var(--accent); }
#rcBody > .primary { width: 100%; padding: 12px; margin-bottom: 12px; }
.narr { margin: 6px 0; padding: 8px 10px; border-left: 3px solid var(--line2); color: var(--text); }
.narr.on, #rcBody li.on { border-color: var(--accent); }
.story { margin-top: 18px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); }
.story p { margin: 8px 0; }
.story p span { color: var(--muted); font-size: 14px; }
.story p b { color: var(--muted); margin-right: 6px; }

/* ---- saves ---- */
.sv-head { display: flex; align-items: center; gap: 8px; }
.sv-head b { flex: 1; }
.del { padding: 0 8px; line-height: 24px; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 20;
  max-width: min(92vw, 520px); padding: 10px 16px; border-radius: 8px;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: 14px; box-shadow: var(--shadow);
}
.mine {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--card);
}
.mine audio { height: 32px; flex: 1; min-width: 180px; }

/* ---- results ---- */
.side { min-width: 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chips button { font-size: 13px; padding: 5px 10px; border-radius: 999px; }
.status { color: var(--muted); font-size: 13px; margin: 4px 0 10px; }
/* from "I heard it" to "make a video of it" */
.to-video { display: block; width: fit-content; max-width: 100%; margin: -4px 0 12px; color: var(--accent); font-size: 13px; text-decoration: none; }
.to-video:hover { text-decoration: underline; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.list li {
  padding: 10px 12px; border-radius: var(--r); border: 1px solid transparent;
  background: var(--card); cursor: pointer;
}
.list li:hover { border-color: var(--line2); }
.list li.on { border-color: var(--accent); }
.list li.loose { opacity: .78; }
.l-en { font-weight: 500; }
.l-zh { color: var(--muted); font-size: 14px; }
.l-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

.keys { color: var(--muted); font-size: 12px; text-align: center; padding: 8px 20px 24px; }

/* ---- narrow windows ---- */
@media (max-width: 1100px) {
  .wrap { padding: 0 24px; }
  .layout { padding: 20px 24px; }
  .logo small { display: none; }
}
@media (max-width: 900px) {
  .nav .wrap { gap: 16px; }
  .nav .links {
    display: none; position: absolute; top: 64px; left: 0; right: 0; z-index: 1; height: auto; flex-direction: column; padding: 10px 16px 16px;
    background: color-mix(in srgb, var(--bg) 96%, transparent); border-bottom: 1px solid var(--line);
  }
  .nav .links.open { display: flex; }
  .nav .links > a { height: auto; padding: 10px 4px; border: 0; }
  .nav .menu { display: block; }
}
@media (max-width: 860px) {
  body { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
  #search { min-width: 0; max-width: none; }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; gap: 0; margin: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line);
  }
  .tabs button { flex: 1; }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
  #save, #explain { max-width: none; }
  .controls.learn { grid-template-columns: 1fr 1fr; }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 12px 16px; gap: 14px; }
  .stage { position: static; }
  .en { font-size: 19px; }
  .controls { display: grid; grid-template-columns: repeat(3, 1fr); }
  .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .keys { display: none; }
}
@media (max-width: 600px) {
  .wrap { padding: 0 16px; }
}
